@@ -326,34 +326,31 @@ extension AppDelegate {
326326
327327 isAutoReconnecting = true
328328
329- DispatchQueue . main . async { [ weak self] in
329+ Task { @ MainActor [ weak self] in
330330 guard let self else { return }
331331 WindowOpener . shared. pendingConnectionId = connection. id
332332 NotificationCenter . default. post ( name: . openMainWindow, object: connection. id)
333333
334- Task { @MainActor in
335- defer { self . isAutoReconnecting = false }
336- do {
337- try await DatabaseManager . shared. connectToSession ( connection)
338-
339- for window in NSApp . windows where self . isWelcomeWindow ( window) {
340- window. close ( )
341- }
342- } catch is CancellationError {
343- // User cancelled password prompt at startup — return to welcome
344- for window in NSApp . windows where self . isMainWindow ( window) {
345- window. close ( )
346- }
347- self . openWelcomeWindow ( )
348- } catch {
349- windowLogger. error ( " Auto-reconnect failed for ' \( connection. name) ': \( error. localizedDescription) " )
334+ defer { self . isAutoReconnecting = false }
335+ do {
336+ try await DatabaseManager . shared. connectToSession ( connection)
350337
351- for window in NSApp . windows where self . isMainWindow ( window) {
352- window. close ( )
353- }
338+ for window in NSApp . windows where self . isWelcomeWindow ( window) {
339+ window. close ( )
340+ }
341+ } catch is CancellationError {
342+ for window in NSApp . windows where self . isMainWindow ( window) {
343+ window. close ( )
344+ }
345+ self . openWelcomeWindow ( )
346+ } catch {
347+ windowLogger. error ( " Auto-reconnect failed for ' \( connection. name) ': \( error. localizedDescription) " )
354348
355- self . openWelcomeWindow ( )
349+ for window in NSApp . windows where self . isMainWindow ( window) {
350+ window. close ( )
356351 }
352+
353+ self . openWelcomeWindow ( )
357354 }
358355 }
359356 }
0 commit comments