Skip to content

Fix worktree-selection hotkeys for folders and disabled slots#322

Merged
sbertix merged 1 commit into
mainfrom
sbertix/sidebar-hotkey-fixes
May 14, 2026
Merged

Fix worktree-selection hotkeys for folders and disabled slots#322
sbertix merged 1 commit into
mainfrom
sbertix/sidebar-hotkey-fixes

Conversation

@sbertix
Copy link
Copy Markdown
Collaborator

@sbertix sbertix commented May 14, 2026

Summary

  • Folder rows in the sidebar now show the ⌃N hint when Cmd is held, matching git rows. They previously bypassed SidebarItemGroupView, so the hint never rendered even though the routing already worked.
  • The Select Worktree menu drops cleared bindings and out-of-range slots before rendering. SwiftUI's .appKeyboardShortcut(nil) inside a CommandMenu leaves a stale keyEquivalent on the underlying NSMenuItem, which made the next slot's key fire the previous slot's button. Filtering upstream means the modifier is never emitted with nil. The same filter closes a sibling case where a bound but rowless slot rendered as a disabled NSMenuItem that swallowed the keystroke (system beep) instead of letting it fall through to the terminal.
  • Pure helpers (worktreeSelectionShortcutDisplay, activeWorktreeSelectionSlots) live on AppShortcuts so both the menu and both sidebar hint sites share one source of truth.
  • Pre-existing em dashes in touched files swapped for · (user-facing menu title) or periods (doc comments).

Test plan

  • make build-app
  • make test (7 new regression tests in AppShortcutsTests cover disabled-override, out-of-range, combined, and the display helper invariants)
  • make check (swift-format + swiftlint clean)
  • Manual: hold Cmd over a folder row, see ⌃N hint
  • Manual: clear ⌃6 in Settings, press ⌃7, the 7th worktree gets selected (not the 6th)
  • Manual: with 2 worktrees, press ⌃3, the keystroke falls through to the terminal instead of beeping

Folder repos in the sidebar bypass `SidebarItemGroupView`, so they never received the ⌃N hint when Cmd was held even though the routing already worked for them. Folder rows now compute the hint via the same shared `AppShortcuts.worktreeSelectionShortcutDisplay` helper as git rows.

Clearing a worktree-selection binding in Settings used to make the next slot's key fire the previous slot's button. SwiftUI's `.appKeyboardShortcut(nil)` inside a `CommandMenu` leaves a stale `keyEquivalent` on the underlying `NSMenuItem`. The Select Worktree menu now drops cleared and out-of-range slots upstream so the modifier is never emitted with nil; the same filter closes a sibling case where a disabled `NSMenuItem` whose `keyEquivalent` is bound but whose row doesn't exist swallows the keystroke instead of letting it fall through.

The new pure helpers live on `AppShortcuts` and are covered by regression tests in `AppShortcutsTests`.
@sbertix sbertix enabled auto-merge (squash) May 14, 2026 23:17
@tuist
Copy link
Copy Markdown

tuist Bot commented May 14, 2026

🛠️ Tuist Run Report 🛠️

Builds 🔨

Scheme Status Duration Commit
supacode 56.1s c83374bf3

@sbertix sbertix merged commit 9b62f0d into main May 14, 2026
2 checks passed
@sbertix sbertix deleted the sbertix/sidebar-hotkey-fixes branch May 14, 2026 23:23
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.

1 participant