feat(hotkeys): 风格包直达快捷键——按风格包 ID 绑定自定义全局键(#759) - #930
Open
bigsongeth wants to merge 2 commits into
Open
Conversation
不做原 issue 的 Alt+1~9 固定槽位(序号随启停位移、macOS 上 Option+数字
会吞特殊字符输入),改为在设置→快捷键里为具体风格包各配一个快捷键:
- prefs 新增 stylePackHotkeys: Vec<{packId, binding}>,默认空、无预设键
- 触发复用 activate_style_pack_by_id:禁用包自动启用、prefs/托盘/前端同步
- 集合式冲突校验:集合内去重 + 与其它全部快捷键互斥,reconcile 兜底(Open-Less#904 模式)
- 删除风格包时清理孤儿绑定;启动 supervisor + 设置变更全量重建注册
- 设置 UI:风格包下拉(SelectLite)+ 录制器 + 增删行,i18n×5
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
概述
实现 #759 的功能部分:为具体风格包绑定自定义全局快捷键,按下直接切换("风格直达")。托盘菜单 bug 部分已拆至 #808,本 PR 不涉及。
设计取舍
不采用原 issue 的 Alt+1~9 固定槽位方案,改为快捷键绑定到风格包 ID:
实现
后端
UserPreferences新增stylePackHotkeys: Vec<StylePackHotkey { packId, binding }>(默认空,serde default 兼容老配置文件,wire 三处映射齐全)set_style_pack_hotkeys(整表替换):集合内去重(同包一条、同键一条)+ 与其它全部快捷键互斥;现有各 setter 反向检查新集合;reject_hotkey_collisions/reconcile_hotkey_collisions([area] 录音方式无效,重启软件会切换回长按识别 #904 兜底模式)同步覆盖Inner.style_pack_hotkeys: HashMap<packId, ComboHotkeyMonitor>,启动 supervisor + 设置变更时全量重建(避免「两包互换按键」的增量更新注册冲突);桥接线程含shortcut_recording_active保护activate_style_pack_by_id:禁用包自动启用、prefs 持久化、prefs:changed广播、托盘刷新,与前端点选激活完全同路径;包已删除时 no-op + warnswitchStyleHotkey循环切换此前静默,一并补上提示parse_primary/parse_global_hotkey已支持数字键与 alt 修饰键前端
验证
cargo check/cargo test --lib(914 + 新增 6 个单测:冲突校验 ×4、serde 兼容 ×2)/tsc --noEmit全绿style pack hotkey listeners installed after 1 attempt(s);真实按键触发日志style pack hotkey activated imported-88cee…(超级豆包),activeStylePackId落盘一致;切换提示胶囊弹出正常;老 preferences.json(无新字段)加载正常Closes #759(托盘部分由 #808 跟进)
🤖 Generated with Claude Code