Skip to content

[bug][hotkey] 5 个快捷 setter 漏校验 Less Computer 键碰撞,与集中式检测不一致 #684

@appergb

Description

@appergb

现象

通过设置里各「录制快捷键」按钮单独设置某个动作键时,可以把它设成与 Less Computer(语音 Agent)快捷键 相同而不被拒绝;但完整保存设置(set_settings → persist_settings)时又会被拒。两条碰撞检测路径不一致 → 要么同一个键被注册给两个动作,要么用户看到"刚才能设、现在又报错"。

根因(已读源码确认)

集中式 reject_hotkey_collisionscommands/hotkeys.rs:216)已正确校验 coding_agent_voice_hotkey(含 mod.rs:813 的测试佐证)。但 5 个快捷 setter 各跑自己的部分 pairwise 校验,全部漏掉 less_computer

  • set_dictation_hotkey / set_translation_hotkey / set_switch_style_hotkey / set_open_app_hotkeycommands/hotkeys.rs
  • set_qa_hotkeycommands/qa.rs:12

而对应的专用校验函数(reject_dictation_less_computer_hotkey_overlap 等)其实早已存在、只是没接进这些 setter。

影响

用户可经单键设置面板把听写/翻译/切换风格/打开应用/QA 任一键设成与 Less Computer 键相同,造成同键多动作或后续保存被拒的不一致体验。

修法(单一职责)

把已存在的 reject_*_less_computer_hotkey_overlap 接进这 5 个 setter(与现有 pairwise 校验同模式),使它们与集中式 reject_hotkey_collisions 一致。

验证

新增 reject_hotkey_collisions 碰撞矩阵单测:每个动作键 == Less Computer 键都被拒、全不同则通过。cargo test --lib commands:: 全绿(52)。

来源:2026-06-16 全仓多 Agent 审计(commands 专项)。

Metadata

Metadata

Assignees

Labels

P2Medium prioritybugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions