Skip to content

Commit 51b76c4

Browse files
fix(ui): Fix reference guide key hint for PC (#782)
* fix: show Ctrl instead of ⌘ on non-Mac keyboards in keyboard shortcut hints The KeyboardShortcutHint component now detects the user's platform and displays 'Ctrl' instead of '⌘' for Windows/Linux users. This fixes the issue where the Reference Guide hint (and other keyboard shortcut hints) incorrectly showed Mac-specific keyboard symbols on non-Mac platforms. Co-authored-by: michael <michael@sourcebot.dev> * changelog --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 940aca0 commit 51b76c4

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111
- Added `isBranchFilteringEnabled` flag to `search_finished` PostHog event. [#781](https://github.com/sourcebot-dev/sourcebot/pull/781)
1212

13+
### Fixed
14+
- Fixed reference guide key hint for PC [#782](https://github.com/sourcebot-dev/sourcebot/pull/782)
15+
1316
## [4.10.15] - 2026-01-22
1417

1518
### Fixed
Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
1-
import { cn } from '@/lib/utils'
2-
import React from 'react'
1+
'use client';
2+
3+
import { cn, IS_MAC } from '@/lib/utils'
4+
import React, { useMemo } from 'react'
35

46
interface KeyboardShortcutHintProps {
57
shortcut: string
68
label?: string
79
className?: string
810
}
911

12+
/**
13+
* Converts Mac-specific keyboard shortcuts to platform-appropriate shortcuts.
14+
* On Mac: displays the shortcut as-is (e.g., "⌘")
15+
* On Windows/Linux: replaces "⌘" with "Ctrl"
16+
*/
17+
function getPlatformShortcut(shortcut: string): string {
18+
if (IS_MAC) {
19+
return shortcut;
20+
}
21+
// Replace Mac Command key symbol with Ctrl for non-Mac platforms
22+
return shortcut.replace(//g, 'Ctrl');
23+
}
24+
1025
export function KeyboardShortcutHint({ shortcut, label, className }: KeyboardShortcutHintProps) {
11-
return (
12-
<div className={cn("inline-flex items-center", className)} aria-label={label || `Keyboard shortcut: ${shortcut}`}>
13-
<kbd
14-
className="px-2 py-1 font-semibold font-sans border rounded-md"
15-
style={{
16-
fontSize: "0.65rem",
17-
lineHeight: "0.875rem",
18-
}}
19-
>
20-
{shortcut}
21-
</kbd>
22-
</div>
23-
)
26+
const platformShortcut = useMemo(() => getPlatformShortcut(shortcut), [shortcut]);
27+
28+
return (
29+
<div className={cn("inline-flex items-center", className)} aria-label={label || `Keyboard shortcut: ${platformShortcut}`}>
30+
<kbd
31+
className="px-2 py-1 font-semibold font-sans border rounded-md"
32+
style={{
33+
fontSize: "0.65rem",
34+
lineHeight: "0.875rem",
35+
}}
36+
>
37+
{platformShortcut}
38+
</kbd>
39+
</div>
40+
)
2441
}

0 commit comments

Comments
 (0)