fix(launch): keep Welcome visible until a main window is on-screen#1027
Closed
fix(launch): keep Welcome visible until a main window is on-screen#1027
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related fixes for the "app launches with no visible window" failure mode.
1.
attemptAutoReconnectno longer destroys Welcome before main window is visibleAppLaunchCoordinator.attemptAutoReconnectwouldorderOutthe Welcome window upfront, then asynchronously try to reconnect saved connections, thenclose()Welcome unconditionally, then try to reshow Welcome only if no main window came up. Failure modes:ensureConnectedhangs (e.g., SSH tunnel never returns) → Welcome stays hidden, no main window painted, user sees nothingensureConnectedthrows after Welcome was alreadyclose()d → reshow attempt depends on the bridge in the destroyed Welcome scene's view treewindowWillCloseobserver inAppDelegatethat also tries to reopen WelcomeFix: Apple-pattern graceful degradation — never destroy fallback UI (Welcome) until the replacement (main window) is confirmed on-screen. Welcome stays visible during reconnect (briefly overlapping with the new main window). Welcome only closes once a main window is confirmed visible. If reconnect hangs or all connections fail, Welcome was never hidden — user has UI to act on.
2.
applicationDidBecomeActivesafety netWhenever the app becomes active (whether from launch, relaunch, or click-to-front from the dock), check if any main or Welcome window is visible. If none, call
WindowOpener.shared.openWelcome(). The call works as long as the bridge has been wired at least once during this session.This catches the residual cases where Welcome was rendered then closed (so the bridge is wired) but no main window came up — e.g., a delayed connection failure, a user closing the only main window, or any future code path that leaves the app in a no-window state.
Known limitation
Neither fix solves the first-launch race seen with
xctrace --launchand (rarely) Xcode runs, where SwiftUI never instantiates any scene's body, so the bridge is never wired. The proper fix for that would require an imperativeNSWindow+NSHostingControllerfallback (essentially the pre-PR-988WelcomeWindowFactorypattern, kept as last-resort fallback). Out of scope for this PR. Workaround: launch the app normally before profiling, thenxctrace record --attach TableProinstead of--launch.Test plan
startupBehavior=.reopenLastand 1 valid saved connection: main window appears, Welcome closes after connect completesstartupBehavior=.reopenLastand 1 invalid saved connection (deleted/wrong host): main window opens with error, Welcome stays visiblelastOpenConnectionIdssaved: Welcome auto-launches normally, no Task runs