Route main window bootstrap through AppDelegate
Merged
LA
7mo ago+151+151+012345678901234567890123456789-51-51-01234567890123456789
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 wmainwindow. - Computer Use: selected
/tmpworkspace 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.