@@ -191,25 +191,15 @@ extension AppDelegate {
191191 // MARK: - Welcome Window Suppression
192192
193193 func scheduleWelcomeWindowSuppression( ) {
194+ // The actual welcome window closing is event-driven:
195+ // - windowDidBecomeKey closes welcome when a main window appears
196+ // - Connection handlers close welcome on success, reopen on failure
197+ // This method just manages the suppression counter after a brief delay
198+ // to allow those event-driven handlers to fire.
194199 Task { @MainActor [ weak self] in
195- // Keep trying to close the welcome window until a main window is visible.
196- // DuckDB and other slow-connecting databases may take several seconds,
197- // so we poll repeatedly rather than giving up after 700ms.
198- var suppressed = false
199- for attempt in 0 ..< 30 {
200- try ? await Task . sleep ( for: . milliseconds( attempt < 4 ? 200 : 500 ) )
201- guard let self else { return }
202- if self . closeWelcomeWindowIfMainExists ( ) {
203- suppressed = true
204- break
205- }
206- }
200+ try ? await Task . sleep ( for: . milliseconds( 500 ) )
207201 guard let self else { return }
208- if !suppressed {
209- // Timed out — restore welcome window so the app isn't left windowless
210- windowLogger. warning ( " Welcome window suppression timed out after 15s, restoring welcome window " )
211- self . openWelcomeWindow ( )
212- }
202+ self . closeWelcomeWindowIfMainExists ( )
213203 self . fileOpenSuppressionCount = max ( 0 , self . fileOpenSuppressionCount - 1 )
214204 if self . fileOpenSuppressionCount == 0 {
215205 self . isHandlingFileOpen = false
@@ -255,6 +245,10 @@ extension AppDelegate {
255245 configuredWindows. insert ( windowId)
256246 }
257247
248+ if isMainWindow ( window) && isHandlingFileOpen {
249+ closeWelcomeWindowIfMainExists ( )
250+ }
251+
258252 if isMainWindow ( window) && !configuredWindows. contains ( windowId) {
259253 window. tabbingMode = . preferred
260254 let pendingId = MainActor . assumeIsolated { WindowOpener . shared. consumePendingConnectionId ( ) }
0 commit comments