Skip to content

Commit 69793bd

Browse files
committed
fix(ios): isolate retained reconnect errors
1 parent 67f853b commit 69793bd

4 files changed

Lines changed: 65 additions & 28 deletions

File tree

‎apps/.i18n/native-source.json‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19843,39 +19843,39 @@
1984319843
},
1984419844
{
1984519845
"kind": "ui-localized-call-multiline",
19846-
"line": 1283,
19846+
"line": 1281,
1984719847
"path": "apps/ios/Sources/Gateway/GatewayConnectionController.swift",
1984819848
"source": "Can't reach gateway at %1$@:%2$@. Verify Tailscale Serve is enabled and publishes this Gateway.",
1984919849
"surface": "apple",
1985019850
"id": "native.apple.1d1aa0192206041c"
1985119851
},
1985219852
{
1985319853
"kind": "ui-localized-call",
19854-
"line": 1292,
19854+
"line": 1290,
1985519855
"path": "apps/ios/Sources/Gateway/GatewayConnectionController.swift",
1985619856
"source": "Can't reach gateway at %1$@:%2$@. Check Tailscale or LAN.",
1985719857
"surface": "apple",
1985819858
"id": "native.apple.f8e351c2a7c24652"
1985919859
},
1986019860
{
1986119861
"kind": "ui-localized-call-multiline",
19862-
"line": 1298,
19862+
"line": 1296,
1986319863
"path": "apps/ios/Sources/Gateway/GatewayConnectionController.swift",
1986419864
"source": "TLS fingerprint verification timed out for %1$@:%2$@. Secure endpoint was reached, but TLS did not finish in time.",
1986519865
"surface": "apple",
1986619866
"id": "native.apple.5939318ffa667d0a"
1986719867
},
1986819868
{
1986919869
"kind": "ui-localized-call-multiline",
19870-
"line": 1306,
19870+
"line": 1304,
1987119871
"path": "apps/ios/Sources/Gateway/GatewayConnectionController.swift",
1987219872
"source": "No secure gateway endpoint was detected at %1$@:%2$@. Enable gateway TLS or Tailscale Serve, or use a trusted private LAN address with Unencrypted selected.",
1987319873
"surface": "apple",
1987419874
"id": "native.apple.9dd9783959c1a4ab"
1987519875
},
1987619876
{
1987719877
"kind": "ui-localized-call",
19878-
"line": 1316,
19878+
"line": 1314,
1987919879
"path": "apps/ios/Sources/Gateway/GatewayConnectionController.swift",
1988019880
"source": "Could not read the TLS certificate from %1$@:%2$@.",
1988119881
"surface": "apple",
@@ -20651,111 +20651,111 @@
2065120651
},
2065220652
{
2065320653
"kind": "ui-localized-call",
20654-
"line": 3802,
20654+
"line": 3805,
2065520655
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2065620656
"source": "Approval needed",
2065720657
"surface": "apple",
2065820658
"id": "native.apple.ce6a022159f2fb41"
2065920659
},
2066020660
{
2066120661
"kind": "ui-localized-call",
20662-
"line": 3803,
20662+
"line": 3806,
2066320663
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2066420664
"source": "Action required",
2066520665
"surface": "apple",
2066620666
"id": "native.apple.0d030e96f7738497"
2066720667
},
2066820668
{
2066920669
"kind": "ui-localized-call",
20670-
"line": 4469,
20670+
"line": 4472,
2067120671
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2067220672
"source": "Connecting...",
2067320673
"surface": "apple",
2067420674
"id": "native.apple.6504753f3621269e"
2067520675
},
2067620676
{
2067720677
"kind": "ui-localized-call",
20678-
"line": 4470,
20678+
"line": 4473,
2067920679
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2068020680
"source": "Reconnecting...",
2068120681
"surface": "apple",
2068220682
"id": "native.apple.c7fbe2a713d78714"
2068320683
},
2068420684
{
2068520685
"kind": "conditional-branch",
20686-
"line": 4789,
20686+
"line": 4792,
2068720687
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2068820688
"source": "Connected",
2068920689
"surface": "apple",
2069020690
"id": "native.apple.c0a005f81d588867"
2069120691
},
2069220692
{
2069320693
"kind": "conditional-branch",
20694-
"line": 4789,
20694+
"line": 4792,
2069520695
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2069620696
"source": "Offline",
2069720697
"surface": "apple",
2069820698
"id": "native.apple.ae33908b61c6d70b"
2069920699
},
2070020700
{
2070120701
"kind": "conditional-branch",
20702-
"line": 5935,
20702+
"line": 5938,
2070320703
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2070420704
"source": "No chat messages yet",
2070520705
"surface": "apple",
2070620706
"id": "native.apple.4a98b3a346be2662"
2070720707
},
2070820708
{
2070920709
"kind": "conditional-branch",
20710-
"line": 6134,
20710+
"line": 6137,
2071120711
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2071220712
"source": "Connecting…",
2071320713
"surface": "apple",
2071420714
"id": "native.apple.b0d9c1ba8ef7ec19"
2071520715
},
2071620716
{
2071720717
"kind": "conditional-branch",
20718-
"line": 6134,
20718+
"line": 6137,
2071920719
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2072020720
"source": "Reconnecting…",
2072120721
"surface": "apple",
2072220722
"id": "native.apple.bd98e19b49309284"
2072320723
},
2072420724
{
2072520725
"kind": "conditional-branch",
20726-
"line": 8419,
20726+
"line": 8422,
2072720727
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2072820728
"source": "Approval",
2072920729
"surface": "apple",
2073020730
"id": "native.apple.0b1eff808df04e2b"
2073120731
},
2073220732
{
2073320733
"kind": "conditional-branch",
20734-
"line": 8419,
20734+
"line": 8422,
2073520735
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2073620736
"source": "This approval was already",
2073720737
"surface": "apple",
2073820738
"id": "native.apple.c74dccc1c5d71750"
2073920739
},
2074020740
{
2074120741
"kind": "conditional-branch",
20742-
"line": 8425,
20742+
"line": 8428,
2074320743
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2074420744
"source": "This approval was already set to Always Allow.",
2074520745
"surface": "apple",
2074620746
"id": "native.apple.4e3a9dc13016600b"
2074720747
},
2074820748
{
2074920749
"kind": "conditional-branch",
20750-
"line": 8426,
20750+
"line": 8429,
2075120751
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2075220752
"source": "Approval set to Always Allow.",
2075320753
"surface": "apple",
2075420754
"id": "native.apple.4864b3b8c6ed7158"
2075520755
},
2075620756
{
2075720757
"kind": "conditional-branch",
20758-
"line": 9730,
20758+
"line": 9733,
2075920759
"path": "apps/ios/Sources/Model/NodeAppModel.swift",
2076020760
"source": "\\(urlText.prefix(500))…",
2076120761
"surface": "apple",

‎apps/ios/Sources/Gateway/GatewayConnectionController.swift‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ final class GatewayConnectionController {
262262
guard availability.canConnect else { return availability.guidanceText }
263263

264264
let connectAttempt = self.beginConnectAttempt()
265-
self.appModel?.clearGatewayProblemWhenSwitching(to: gateway.stableID)
266265
self.pendingConnectionStableID = gateway.stableID
267266
defer { self.finishConnectAttempt(connectAttempt.suppressionLease) }
268267
await self.waitForPendingForgetCleanup(stableID: gateway.stableID)
@@ -381,7 +380,6 @@ final class GatewayConnectionController {
381380
guard let resolvedPort = Self.resolvedManualPort(host: host, port: port)
382381
else { return }
383382
let stableID = self.manualStableID(host: host, port: resolvedPort)
384-
self.appModel?.clearGatewayProblemWhenSwitching(to: stableID)
385383
self.pendingConnectionStableID = stableID
386384
await self.waitForPendingForgetCleanup(stableID: stableID)
387385
guard self.connectAttemptGeneration == connectAttempt.suppressionLease.generation else { return }

‎apps/ios/Sources/Model/NodeAppModel.swift‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,7 +3416,7 @@ extension NodeAppModel {
34163416
!$0.isEmpty && !GatewayStableIdentifier.matches($0, effectiveStableID)
34173417
} ?? false
34183418
if targetChanged {
3419-
self.clearGatewayProblemWhenSwitching(to: effectiveStableID)
3419+
self.clearGatewayProblemForCommittedTargetSwitch(to: effectiveStableID)
34203420
}
34213421
let hasForeignCachedApproval = self.watchExecApprovalPromptsByID.values.contains {
34223422
!GatewayStableIdentifier.matches($0.gatewayStableID, effectiveStableID)
@@ -3699,10 +3699,12 @@ extension NodeAppModel {
36993699
self.gatewayAutoReconnectEnabled = true
37003700
self.gatewayPairingPaused = false
37013701
self.gatewayPairingRequestId = nil
3702+
// A retained error is presentation history, not live operator control. Explicit retries
3703+
// must retire the old pairing state so the replacement session can clear the snapshot.
3704+
self.operatorGatewayProblem = nil
37023705
if !preservingGatewayProblem {
37033706
// Same-target reconnects keep the prior failure readable until success or a new failure.
37043707
// Initial connects and target changes must not inherit another gateway's problem state.
3705-
self.operatorGatewayProblem = nil
37063708
self.clearGatewayConnectionProblem()
37073709
}
37083710
self.credentialHandoffFailureGeneration = nil
@@ -3752,7 +3754,8 @@ extension NodeAppModel {
37523754
}
37533755

37543756
func beginGatewayPreconnectVerification(statusText: String) {
3755-
self.lastGatewayProblem = nil
3757+
// Preflight has not committed the replacement target yet. Keep the readable snapshot
3758+
// while retiring live pairing control; the committed route switch clears the snapshot.
37563759
self.operatorGatewayProblem = nil
37573760
self.gatewayPairingPaused = false
37583761
self.gatewayPairingRequestId = nil
@@ -10696,13 +10699,13 @@ extension NodeAppModel {
1069610699
#endif
1069710700

1069810701
extension NodeAppModel {
10699-
func clearGatewayProblemWhenSwitching(to stableID: String) {
10702+
private func clearGatewayProblemForCommittedTargetSwitch(to stableID: String) {
1070010703
guard let currentStableID = self.activeGatewayConnectConfig?.effectiveStableID
1070110704
?? self.connectedGatewayID,
1070210705
!GatewayStableIdentifier.matches(currentStableID, stableID)
1070310706
else { return }
10704-
// A retained problem and status belong to their gateway. Replace both as soon as another
10705-
// target is chosen, or the replacement connection can present the previous gateway's error.
10707+
// This runs only when the replacement config commits, without a suspension before the
10708+
// route generation advances. Preflight retains the prior snapshot until this boundary.
1070610709
self.operatorGatewayProblem = nil
1070710710
self.clearGatewayConnectionProblem()
1070810711
self.setGatewayConnectionProgress(reconnecting: false)

‎apps/ios/Tests/GatewayConnectionControllerTests.swift‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ private func waitForActiveGateway(stableID: String, appModel: NodeAppModel) asyn
414414
pauseReconnect: false)
415415
appModel._test_applyOperatorGatewayConnectionProblem(problem)
416416

417-
appModel.clearGatewayProblemWhenSwitching(to: currentConfig.effectiveStableID)
418417
#expect(appModel.lastGatewayProblem == problem)
419418

420419
appModel.applyGatewayConnectConfig(currentConfig, forceReconnect: true)
@@ -425,6 +424,10 @@ private func waitForActiveGateway(stableID: String, appModel: NodeAppModel) asyn
425424
let replacementConfig = Self.makeGatewayConnectConfig(
426425
url: replacementURL,
427426
stableID: "manual|replacement.example.com|443")
427+
appModel.beginGatewayPreconnectVerification(statusText: "Verifying gateway TLS fingerprint…")
428+
#expect(appModel.lastGatewayProblem == problem)
429+
#expect(appModel.gatewayDisplayStatusText == problem.localizedStatusText)
430+
428431
appModel.applyGatewayConnectConfig(replacementConfig, forceReconnect: true)
429432
#expect(appModel.lastGatewayProblem == nil)
430433
#expect(appModel.gatewayStatusText == "Connecting…")
@@ -477,6 +480,39 @@ private func waitForActiveGateway(stableID: String, appModel: NodeAppModel) asyn
477480
#expect(appModel.gatewayDisplayStatusText == problem.localizedStatusText)
478481
#expect(!appModel.gatewayPairingPaused)
479482
#expect(appModel.gatewayPairingRequestId == nil)
483+
484+
appModel._test_clearGatewayConnectionProblem()
485+
486+
#expect(appModel.lastGatewayProblem == nil)
487+
#expect(!appModel.gatewayPairingPaused)
488+
#expect(appModel.gatewayPairingRequestId == nil)
489+
}
490+
491+
@Test @MainActor func `gateway preflight retains only the readable problem snapshot`() {
492+
let appModel = NodeAppModel()
493+
defer { appModel.disconnectGateway() }
494+
let config = Self.makeGatewayConnectConfig()
495+
appModel.applyGatewayConnectConfig(config)
496+
let problem = GatewayConnectionProblem(
497+
kind: .pairingScopeUpgradeRequired,
498+
owner: .gateway,
499+
title: "Additional permissions required",
500+
message: "Approve the requested permissions on the gateway.",
501+
requestId: "req-admin",
502+
retryable: false,
503+
pauseReconnect: true)
504+
appModel._test_applyOperatorGatewayConnectionProblem(problem)
505+
506+
appModel.beginGatewayPreconnectVerification(statusText: "Verifying gateway TLS fingerprint…")
507+
508+
#expect(appModel.lastGatewayProblem == problem)
509+
#expect(appModel.gatewayDisplayStatusText == problem.localizedStatusText)
510+
#expect(appModel.gatewayStatusText == "Verifying gateway TLS fingerprint…")
511+
#expect(!appModel.gatewayPairingPaused)
512+
#expect(appModel.gatewayPairingRequestId == nil)
513+
514+
appModel._test_clearGatewayConnectionProblem()
515+
#expect(appModel.lastGatewayProblem == nil)
480516
}
481517

482518
@Test func `gateway connect config keeps stable owner bytes exact`() {

0 commit comments

Comments
 (0)