Repository navigation
feat(mobile): say why a host is unreachable instead of "Connecting via Relay…" - #21566
Conversation
…a Relay…"
The home-screen host row and host header showed "Connecting via Relay…" for
as long as the desktop stayed unreachable, even when every relay dial had
ended with the cell's 4404 host-offline close. A user's diagnostics export
showed 25 such dials over 25 hours behind that label, and the diagnostics
report itself said "No single failure cause" because relay dial failures
were not recognised and every app resume emptied the evidence window.
Relay close codes now map to a closed RelayHostReachability verdict
(signed-out, host-offline, credential-refused, unreachable), latched after
two consecutive identical dial failures and cleared only by an authenticated
session. The existing signed-out close reason becomes a member of the same
verdict instead of a parallel boolean. classifyConnection renders each
verdict as a label plus a detail line ("Host 1 is offline" / "Check it's
awake, Orca is running, and you're signed in").
Relay dial failures carry their close code as a structured field on the
connection log entry, so the diagnostics analysis names the cause without
parsing error text, and an app resume no longer hides the last failure: it
is reported with a "Before the app last resumed" qualifier and is never a
sendable incident.
Only header lines change: the baseline pin on every golden and the adapterSha256 on the twelve goldens whose mount adapters gained the getRelayHostReachability context method. No checkpoint moved, which also shows the commits between the old and new baseline changed no observed RPC behaviour.
There was a problem hiding this comment.
Important
The diagnostics selection in connection-diagnostics-analysis.ts prefers the newest relay verdict over the newest diagnostic failure, so a newer director 401/503 or a newer relay-session-failed can be masked by an older 4404/4401/1006 verdict — naming the wrong cause and suppressing an incident the report used to offer. Details inline.
Reviewed changes
- Relay verdict mapping — new pure
relay-host-reachability.tsmaps the cell close codes (4404 / 4401 / 1006) to a closed verdict set;signed-outcan only come from the cell's close reason. - Verdict latch —
relay-host-reachability-latch.tsreports after two identical failures, assertssigned-outimmediately, and is retired only by an authenticated session. hostSignedOutfolded into the verdict —RelayRecoveryEvidencenow owns pairing-rejection + reachability together; the boolean and its plumbing are removed from the transport, context contract, hooks, projection, and card.- Row copy —
connection-health.tsrenders the verdict label plus a second line;MobileHostCardshows the detail line; the home projection collapses four lookup maps into one. - Diagnostics —
relayCloseCodebecomes a structured log field, relay dial failures get their own advice branch, and evidence from before the last resume is still reported but marked stale.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…the same network A direct session also rotates the credential, but telling the user to connect on the same network once explains the mechanism instead of giving an action, and re-pairing is the one remedy that works from anywhere.
… the real stale boundary Relay-path evidence still outranks a newer direct timeout, but among relay failures the newest now wins: an older 4404 verdict no longer hides a newer session close (which was also the sendable incident) or a director refusal. The stale prefix names a network change when that, not a resume, was the boundary.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the single commit since the prior Pullfrog review (5ee24b6e8d), which reworks diagnostics failure selection in connection-diagnostics-analysis.ts. Both prior review threads are addressed.
- Newest relay failure wins the diagnosis —
newestFailurenow filters to diagnostic failures, prefers the newest relay-path entry, and falls back to the newest overall, so a newerrelay-session-failedor director 401/503 is no longer masked by an older 4404/4401/1006 verdict, while a relay verdict still outranks a newer direct timeout. - Stale boundary is named —
selectDiagnosticFailurereturns the boundary kind (app-resumed/network-changed), and the report prefixes "Before the app last resumed" or "Before the last network change" accordingly. - Reportable-incident selection simplified —
getReportableConnectionIncidentIdreuses the same selection and stale check;findCurrentDiagnosticFailureandisRelayDialVerdictwere removed. - Regression tests added — three tests cover ordering among relay failures and the network-change boundary; the file's 13 tests pass locally.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…21588) #21566 re-recorded the corpus with `baseline` set to its own branch commit `47d24d324e`, which the squash merge left unreachable from main. The pin guard on the push to main fails, and so does the pin job on every open pull request, since the merge ref cannot reach that commit either. Repin to main's tip `889c2b562f` and re-record from that tree. Every golden's body is byte-identical to the one #21566 recorded; only the `baseline` header line moves (788 files, one line each). Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

ELI5
When your desktop is asleep, Orca is closed, or you signed out, the phone used to sit on "Connecting via Relay…" forever. Now the host row says what is actually wrong ("Host 1 is offline", "Sign-in required on Host 1", "Can't reach Relay") and what to check, and the diagnostics report names the cause too.
What Changed
Before: on the home screen and host header, any host that Relay could not reach read "Connecting via Relay…" until the twelfth retry, whatever the relay had said. A user's diagnostics export showed 25 relay dials over 25 hours, every one closed by the cell with 4404 (host offline), behind that label. The export's own "Likely cause" line said "No single failure cause can be determined", because the analysis did not recognise relay dial failures and every app resume (about once a minute on iOS) emptied the evidence window.
After: two consecutive relay dial failures with the same meaning turn the row into a verdict with a second line:
signed-outreasonThe diagnostics report now says, for example, "Relay answered, but the desktop is not connected to it (close code 4404, host offline)" with a matching next step. If the only evidence is from before the last app resume it is still reported, prefixed "Before the app last resumed:", and never offered as a sendable incident.
Mechanism. A closed
RelayHostReachabilityverdict (mobile/src/transport/relay-host-reachability.ts) maps the relay close code. A small latch beside the existing pairing-rejection latch counts consecutive identical verdicts and reports after two; only an authenticated session on either path clears it. The existing "desktop signed out" close reason, which used to be a separate boolean threaded through twelve files, is now thesigned-outmember of the same verdict, asserted immediately and never downgraded by a later plain 4404.classifyConnectionrenders the verdict from one copy table, independent of whether the relay recovery path is still pending (a refused credential clears that path, and the direct retry loop must not hide it). Relay dial log entries carry the close code as a structured field, so the diagnostics analysis reads a number instead of an error string.Why
The phone already had every signal it needed: the cell's close code was on the wire and the signed-out reason was already latched. Nothing turned them into words. Alternatives considered:
hostSignedOutas its own boolean and add a second field. That was the first draft; a review pass folded it into the verdict, which deleted a parallel path through the connection path, logical client, context contract, hooks, projection and list.signed-outreason is fixed separately in fix(relay): carry the signed-out reason when the broker's own renewal notices the session loss #21562, and persisting the reason relay-side is a follow-up.The 4401 detail says only "re-pair": a direct session would also rotate the refused credential, but that explains a mechanism instead of giving an action, and re-pairing works from anywhere. A paired phone should rarely see 4401 at all (revoked on the desktop, a month without any relay session, or a desync worth a bug report).
The 4404 detail still mentions sign-in on purpose: today a signed-out desktop often yields a plain 4404 (see #21562), and the hint costs nothing when the desktop is merely asleep.
Linked Issue
Fixes #
Visual Proof
Real
MobileHostCardwith verdicts from the realclassifyConnection, rendered through react-native-web at 393 px. Before (and still, under two identical failures):After two 4404s:
After two 4401s:
After two 1006s:
Testing
From
mobile/:From the repo root:
pnpm run check:code-quality:changedpasses.The second commit re-records the RPC goldens: three rpc-recording mount adapters gained the new context method, which changes their pinned
adapterSha256.git diff -U0 -- mobile/rpc-foundation/goldenson that commit shows onlybaselineandadapterSha256header lines; no checkpoint moved.New behaviour tests: the close-code mapping for every code the cell can send; the latch (streak of two, alternation, replacement, unmapped failures, signed-out stickiness, clear on connect); the controller banking a verdict ahead of the credential gate and ignoring failures under a live session; the establisher's close reason reaching the logical client through the real supervisor; verdict copy and precedence; the card's detail line and accessibility label; and the diagnostics analysis against literal entries taken from the real export (stale-window prefix, relay verdict outranking a newer LAN timeout, 4401/1006/4409, director 503 precedence).
Platforms: iOS and Android share this code; verified with the mobile test suite on macOS. Not exercised on a device.
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No wire change: the phone reads close codes and a close reason it already received. Old hosts and cells are unaffected. Direct-only hosts (no relay) keep today's "Can't connect" / "Can't reach desktop" copy.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)