Skip to content

fix(mobile): distinguish delayed dial deadlines from unreachable hosts - #31478

Merged
nwparker merged 9 commits into
mainfrom
nwparker/mobile-suspension-diagnostics
Oct 22, 2026
Merged

nwparker merged 9 commits into
mainfrom
nwparker/mobile-suspension-diagnostics

Conversation

@nwparker

@nwparker nwparker commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​391 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​390
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​200 $\color{#cf222e}{\Huge{\mathbf{−}}}$​42 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​158

ELI5

When a phone puts Orca to sleep, its connection alarm can ring hours late. Orca now says the alarm was delayed and checks the connection again. A normal timeout still reports a connection failure. Reports also stop presenting a saved host version as today's version.

Problem and fix

A connect deadline armed for 12 seconds was delivered 2h44m later and blamed the endpoint. That gap proves late delivery; it cannot establish why JavaScript stopped running or whether the endpoint was reachable. Diagnostics could also display a previously cached host version as current.

Fixes #18829.

  • Measure elapsed time with the monotonic clock. Reuse the native transport owner's existing AppState listener to supplement clocks that pause during device sleep, counting wall-time gaps only within inactive/background segments. Foreground wall-clock changes and earlier background time do not contaminate fresh deadlines.
  • Delivery more than 60 seconds beyond the connect/handshake budget emits a suspended-dial warning: the app may have been suspended and the connection state is unknown. The same forced close and reconnect path runs. Ordinary 12-second connect and 5-second handshake deadlines retain their errors.
  • Let delayed-deadline evidence replace an older direct timeout, and let a subsequent on-time failure replace that warning.
  • Use the settled status value supplied by the diagnostics route rather than a persisted host-version fallback. Disconnected reports say unknown (not currently connected). If log hydration crosses a connection timestamp change, discard the earlier operation's supplied version rather than attach it to the replacement connection.

Reliability and performance

Invariant: deadline evidence must describe what the client observed while retaining the existing socket-close/retry owner; captured host metadata must not cross an observed reconnect. The oracle is the production socket/report behavior under delayed callbacks, clock changes and asynchronous storage.

The adjacent mobile-relay.endpoint-recovery gate passes. There is no manifest gate specifically for deadline attribution; focused clock/socket/diagnosis regressions provide that oracle, with physical device sleep an explicit coverage gap.

The native root provider owns the physical sockets and existing AppState listener. The web-page provider is a bridge client and does not dial. No additional timer, listener, polling, RPC, protocol field, subprocess or startup wait is added. Clock accounting is O(1), and the report follow-up adds synchronous getter reads. Existing cleanup guards and retry ownership remain intact.

Mixed host/client versions retain the existing protocol. Host macOS/Linux/Windows, SSH/WSL, local/daemon terminal ownership, and git/folder workspace behavior are unaffected. Mobile direct/relay contracts are exercised deterministically on macOS; Android and physical Hermes sleep remain gaps.

Verification

  • Independent sub-agent review traced all changed production paths and found no remaining deadline/retry blocker. It reproduced an additional existing report race: reconnecting during log hydration paired the previous version with the new connected state. Two tests failed before the connection-timestamp guard; all four report-operation cases pass afterward.
  • 128 tests across 13 mobile suites pass after the follow-up: deadline boundaries, foreground/background clock changes, paused monotonic time, mid-background arms, repeated sleep segments, lifecycle revival, actual socket redial, fresh failures after delayed evidence, authentication, host status, report hydration and version display.
  • Adjacent transport reliability gate: 147 mobile tests across 11 files plus 6 shared tests pass. Report-only follow-up does not alter those transport paths.
  • Changed-code quality: 0 new findings across 16 files. Formatting and diff whitespace checks pass.
  • Existing local mobile typecheck has four dependency errors in TerminalWebView.tsx (TS2769/TS7006), also verified on baseline sources. Exact-head GitHub checks are required before merge.
  • Earlier real simslim iOS simulator / native WKWebView proof used the production socket session, diagnostics view and copied report: a deliberately deferred 12-second callback delivered at 73 seconds becomes a warning; a 5-second handshake delivered at 5,008ms remains an error, while delivery at 66,010ms becomes an interruption. Each forced close occurred once. A stale supplied 1.4.196 becomes unknown while disconnected. Home/background/resume was exercised; the fixture injects the pending socket and late delivery.

Visual proof

Actual simulator framebuffer captures, inspected for readable diagnostics, severity and host-version reporting. The footer shows a line from the production copied report; the fixture labels the injected timer condition.

Before After
Before: late callback blames the endpoint and shows cached version After: late callback is an interruption and disconnected version is unknown

Current-main compatibility

Synchronized main ec546de75ac after it independently repaired the Portuguese catalog key and queued-editor i18n mock. Retain both upstream versions unchanged, removing these incidental repairs from this PR's final diff. The diagnostics production files are byte-unchanged by this sync. All 128 focused mobile tests and 17 existing queued-editor tests pass after synchronization; the independent reviewer checked both conflict resolutions and catalog parity.

Community credit and merge risk

Adapted the deadline-classification idea from @innocarpe's #24425, retained the current direct framing lifecycle, reused the existing AppState listener, and addressed the stale-version half of #18829. Wooseong Kim and Cursor receive commit co-author credit. #24425 is superseded by this PR.

Low merge risk: this corrects diagnostic evidence while preserving connection mechanics. Busy foreground JavaScript and background wall-clock changes can also cause the qualified warning. Physical iPad hours-long suspension/Hermes has not been proved. The narrow captured-version guard uses existing connection timestamps; it does not redesign the unchanged host-status hook's cache ownership or claim to cover an exceptionally batched reconnect that React never observes.

nwparker and others added 2 commits October 21, 2026 01:28
Classify late connect/handshake callbacks using monotonic elapsed time,
retain the existing forced-close/retry path, and supersede earlier direct
timeouts in the diagnostic summary. Only report a host version from a live,
settled status read; disconnected diagnostics no longer expose a stale cache.

Adapted from community PR #24425, with the current framing lifecycle retained.
Fixes #18829.

Co-authored-by: Wooseong Kim <[email protected]>
Co-authored-by: Cursor <[email protected]>
Reuse the connection revival AppState listener to supplement monotonic timing only when the app left the foreground. Native steady clocks can pause during device sleep; foreground wall-clock steps still cannot turn a normal timeout into suspension.

Co-authored-by: Wooseong Kim <[email protected]>
Co-authored-by: Cursor <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 22e947f0-f390-4624-bc16-6457b022c91c
📥 Commits

Reviewing files that changed from the base of the PR and between 84af8ef and 5c6bd7e.

📒 Files selected for processing: 15
  • mobile/app/connection-log.tsx
  • mobile/src/diagnostics/connection-diagnostics-analysis.test.ts
  • mobile/src/diagnostics/connection-diagnostics-analysis.ts
  • mobile/src/diagnostics/connection-diagnostics-report.test.ts
  • mobile/src/diagnostics/connection-diagnostics-report.ts
  • mobile/src/diagnostics/native-diagnostics-operations.ts
  • mobile/src/transport/connection-revival-triggers.test.ts
  • mobile/src/transport/connection-revival-triggers.ts
  • mobile/src/transport/rpc-client-socket-session.ts
  • mobile/src/transport/rpc-client-synthesized-close-diagnostics.test.ts
  • mobile/src/transport/socket-deadline-clock.test.ts
  • mobile/src/transport/socket-deadline-clock.ts
  • mobile/src/transport/socket-deadline-suspension.test.ts
  • mobile/src/transport/socket-deadline-suspension.ts
  • mobile/src/transport/types.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The transport now measures socket deadlines across app suspension and reports delayed deadlines as suspended dials rather than ordinary timeouts. Diagnostics recognize the new failure type. Host version reporting now uses the live desktop version only when the host is connected.

Priority: ⬇️ Low

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 5c6bd

The diagnostics changes appear ready to merge after normal checks. Physical-device sleep behavior remains untested, but no concrete failure is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 17.65% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 15 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: distinguishing delayed mobile dial deadlines from unreachable hosts.
Linked Issues check Passed The PR addresses the active coding requirements in #18829. RpcClientSocketSession measures connect and handshake deadline delivery with startSocketDeadlineClock, and `socket-deadline-suspension.ts…
Out of Scope Changes check Passed The changed production files implement the two behaviors in #18829: delayed deadline classification and removal of stale disconnected host-version metadata. The added clock, lifecycle, socket, diagnos…
Description check Passed The description is complete and closely follows the required template. It includes the ELI5 summary, detailed changes, rationale, linked issue, visual proof, testing results, compatibility notes, limi…
Full details: Linked Issues check

Explanation

The PR addresses the active coding requirements in #18829. RpcClientSocketSession measures connect and handshake deadline delivery with startSocketDeadlineClock, and socket-deadline-suspension.ts classifies delivery more than 60 seconds late as suspended-dial. The existing forced-close and retry path remains active. Ordinary deadlines retain connect-timeout and handshake-timeout errors. Delayed evidence is handled by the diagnostics analysis and regression tests. buildConnectionDiagnosticsReport reports a host version only for a connected state, and the diagnostics route passes no desktop version while host status is pending. The added tests cover suspension timing, clock changes, diagnostic precedence, reconnect behavior, and disconnected version reporting.

Full details: Out of Scope Changes check

Explanation

The changed production files implement the two behaviors in #18829: delayed deadline classification and removal of stale disconnected host-version metadata. The added clock, lifecycle, socket, diagnostics, and report tests verify those behaviors. The changes preserve the existing close and retry mechanics and add no host protocol fields. No unrelated production behavior is demonstrated by the reviewed summary or the focused source files.

Full details: Description check

Explanation

The description is complete and closely follows the required template. It includes the ELI5 summary, detailed changes, rationale, linked issue, visual proof, testing results, compatibility notes, limitations, and merge-risk assessment. The checklist boxes and AI disclosure field are not explicitly completed, but the required information is provided elsewhere and the description is sufficiently detailed.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

nwparker and others added 5 commits October 21, 2026 01:48
Finalize wall-minus-monotonic gaps at resume and sample the accumulator at deadline arm. A short inactive period can no longer let a later foreground clock jump misclassify a normal timeout as suspension. Cover the reported regression, mid-background deadlines, repeated segments, and backward clock movement.

Co-authored-by: Wooseong Kim <[email protected]>
Co-authored-by: Cursor <[email protected]>
Capture the connection timestamp associated with the supplied live host
version. If log hydration crosses a reconnect, report the version as unknown
rather than attaching the previous connection's version to the new session.

Add red/green production-report regressions for reconnect during hydration,
disconnected operation creation, and a stable live connection.

Co-authored-by: Wooseong Kim <[email protected]>
Co-authored-by: Cursor <[email protected]>
Current main generalized the failure word to cliTooOld with an agent
placeholder, but left Portuguese on codexCliTooOld. Preserve the existing
translation while matching the renamed key and interpolation contract.

Unblocks the catalog parity check after synchronizing main for #31478.
The current-main queued editor import graph now reads i18n.language while
building the agent catalog. Supply the English locale alongside the existing
translation stub, matching neighboring fixtures and preserving every assertion.

Unblocks the suite-load failure found by full CI for #31478.
@nwparker
nwparker merged commit ea42a20 into main Oct 22, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile: iOS background suspension reported as "endpoint unreachable"; diagnostics shows a stale Host Orca version as current

1 participant