feat(history): 润色未变化检测与历史重新润色 (Fixes #653)
User description
摘要
Fixes #653
非原文润色结果与 ASR 原文规范化比较后完全一致时,标记 polishUnchanged 并在历史页提供「重新润色」;功能默认关闭,需在 设置 → 隐私 → 数据存储 开启「润色未变化检测」。
依赖说明: 本分支基于
feat/android-auto-update(上游 PR #664)。若 #664 尚未合并,diff 会包含 Android 自动更新相关提交;Issue #653 专属改动为最近 2 个 commit、约 15 个文件(+510 行)。
修复 / 新增 / 改进
- 检测与标记:
normalize_for_polish_compare+is_polish_unchanged;end_session在 pref 开启且非 raw 时写入errorCode = polishUnchanged。 - 历史重新润色:新增
repolish_history_entryIPC / command;按原stylePackId(或 mode fallback)单轮润色并原地回写,保留id/createdAt/ 录音 / 插入状态。 - 边界修复:翻译听写条目(
translationActive)禁止重新润色(UI + IPC);回写时仅重算None/polishUnchanged/polishFailed,保留focusRestoreFailed、windowsImeTsfRequired等插入错误码。 - 前端:History 列表 tag、详情 banner、「重新润色」按钮(pref 门控);
DataStorageSection全局开关,默认 关。 - i18n:en / zh-CN / zh-TW / ja / ko。
- 单测:
is_polish_unchanged、resolve_polish_unchanged_error_code、resolve_repolish_history_error_code等(CI Linux / macOS 已跑过)。
兼容
- 不包含:模糊相似度阈值、自动重试、overlay 胶囊展示、改造现有裸
repolish(rawText, mode)IPC。 - 对现有用户 / 本地环境 / 构建流程的影响:
- 默认关闭,现有用户行为不变;开启后仅影响新完成的听写会话及历史页 UI。
- 重新润色依赖已配置的 LLM 凭据与网络,与现有润色路径相同。
- Android 与桌面共用同一套 History / Settings UI,无额外 native 模块。
测试计划
-
[x] 命令:
npm run build -
[x] 结果:通过
-
[x] 证据路径:本地构建
-
[x] 命令:CI
workflow_dispatch(feat/issue-653-polish-unchanged) -
[x] 结果:4 job success(Android cargo check / macOS / Linux / Windows)
-
[x] 证据路径:https://github.com/HKLHaoBin/openless/actions/runs/27520160830
-
[x] 命令:
cargo test --lib(polish / repolish 相关,CI) -
[x] 结果:通过(Windows 本地缺 MSVC linker,未本地跑)
-
[x] 证据路径:同上 CI Linux / macOS job
-
[x] 命令:Android release APK 真机
adb install -r+ History / 设置操作 -
[x] 结果:启动无 crash;pref 开启时列表 tag + 详情 banner +「重新润色」可见;点击重新润色触发 LLM;pref 关闭后 tag / banner / 按钮隐藏
-
[x] 证据路径:
ci-artifacts/openless-653-*.png(本地,未提交) -
[ ] 命令:桌面端 History 回归(pref 开/关、重新润色、raw / 翻译条目)
-
[ ] 结果:待 reviewer / 维护者复测
-
[ ] 证据路径:—
PR Type
Enhancement, Bug fix
Description
-
Detect unchanged polish and allow re-polish from history
-
Add polish unchanged detection, repolish IPC, and UI
-
Fix Android release JNI crashes and overlay service issues
-
Update Android updater logic and CI for signed APK builds
Diagram Walkthrough
flowchart LR
A[End session] --> B{polish unchanged?}
B -- Yes --> C[Mark errorCode=polishUnchanged]
B -- No --> D[Normal flow]
C --> E[History detail shows banner + repolish button]
E --> F[User clicks repolish]
F --> G[IPC: repolish_history_entry]
G --> H[Re-polish with original style pack]
H --> I[Update entry in history]
File Walkthrough
| Relevant files | |||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Enhancement | 15 files
| ||||||||||||||||||||||||||||||
| Configuration changes | |||||||||||||||||||||||||||||||
| Bug fix | 6 files
| ||||||||||||||||||||||||||||||
| Miscellaneous | |||||||||||||||||||||||||||||||
| Documentation | 7 files
| ||||||||||||||||||||||||||||||
| Tests |
PR Reviewer Guide 🔍
Here are some key observations to aid the review process:
|
🎫 Ticket compliance analysis 🔶 664 - Partially compliant Compliant requirements:
Non-compliant requirements:
Requires further human verification:
653 - Partially compliant Compliant requirements:
Non-compliant requirements:
Requires further human verification:
|
| ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪ |
| 🧪 PR contains tests |
| 🔒 No security concerns identified |
⚡ Recommended focus areas for reviewCompile Error
resolve_style_pack_for_history_entry is defined inside the mod tests block (around line 6238), making it private to the test module. It is called from the public repolish_history_entry method at line 1479, which will fail to compile because the function is not accessible outside the test module. This function must be moved out of the mod tests block into regular scope to be usable. |
感谢 bot 标注,这条 Compile Error 是误报,当前代码可以正常编译。
resolve_style_pack_for_history_entry 并不在 mod tests 内部:测试模块在 coordinator.rs L6236 的 } 处结束,该 helper 从 L6238 起定义在模块顶层(与后面的 enabled_phrases 同级),repolish_history_entry(L1479)调用它是合法的同一模块内可见性。
CI 已在四平台通过(含 Android cargo check / macOS / Linux / Windows),若为真实编译错误,check 阶段会直接失败。
无需为此改动代码。
PR 合并冲突提示
1. 与 #664 的包含关系
- 本分支前 9 个 commit 即为 #664(Android 应用内更新)的工作,后 2 个才是 #653 历史润色
- 请勿与 #664 分别合入——只合本 PR 即可(或只合 #664 后关闭本 PR 并 cherry-pick 剩余 commit)
2. dictation.rs(与 #682、#688、#692)
- 上述三个听写小修复 PR 与本 PR 均改 coordinator/dictation.rs
- 本地模拟:无论谁先合,另一方合入时都会在 dictation.rs 冲突
- #682/#688/#692 三者之间可共存,但与 #666 不行
3. 其他重叠(低风险)
- ypes.rs、i18n/*、lib.rs 与 #638 有交集,通常可自动合并
建议合并顺序: 先定听写小修复(#682→#688→#692)与本 PR 谁先合,另一方 rebase 并解决 dictation.rs;不要同时合 #664。
关闭原因:本 PR 前 9 个 commit 与 #664 重复的 Android 自动更新部分,已由 #704 在最新 \eta\ 上单独重迁合入。\n\n#653 历史润色(本 PR 后 2 个 commit)将基于当前 \eta\ 另开独立 PR,避免与 Android 更新再次捆绑、减少审查与合并冲突。\n\n请审查 #704(Android 更新);#653 跟进 PR 将单独提交。