Skip to content

feat(mobile): say why a host is unreachable instead of "Connecting via Relay…" - #21566

Merged
Jinwoo-H merged 4 commits into
mainfrom
mobile-relay-host-status
Sep 19, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
mobile-relay-host-status

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​788 $\color{#cf222e}{\Huge{\mathbf{−}}}$​92 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​696
Prod 816 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1264 $\color{#cf222e}{\Huge{\mathbf{−}}}$​953 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​311

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:

Relay says Row
4404 host offline "Host 1 is offline" / "Check it's awake, Orca is running, and you're signed in" (red)
4404 with the cell's signed-out reason "Sign-in required on Host 1" / "Sign in to Orca on your desktop to reconnect" (red, immediate, sticky)
4401 or director 401, credential refused "Relay access expired for Host 1" / "Re-pair with your desktop" (red)
1006 transport close "Can't reach Relay" / "Check your connection" (amber)
anything else unchanged, "Connecting via Relay…"

The 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 RelayHostReachability verdict (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 the signed-out member of the same verdict, asserted immediately and never downgraded by a later plain 4404. classifyConnection renders 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:

  • Show the verdict on the first failure. One dial is a blip (cell rollout, network flap). Two identical in a row is a state, and matches the existing pairing-rejection latch's approach.
  • Keep hostSignedOut as 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.
  • Parse the close code out of the log text for diagnostics. The analysis module historically regexes messages; adding a structured field instead keeps the new path parse-free and old persisted entries still load (the field is optional).
  • Ask Orca Cloud whether the desktop is signed in. Auth keeps no per-host record, so there is nothing to ask. The desktop-side gap that often swallows the signed-out reason 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 MobileHostCard with verdicts from the real classifyConnection, rendered through react-native-web at 393 px. Before (and still, under two identical failures):

row-before.png

After two 4404s:

row-host-offline.png

After two 4401s:

row-credential-refused.png

After two 1006s:

row-unreachable.png

Testing

From mobile/:

node_modules/.bin/tsc --noEmit                                  # clean
node scripts/check-tests-typecheck-ratchet.mjs                  # OK, 667 test files, new tests are checked
node_modules/.bin/oxfmt --check .                               # clean
node_modules/.bin/vitest run                                    # 6857 passed, 794 skipped, 0 failed
ORCA_BACKGROUND_LAUNCH=1 RPC_FOUNDATION_RECORD=1 pnpm --dir mobile exec tsx scripts/rpc-recording.mts --record

From the repo root: pnpm run check:code-quality:changed passes.

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/goldens on that commit shows only baseline and adapterSha256 header 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.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts maps the cell close codes (4404 / 4401 / 1006) to a closed verdict set; signed-out can only come from the cell's close reason.
  • Verdict latch — relay-host-reachability-latch.ts reports after two identical failures, asserts signed-out immediately, and is retired only by an authenticated session.
  • hostSignedOut folded into the verdict — RelayRecoveryEvidence now 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.ts renders the verdict label plus a second line; MobileHostCard shows the detail line; the home projection collapses four lookup maps into one.
  • Diagnostics — relayCloseCode becomes 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 — newestFailure now filters to diagnostic failures, prefers the newest relay-path entry, and falls back to the newest overall, so a newer relay-session-failed or 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 — selectDiagnosticFailure returns 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 — getReportableConnectionIncidentId reuses the same selection and stale check; findCurrentDiagnosticFailure and isRelayDialVerdict were removed.
  • Regression tests added — three tests cover ordering among relay failures and the network-change boundary; the file's 13 tests pass locally.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 889c2b5 into main Sep 19, 2026
24 checks passed
Jinwoo-H added a commit that referenced this pull request Sep 19, 2026
…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
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.

1 participant