Skip to content

Menu shortcut reads live hotkey + dev-run teardown on Ctrl-C#4

Merged
GordonBeeming merged 3 commits into
mainfrom
gb/menu-shortcut-and-dev-cleanup
Apr 22, 2026
Merged

Menu shortcut reads live hotkey + dev-run teardown on Ctrl-C#4
GordonBeeming merged 3 commits into
mainfrom
gb/menu-shortcut-and-dev-cleanup

Conversation

@GordonBeeming
Copy link
Copy Markdown
Owner

Summary

  • Menu shortcut now reads the configured hotkey. The "Search Screenshots…" item in the menu bar dropdown was hardcoded to ⇧⌘S, so rebinding the invoke hotkey in Preferences (Hyper+S, etc.) left the menu displaying a stale glyph. It now maps the live HotKeyChord to a SwiftUI KeyboardShortcut?. Chords SwiftUI can't represent (empty, non-mappable keycodes) return nil so the menu drops the glyph rather than show the wrong one — the global Carbon hotkey still fires regardless.
  • dev-run.sh cleans up on Ctrl-C. The tail banner used to say "Ctrl-C to stop — app keeps running", which meant every ./Scripts/dev-run.sh session left Distribution/Vista.app on disk and the dev app running in the menu bar. Since the dev bundle shares com.gordonbeeming.vista with the brew-installed prod copy, a stale dev build silently wins the hotkey and UserDefaults on the next login. Ctrl-C now installs an EXIT trap that pkill -x Vista and rm -rf Distribution/Vista.app. Scoped to the tailing branch — --no-tail stays fire-and-forget.

Test plan

  • swift build — compiles clean
  • Open the menu bar dropdown with default ⇧⌘S → menu shows ⇧⌘S
  • Rebind to Hyper+S in Preferences → Shortcuts → reopen menu → shows ⌃⌥⇧⌘S
  • ./Scripts/dev-run.sh, Ctrl-C → expect 🧹 Stopping Vista and removing …/Distribution/Vista.app banner, menu-bar icon gone, Distribution/Vista.app deleted
  • ./Scripts/dev-run.sh --no-tail → app launches, script exits, app + bundle both still present

GordonBeeming and others added 2 commits April 22, 2026 23:37
The "Search Screenshots…" item hardcoded ⇧⌘S, so rebinding the invoke
hotkey to anything else (Hyper+S in my case) left the menu displaying
the old default — a quiet lie to anyone who's touched Preferences.
Read the live HotKeyChord instead and map it to a KeyboardShortcut?.
Chords SwiftUI can't represent (empty, non-mappable keycodes) return
nil, so the menu drops the glyph instead of showing the wrong one.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
Ctrl-C out of the log tail now means "done dev-running": pkill -x
Vista, then rm -rf Distribution/Vista.app. The dev bundle shares
com.gordonbeeming.vista with the brew-installed prod copy, so a stale
dev build left on disk silently wins the hotkey and UserDefaults on
the next launch. The teardown closes that hazard. Scoped to the
tailing branch; --no-tail is still fire-and-forget.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
@GordonBeeming GordonBeeming marked this pull request as ready for review April 22, 2026 13:38
Copilot AI review requested due to automatic review settings April 22, 2026 13:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the menu bar “Search Screenshots…” item to display the currently configured global hotkey, and improves the dev-run.sh developer workflow by cleaning up the dev app bundle/process on Ctrl-C when tailing logs.

Changes:

  • Map the live HotKeyChord preference into a SwiftUI KeyboardShortcut? for menu rendering.
  • Add keyboard-layout-aware keycode→glyph translation for menu shortcut display.
  • Add an EXIT trap in Scripts/dev-run.sh (tailing mode) to stop Vista and remove Distribution/Vista.app on exit/Ctrl-C.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
Sources/Vista/MenuBarContentView.swift Replaces hardcoded shortcut with a live HotKeyChordKeyboardShortcut? mapping for accurate menu glyphs.
Scripts/dev-run.sh Adds Ctrl-C/exit cleanup in the log-tailing branch to prevent stale dev bundles/processes from lingering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/Vista/MenuBarContentView.swift Outdated
Comment thread Scripts/dev-run.sh
Comment thread Sources/Vista/MenuBarContentView.swift Outdated
Two bot-review follow-ups on the menu shortcut change:

- `HotKeyChord.layoutCharacter(for:)` now owns the UCKeyTranslate →
  String conversion. `KeyRecorderView.layoutKeyName` and the menu
  shortcut extension both call into it, each applying its own casing
  rule at the call site (uppercase for the recorder badge, lowercase
  for SwiftUI's `KeyEquivalent`). Kills the two near-identical copies
  of the layout-translation plumbing.
- The "cleared chord" sentinel was `keyCode != 0`, but Carbon virtual
  keycode 0 is `kVK_ANSI_A`, so any chord on the A key (e.g. Hyper+A)
  was silently returning nil and dropping the menu glyph. Guard on
  `(keyCode == 0 && modifiers == 0)` instead — only the fully-empty
  chord means "no shortcut".

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: GitButler <gitbutler@gitbutler.com>
@GordonBeeming GordonBeeming merged commit ce485b2 into main Apr 22, 2026
2 checks passed
@GordonBeeming GordonBeeming deleted the gb/menu-shortcut-and-dev-cleanup branch April 22, 2026 13:53
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