Open-Less#904:1.3.15 新增的选区润色默认键(Windows=右 Alt)在旧配置升级时被
无条件注入。若用户录音键恰为右 Alt,则偏好文件出现持久冲突,之后任何
set_settings(含切「自动」录音方式)都被 reject_hotkey_collisions 整体
拒绝,前端又静默吞错——表现为界面显示已切换、重启后回退按住说话。
修复:
- types.rs:旧文件升级时若默认注入的选区润色键与录音键相同,改为停用
新功能而非写入冲突值;
- commands/settings.rs:保存兜底 reconcile_hotkey_collisions——热键
冲突/非法不再拒绝整份保存,按核心度自动恢复旧值或停用冲突的非核心键
(录音键永不参与调整),其余设置照常落盘并写日志;
- HotkeySettingsContext.tsx:保存失败回滚乐观状态并弹出失败提示,杜绝
「假保存」;
- 回归测试:升级迁移停用冲突键、历史冲突下切模式仍可保存、非核心键
重叠/非法自动化解;4 个旧「保存被拒」测试同步改为新兜底语义。
验证:新增测试全过;cargo test --lib 924 通过、2 失败均与改动前基线
一致(cooldown 时序抖动 + Windows 符号链接权限环境测试);前端
tsc --noEmit 与 frontend-test-runner 全过。
User description
背景
#904:1.3.15 新增的「录音方式:自动」无效,切换后重启软件会回退到「按住说话」。
根因(证据链完整)
default_selection_polish_hotkey)。selectionPolishHotkey被无条件补入默认右 Alt;迁移只保护录音键为历史默认 Right Control 的用户(is_right_control_modifier_shortcut),不覆盖自定义录音键为右 Alt 的用户 → 偏好文件出现持久冲突:dictationHotkey == selectionPolishHotkey == RightAlt。set_settings(含切「自动」模式)都被reject_hotkey_collisions整体拒绝、不落盘;前端updatePrefs乐观更新 + 无 catch 静默吞错 → 界面显示已切换,重启后读回旧值(按住说话)。mode=Hold、从未出现mode=Auto,且每次按录音键(vk=165=右 Alt)同时触发selection-polish workflow failed——冲突在运行时显形。改动
None),不再写入冲突值。reconcile_hotkey_collisions——persist_settings校验到热键冲突/非法时不再整体拒绝,按核心度从高到低自动化解:冲突的非核心热键恢复旧值,旧值本身也是历史冲突则停用(翻译键回退默认 Shift),录音键永不参与调整;其余设置照常落盘并写日志。对受影响的用户,下一次任意设置保存即自动修复历史冲突。updatePrefs保存失败时回滚乐观状态、弹出失败提示并记日志,杜绝「假保存」。验证
cargo test --lib:924 通过,2 失败与改动前基线完全一致(cooldown 时序抖动 + Windows 符号链接权限环境测试,旧二进制同样失败)。tsc --noEmit与frontend-test-runner全过。行为变更提示
保存遇到热键冲突时不再失败,而是自动恢复/停用冲突的非核心热键(日志留痕),核心录音键始终保留;升级用户首次保存会顺带停用与新功能冲突的默认键。
Fixes #904
PR Type
Bug fix
Description
Fix [area] 录音方式无效,重启软件会切换回长按识别 #904: hotkey collisions no longer block settings saves.
Add auto-reconcile fallback for conflicting non-core hotkeys.
Change upgrade migration to disable default selection-polish hotkey on overlap.
Roll back optimistic settings state when save fails to prevent fake saves.
Diagram Walkthrough
flowchart LR A["User saves settings with hotkey conflict"] --> B{"Collision detected"} B -- "Yes" --> C["Reconcile non-core hotkeys"] C --> D["Restore old value or disable key"] D --> E["Persist remaining settings"] B -- "No" --> F["Save normally"] E --> G["Notify UI / rollback on failure"] F --> GFile Walkthrough
mod.rs
Adapt hotkey collision tests to reconcile behavioropenless-all/app/src-tauri/src/commands/mod.rs
rejection.
disabled or restored.
settings.rs
Add hotkey collision auto-reconcile on saveopenless-all/app/src-tauri/src/commands/settings.rs
reconcile_hotkey_collisionsto auto-resolve conflicting orinvalid non-core hotkeys.
rejecting the whole save.
side-specific invalid keys.
types.rs
Prevent default selection-polish hotkey collision on upgradeopenless-all/app/src-tauri/src/types.rs
hotkey.
right-Alt configurations.
HotkeySettingsContext.tsx
Rollback optimistic settings on save failureopenless-all/app/src/state/HotkeySettingsContext.tsx
persistedPrefsRef.savedfailure event and rethrows the error to surface thefailure to the user.