Skip to content

fix(remote-terminal): calm, honest reconnect status — one notice per server, cause, delay from measured RTT - #33095

Merged
nwparker merged 5 commits into
mainfrom
nwparker/calm-reconnect-banner
Oct 24, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/calm-reconnect-banner

Conversation

@nwparker

@nwparker nwparker commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​656 $\color{#cf222e}{\Huge{\mathbf{−}}}$​53 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​603
Prod 29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1244 $\color{#cf222e}{\Huge{\mathbf{−}}}$​284 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​960

ELI5

When the link to a remote Orca server hiccups, every terminal used to flash "Reconnecting to remote runtime" after one second, all at once, and it always said "retrying automatically", even when nothing was retrying. Now Orca waits until a reconnect is clearly taking longer than a normal one. It then shows one calm notice for the server instead of one in every pane, says why and for how long, and only claims it is retrying when it is.

What Changed

Before, for the user:

  • A banner appeared after 1 s in every pane of every visible tab whenever the server's shared connection dropped.
  • It could vanish a moment later and come back, which made it flicker.
  • It said "Orca is retrying automatically" even for a pane that was parked waiting for an outside trigger.
  • It never named the server or the cause.

After, for the user:

  • Delay. Self-healing recovery is announced only after 5 s. A notice that has appeared stays up for at least 2 s. A link that answers and drops again within 1 s counts as one outage. Banners that need action (disconnected, pairing refused, WSL host unavailable) still show immediately.
  • One notice per server. While a server's shared connection is down (only on the transport-down verdict, never for "checking" or a failed status probe over a live socket), the first visible terminal surface on that server shows one notice. Every pane on that server stays quiet, on every surface, until the notice has finished its hold. A pane that is still down when the notice ends speaks at once, using its own start time.
  • Cause and duration. The text names the server and shows "Down for N sec". The causes are: connection to the server dropped, server restarting (from the remote-server updater), terminal stopped responding (stream stall), terminal stream closed and reattaching, a neutral "Reattaching terminal" for capacity backoffs, and waiting for the server. A parked pane says "Waiting for ", offers Reconnect, and never says it is retrying.
  • Tailscale hint. When the server's endpoint is a Tailscale address (100.64/10, *.ts.net, or fd7a:115c:a1e0::/48), the notice shows tailscale ping <host>. This reuses remote-runtime-tailscale-hint.ts. Only plain DNS or IP hosts reach the command, so a crafted endpoint can't inject shell syntax.
  • Mobile. The session header label and dot, and the host header dot, used to flip to amber "Reconnecting" the instant the socket dropped. They now follow the same schedule. The first connect and a refused pairing still show at once.
  • Every new string uses translate() in all 7 locales. The zh strings were written natively (for example "正在重新连接 Studio Mac", "已断开 22秒", "检查 Tailscale 链路:").

Mechanism:

  • src/shared/calm-status-reveal.ts: a pure reveal schedule driven by the clock, shared by desktop and mobile.
  • PtyTransportRecoveryState gains optional cause and waiting fields. These are renderer-local and never sent over the wire. The snapshot controller marks stall-driven closes with stalled: true. parkRetryForExternalTrigger now notifies, so the pane can say it is waiting.
  • remote-server-notice-claims.ts keeps one record per server. It tracks which mounted surfaces observe the outage, so its start time survives a tab switch. It tracks which visible surfaces can speak, and the first one shows the notice. It also tracks which surfaces have the notice on screen, including its hold, so panes on every surface wait it out.
  • The recovery portals moved to TerminalPaneRecoveryPortals.tsx, and the presentation was factored into RemoteRuntimeRecoveryCard.

Why

Measured delay. I drove the real shared-control client against the shared-control test server (real E2EE handshake and auth) through a TCP proxy that adds round-trip latency, then timed a server-side close until the subscription was replayed. Five runs per RTT:

RTT drop → ready drop → resubscribed
0 ms ~0.30 s ~0.31 s
200 ms ~1.19 s ~1.39 s
400 ms ~2.09 s ~2.49 s

That works out to about 0.3 s + 5.5 RTT. A pane's own resubscribe and snapshot add about 2 RTT, and TLS to a relay adds about 2 more, so one clean reconnect at 400 ms RTT takes about 4.1 s. The old 1 s delay was always crossed at 150 ms RTT or more. A 5 s delay hides one clean reconnect on a relay-like link, while anything longer means an attempt actually failed.

Alternatives considered:

  • Lengthening only the per-pane delay would still show N banners at once on a real outage.
  • A global toast would disappear, but this status has to persist.
  • A status-bar-only signal is too easy to miss for a terminal that has stopped echoing.

The per-surface claim keeps exactly one notice per server on screen without a new store slice.

ref-oss check: I compared this with how established remote-development clients present reconnects. They show a single connection-level notice rather than one per editor or terminal, reveal it only after a quiet period, and offer an explicit "reconnect now". This design matches that approach, so it did not change.

Linked Issue

No issue. This was reported directly by a user on a desktop paired over Tailscale, likely through a relay with 200–400 ms RTT. Thanks to that reporter.

Visual Proof

CDP screenshots of each state, light and dark, in en and zh. I rendered the real components inside a background-launched dev app (ORCA_BACKGROUND_LAUNCH=1, isolated profile) so the real theme tokens apply. These are component renders inside the live app, not a captured live outage. The 32 PNGs are available from the author, and attachment upload was unavailable from the agent environment.

Testing

  • Automated tests added/updated:
    • calm-status-reveal.test.ts covers the delay, the minimum visible time, the hold, flapping, immediate states, and a carried-over start time.
    • The banner tests cover the cause copy, a parked pane not claiming it is retrying, a neutral capacity refusal, the Tailscale hint, the hold, a manual Reconnect keeping the banner up, and a pane speaking at once after the server notice.
    • TerminalPaneRecoveryPortals.test.tsx checks that two split panes produce one notice and no pane banners, and that panes stay quiet during the notice's hold.
    • The claim registry tests cover the single speaker and a start time that survives a tab switch.
    • The transport test checks that a shared drop carries cause: 'connection' and clears it when healthy.
    • The recovery-state test checks that a parked retry reports waiting.
    • The mobile step tests cover the delay, the immediate states, a mount mid-outage, and the minimum visible time.
  • Ran the unit folders around the changed files and their importers: src/renderer/src/components/terminal-pane, src/renderer/src/runtime, src/renderer/src/components/native-chat, src/shared/remote-runtime, and src/renderer/src/hooks. All passed. The mobile src/transport, src/session, and src/host-screen tests also passed.
  • Full static job run locally: pnpm lint (all ratchets, localization catalogs, extraction and coverage), oxfmt check, run-ratchets, changed-code quality, React Doctor changed lines, Zustand fan-out, pnpm tc, and mobile tsc.
  • I did not exercise a real Tailscale or relay outage end to end. The screenshots are component renders inside the running app.

Review

Codex review is clean on the final head. The independent review found no P0, P1 or P2 issues. Addressed along the way: probe failures being announced as drops, holds unmounting, the start time across tabs, overlap during the hold on every surface, the timer inside the live region, capacity refusals, the mobile minimum visible time, and validating the host in the pasteable command.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Remote and mixed versions: there are no wire changes. The new fields are renderer-local, and old hosts are unaffected.
  • Folder workspaces: the owning server comes from workspaceOwnerHostId, which covers folder workspaces.
  • WSL, pairing refused, and the SSH overlay keep their own immediate banners, and the server notice stands aside for them.
  • Follow-up: when the shared connection publishes a close cause (in progress elsewhere), selectRemoteServerOutageCause can map keepalive and wake-probe timeouts to a "stopped responding" variant.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The changes add calm reveal timing for mobile connection states and remote terminal outages. Remote PTY recovery reports causes such as connection loss, stalled streams, and ended streams. Recovery cards and banners display cause-specific information, while shared claims coordinate server outage notices across panes. The changes also add localized recovery copy and tests for timing, recovery classification, notice coordination, and reconnect behavior.

Priority: Normal

Merge Risk: Low · up to ca741

A refused pairing can trigger a pane retry that cannot succeed. Limit retries to successful or transient connection results; the remaining risk is narrow.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description is detailed and on-topic, but it does not satisfy required template items. It explicitly provides no linked issue, does not attach the required visual proof for UI changes, and omits t… Add an actual linked issue under “Fixes #” or confirm the author is an internal maintainer covered by the template exception. Attach before-and-after screenshots or videos for the UI changes. Add the complete Checklist section and mark each…
Docstring Coverage Warning Docstring coverage is 21.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 57 functions across 33 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: calmer, more accurate reconnect status for remote terminals. It is specific and related to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and on-topic, but it does not satisfy required template items. It explicitly provides no linked issue, does not attach the required visual proof for UI changes, and omits the Checklist section.

Resolution

Add an actual linked issue under “Fixes #” or confirm the author is an internal maintainer covered by the template exception. Attach before-and-after screenshots or videos for the UI changes. Add the complete Checklist section and mark each item or explain any exception.

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
nwparker force-pushed the nwparker/calm-reconnect-banner branch from 7327048 to 037d34a Compare October 24, 2026 09:29

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Do not retry the pane after a failed pairing reconnect. · TerminalPaneRecoveryPortals.tsx:33-41

src/renderer/src/components/terminal-pane/TerminalPaneRecoveryPortals.tsx:33-41
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not retry the pane after a failed pairing reconnect.

runtimeEnvironments.connect can resolve with { ok: false, error: { code: 'unauthorized' } } when the pairing refusal remains. The current finally(retry) ignores that result and can start retryRecovery while the status owner is blocked by the refusal. Retry only after success or a transient runtime_unavailable result.

Suggested fix
         .connect({ selector: pairingRefusedEnvironmentId })
+        .then((response) => {
+          if (response.ok || response.error.code === 'runtime_unavailable') {
+            retry()
+          }
+        })
         .catch(() => undefined)
-        .finally(retry)

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46cb19c6-f05b-4997-9f2f-8f3e62006a8c
Commits

Reviewing files that changed from the base of the PR and between 037d34a and ca741e0.

Files selected for processing: 4
  • src/renderer/src/components/terminal-pane/TerminalPaneRecoveryPortals.test.tsx
  • src/renderer/src/components/terminal-pane/TerminalPaneRecoveryPortals.tsx
  • src/renderer/src/components/terminal-pane/TerminalRemoteRuntimeReconnectBanner.test.tsx
  • src/renderer/src/components/terminal-pane/TerminalRemoteRuntimeReconnectBanner.tsx

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

@nwparker
nwparker merged commit 59cc469 into main Oct 24, 2026
109 of 113 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