fix: close main window before reopening welcome on connection failure#236
fix: close main window before reopening welcome on connection failure#236
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fdb5e9004
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| Self.logger.error( | ||
| "Failed to connect: \(error.localizedDescription, privacy: .public)") | ||
| handleConnectionFailure(error: error) |
There was a problem hiding this comment.
Run failure recovery on the MainActor
In connectToDatabase, the catch path now calls handleConnectionFailure directly from an unstructured Task, but that helper performs AppKit/SwiftUI UI work (closeWindows, openWindow, AlertHelper.showErrorSheet). Because the previous await MainActor.run hop was removed, failed connections can execute UI operations off the main actor, which can trigger AppKit thread-safety crashes or undefined UI behavior during connection errors.
Useful? React with 👍 / 👎.
|
|
||
| private func handleConnectionFailure(error: Error) { | ||
| // Close the main window first so macOS doesn't merge it with the welcome window | ||
| NSApplication.shared.closeWindows(withId: "main") |
There was a problem hiding this comment.
Close only the failed main window
handleConnectionFailure now calls NSApplication.shared.closeWindows(withId: "main"), and that helper closes all windows whose identifier contains main. In sessions where users already have other main windows open (for example after opening Welcome via “Manage Connections”), one failed connection attempt will close unrelated active windows/tabs and can drop in-progress work.
Useful? React with 👍 / 👎.
Summary
handleConnectionFailurefor clarity.Test plan