Repository navigation
fix(desktop): show platform-specific hotkey symbols - #353
Conversation
Before, the hotkey table would display with the Mac meta key in the table. This PR changes it to "Super" on Linux and "Win" on Windows. This PR is tested on Linux but not Mac or Windows.
- Mac: ⌘ ⌃ ⌥ ⇧ - Windows: Win Ctrl Alt Shift - Linux: Super Ctrl Alt Shift Refactored to pre-compute display symbols using PLATFORM constants instead of runtime navigator parsing. Adds `.display` property to all HOTKEYS entries and centralizes platform logic in hotkeys.ts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughThe PR refactors the hotkey system to display platform-specific keyboard symbols by centralizing display logic in the shared hotkeys module, precomputing display arrays at definition time, and removing runtime formatting dependencies from UI components. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/desktop/src/shared/hotkeys.ts (1)
9-13: Consider a cleaner conditional structure.The nested ternary is readable but could be slightly cleaner using an object lookup pattern. Current approach is acceptable given there are only 3 platforms.
Optional alternative using a platform map:
-const MODIFIER_MAP = PLATFORM.IS_MAC - ? { meta: "⌘", ctrl: "⌃", alt: "⌥", shift: "⇧" } - : PLATFORM.IS_WINDOWS - ? { meta: "Win", ctrl: "Ctrl", alt: "Alt", shift: "Shift" } - : { meta: "Super", ctrl: "Ctrl", alt: "Alt", shift: "Shift" }; +const PLATFORM_MODIFIERS = { + mac: { meta: "⌘", ctrl: "⌃", alt: "⌥", shift: "⇧" }, + windows: { meta: "Win", ctrl: "Ctrl", alt: "Alt", shift: "Shift" }, + linux: { meta: "Super", ctrl: "Ctrl", alt: "Alt", shift: "Shift" }, +} as const; + +const MODIFIER_MAP = PLATFORM.IS_MAC + ? PLATFORM_MODIFIERS.mac + : PLATFORM.IS_WINDOWS + ? PLATFORM_MODIFIERS.windows + : PLATFORM_MODIFIERS.linux;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx(6 hunks)apps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx(2 hunks)apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx(2 hunks)apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsx(2 hunks)apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx(2 hunks)apps/desktop/src/shared/hotkeys.ts(4 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
apps/desktop/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)
For Electron interprocess communication, ALWAYS use tRPC as defined in
src/lib/trpc
Files:
apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsxapps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsxapps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsxapps/desktop/src/shared/hotkeys.tsapps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx
apps/desktop/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)
apps/desktop/**/*.{ts,tsx}: Please use alias as defined intsconfig.jsonwhen possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary
Files:
apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsxapps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsxapps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsxapps/desktop/src/shared/hotkeys.tsapps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Use Biome for code formatting and linting, running at root level for speed
Files:
apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsxapps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsxapps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsxapps/desktop/src/shared/hotkeys.tsapps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Avoid
anytype and prioritize type safety in TypeScript code
Files:
apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsxapps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsxapps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsxapps/desktop/src/shared/hotkeys.tsapps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx
**/components/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/components/**/*.{ts,tsx}: Structure project folders as one folder per component with PascalCase naming (ComponentName/ComponentName.tsx + index.ts barrel export)
Co-locate component dependencies (utils, hooks, constants, config, tests, stories) next to the file using them
Use one component per file (no multi-component files)
Files:
apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsxapps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsxapps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsxapps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx
apps/desktop/src/renderer/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Call IPC methods from renderer process using window.ipcRenderer.invoke with type-safe object parameters
Files:
apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsxapps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsxapps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsxapps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx
🧠 Learnings (1)
📚 Learning: 2025-11-24T21:33:13.267Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.267Z
Learning: Applies to apps/desktop/**/*.{ts,tsx} : Please use alias as defined in `tsconfig.json` when possible
Applied to files:
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsxapps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsxapps/desktop/src/shared/hotkeys.ts
🧬 Code graph analysis (5)
apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsx (1)
apps/desktop/src/shared/hotkeys.ts (1)
HOTKEYS(65-205)
apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx (1)
apps/desktop/src/shared/hotkeys.ts (1)
HOTKEYS(65-205)
apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx (1)
apps/desktop/src/shared/hotkeys.ts (2)
HotkeyWithDisplay(209-209)HOTKEYS(65-205)
apps/desktop/src/shared/hotkeys.ts (1)
apps/desktop/src/shared/constants.ts (1)
PLATFORM(5-9)
apps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx (1)
apps/desktop/src/shared/hotkeys.ts (1)
HOTKEYS(65-205)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Deploy API
- GitHub Check: Deploy Web
- GitHub Check: Deploy Docs
- GitHub Check: Deploy Marketing
- GitHub Check: Deploy Admin
- GitHub Check: Build
🔇 Additional comments (10)
apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsx (1)
32-34: LGTM!Clean migration to using the precomputed
displayarray. The change correctly leverages the centralized platform-specific formatting fromHOTKEYS.TOGGLE_SIDEBAR.display.apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx (1)
26-28: LGTM!Consistent with the refactoring pattern. Correctly uses
HOTKEYS.SHOW_HOTKEYS.displayfor platform-specific key rendering.apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx (1)
20-22: LGTM!Clean iteration over
shortcut.displayfor the shortcuts array. The precomputed display arrays work correctly with the existing component structure.apps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx (1)
76-78: LGTM!Consistent with the PR's refactoring pattern. The dropdown menu item correctly renders keyboard shortcut hints using the precomputed
displayarray.apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx (2)
57-63: Clean synthetic hotkey construction.Good approach to reuse the platform-specific meta key symbol from an existing hotkey's
displayarray when creating the consolidated "Switch to Workspace 1-9" entry.
72-73: LGTM!Correctly extracts the modifier key symbol for the inline hint. The destructuring pattern is safe since all hotkey definitions have at least one key.
apps/desktop/src/shared/hotkeys.ts (4)
31-36: Well-designed formatting function.Clean implementation that handles both modifier keys and special keys with appropriate fallback to uppercase for regular characters.
39-41: Elegant helper pattern.The
hotkey()wrapper is a clean approach to pre-compute display at definition time, ensuring type safety with the generic constraintT extends { keys: string }.
205-209: Good type design.The
as const satisfiespattern ensures type safety while preserving literal types. ExportingHotkeyWithDisplayprovides a clean public API for consumers.
236-292: Correctly scoped internal helpers.Making
matchesHotkeyandfindMatchingHotkeynon-exported (internal) while keepingisAppHotkeyas the public API is good encapsulation. The matching logic is comprehensive, handling arrow keys, special characters, and modifier combinations.
Summary
Refactored hotkey system to pre-compute display symbols using PLATFORM constants instead of runtime navigator parsing.
Credits
Closes #346
Closes #348
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.