Skip to content

fix: route Cmd+T through newWindowForTab responder chain to prevent focus flash#1078

Merged
datlechin merged 1 commit into
mainfrom
fix/native-tab-cmd-t-routing
May 7, 2026
Merged

fix: route Cmd+T through newWindowForTab responder chain to prevent focus flash#1078
datlechin merged 1 commit into
mainfrom
fix/native-tab-cmd-t-routing

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • Bug: in a native NSWindow tab group, Cmd+T opens the new query tab and it briefly becomes key, then focus jumps back to the previous tab.
  • Root cause: SwiftUI menu's Button("New Tab") called actions?.newTab() directly, bypassing AppKit's tab-aware focus management. After the menu key-equivalent dispatch returned, AppKit reasserted the previously-key window.
  • Fix: route Cmd+T through the standard AppKit responder chain by overriding newWindowForTab(_:) on EditorWindow (matches the existing performClose(_:) override pattern), and dispatching from the SwiftUI menu and toolbar button via NSApp.sendAction(#selector(NSWindow.newWindowForTab(_:)), to: nil, from: nil) — the same pattern already used for selectNextTab(_:) / selectPreviousTab(_:) in this file.

Test plan

  • Open a table tab, press Cmd+T → new query tab stays focused, no flash back.
  • Click the toolbar + button → same behavior.
  • Empty connection window (no tabs yet) → Cmd+T adds an in-window query tab.
  • Multiple connection windows open → Cmd+T opens new tab in the focused connection.
  • AppKit's auto-injected "Window > New Tab" menu item → routes through the same override.
  • Cmd+W still routes through closeTab() (regression check on performClose(_:)).

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit 497e550 into main May 7, 2026
2 checks passed
@datlechin datlechin deleted the fix/native-tab-cmd-t-routing branch May 7, 2026 12:29
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