Skip to content

refactor: replace native window tabs with in-app tab bar#763

Open
datlechin wants to merge 1 commit intomainfrom
refactor/in-app-tab-bar
Open

refactor: replace native window tabs with in-app tab bar#763
datlechin wants to merge 1 commit intomainfrom
refactor/in-app-tab-bar

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

  • Replace native macOS window tabs (addTabbedWindow, 600-900ms per call) with a custom SwiftUI EditorTabBar for instant tab switching
  • Tab restoration now loads all tabs into a single window instead of opening N separate native windows (eliminates N² view lifecycle cascades)
  • All editor tab navigation (openTableTab, newTab, FK navigation, favorites, etc.) now adds in-app tabs instead of creating new NSWindow instances

Key changes

New components:

  • EditorTabBar / EditorTabBarItem — custom tab bar with drag-to-reorder, close buttons, context menus, preview tab styling, dirty indicators
  • MainContentCoordinator+TabOperations — tab lifecycle operations (close, reorder, rename, duplicate)

Redirected navigation (13 call sites):

  • MainContentCoordinator+Navigation — 5 sites (active work guard, default open, preview paths)
  • MainContentCoordinator+SidebarActions — 3 sites (createNewTable, createView, editView)
  • MainContentCoordinator+FKNavigation — 1 site
  • MainContentCoordinator+Favorites — 1 site
  • MainContentCoordinator — 2 sites (loadQueryIntoEditor, insertQueryFromAI)
  • MainContentCommandActions — 1 site (openFile)

Simplified infrastructure:

  • Removed onDisappear 200ms grace period (no more tab group merge cascades)
  • Simplified quit-time persistence (single coordinator saves directly, no multi-window aggregation)
  • Cmd+T adds in-app tab via coordinator instead of creating native window
  • Cmd+W closes in-app tab when >1 tab, closes window on last tab
  • Cmd+1-9, Cmd+Shift+[/] switch in-app tabs
  • Set window.tabbingMode = .disallowed (native window tabs only for connection grouping)

Test plan

  • Cmd+T adds in-app tab instantly (no 600ms delay)
  • Click table in sidebar opens in-app tab
  • Click table with active work (unsaved changes/filters/sort) opens new in-app tab
  • Cmd+W closes tab when >1 tab exists
  • Cmd+W closes window on last tab
  • Close tab with unsaved changes shows confirmation dialog
  • Cmd+1-9 switches to Nth in-app tab
  • Cmd+Shift+[ and Cmd+Shift+] cycle through tabs
  • Quit with 5 tabs open → relaunch → all 5 restored in one window
  • Preview tabs: single-click sidebar → italic preview tab, double-click → promoted
  • Drag tabs to reorder in tab bar
  • Context menu: Close, Close Others, Close to Right, Close All, Duplicate
  • FK navigation opens in-app tab
  • Database switch clears tabs correctly
  • ER diagram, server dashboard, create table all add in-app tabs
  • Multiple connections open as separate windows (each with own tab bar)

…switching

Native macOS window tabs used addTabbedWindow() which took 600-900ms per
call, causing severe lag on Cmd+T and tab restoration. This refactor moves
to a single-window-per-connection architecture with a custom SwiftUI tab
bar, eliminating the N² view lifecycle cascades during tab restore.
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