fix(ime): 繁中用户语音输入始终输出繁体 / enforce 简繁 script on output (#643)#729
Merged
Conversation
) Traditional-Chinese users got Simplified output. finalize_polished_text only ran the deterministic OpenCC conversion for Raw mode / polish failures, leaving successful polish modes to the LLM — which defaults to Simplified for Chinese. The streaming-insert path bypassed the conversion entirely. - finalize_polished_text: for non-translation dictation, always apply apply_chinese_script_preference. It is a no-op for ChineseScriptPreference::Auto (the default), so zero impact on users who didn't pick a script; for Simplified/ Traditional it now guarantees the output script instead of trusting the LLM. - streaming_insert_eligible: gains the script preference and disables streaming insert when it is non-Auto, so the one-shot path runs (streaming types live and has no finished text to post-process). Tests: polish_output_honors_chinese_script_preference (S2t actually converts; Auto is a no-op) + streaming_disabled_for_non_auto_script_so_opencc_runs. 470 lib tests pass. Closes #643
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
问题 / Problem
繁體中文使用者每次语音输入都得到简体输出(issue #643)。设置里选了「繁體中文」也没用 —— 这是确认过的已知 bug。
根因 / Root cause
coordinator/dictation.rs::finalize_polished_text只在 Raw 模式 / polish 失败 时才跑确定性的 OpenCC 简↔繁转换(apply_chinese_script_preference)。polish 成功的模式(light/structured/formal)把字形交给 LLM —— 而中文 LLM 默认输出简体,繁中提示并不可靠。流式插入路径(already_streamed)则完全跳过转换。chineseScriptPreference默认是Auto,所以这个 bug 只影响显式选了简/繁的用户。改动 / Fix
finalize_polished_text:非翻译听写始终调用apply_chinese_script_preference。Auto时内部是 no-op(默认用户零影响);Simplified/Traditional时确定性保证输出字形,不再赌 LLM。streaming_insert_eligible:加入字形偏好参数,非 Auto 时关掉流式插入(流式边出边落字、没有成品可后处理),走一次性路径让 OpenCC 转换生效。测试 / Tests
polish_output_honors_chinese_script_preference:polish 成功路径下,繁体偏好真的把「学习」转成不含简体字、Auto 不转换。streaming_disabled_for_non_auto_script_so_opencc_runs:非 Auto 关流式、Auto 不受影响。cargo test --lib470 通过。Closes #643
PR Type
Bug fix, Tests
Description
Always enforce Chinese script preference on dictation output
Disable streaming insert for non-Auto script preferences
Add tests verifying script conversion and streaming eligibility
Diagram Walkthrough
File Walkthrough
dictation.rs
Enforce script preference and disable streaming for non-Autoopenless-all/app/src-tauri/src/coordinator/dictation.rs
finalize_polished_textto always apply OpenCC scriptconversion for non-translation dictation (previously only on raw mode
or polish failure)
streaming_insert_eligibleto disable streaming when scriptpreference is non-Auto, ensuring one-shot path runs OpenCC conversion
polish_output_honors_chinese_script_preferenceandstreaming_disabled_for_non_auto_script_so_opencc_runs