From 9a0a46bc8baf02df822e64ad270aa9d3caf013ae Mon Sep 17 00:00:00 2001 From: Andrew Blakeslee Moore Date: Mon, 6 Jul 2026 12:46:02 -0700 Subject: [PATCH] Network Reconnection Delay Nucleic-Session: 4BE3E40C-E939-444C-8AED-93C0AFE13C07 Co-authored-by: Nucleic --- NucleicRemote/NucleicRemote/NucleicRemoteApp.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/NucleicRemote/NucleicRemote/NucleicRemoteApp.swift b/NucleicRemote/NucleicRemote/NucleicRemoteApp.swift index 3546d9a..0337176 100644 --- a/NucleicRemote/NucleicRemote/NucleicRemoteApp.swift +++ b/NucleicRemote/NucleicRemote/NucleicRemoteApp.swift @@ -31,11 +31,18 @@ struct NucleicRemoteApp: App { // activity flag current so it only notifies for background transitions. .onChange(of: scenePhase) { _, phase in store.setScenePhaseActive(phase == .active) - if phase == .active { + switch phase { + case .active: // Re-plan transports immediately on foreground — the network may have // changed while suspended, so don't wait for a dead socket to notice. store.onForeground() Task { await HeartbeatReporter.reportIfDue() } + case .background: + // Hold the process (and its live sockets) briefly so a quick app-switch + // doesn't drop the connection and force a cold reconnect on return. + store.onBackground() + default: + break } } }