✨ feat: Cmd-hold shortcut hints for toolbar & sidebar footer#63
Conversation
…tons - Overlay ShortcutHintPill on all 5 toolbar buttons (Toggle Sidebar ⌘B, Files ⌘E, Git ⌘G, Split Right ⌘D, Split Down ⇧⌘D) via ShortcutHintModifierMonitor + Combine subscription - Add ⇧⌘O shortcut hint to sidebar footer Open Project button - Unify footer button label from 'Add Repository' to 'Open Project' (same underlying action: showAddProjectPanel) - Fix sidebar tooltip from incorrect ⌘0 to actual default ⌘B - Add shortcut hints to split button tooltips - Update en + zh-Hans localization strings Amp-Thread-ID: https://ampcode.com/threads/T-019d872d-c86f-72fb-af91-81864d8eaaef Co-authored-by: Amp <amp@ampcode.com>
All 5 toolbar buttons now use the same NSImage.SymbolConfiguration (pointSize: 13). Previously sidebar/files/git used the default size while split right/down were set to 11pt. Amp-Thread-ID: https://ampcode.com/threads/T-019d872d-c86f-72fb-af91-81864d8eaaef Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019d872d-c86f-72fb-af91-81864d8eaaef
The previous approach used item.value(forKey: "view") which returns nil for image-based NSToolbarItems. Now walks the window's view hierarchy to find toolbar button views by matching their identifier, and overlays pills on the superview so they render above the buttons. Amp-Thread-ID: https://ampcode.com/threads/T-019d872d-c86f-72fb-af91-81864d8eaaef Co-authored-by: Amp <amp@ampcode.com>
Rewrote toolbar item creation to use custom NSButton views via item.view instead of image-based items. This gives us direct references to the button views. Pills are now overlaid on themeFrame (the titlebar container) using coordinate conversion from the owned button anchors — same proven pattern as the update pill overlay. The previous approach failed because: 1. image-based NSToolbarItems don't expose their internal views 2. NSView.identifier matching on private toolbar views is unreliable 3. pills added to toolbar's internal superview get clipped Amp-Thread-ID: https://ampcode.com/threads/T-019d872d-c86f-72fb-af91-81864d8eaaef Co-authored-by: Amp <amp@ampcode.com>
Switched from Auto Layout constraints to frame-based positioning. AppKit uses bottom-left origin (y increases upward), but Auto Layout topAnchor with a large constant pushes downward — causing pills to appear at the window bottom instead of above the toolbar. Amp-Thread-ID: https://ampcode.com/threads/T-019d872d-c86f-72fb-af91-81864d8eaaef Co-authored-by: Amp <amp@ampcode.com>
- Replace 5 separate @objc action methods with single toolbarAction(_:) dispatcher using KeyPath callbacks - Consolidate toolbar item definitions, shortcut hints, and callbacks into a single ToolbarItemDef array - Eliminate repetitive switch in toolbar(_:itemForItemIdentifier:) with data-driven lookup - Merge toolbarDefaultItemIdentifiers and toolbarAllowedItemIdentifiers into shared defaultItemIds constant Amp-Thread-ID: https://ampcode.com/threads/T-019d872d-c86f-72fb-af91-81864d8eaaef Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e780f618f7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ToolbarItemDef(id: ToolbarID.toggleSidebar, label: .localized("Toggle Sidebar"), | ||
| toolTip: .localized("Show or hide the sidebar (⌘B)"), | ||
| symbol: "sidebar.left", hint: "⌘B", callback: \.onToggleSidebar), |
There was a problem hiding this comment.
Read toolbar hint strings from keybinding state
toolbarItemDefs now hardcodes Cmd-hold pill hints (for example "⌘B", "⌘E", "⌘D") and tooltip shortcut text, but these actions are configurable in the app’s key-binding system. If a user remaps or removes any of those bindings, the toolbar still advertises the old default shortcuts, which is misleading and points users to shortcuts that no longer work. Please derive these displayed shortcuts from the active bindings at runtime (or hide hints when unbound).
Useful? React with 👍 / 👎.
Summary
Add shortcut hint pills to toolbar buttons and sidebar footer when long-pressing ⌘, matching the existing sidebar row hint behavior.
Toolbar
NSButtonviews viaitem.viewfor reliable view ownershipthemeFrameusing frame-based coordinate conversionToolbarItemDefarray replaces repetitive switch/action boilerplateSidebar Footer
⇧⌘Oshortcut hint to the Open Project buttonFixes
⌘0to actual default⌘B⌘D,⇧⌘D)