fix: adapt keyboard shortcut display for macOS#2484
Conversation
|
@copilot resolve the merge conflicts in this pull request |
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — gpt-5.4 via Qwen Code /review
Closes QwenLM#2227 On macOS, keyboard shortcut hints now use native modifier symbols (⌃ for Ctrl, ⌘ for Cmd, ⌥ for Alt, ⇧ for Shift) instead of the generic "ctrl+", "cmd+" text format. - Add formatShortcut() utility in shortcutFormatter.ts - Apply to KeyboardShortcuts panel and retry hint messages - Non-macOS platforms are unaffected
bc3eb5e to
aa8428d
Compare
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — gpt-5.5 via Qwen Code /review
|
@Br1an67 friendly ping — CI is currently red on all 9 Root cause: the PR branch is based on Fix: rebase (or merge) latest Thanks for the contribution! |
|
Reviewed the change. Direction is correct (native symbols on Mac, full no-op elsewhere keeps the blast radius tiny), but a few points worth addressing: Main issues1.
|
Dismissing the prior auto-LGTM: CI is failing on all platforms (build error) and a fresh review surfaced i18n / layout-width / minor issues that need addressing.
|
Two follow-ups on the review state: Dismissed the prior auto-LGTM — the earlier CI is red, but it's not from this change. The failing test is |
DragonnZhang
left a comment
There was a problem hiding this comment.
Downgraded from Approve to Comment: CI has test failures (pre-existing base branch issues in coreToolScheduler.test.ts, not caused by this PR).
[Suggestion] Help.tsx (lines 110-155) still renders shortcuts as hardcoded strings (Ctrl+C, Ctrl+L, Ctrl+O, Alt+Left/Right) without going through formatShortcut. On macOS, the bottom shortcut bar will show symbols like ⌃C, while the Help dialog shows Ctrl+C for the exact same shortcuts — a user-visible inconsistency.
Suggested fix: also route Help.tsx shortcut keys through formatShortcut().
Overall: clean implementation, no blocking issues. The i18n coupling and layout-width concerns previously raised by @wenshao remain valid and are not repeated here. — Qwen Code /review
|
|
||
| return shortcut | ||
| .split(/\s+/) | ||
| .map((combo) => { |
There was a problem hiding this comment.
[Nice to have] combo.split('+') cannot represent the + key itself (e.g., ctrl++ for zoom-in would silently mangle). No current shortcut uses + as a key, but consider documenting this limitation or switching to a regex-based parser that matches known modifiers and leaves the remainder as the key.
— Qwen Code /review
| it('converts modifier keys to Mac symbols on darwin', async () => { | ||
| Object.defineProperty(process, 'platform', { value: 'darwin' }); | ||
| const { formatShortcut } = await import('./shortcutFormatter.js'); | ||
| expect(formatShortcut('ctrl+y')).toBe('⌃Y'); |
There was a problem hiding this comment.
[Nice to have] Consider adding test cases for combined modifiers (ctrl+shift+y → ⌃⇧Y), single-character keys (!, /, @), and mixed-case input (Ctrl+Y) to catch regressions if future shortcuts use these patterns.
— Qwen Code /review
TLDR
On macOS, keyboard shortcut hints now use native modifier symbols (
⌃for Ctrl,⌘for Cmd,⌥for Alt,⇧for Shift) instead of the generic text format.Closes #2227
Dive Deeper
The CLI keyboard shortcut panel and error retry hints displayed shortcuts like
ctrl+y,cmd+vregardless of platform. On macOS, the convention is to use symbolic modifiers (⌃Y,⌘V).Changes:
packages/cli/src/ui/utils/shortcutFormatter.ts— NewformatShortcut()utility that converts modifier names to macOS symbols whenprocess.platform === "darwin"packages/cli/src/ui/components/KeyboardShortcuts.tsx— ApplyformatShortcut()to shortcut key displaypackages/cli/src/ui/hooks/useGeminiStream.ts— ApplyformatShortcut()to "Press Ctrl+Y to retry" hint messagespackages/cli/src/ui/utils/shortcutFormatter.test.ts— Tests for Mac symbol conversion, multi-part shortcuts, and non-Mac passthroughNon-macOS platforms are completely unaffected — the formatter is a no-op on Linux/Windows.
Reviewer Test Plan
⌃Y,⌃C,⌘Vetc.⌃Yinstead ofCtrl+Yctrl+y,ctrl+c)Testing Matrix
Linked issues / bugs
Closes #2227