fix(mobile): Local Network permission sheet leaves pairing stuck - #7257
fix(mobile): Local Network permission sheet leaves pairing stuck#7257imMxts wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Establishment ignored application-active-probe and the mobile adapter never started the suspension clock on AppState inactive, so Allow on the iOS Local Network sheet left pairing on Reconnecting until force-quit.
ApprovabilityVerdict: Approved cf7995e This is a straightforward bug fix for mobile pairing getting stuck when iOS permission sheets appear. The changes track 'inactive' app state and reset the connection retry ladder more aggressively during reconnection—a safer fallback behavior. Well-tested with documentation updates. You can customize Macroscope's approvability policy. Learn more. |
Fixes #5061
What Changed
waitForEstablishmentInterruptnow returnstruefor anyisApplicationActiveWakeup(application-active,application-active-probe, orapplication-active-reconnect), so a short resume during connection setup resets the retry ladder the same way a long resume already did.mobileSuspensionStartedAtMsstarts that clock on AppStateinactiveas well asbackground(??=keeps the earlier stamp;activeclears it). The Wakeups paragraph indocs/internals/connection-runtime.mdno longer says establishment ignores probe.Why
First-time iOS LAN pairing: user taps Allow on the Local Network sheet, the environment stays on
Failed to connect. Reconnecting…until force-quit. The sheet isactive → inactive → active; that resume is anapplication-active-probe. Establishment consumed the probe and left the doomed attempt on the retry ladder. The mobile adapter never started the suspension clock oninactive, so a permission sheet could not be classified as a real resume.waitForEstablishmentInterruptalready returnedresetRetryforapplication-active-reconnect. Extending that predicate is the existing seam — same interface, more behaviour.mobileApplicationActiveWakeupstill classifies short inactive as probe; web/desktop inherit the supervisor change viaisApplicationActiveWakeup. Connected-phasemonitorConnectedLeasestill probes on probe and only replaces the lease on reconnect.Test
restarts the retry ladder when a short resume interrupts connection setuptimed out at 60000ms onupstream/main(waitForEstablishmentInterruptswallowedapplication-active-probe; hanging prepare on attempt 2 never reset). After the fix the same assertion reachedphase === "connected" && generation === 2 && attempt === 1.starts the clock on inactive so a short permission sheet stays a probecovers the AppStateinactivestamp that the supervisor test cannot see.vp test run packages/client-runtime/src/connection/supervisor.test.ts apps/mobile/src/connection/app-state-wakeups.test.ts— 36 + 5 passed.vp linton the touched source and test files: 0 errors.UI Changes
No UI change.
Deliberately not included
supervisor.ts:421-427).monitorConnectedLeasestill callslease.session.probeforapplication-active/application-active-probeand only replaces the lease onapplication-active-reconnect.ConnectionWakeupreason (wakeups.ts:5-9). A new reason would widen the interface and collide with fix(mobile): probe on network path changes, restore server leases on reconnect #5154.mobileApplicationActiveWakeupduration rule unchanged. Short inactive remains probe; only the stamp helper now treatsinactivelikebackground.apps/web/src/connection/platform.ts:93-99) still emits plainapplication-active.connectivityLayerAppState network re-read (apps/mobile/src/connection/platform.ts:63-70) — fix(client-runtime): re-read network status when the app resumes #4528 / fix(connection): refresh network status after app activation #5597 resume network refresh.network-path-changed— not in this tree; hunks kept off that path.supervisor.ts:34-35,supervisor.ts:425-427; tests atsupervisor.test.ts:1021and:1044).background-activity.ts:30-34).threads.ts:548-557).shouldResubscribeAfterWakeupis unchanged.inactive; there is no API to tell them apart.presentation.ts:68-81).ConnectionsNewRouteScreen.tsx:150-155,onboarding.ts:13-20).Checklist
Implemented with grok-4.6 in T3 Code.
Note
Medium Risk
Changes shared
EnvironmentSupervisorestablishment interrupts for all platforms; scope is narrow and connected-phase probing is unchanged, but any platform can now restart setup on short foreground wakeups.Overview
Fixes iOS first-time LAN pairing getting stuck on Reconnecting… after the Local Network permission sheet (
active → inactive → active).Shared supervisor: During connection establishment,
waitForEstablishmentInterruptnow interrupts and resets the retry ladder for any application-active wakeup (application-active,application-active-probe, orapplication-active-reconnect), not only long-backgroundapplication-active-reconnect. Short resumes during setup therefore abandon a doomed in-flight attempt instead of waiting through backoff. Connected-phase behavior is unchanged (probe vs full reconnect).Mobile wakeups: New
mobileSuspensionStartedAtMsstarts the background suspension clock on AppStateinactiveas well asbackground(first timestamp is kept throughinactive;activeclears it). The mobile wakeup layer uses this so a brief permission sheet still classifies as a shortapplication-active-probewith correct timing.Docs and tests cover the new establishment and AppState behavior.
Reviewed by Cursor Bugbot for commit cf7995e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix mobile pairing getting stuck when Local Network permission sheet appears
mobileSuspensionStartedAtMsto track suspension start across bothinactiveandbackgroundapp states, preserving the earliest timestamp and clearing it onactive.EnvironmentSupervisorso that any application-active wakeup (application-active,application-active-probe, orapplication-active-reconnect) interrupts an in-flight connection attempt and resets the retry ladder — previously onlyapplication-active-reconnectdid this.inactivebefore returning toactive; without this fix, that transition was not recognized as a suspension, leaving the pairing flow stuck waiting for a retry.inactiveblips now emitapplication-active-probewakeups and reset the retry ladder, which may cause more reconnect attempts after transient interruptions.Macroscope summarized cf7995e.