Skip to content

fix(desktop): show platform-specific hotkey symbols - #353

Merged
saddlepaddle merged 2 commits into
mainfrom
hotkey-display-fix
Dec 13, 2025
Merged

saddlepaddle merged 2 commits into
mainfrom
hotkey-display-fix

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Dec 13, 2025 •

Copy link
Copy Markdown
Collaborator

Summary

  • Mac: ⌘ ⌃ ⌥ ⇧
  • Windows: Win Ctrl Alt Shift
  • Linux: Super Ctrl Alt Shift

Refactored hotkey system to pre-compute display symbols using PLATFORM constants instead of runtime navigator parsing.

Credits

  • Initial implementation by @JakeRoggenbuck (commit c391007)
  • Refactored to use pre-computed symbols for reliability

Closes #346
Closes #348

Test plan

  • Verify hotkey display on Mac shows symbols (⌘, ⌃, ⌥, ⇧)
  • Verify hotkey display on Windows shows text (Win, Ctrl, Alt, Shift)
  • Verify hotkey display on Linux shows text (Super, Ctrl, Alt, Shift)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Consolidated keyboard shortcut display logic across the application with platform-aware key symbol mapping and precomputed display arrays, improving consistency in how keyboard shortcuts are presented throughout the interface.

✏️ Tip: You can customize this high-level summary in your review settings.

JakeRoggenbuck and others added 2 commits December 12, 2025 22:20
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>
@coderabbitai

coderabbitai Bot commented Dec 13, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The 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

Cohort / File(s) Summary
Shared hotkey infrastructure
apps/desktop/src/shared/hotkeys.ts
Introduces platform-aware key symbol mapping (MODIFIER_MAP, KEY_MAP), adds formatKeys() and hotkey() helpers to precompute display arrays, makes HotkeyDefinition internal, creates HotkeyWithDisplay type, updates HOTKEYS definitions with display arrays, and converts matchesHotkey/findMatchingHotkey to internal helpers.
Keyboard shortcuts settings
apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx
Updates HotkeyRow and consolidateWorkspaceJumps to use HotkeyWithDisplay type, removes formatKeysForDisplay import, switches display rendering to use hotkey.display property directly.
Hotkey display in UI components
apps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx, apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx, apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx
Removes formatKeysForDisplay imports and usage; replaces with direct access to HOTKEYS entries' precomputed display arrays for rendering keyboard shortcut labels.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Hotkeys.ts refactoring — Significant changes to module exports, new type definitions, and platform-aware logic require careful verification
  • API surface changes — HotkeyDefinition is no longer exported; new HotkeyWithDisplay type and modified getHotkeysByCategory() signature affect component consumption patterns
  • Display array precomputation — Verify that formatKeys() correctly maps modifier+key strings to platform-specific symbols for Mac, Windows, and Linux
  • Component consistency — Ensure all 5 affected UI components correctly reference the new display arrays without missing any hotkey usages

Possibly related PRs

Poem

🐰 Hark! Symbols dance across each platform bright,
⌘ on Mac, Win on Windows—what a sight!
Super on Linux, display arrays precomputed,
Hotkey logic centralized, no more refactored,
Platform-aware, elegant, and quite recruited! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: refactoring hotkey display to use platform-specific symbols, which is the core objective of the PR.
Description check ✅ Passed The description includes summary, related issues, test plan, and credits, covering the key aspects of the changes and linking to issues #346 and #348.
Linked Issues check ✅ Passed The code changes fully implement requirements from both linked issues: pre-computed platform-specific hotkey display symbols, removal of formatKeysForDisplay export, centralized platform detection logic in hotkeys.ts, and proper symbol/text rendering per platform.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to hotkey display refactoring as required by issues #346 and #348; no unrelated modifications detected beyond the stated objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotkey-display-fix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e0dc91b and 1e7e21e.

📒 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.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx
  • apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx
  • apps/desktop/src/shared/hotkeys.ts
  • apps/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 in tsconfig.json when 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.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx
  • apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx
  • apps/desktop/src/shared/hotkeys.ts
  • apps/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.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx
  • apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx
  • apps/desktop/src/shared/hotkeys.ts
  • apps/desktop/src/renderer/screens/main/components/TopBar/HelpMenu/HelpMenu.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid any type and prioritize type safety in TypeScript code

Files:

  • apps/desktop/src/renderer/screens/main/components/TopBar/SidebarControl.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx
  • apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx
  • apps/desktop/src/shared/hotkeys.ts
  • apps/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.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx
  • apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx
  • apps/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.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/SettingsButton/SettingsButton.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx
  • apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx
  • apps/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.tsx
  • apps/desktop/src/renderer/screens/main/components/SettingsView/KeyboardShortcutsSettings.tsx
  • apps/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 display array. The change correctly leverages the centralized platform-specific formatting from HOTKEYS.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.display for platform-specific key rendering.

apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/EmptyTabView.tsx (1)

20-22: LGTM!

Clean iteration over shortcut.display for 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 display array.

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 display array 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 constraint T extends { keys: string }.


205-209: Good type design.

The as const satisfies pattern ensures type safety while preserving literal types. Exporting HotkeyWithDisplay provides a clean public API for consumers.


236-292: Correctly scoped internal helpers.

Making matchesHotkey and findMatchingHotkey non-exported (internal) while keeping isAppHotkey as the public API is good encapsulation. The matching logic is comprehensive, handling arrow keys, special characters, and modifier combinations.

@github-actions

github-actions Bot commented Dec 13, 2025 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

Service Status
Neon Database (Neon) ✅

Thank you for your contribution! 🎉


Preview resources have been processed for cleanup

This branch was previously deployed

1 inactive deployment
preview — 1e7e21eb Deployed Dec 13, 2025 by saddlepaddle via Deploy Marketing #240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants