惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
爱范儿
爱范儿
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
美团技术团队
Y
Y Combinator Blog
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
Martin Fowler
Martin Fowler
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
M
MIT News - Artificial intelligence
博客园 - Franky
V
Visual Studio Blog
I
InfoQ
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
博客园 - 司徒正美
L
LangChain Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(ios): force stale foreground gateway reconnects (#925...
Solvely-Coli · 2026-06-14 · via Recent Commits to openclaw:main

@@ -188,6 +188,7 @@ final class NodeAppModel {

188188

@ObservationIgnored private var backgroundGraceTaskTimer: Task<Void, Never>?

189189

private var backgroundReconnectSuppressed = false

190190

private var backgroundReconnectLeaseUntil: Date?

191+

@ObservationIgnored private var foregroundGatewayResumeCheckInFlight = false

191192

private var lastSignificantLocationWakeAt: Date?

192193

@ObservationIgnored private let watchReplyCoordinator = WatchReplyCoordinator()

193194

private var watchExecApprovalPromptsByID: [String: ExecApprovalPrompt] = [:]

@@ -214,6 +215,7 @@ final class NodeAppModel {

214215

private static let watchExecApprovalBridgeStateKey = "watch.execApproval.bridge.state.v1"

215216

private static let backgroundAliveLastSuccessAtMsKey = "gateway.backgroundAlive.lastSuccessAtMs"

216217

private static let backgroundAliveLastTriggerKey = "gateway.backgroundAlive.lastTrigger"

218+

private static let foregroundResumeHealthTimeoutSeconds = 1

217219218220

var cameraHUDText: String?

219221

var cameraHUDKind: CameraHUDKind?

@@ -417,9 +419,7 @@ final class NodeAppModel {

417419

self.isBackgrounded = false

418420

self.endBackgroundConnectionGracePeriod(reason: "scene_foreground")

419421

self.clearBackgroundReconnectSuppression(reason: "scene_foreground")

420-

if self.operatorConnected {

421-

self.startGatewayHealthMonitor()

422-

}

422+

var shouldStartGatewayHealthMonitor = self.operatorConnected

423423

if phase == .active {

424424

self.voiceWake.resumeAfterExternalAudioCapture(wasSuspended: self.backgroundVoiceWakeSuspended)

425425

self.backgroundVoiceWakeSuspended = false

@@ -444,6 +444,8 @@ final class NodeAppModel {

444444

// iOS may suspend network sockets in background without a clean close.

445445

// On foreground, force a fresh handshake to avoid "connected but dead" states.

446446

if backgroundedFor >= 3.0 {

447+

shouldStartGatewayHealthMonitor = false

448+

self.foregroundGatewayResumeCheckInFlight = true

447449

Task { [weak self] in

448450

guard let self else { return }

449451

let operatorWasConnected = await MainActor.run { self.operatorConnected }

@@ -452,31 +454,26 @@ final class NodeAppModel {

452454

let healthy = await (try? self.operatorGateway.request(

453455

method: "health",

454456

paramsJSON: nil,

455-

timeoutSeconds: 2)) != nil

457+

timeoutSeconds: Self.foregroundResumeHealthTimeoutSeconds)) != nil

456458

if healthy {

457-

await MainActor.run { self.startGatewayHealthMonitor() }

459+

await MainActor.run {

460+

self.foregroundGatewayResumeCheckInFlight = false

461+

self.startGatewayHealthMonitor()

462+

}

458463

return

459464

}

460465

}

461466462-

await self.operatorGateway.disconnect()

463-

await self.nodeGateway.disconnect()

464467

await MainActor.run {

465-

guard !self.isAppleReviewDemoModeEnabled else { return }

466-

self.setOperatorConnected(false)

467-

self.gatewayConnected = false

468-

// Foreground recovery must actively restart the saved gateway config.

469-

// Disconnecting stale sockets alone can leave us idle if the old

470-

// reconnect tasks were suppressed or otherwise got stuck in background.

471-

self.gatewayStatusText = "Reconnecting…"

472-

self.talkMode.updateGatewayConnected(false)

473-

if let cfg = self.activeGatewayConnectConfig {

474-

self.applyGatewayConnectConfig(cfg)

475-

}

468+

self.foregroundGatewayResumeCheckInFlight = false

476469

}

470+

await self.restartGatewaySessionsAfterForegroundStaleConnection()

477471

}

478472

}

479473

}

474+

if shouldStartGatewayHealthMonitor {

475+

self.startGatewayHealthMonitor()

476+

}

480477

@unknown default:

481478

self.isBackgrounded = false

482479

self.endBackgroundConnectionGracePeriod(reason: "scene_unknown")

@@ -786,6 +783,12 @@ final class NodeAppModel {

786783787784

func refreshGatewayOverviewIfConnected() async {

788785

guard await self.isOperatorConnected() else { return }

786+

if self.foregroundGatewayResumeCheckInFlight {

787+

GatewayDiagnostics.log("gateway overview refresh deferred reason=foreground_resume_check")

788+

try? await Task.sleep(

789+

nanoseconds: UInt64(Self.foregroundResumeHealthTimeoutSeconds) * 1_000_000_000)

790+

guard await self.isOperatorConnected(), !self.foregroundGatewayResumeCheckInFlight else { return }

791+

}

789792

await self.refreshBrandingFromGateway()

790793

await self.refreshAgentsFromGateway()

791794

}

@@ -1986,12 +1989,33 @@ extension NodeAppModel {

19861989

}

1987199019881991

func resetGatewaySessionsForForcedReconnect() async {

1989-

self.nodeGatewayTask?.cancel()

1992+

let nodeGatewayTask = self.nodeGatewayTask

1993+

let operatorGatewayTask = self.operatorGatewayTask

1994+

nodeGatewayTask?.cancel()

19901995

self.nodeGatewayTask = nil

1991-

self.operatorGatewayTask?.cancel()

1996+

operatorGatewayTask?.cancel()

19921997

self.operatorGatewayTask = nil

19931998

await self.operatorGateway.disconnect()

19941999

await self.nodeGateway.disconnect()

2000+

// Foreground recovery reuses the same config immediately after reset.

2001+

// Wait for canceled loops so their shutdown cleanup cannot clobber the new reconnect state.

2002+

if let operatorGatewayTask {

2003+

await operatorGatewayTask.value

2004+

}

2005+

if let nodeGatewayTask {

2006+

await nodeGatewayTask.value

2007+

}

2008+

}

2009+2010+

private func restartGatewaySessionsAfterForegroundStaleConnection() async {

2011+

await self.resetGatewaySessionsForForcedReconnect()

2012+

guard !self.isAppleReviewDemoModeEnabled else { return }

2013+

self.setOperatorConnected(false)

2014+

self.gatewayConnected = false

2015+

self.gatewayStatusText = "Reconnecting…"

2016+

self.talkMode.updateGatewayConnected(false)

2017+

guard let cfg = self.activeGatewayConnectConfig else { return }

2018+

self.applyGatewayConnectConfig(cfg, forceReconnect: true)

19952019

}

1996202019972021

func disconnectGateway() {

@@ -4826,6 +4850,10 @@ extension NodeAppModel {

48264850

(self.nodeGatewayTask != nil, self.operatorGatewayTask != nil)

48274851

}

482848524853+

func _test_restartGatewaySessionsAfterForegroundStaleConnection() async {

4854+

await self.restartGatewaySessionsAfterForegroundStaleConnection()

4855+

}

4856+48294857

func _test_handleSuccessfulBootstrapGatewayOnboarding() async {

48304858

await self.handleSuccessfulBootstrapGatewayOnboarding(

48314859

url: URL(string: "wss://gateway.example")!,