Skip to content

Flag client/server app-version skew and self-heal stale subscriptions after serve restarts - #9614

Closed
tomdebres wants to merge 4 commits into
stablyai:mainfrom
tomdebres:tomdebres/flag-client-server-version-mismatch
Closed

tomdebres wants to merge 4 commits into
stablyai:mainfrom
tomdebres:tomdebres/flag-client-server-version-mismatch

Conversation

@tomdebres

@tomdebres tomdebres commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two connection-layer fixes for desktop clients paired with a remote orca serve host, both hit in the field on 2026-07-20 with a headless server on v1.4.146 and a desktop client that had auto-updated to v1.4.147:

1. App-version skew is now detected and surfaced instead of failing downstream with misleading errors.

The runtime WS connect path exchanged no app version at all: the E2EE handshake (e2ee_hello/e2ee_auth) carries none, and status.get only carried the protocol number, which hard-blocks solely on true protocol incompatibility. A client running ahead of its server (desktop auto-update raced the server's twice-daily update) failed with errors like "could not launch claude in a new terminal", with no hint that the real cause was version skew. Now:

  • status.get includes the server's appVersion, and the client evaluates a non-blocking skew verdict against its own version in the new dependency-free src/shared/app-version-skew.ts (semver-style compare including -rc.N prereleases; a live server that reports no appVersion provably predates this feature and is treated as older; unparseable versions stay silent).
  • A proactive bottom-right warning toast (skill-freshness-nudge pattern) announces the skew with a "Manage server" action — one per environment per version pair per session, retracted when a reachable probe reports matching versions. This is the surface that reaches users in the default Projects view, where host section headers don't render.
  • The sidebar host header shows an amber "Server outdated" / "App outdated" detail plus a caution icon, and the host menu gets an amber "Server update recommended" / "App update recommended" item whose tooltip spells it out: "This Orca server (1.4.146) is older than your app (1.4.147). Update the server, or some features may fail." Both skew directions are flagged.
  • The connection is never blocked on app-version skew alone; the existing protocol-incompatibility hard block is unchanged and takes precedence in the UI.

2. Stale worktree subscriptions after a serve restart behind a WS-terminating relay are now self-healing.

Same day, second report: the serve process restarted (auto-update) while a client stayed connected via a relay. The client's worktree-graph subscription lives in the server's in-memory registry, which died with the old process; worktrees created after the restart never appeared in the client sidebar until a manual app reload — even though both builds already contained the #7827 socket-liveness monitor (merged 2026-07-08, i.e. before this incident). That monitor pings at the RFC 6455 control-frame layer and declares death on inbound silence — but a WS-terminating relay answers protocol pings itself, so pongs prove only that the relay is reachable, not that the E2EE session behind it is alive. Fix: a session-level probe on the shared-control connection (SharedControlSessionProbe) sends an encrypted status.get every 15s while subscriptions are active (10s timeout). Only the server holding the connection's session keys can answer, so a relay can't fake it; a failed probe force-closes the socket and reuses the existing reconnect + replay(+tag) machinery from #7827/#7718 unchanged. This complements — not replaces — the socket-level monitor: that one is cheaper and catches half-open TCP; the session probe catches "transport up, session dead".

The src/relay/ SSH path is untouched — it already has its own wire-level version handshake (relay-handshake.ts).

Screenshots

In the PR comments: captured end-to-end from a real orca serve at app version 1.4.100 paired to a 1.4.147-rc.4 client over the production WS/E2EE path — toast, sidebar host header, and host menu.

Testing

  • pnpm lint — passes except two pre-existing switch-exhaustiveness errors (skill-freshness-group.tsx, daemon-server.ts) that reproduce identically on pristine upstream/main with no working-tree changes; not introduced by this PR.
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions

New/updated tests:

  • src/renderer/src/components/sidebar/runtime-version-skew-nudge-plan.test.ts — toast cadence: new skew shows, same version pair never re-nags within a session, changed pair re-notifies, resolution clears only on a reachable matching probe (unreachable blips don't reset dedupe), multi-environment independence.
  • src/shared/remote-runtime-shared-control-connection.test.ts — repro of the field bug: server answers the first subscription, then goes silent with autoPong still enabled (relay answering pings), asserting the session probe force-reconnects and replays the subscription with no consumer-visible close. Also: probes keep a healthy connection on one socket; no probing while only one-shot requests are active.
  • src/shared/app-version-skew.test.ts — match/older/newer, missing server version, rc ordering (rc.10 > rc.2), release-vs-rc, unparseable versions stay silent, build metadata ignored.
  • src/shared/execution-host-registry.test.ts — skew passes through to runtime host entries; a stale skew verdict is dropped when a probe records the server unreachable.
  • src/renderer/src/components/sidebar/host-header-menu-items.test.ts — skew surfaces for usable hosts; a blocking verdict wins over skew.

AI Review Report

Reviewed by Claude Code (agent-driven end to end). Checks performed:

  • Cross-platform (macOS/Linux/Windows): no platform-specific code paths added; timers use unref() guarded for DOM typings (mobile mirrors shared code), no path/shortcut/shell handling touched.
  • SSH/remote vs local: changes affect only the remote runtime environment path; the SSH relay (src/relay/, which has its own version handshake) and local execution are untouched. Skew is only evaluated for reachable remote runtime statuses, never for local/SSH hosts.
  • Rebase-interaction risk (main moves fast): rebased onto current upstream/main; the session probe was deliberately re-layered on top of fix: Remote Orca Server reconnect liveness — recover mirrors, input routing, and creates after tunnel drops #7827's socket-liveness + replay-tagging machinery rather than duplicating it, and reuses its close→reconnect→replay path unchanged.
  • Behavioral risks reviewed: probe-vs-reconnect races (probe failure only force-closes if the socket is unchanged since the probe started); idle-timer leaks (probe never reschedules on a non-ready connection — markReady restarts it); old servers (missing appVersion treated as older by construction — any server without this code predates it); old clients (ignore the new optional field); noise control (skew warning is non-blocking amber, never toasts, and is dropped when the host is unreachable or blocked).
  • Performance: one small encrypted RPC per 15s per environment with active subscriptions (server already pings every client at the same cadence); skew evaluation is O(1) at status ingestion; no hot-path work added.
  • UI quality: amber caution tier per existing sidebar precedent (text-amber-*), destructive red reserved for blocking states; tooltips/menu per existing host-header patterns; localization catalog synced for all five locales.
  • Git-provider/agent neutrality: not applicable — no provider- or agent-specific surfaces touched.

Security Audit

  • Input handling: appVersion is parsed with a strict anchored regex (parseAppVersion); unparseable/hostile strings yield no verdict and are never interpolated into anything but a UI string. No eval/dynamic code.
  • Command execution / path handling: none added.
  • Auth/secrets: the session probe runs inside the existing authenticated E2EE channel using the already-held device token; no new auth surface, no token logging. The probe cannot be answered by an unauthenticated middlebox — that is its purpose.
  • DoS considerations: probe cadence is fixed (15s) and gated on active subscriptions; a malicious server ignoring probes only causes the client to close its own socket and back off via the existing bounded reconnect schedule.
  • Dependencies: none added (version compare is hand-rolled to stay dependency-free, matching protocol-compat.ts's pattern).
  • IPC: no new IPC channels; renderer reads its own version via the existing updater:getVersion handler.

Notes

  • A server predating this change reports no appVersion; clients with this change show "Server outdated" for it (correct by construction), with a version-less tooltip message.
  • The CLI runtime client has no version source of its own today, so it keeps its protocol-only gate; adding an app-version warning there is a possible follow-up.
  • The two lint:switch-exhaustiveness failures noted above reproduce byte-identically on pristine upstream/main (skill-freshness-group.tsx:101, daemon-server.ts:652) — pre-existing, and worth a separate fix.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 10ce0980-a8f1-44fc-93cb-45890d88572b

📥 Commits

Reviewing files that changed from the base of the PR and between 985d03b9eb821b8c2c12ab147f6a1987023c46d5 and 7146181779a59000c05088a21dad802d35a8bfe2.

📒 Files selected for processing (1)
  • src/renderer/src/components/sidebar/RuntimeVersionSkewNudge.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/sidebar/RuntimeVersionSkewNudge.tsx

📝 Walkthrough

Walkthrough

The change adds runtime app-version reporting, cached client-version retrieval, SemVer-based skew evaluation, and skew propagation through runtime status, host registry, sidebar models, and host warnings. Localized messages support outdated and update-recommended states. It also adds shared-control session probes with configurable timing, stale-session detection, reconnect handling, socket cleanup, and tests covering silent and responsive relayed sessions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly captures both main changes: app-version skew detection and self-healing stale subscriptions.
Description check ✅ Passed The description includes all required sections and covers summary, screenshots, testing, AI review, security audit, and notes.
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.

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.

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/shared/remote-runtime-shared-control-session-probe.ts (1)

57-84: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Success branch lacks the same stale-socket guard as the failure branch.

The catch branch re-checks this.hooks.getSocket() === probedSocket before calling forceClose, to avoid acting on a stale probe after an unrelated reconnect. The success branch's this.schedule() has no equivalent guard — it currently can't misfire only because closeSharedControlSocket unconditionally rejects all pending requests on any socket close, so a stale probe's promise can never resolve. This is correct today, but it's an implicit dependency on that rejection invariant rather than something enforced locally in this file.

For symmetry and to guard against a future refactor of the pending-request cleanup path, consider skipping this.schedule() in the success branch too when getSocket() !== probedSocket.

🛡️ Optional defensive guard
     const probedSocket = this.hooks.getSocket()
     try {
       await this.hooks.probe(this.hooks.timeoutMs)
-      this.schedule()
+      if (this.hooks.getSocket() === probedSocket) {
+        this.schedule()
+      }
     } catch (error) {

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7139a70e-a410-4437-b6df-10e4caf541e2

📥 Commits

Reviewing files that changed from the base of the PR and between 658532a and 3865d6d.

📒 Files selected for processing (25)
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/settings/RuntimeEnvironmentsPane.tsx
  • src/renderer/src/components/sidebar/HostSectionHeaderMenu.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/host-header-menu-items.test.ts
  • src/renderer/src/components/sidebar/host-header-menu-items.ts
  • src/renderer/src/components/sidebar/host-section-rows.ts
  • src/renderer/src/components/sidebar/sidebar-host-options.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/runtime/client-app-version.ts
  • src/renderer/src/store/slices/runtime-status.ts
  • src/shared/app-version-skew.test.ts
  • src/shared/app-version-skew.ts
  • src/shared/execution-host-registry.test.ts
  • src/shared/execution-host-registry.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-ready.ts
  • src/shared/remote-runtime-shared-control-session-probe.ts
  • src/shared/remote-runtime-shared-control-types.ts
  • src/shared/runtime-types.ts

Comment thread src/renderer/src/i18n/locales/ja.json Resolved

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7635f31f-c758-437e-80b9-e5625934e428

📥 Commits

Reviewing files that changed from the base of the PR and between 3865d6d and 97d17460e3d336c30fa52e32d31813c1c419b2f1.

📒 Files selected for processing (10)
  • src/renderer/src/App.tsx
  • src/renderer/src/components/sidebar/RuntimeVersionSkewNudge.tsx
  • src/renderer/src/components/sidebar/runtime-version-skew-nudge-plan.test.ts
  • src/renderer/src/components/sidebar/runtime-version-skew-nudge-plan.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/remote-runtime-shared-control-session-probe.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/shared/remote-runtime-shared-control-session-probe.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/zh.json

@tomdebres

tomdebres commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Evidence (end-to-end)

The PR surfaces version skew in three places. These captures are from a real setup: an actual orca serve instance running this branch with app version 1.4.100, paired over the real WS/E2EE path to the dev client at 1.4.147-rc.4 — the skew verdict is computed live from the server-reported version.

1. Proactive toast on skew detection (skill-freshness-nudge pattern; default Projects view, no host filter needed). One toast per environment per version pair per session — periodic probes never re-nag — with a Manage server action deep-linking to the server settings; retracted when a reachable probe reports matching versions:

toast: Orca server Home Server is outdated

2. Sidebar host header for the same paired server (host-filter view) — amber caution icon + "Server outdated" detail:

host header with live skew

3. Host menu — amber "Server update recommended" item; its tooltip carries the full sentence ("This Orca server (1.4.146) is older than your app (1.4.147). Update the server, or some features may fail."). This capture predates the live-pairing setup and used staged store data; the rendering is identical and driven by the same verdict:

host menu with Server update recommended item

The reverse direction (server newer than client) renders the same surfaces with "App outdated" / "App update recommended" wording.

Also applied the reviewer suggestion to mirror the stale-socket guard on the session probe's success branch.

@tomdebres
tomdebres force-pushed the tomdebres/flag-client-server-version-mismatch branch from 7146181 to 899fc56 Compare July 22, 2026 11:50
@tomdebres

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. One real conflict: remote-runtime-shared-control-connection.ts collided with #9774's refactor (extracted reconnect scheduler + socket-generation close guard). Resolution keeps main's refactored structure and re-weaves this PR's session probe into it; the probe's forceClose now routes through the generation-guarded close path via a new currentGeneration() accessor (safe — the probe only force-closes the socket it just probed, and it drops the close if the socket changed). This PR's incidental inlining refactors from the pre-#9774 file were dropped in favor of main's extractions. Typecheck plus the connection, app-version-skew, and nudge-plan suites (45 tests) pass.

@AmethystLiang
AmethystLiang requested a review from OrcaWin July 22, 2026 17:04
@AmethystLiang AmethystLiang added the orca-remote-server Remote Orca Server / orca serve / paired remote runtime label Jul 22, 2026
@AmethystLiang

Copy link
Copy Markdown
Contributor

Associating this PR with related issue(s): #7718

1 similar comment
@AmethystLiang

Copy link
Copy Markdown
Contributor

Associating this PR with related issue(s): #7718

@tomdebres

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (~84 new commits). Notable overlap this round: #9839 (remote server updates) landed its own appVersion + remoteUpdateSupport reporting on runtime status. Resolution unions the type (appVersion?: string | null — #9839's consumers all truthiness-guard it, and this PR's skew evaluator already accepts null/undefined), and #9839's status.get handler now stamps the updater-snapshot version over the runtime snapshot, which this PR's skew detection consumes as-is — so the two features compose: #9839 gives the update path, this PR gives the proactive skew warning that points users at it. The session-probe weave into the #9774 refactor carried over unchanged (main's new reconnectNow() merged cleanly alongside). Typecheck and 541 tests across the connection/skew/RPC-method suites pass.

@tomdebres
tomdebres force-pushed the tomdebres/flag-client-server-version-mismatch branch from 899fc56 to 641eafd Compare July 23, 2026 07:52
… after serve restarts

- status.get now reports the server's appVersion; clients evaluate a
  non-blocking skew verdict (new shared/app-version-skew.ts) and surface
  amber warnings in the sidebar host header and host menu, both directions.
  Protocol-incompatibility blocking is unchanged and takes precedence.
- Shared-control connections gain an app-level liveness probe (status.get
  every 15s while subscribed). A serve restart behind a relay that keeps
  the socket open no longer strands worktree-graph subscriptions: a failed
  probe force-closes the socket and reuses reconnect + replay.
The sidebar host-header warning only renders in explicit host-filter
views, so skew needed a bottom-right nudge (skill-freshness pattern):
one warning toast per environment per version pair per session, with a
Manage server action. Also guard the session probe's success branch
against stale sockets (review feedback).
…unavailable

The name can lag the first probe (pairing races status refresh) or be
unset; showing an opaque environment id in the toast title was worse
than a generic title. Found while capturing end-to-end evidence.
@tomdebres

Copy link
Copy Markdown
Contributor Author

Rebased onto current main. Two small conflicts, both resolved as unions: closeSocket keeps main's compressed null assignment plus this PR's sessionProbe.clear(), and the shared-control types file keeps both main's new RemoteRuntimePreparedRequest import and this PR's RemoteRuntimeSocketLivenessOptions. Typecheck and the connection/skew/nudge suites (48 tests) pass.

@tomdebres

Copy link
Copy Markdown
Contributor Author

As the summary says, this PR is really two independent fixes — it is being split so each can be reviewed on its own. Now open, both self-contained against current main:

The two fixes share no files, so the split is clean. The remaining ~540 changed lines here — the skew surfacing UI (sidebar host-header warning + menu item, proactive toast nudge, i18n strings, execution-host-registry passthrough) — exceeded a reasonable single-PR budget on top of #10234, so this PR will be rebased and shrunk to exactly that UI layer once #10234 and #10235 land. Not closing this PR.

@tomdebres

Copy link
Copy Markdown
Contributor Author

Closing in favor of the split: #10234 (app-version skew detection) and #10235 (self-heal stale subscriptions after serve restarts) — both are self-contained against current main with all review findings resolved. The end-to-end evidence in this PR's thread applies to the combined behavior and remains valid for both.

@tomdebres tomdebres closed this Jul 24, 2026
tomdebres added a commit to tomdebres/orca that referenced this pull request Aug 7, 2026
Servers report appVersion in status.get; the renderer derives a
non-blocking AppVersionSkew verdict when ingesting runtime status.
UI surfacing stays in stablyai#9614.

Split out of stablyai#9614.
tomdebres added a commit to tomdebres/orca that referenced this pull request Aug 9, 2026
Add an encrypted session probe to the shared control connection: a
WS-terminating relay answers protocol pings itself, so a restarted
orca serve behind it looks alive while its subscription registry is
gone. A failed probe force-closes into the existing reconnect+replay
machinery.

Split out of stablyai#9614.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

orca-remote-server Remote Orca Server / orca serve / paired remote runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants