Problem
Restoring tabs on app launch freezes the app. With 12 tabs: ~10 seconds. With 30 tabs: 24+ seconds, 100% CPU, 800MB RAM.
Root cause
Each tab = one NSWindow (macOS native tab requirement). Each NSWindow creation via SwiftUI's openWindow takes ~800ms:
- Full SwiftUI view hierarchy creation
- SessionStateFactory + MainContentCoordinator instantiation
- SourceEditor + TreeSitterClient initialization
- Schema loading race condition (12+ parallel loads)
- databaseDidConnect notification storm (24+ events)
Profiling data
[RESTORE] Disk load: 35ms, 30 tab(s) ← Fast
[RESTORE] Opened 29 native tabs in 11541ms ← BOTTLENECK
[RESTORE] Connected in 3163ms
[RESTORE] loadSchemaIfNeeded × 25 ← Redundant
[RESTORE] refreshTables × 12 ← Redundant
Fix direction
Option A: Internal tab bar (recommended)
Build a SwiftUI tab bar inside a single window. All tabs live in one NSWindow, only the active tab's editor is rendered. Native macOS tabs become optional (drag-out). This is how TablePlus, DataGrip, DBeaver, and VS Code work.
Option B: Lazy NSWindow creation
Keep native tabs but create lightweight placeholder NSWindows (AppKit, not SwiftUI) that only show a title. Swap in the full SwiftUI content when the user activates a tab.
Incremental improvements (already identified)
- Schema load coalescing: add Task-based deduplication on SQLSchemaProvider
- refreshTables gate: only first coordinator per connection calls refreshTables
- These reduce redundant work but don't fix the core window creation bottleneck
Problem
Restoring tabs on app launch freezes the app. With 12 tabs: ~10 seconds. With 30 tabs: 24+ seconds, 100% CPU, 800MB RAM.
Root cause
Each tab = one NSWindow (macOS native tab requirement). Each NSWindow creation via SwiftUI's
openWindowtakes ~800ms:Profiling data
Fix direction
Option A: Internal tab bar (recommended)
Build a SwiftUI tab bar inside a single window. All tabs live in one NSWindow, only the active tab's editor is rendered. Native macOS tabs become optional (drag-out). This is how TablePlus, DataGrip, DBeaver, and VS Code work.
Option B: Lazy NSWindow creation
Keep native tabs but create lightweight placeholder NSWindows (AppKit, not SwiftUI) that only show a title. Swap in the full SwiftUI content when the user activates a tab.
Incremental improvements (already identified)