Skip to content

fix(mobile): stop calling a host Disconnected while a dial is in progress - #36802

Merged
nwparker merged 1 commit into
mainfrom
nwparker/mobile-connecting-labels
Nov 1, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/mobile-connecting-labels

Conversation

@nwparker

@nwparker nwparker commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​75
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​160 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​131

ELI5

When you tap a desktop, the phone often tries a direct connection, then falls back to the relay. During that fallback the host screen said "Disconnected" (and eventually "Can't connect") even though it was still connecting. Now it says "Connecting via Relay…", like the native screens.

What Changed

  • Relay dial from idle. A relay dial started from idle (after a background suspend, or with no live session) kept the client disconnected until the relay hello, which can be 12 s or more on a slow link. The relay session starts in connecting without announcing it. forwardMigrationDialState now forwards the replacement's initial dial state. It's still a no-op while the logical client is connected or reconnecting.
  • Path information for the page. The WebView page hard-coded "no pending path, relay connecting". So a direct dial that failed over to relay read as Reconnecting, then "Can't connect" with the unreachable empty list, while relay was still working.
    • Bridge connection snapshots now carry activePath, pendingPath and relayHostReachability.
    • The shell sends a new connectionPath frame when only those change.
    • On the page, path frames fire path listeners, never state listeners, so nothing mistakes them for a reconnect.
    • Page subscribeHostState and subscribeAllHosts re-notify on path changes, as native host state does.

Why

On a remote network the direct LAN dial times out (12 s connect deadline) and leaves the client reconnecting while relay is still dialing. Native screens already label that "Connecting via Relay…", but the page couldn't see the pending path.

Compatibility:

  • The snapshot fields are optional. Older shells omit them, and the page keeps its previous defaults.
  • Pages announce connectionPathFrames in ready, so older pages never receive the new frame type.
  • Older shells strip the unknown ready field.

Effect of the forwarder change on listeners

The new connecting → … → disconnected sequence for a failed relay dial from idle (before, it silently stayed disconnected) has no side effects:

  • Stale-dial detection reads only the physical direct client's own state.
  • The connect-refetch gates fire only on connected.
  • The logical client never queues requests on state.
  • The host-list action sheet now hides "Connect" while a relay dial is already in progress.

Linked Issue

N/A (internal).

Visual Proof

Not captured for the relay case: reproducing it needs Orca Cloud relay with an unreachable direct endpoint. The label logic itself (classifyConnection for a pending relay path) is unchanged; this PR only feeds it the inputs the page was missing.

Testing

  • stable-logical-rpc-client.test.ts: a replacement that never announces connecting still shows connecting, and a failed narrated dial restores disconnected.

  • bridge-host-init.test.ts: a page that reads path frames gets one on a path change, and an older page gets none.

  • bridge-rpc-client-frames.test.ts: ready declares the frame, and a path frame updates the getters without firing state listeners.

  • Mobile src/mobile-web-shell, src/transport and the bridge recording suites pass; the full mobile suite passes; mobile typecheck and typecheck:tests pass.

  • The bridge changes were exercised in the real iOS app against a desktop built from this stack. Pairing, the host screen, the session screen and terminal streaming all ran through the new bridge code without regressions.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Stack 5/5. Base: #36818 (pure module move).

@nwparker
nwparker force-pushed the nwparker/mobile-compressed-frames branch from e63caec to 8242c40 Compare October 31, 2026 23:57
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from b1fda81 to 13ef95b Compare October 31, 2026 23:58
@nwparker
nwparker changed the base branch from nwparker/mobile-compressed-frames to nwparker/mobile-bridge-connection-snapshot October 31, 2026 23:58
@nwparker
nwparker force-pushed the nwparker/mobile-bridge-connection-snapshot branch from f9bcebc to e04caaf Compare November 1, 2026 00:29
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from 13ef95b to 88feaf8 Compare November 1, 2026 00:29
@nwparker
nwparker force-pushed the nwparker/mobile-bridge-connection-snapshot branch from e04caaf to 49524a4 Compare November 1, 2026 00:54
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from 88feaf8 to 3d41286 Compare November 1, 2026 00:54
@nwparker
nwparker force-pushed the nwparker/mobile-bridge-connection-snapshot branch from 49524a4 to b09e382 Compare November 1, 2026 01:20
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from 3d41286 to 318ced7 Compare November 1, 2026 01:20
@nwparker
nwparker force-pushed the nwparker/mobile-bridge-connection-snapshot branch from b09e382 to 1e16e1f Compare November 1, 2026 01:52
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from 318ced7 to 0c469a5 Compare November 1, 2026 01:52
@nwparker
nwparker force-pushed the nwparker/mobile-bridge-connection-snapshot branch from 1e16e1f to 038a239 Compare November 1, 2026 02:02
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from 0c469a5 to 5c83410 Compare November 1, 2026 02:02
@nwparker
nwparker force-pushed the nwparker/mobile-bridge-connection-snapshot branch from 038a239 to f2379da Compare November 1, 2026 02:16
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from 5c83410 to 87a9156 Compare November 1, 2026 02:16
@nwparker
nwparker force-pushed the nwparker/mobile-bridge-connection-snapshot branch from f2379da to 71a9680 Compare November 1, 2026 02:23
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from 87a9156 to 6d346e7 Compare November 1, 2026 02:23
@nwparker
nwparker changed the base branch from nwparker/mobile-bridge-connection-snapshot to main November 1, 2026 02:29
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from 6d346e7 to b4eba1e Compare November 1, 2026 02:29
…ress

Two paths showed Disconnected while the phone was still connecting:

- A relay dial started from idle (after a background suspend, or when no
  session was live) left the client disconnected until the relay hello,
  because the replacement session starts in connecting without announcing
  it. The migration now forwards the replacement's initial dial state.
- The host screen page never learned which path the shell was dialing, so
  a direct dial that failed over to relay read as Reconnecting, then Can't
  connect and the unreachable empty list, while relay was still working.
  Bridge connection snapshots now carry the active and pending paths and
  the relay verdict, and the shell sends a connectionPath frame when only
  those change, so the page shows Connecting via Relay like the native
  screens. Path frames fire path listeners, never state listeners, so
  nothing on the page mistakes them for a reconnect.

Mixed versions: the snapshot fields are optional, so older shells omit
them and the page keeps its previous defaults. Pages announce
connectionPathFrames in ready; older pages never receive the new frame.
@nwparker
nwparker force-pushed the nwparker/mobile-connecting-labels branch from b4eba1e to f26add3 Compare November 1, 2026 02:31
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Finishing Touches
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

@nwparker
nwparker merged commit 833f6cc into main Nov 1, 2026
25 of 26 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.

1 participant