feat: configurable keyboard shortcuts for the panel toggles (mod+b / mod+t) - #97
Open
dailin3 wants to merge 1 commit into
Open
feat: configurable keyboard shortcuts for the panel toggles (mod+b / mod+t)#97dailin3 wants to merge 1 commit into
dailin3 wants to merge 1 commit into
Conversation
…mod+t) - SidebarPrefs gains shortcutPanel (mod+b) and shortcutTerminal (mod+t), canonical combo strings (mod|meta|ctrl[+alt][+shift]+key) or '' (disabled). - New pure combo vocabulary module (src/client/shortcut-combo.ts): parse / normalize / match with exact-modifier semantics / platform labels, kept import-free so the client prefs parser shares the grammar without react. - New document-level capture listener (src/client/shortcuts.ts): Cmd/Ctrl+B toggles the right sidebar, Cmd/Ctrl+T the bottom terminal panel (the merged drawer on narrow viewports); reads prefs live, skips IME/repeat/ capture-control events, disposed with the fiber. - Side card settings gain two key-capture rows (KeyCaptureInput): click, press the new chord; Backspace/Delete disables. Toggle tooltips show the bound shortcut. - PrefsSchema registers the two fields; parsePrefs normalizes malformed values to '' (disabled) instead of arming a typing-hijack combo. - Tests: shortcuts.spec.ts (vocabulary + prefs integration), key-capture-input.spec.tsx (SSR), updated prefs-shape expectations in unit/plugin-shape/smoke/side-card specs. README shortcut tables updated.
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.
背景
用户在 GUI 里需要快捷唤起/收起侧边栏和底部终端面板。本 PR 新增两条可配置快捷键,默认:
mod+b(macOS 为 ⌘B,Windows/Linux 为 Ctrl+B)→ 唤起/收起右侧侧边栏mod+t(⌘T / Ctrl+T)→ 唤起/收起底部面板(终端);窄窗口下切换合并抽屉改动
SidebarPrefs新增shortcutPanel/shortcutTerminal(规范组合键字符串:mod|meta|ctrl[+alt][+shift]+key,空字符串 = 禁用);PrefsSchema注册两个字段;parsePrefs把非法值规范化为''(禁用),绝不武装一个会在打字时误触发的组合。src/client/shortcut-combo.ts(零依赖、无 react):解析/规范化/精确修饰键匹配/平台化显示标签(⌘B / Ctrl+B)。精确修饰键语义:mod+b不会吞掉ctrl+alt+b这类别的组合。src/client/shortcuts.ts:document 捕获阶段 keydown,实时读 prefs(设置提交即换绑),跳过 IME 组合/repeat/快捷键录制控件内按键,随 fiber 释放。KeyCaptureInput)——点击后按下新组合键即可改绑,Backspace/Delete 禁用;两个面板开关按钮的 tooltip 显示当前绑定的快捷键。tests/shortcuts.spec.ts(词汇+prefs 集成)、tests/key-capture-input.spec.tsx(SSR 渲染),并同步 unit/plugin-shape/smoke/side-card 里 prefs 形状断言。已知限制
Cmd/Ctrl+T属于浏览器保留键(新标签页),普通浏览器标签页里页面 JS 收不到;在桌面壳(Tauri/Pake 包装)里可用。Cmd/Ctrl+B无此限制。测试
pnpm run typecheck✅;pnpm run test:新增/相关用例全绿(本机沙箱环境下 node-pty 的posix_spawnp用例失败为环境问题,与本次改动无关)。