Route main window bootstrap through AppDelegate

Merged
LA
7mo ago
+151-51

Fixes the duplicate-window path behind external folder opens.

What changed:

  • SwiftUI WindowGroup now hosts only a hidden bootstrap view and does not own ContentView state.
  • AppDelegate creates and owns real ContentView main windows, including FileExplorerState.
  • TerminalController starts against the active AppDelegate window manager.
  • Reopen and external folder opens reuse AppDelegate main-window state.

Verification:

  • Built and launched tag wmain.
  • Replayed /usr/bin/open -a <wmain.app> <folder> for /var/tmp, ~, ~/fun, ~/fun/cmuxterm-hq, and /tmp.
  • Debug socket: 1 logical window, 6 workspaces.
  • WindowServer: 1 visible layer-0 cmux DEV wmain window.
  • Computer Use: selected /tmp workspace showed a rendered terminal prompt.

Summary by CodeRabbit

  • Bug Fixes

    • Prevented duplicate windows from appearing and lingering; duplicates are now detected, closed, and logged in debug builds.
    • Fixed reopen/startup behavior so the app reliably activates or creates the primary window when reopened or launched.
  • Improvements

    • Disabled automatic OS window restoration to avoid resurrecting stale windows.
    • Track file-explorer state per main window so each window preserves its explorer view independently.
    • Improved window lifecycle stability and diagnostics.