[codex] Fix command palette query focus#287
Merged
Merged
Conversation
40941b3 to
4a7b675
Compare
4a7b675 to
51affc7
Compare
51affc7 to
53fcd1a
Compare
53fcd1a to
7962f72
Compare
7962f72 to
623392d
Compare
6 tasks
shanegao
pushed a commit
to shanegao/Prowl
that referenced
this pull request
May 19, 2026
Adds three worktree navigation commands and reverses the focus-restore default so future delegate handlers inherit it for free. Navigation actions (gated on selectedWorktreeID): - Reveal in Finder — dispatches openWorktree(.finder), so it always opens Finder regardless of the user's configured default editor. No hotkey hint: ⌘O binds the configurable openWorktree action, which may resolve to a different tool. - Copy Path — writes selectedTerminalWorktree.workingDirectory.path to NSPasteboard inline. No hotkey hint: the underlying ⌘⇧C binding is dead (onevcat#295 tracks removing it). - Reveal in Sidebar — sends .showLeftSidebar followed by .revealSelectedWorktreeInSidebar. Focus restore refactor: The original fix (onevcat#287) patched five sites to merge restoreCommandPaletteTerminalFocusEffect into their effects. Every delegate handler added since silently dropped the behavior (Toggle Sidebar / Active Agents / Shelf, Show Diff, and the new navigation actions all lost focus restoration). Instead of per-case opt-in, this commit adds a dedicated Reduce after `core` that fires the restore for every CommandPalette delegate action except those in commandPaletteDelegateChangesActiveSelection (selectWorktree, jumpToLatestUnread, viewArchivedWorktrees, newWorktree, toggleCanvas). The three explicit .merge(restore...) calls in checkForUpdates / refreshWorktrees / debugTestToast are removed since they're now redundant. Future commands get focus restoration by default; opting out means adding the case to the deny list. Implementation notes: - navigationDelegateAction helper in CommandPaletteFeature mirrors the existing pullRequestDelegateAction pattern, keeping appDelegateAction under the cyclomatic-complexity threshold. - ghosttyCommand test updated to expect both performBindingAction and the new focusSelectedTab effect (order-independent assertions). - New tests cover the whitelist default (toggleLeftSidebar) and the deny list (toggleCanvas), plus delegate routing for all three new navigation actions.
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.
Summary
@FocusStatequery focus handoff with a thin AppKit-backed query field, following the existing terminal search overlay pattern.Cmd+Pmenu-command path cannot leave the terminal as first responder.Cmd+P, and passive command actions such as check-for-updates/refresh/debug toast.terminalClient.canvasFocusedWorktreeID().Root Cause Evidence
The reproduced behavior on macOS 26.5 is specific:
Cmd+Popens the palette.Cmd+Shift+Pworked in the original implementation.That points away from shortcut delivery or overlay presentation, and toward the query field failing to become first responder after the
Cmd+Popen path. Earlier attempts also ruled out Ghostty keybind routing and upstream menu identity alignment as sufficient fixes.One intermediate AppKit field version made things worse because it replaced the existing keyboard shortcut fallback and closed the palette on text-field focus churn. This version intentionally avoids that: it preserves the fallback shortcut buttons and does not use blur as a dismiss signal.
Regression Check
TerminalClient.Command.focusSelectedTab.selectedTerminalWorktree; Canvas restore usescanvasFocusedWorktreeID; worktree selection explicitly does not restore the previous terminal focus.Validation
xcodebuild test -project supacode.xcodeproj -scheme supacode -destination "platform=macOS" -only-testing:supacodeTests/AppShortcutsTests -only-testing:supacodeTests/CommandPaletteFeatureTests -only-testing:supacodeTests/AppFeatureCommandPaletteTests CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" -skipMacroValidation 2>&1 | xcsift -f toonmake build-app 2>&1 | xcsift -f toonManual Verification
Cmd+P, type a query, and verify the text appears in the Command Palette field rather than the terminal.Cmd+Pthen Up/Down changes palette selection.Cmd+Pthen clicking the query field still allows typing.Cmd+Shift+Popens the palette and accepts typing.Cmd+Pdismisses the palette and returns typing focus to the previous terminal in Normal, Shelf, and Canvas modes.