Repository navigation
fix: show platform-correct hotkey labels in recording overlays - #19
Merged
Merged
Conversation
The in-app and native recording overlays hard-coded "Stop ⌥" and "Cancel esc", so Windows users saw macOS symbols and nobody saw their configured keys. - frontend/src/hotkeyLabels.ts formats key names per platform; App uses it for settings, the Home badge and the RecordingOverlay labels. - hotkey.ShortLabel is the Go equivalent. Both are tested against the shared table in internal/hotkey/testdata/short_labels.json. - overlay.SetHotkeyLabels updates the native overlays on macOS and Windows (no-op elsewhere). app.go refreshes it from config at startup, on re-registration and after each hotkey change, under a lock so concurrent changes cannot leave a stale label. - Native buttons grow to fit their captions; Windows hit testing uses the same rectangles that are drawn, and the Windows overlay test now clicks the labelled layout.
The Home badge and sidebar hint rendered with the macOS defaults until GetPlatform and the hotkey bindings resolved, so Windows briefly showed ⌥. They now appear once the platform and both keys have loaded. Also extend the shared label table with every alias the formatters accept, so the Go and TypeScript implementations cannot drift.
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.
Problem
The recording UI hard-coded macOS key symbols and ignored the configured hotkeys:
RecordingOverlay.tsx)Stop ⌥/Cancel escon every platformApp.tsx)⌥/⌘symbols on Windows/Linux toooverlay_darwin.go)Stop ⌥/Cancel escappearance.go)Stop(no key) /Cancel escA Windows user with Right Alt saw
⌥. A Mac user with Right Command also saw⌥.Fix
frontend/src/hotkeyLabels.ts:formatHotkeyShortLabelgives the compact badge label.formatHotkeyLabelgives the Settings/sidebar label.App.tsxnow uses these instead of its two switch tables.internal/hotkey/labels.go:ShortLabel/ShortLabelFor(name, goos)are the Go equivalent for the native overlays.internal/hotkey/testdata/short_labels.json, so they can't drift apart.⌥ ⌘ ⌃ ⇧ ⇪ fn Esc ⇥ ↩ ⌫Alt Win Ctrl Shift Caps Fn Esc Tab Enter Bksp DelSuperfor the meta key.⌥.RecordingOverlaytakesstopKeyLabel/cancelKeyLabelprops.Apppasses them from the loadedcurrentHotkey,cancelHotkeyandplatform.overlay.SetHotkeyLabels(stop, cancel)for darwin, windows, and a no-op for other builds.app.gorefreshes it from config at startup, inReregisterHotkey, and afterSetRecordingHotkey/SetCancelHotkeysave. The refresh runs under a lock so concurrent changes can't leave a stale label. Labels update live, even while the panel is open.Stop <key>/Cancel <key>and grow to fit, right-aligned.appearance.godraws the same captions and sizes the buttons to fit. Hit testing uses the rectangles from the last drawn frame. Captions without a key keep the original 70/75 px layout.overlay_windows_test.gonow also sets wide labels and checks that clicks follow the drawn buttons.Files
frontend/src/hotkeyLabels.ts(new)frontend/src/App.tsxfrontend/src/RecordingOverlay.tsxinternal/hotkey/labels.go(new)internal/overlay/{appearance.go, overlay_darwin.go, overlay_windows.go, overlay_other.go}app.gofrontend/src/{hotkeyLabels.test.ts, RecordingOverlay.test.tsx}internal/hotkey/{labels_test.go, testdata/short_labels.json}internal/overlay/appearance_test.go.github/workflows/ci.yml: runsnpm testin the macOS job. Before this, the frontend tests never ran in CI.Small, intentional text changes
The long labels (Settings and sidebar) now follow one rule:
Right ⌃/Right ⇧. They used to beRight Ctrl/Right Shift, which didn't matchRight ⌥/Right ⌘.Enterinstead ofReturn.Superinstead ofWin.Compact badge changes:
⊞and the Mac glyphs becomeWin/Super,Alt,Ctrl,Shift,Caps,Tab,Enter,Bksp,Del.Spacereplaces␣,↩replaces↵, andfnmatches the key cap.deleteshows⌫, because that's the keyhotkey_darwin.goactually binds.Onboarding still uses Go's
GetRecordingHotkeyDisplayName("Right Option (⌥)" / "Right Alt"). That text is already platform-correct, so this PR leaves it alone.Tests
cd frontend && npm test:Appkeeps the badges hidden whileGetPlatformis pending, then showsAlt/Right Alton Windows with no⌥at any point. It also passes the configured keys to the overlay (⌘/F10).RecordingOverlayrenders the configured labels: WindowsAlt/Esc, macOS⌘,F9/F10. It omits an empty badge and keeps the button wiring.go test -race ./...passes on macOS, including:TestShortLabelFor, which uses the shared table;TestButtonText;TestOverlayButtonsFitHotkeyLabels, which covers the original layout for bare captions, wider buttons that fit their captions at 1x/1.5x/2x, no overlap with the status text, and the key label actually being drawn.GOOS=windows go vetis clean forinternal/overlay.GOOS=windows CGO_ENABLED=0 go test -cbuilds for./internal/overlayand./internal/hotkey.GOOS=windows go vet ./...for the whole module still stops at portaudio (needs cgo), the same as onmain.hotkey_windows.go:136, in a file this PR doesn't touch.npm run build,go vet ./...pass.Manual verification (macOS,
wails devwith an isolated HOME, driven via bindings)rightoption/escape⌥Stop ⌥·Cancel EscStop ⌥·Cancel Escf9/escape, set in SettingsF9Stop F9·Cancel EscStop F9·Cancel Escrightcommand/f10, set in Settings⌘Stop ⌘·Cancel F10Stop ⌘·Cancel F10rightshift/f10, after rebase and review fixes⇧, sidebarRight ⇧Stop ⇧·Cancel F10Stop ⇧·Cancel F10rightalt, withGetPlatformmocked towindowsAlt, sidebarRight AltStop Alt·Cancel Escgo testartifact) showsStop Alt·Cancel EscScreenshots were taken locally. They aren't attached because they come from a dev build.
Merging with PR #18
This branch first added its own minimal Vitest setup, byte-identical to PR #18's (
package.json,vite.config.ts,src/test/setup.ts, the md5 file). #18 was merged while this was in progress. After rebasing onto it, those files and the lockfile are unchanged frommain. The only test-infrastructure change left is the CInpm teststep. Locally, all 77 frontend tests pass, including #18's.Please check on Windows
Stop Alt/Cancel Escwith default keys, and the buttons should still be clickable.