Skip to content

fix(welcome): wire WindowOpener bridge from all scenes to fix missing-window race#1213

Merged
datlechin merged 1 commit into
mainfrom
fix/window-opener-bridge-wiring-race
May 11, 2026
Merged

fix(welcome): wire WindowOpener bridge from all scenes to fix missing-window race#1213
datlechin merged 1 commit into
mainfrom
fix/window-opener-bridge-wiring-race

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

Welcome window sometimes failed to appear on launch and Dock-icon clicks did nothing. Console showed:
```
WindowOpener call queued; bridge not yet wired
WindowOpener call queued; bridge not yet wired
WindowOpener call queued; bridge not yet wired
```
…and the queue never drained.

Root cause

`WindowOpenerBridge` is the SwiftUI view that hands `openWindow` / `openSettings` closures to the AppKit-world `WindowOpener` singleton. It was mounted only in the Welcome scene and wired itself in `.onAppear { wireUp() }`.

If state restoration or a launch intent caused Welcome to be `orderOut`'d before its view body's first appearance, `.onAppear` never fired, the bridge never wired, and every subsequent `WindowOpener.shared.openWelcome()` call from `AppLaunchCoordinator` / `applicationShouldHandleReopen` / etc. was queued indefinitely. The app would launch with no visible window and Dock-icon clicks would silently queue more calls onto the dead queue.

Fix

  1. Mount `WindowOpenerBridge` in all four SwiftUI scenes: Welcome, ConnectionForm, IntegrationsActivity, Settings. Whichever scene materializes first triggers the wire-up; subsequent scenes call `wire(...)` again, which is idempotent (overwrites the same closures, drains the now-empty queue).
  2. Switch `.onAppear` → `.task`. `.task` fires reliably when the view enters the hierarchy, even if it never reaches the visible state.

Test plan

  • Launch the app cleanly (no restored state). Welcome window appears.
  • Launch with a restored connection window. Welcome window does NOT appear (correct), but clicking the Dock icon shows Welcome.
  • Cmd+, to open Settings works.
  • Click "+" to open New Connection works.
  • Console has no "WindowOpener call queued; bridge not yet wired" warnings during normal launch.

@datlechin datlechin merged commit a684714 into main May 11, 2026
2 checks passed
@datlechin datlechin deleted the fix/window-opener-bridge-wiring-race branch May 11, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant