fix(polish): Traditional 模式强制中文字形转换,不再只靠 prompt (#622)#629
Merged
Conversation
繁体用户实测:选 Traditional 后最终插入文字仍可能含简体。根因—— 1. finalize_polished_text 仅在 Raw / 翻译 / 润色失败时强制 apply_chinese_script_preference; 普通模式 LLM 润色成功时只靠 system prompt 指示 LLM 输出繁体,而部分 provider 会 跟随简体 ASR 输入继续输出简体,prompt 指示不可靠(issue #622)。 2. 流式插入路径逐字落字,刻意跳过 apply_chinese_script_preference(dictation_streaming.rs 注释明示),无法回退已落字符。 修复: - finalize_polished_text 在非流式路径下无条件套用 apply_chinese_script_preference (对 Auto 是 no-op,不影响自动模式行为;非 Auto 时保证最终文字不混简体)。 - streaming_insert_eligible 增加 chinese_script_preference 门:非 Auto 时关闭流式, 转走会做字形转换的一次性路径(满足 issue「无法安全转换则 fallback 到 one-shot」)。 - 新增单测:finalize 对 issue 两个验收用例输出繁体;非 Auto 时流式不 eligible。 Auto 模式保持原行为不变。
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
H-Chris233
approved these changes
Jun 9, 2026
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
背景
issue #622:当 Chinese Script Preference 设为 Traditional 时,OpenLess 最终插入的文字仍可能含简体中文(台湾繁体用户实测)。验收用例:
根因
finalize_polished_text只在 Raw / 翻译 / 润色失败 时强制apply_chinese_script_preference;普通模式 LLM 润色成功时仅靠 system prompt 指示 LLM 输出繁体。但部分 provider 会跟随简体 ASR 输入继续输出简体——prompt-level 指示不可靠(issue 原文已指出)。dictation_streaming.rs注释明确写着「不在流式路径里做apply_chinese_script_preference」,已落的字符无法回退转换。改动(
coordinator/三文件,单一职责)finalize_polished_text:非流式路径下无条件套用apply_chinese_script_preference。该函数对Auto是 no-op(不影响自动模式),非Auto时保证 ASR/LLM 产生的简体在插入前被转成目标字形。streaming_insert_eligible:新增chinese_script_preference入参——非Auto时判定不走流式,转入会做字形转换的一次性路径。对应 issue 验收项「若流式无法安全套用转换,应 fallback 到 one-shot」。finalize_forces_traditional_even_on_successful_polish覆盖 issue 两个验收用例;streaming_insert_ineligible_when_chinese_script_forced验证非 Auto 关闭流式。验收对照
验证
cargo check --manifest-path src-tauri/Cargo.toml✅cargo test --lib(新增 3 项断言全过)✅🤖 Generated with Claude Code
PR Type
Bug fix
Description
Enforce Chinese script conversion for non-Auto preferences
Force streaming insertion fallback when script preference is set
Apply conversion unconditionally after successful polish
Diagram Walkthrough
flowchart LR A["ASR Input (may be Simplified)"] --> B["Polish pipeline"] B --> C{"Script Preference?"} C -- "Auto" --> D["Streaming insertion allowed"] C -- "Traditional/Simplified" --> E["Fallback to one-shot insertion"] E --> F["apply_chinese_script_preference"] F --> G["Final output (forced to preferred script)"] D --> H["Streaming insertion (no conversion)"] H --> GFile Walkthrough
dictation.rs
Add tests for script conversion enforcementopenless-all/app/src-tauri/src/coordinator/dictation.rs
preference is Traditional or Simplified
covering two acceptance cases
dictation_end.rs
Pass script preference to streaming eligibilityopenless-all/app/src-tauri/src/coordinator/dictation_end.rs
chinese_script_preferencetostreaming_insert_eligiblecalldictation_streaming.rs
Enforce script conversion and fallback streamingopenless-all/app/src-tauri/src/coordinator/dictation_streaming.rs
preference is not Auto