Skip to content

fix(ssh): a new desktop can connect to a host already running a different Orca server version - #28642

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/orcad-adopt-running-version
Oct 14, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/orcad-adopt-running-version

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​210 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​208
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​143 $\color{#cf222e}{\Huge{\mathbf{−}}}$​40 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​103

ELI5

If another copy of Orca (a different version) already started Orca's server on an SSH host, a desktop connecting to that host for the first time now joins that server instead of failing. It updates the server later only if that's safe.

What Changed

Before: A fresh desktop profile connecting to a host whose managed server was started by a different Orca version failed with "Orca couldn't start its server on this host. Try connecting again." Retrying never helped, whether or not terminals were open on the host. This also happened when the host's server was newer than the desktop.

After: The desktop pairs with the server that's already running, keeps that server's version, and connects. Right after pairing, it runs the same update check that every linked desktop runs on connect. That check asks the server how many terminals are live and updates it only when the existing rules allow (no terminals running, and the host isn't on a newer Orca). Otherwise the desktop stays connected and shows the usual "update deferred" or "host is newer" note.

Mechanism:

  • createManagedOrcadEnvironment now checks the host's activation record before uploading anything. If it names a different version, adoptRunningOrcadVersion (new file, orcad-running-version-adoption.ts) handles it:
    • It reuses wakeStoppedManagedOrcad, so a server is started only if it's proven stopped, and only under the host fence.
    • It re-reads the record, hashes the installed bytes of the running slot, and checks that slot's readiness against that identity.
    • The deploy then opens the tunnel and saves the pairing link exactly as it does for a fresh deploy, and returns already-current with the running version.
  • When there's nothing to adopt, the deploy runs as before. That covers: no active version, this desktop's own version, the host fence held, the server stopped elsewhere, --force, and a relay migration. So the downgrade refusal still applies when nothing is running.
  • When the running server's process state can't be verified, the connect fails and says so. Nothing is started, stopped or registered, and the deploy claim is released as before.
  • ssh-host-server-on-connect.ts: after a deploy returns already-current, the connect runs checkManagedServerUpdate. Without this, an adopted server would only be offered an update on the next connect.

Why

  • Why not deploy over it? Before pairing, the desktop can't count the host's terminals. The update planner rightly treats an unknown count as "maybe live" and won't restart over it, so a deploy-first path can never succeed there.
  • Why not count terminals some other way? The count is only available from the server, and only over a paired connection. SSH access already authorizes the pairing, the same way the same-version path reads the readiness file over SSH.
  • Why adopt before uploading? The host is left exactly as it was, with no extra installed version.
  • Wire compatibility: pairing still goes through the runtime protocol-version gate (evaluateRuntimeCompat). A server too old to speak this client's protocol is reported as incompatible, not used silently. An older server that can't answer the terminal count leaves the update deferred, and the client never assumes zero.
  • WSL: WSL hosts already count the running server's terminals over a short-lived bridge (readWslOrcadIncumbent) and keep it serving while an update waits, so that path doesn't need this change. A WSL host running a newer Orca still reports a forceable deferral, which is deliberate and covered by its own test. That's unchanged here.

Linked Issue

Found while testing the 1.4.225 release candidate (candidate 8).

Visual Proof

N/A: no UI change. The connect now succeeds and uses the existing status notes.

Testing

  • orcad-running-version-adoption.test.ts: covers adopting a serving build (checked against its own installed hash), adopting a build that was stopped and restarted only after being proven stopped, falling back to the deploy when the host was stopped, fenced or moved to this build in the meantime, and an unverifiable or unrecoverable host, which throws and launches nothing.

  • orcad-runtime-deployment.test.ts: covers a host on an older and on a newer Orca, each adopted with no upload or restart, --force still deploying, the same-version path unchanged (no wake, deploy returns already-active), and an unverifiable host, which registers nothing.

  • ssh-host-server-on-connect.test.ts: covers the update check running right after adoption, with a deferral shown as a note on a managed connect.

  • pnpm tc:node, pnpm test src/main/ssh src/main/ipc src/main/wsl (8350 passed), pnpm run check:code-quality:changed.

  • I didn't run a real Docker host check: Docker isn't available on the machine this was built on.

  • I manually tested these changes locally

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

Review

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

  • SSH: this is SSH-only. A running server is never stopped by this path, and an unverifiable one is reported as unverifiable, never as exited.
  • Cross-platform: the slot paths and wake are the existing helpers, which already work for Windows SSH hosts.

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)

…rent Orca server version

A first connect onto a host whose managed server another Orca version
started deferred the update (its terminal count needs pairing) and failed
the connect. Pair with the running build as it is, before uploading
anything, then let the linked update check ask it for its terminals.
@coderabbitai

coderabbitai Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4e0b6767-1b4e-4a3e-8d8d-fec6a7c7df08
📥 Commits

Reviewing files that changed from the base of the PR and between b5c568e and 7e56b0d.

📒 Files selected for processing: 6
  • src/main/ssh/orcad-running-version-adoption.test.ts
  • src/main/ssh/orcad-running-version-adoption.ts
  • src/main/ssh/orcad-runtime-deployment.test.ts
  • src/main/ssh/orcad-runtime-deployment.ts
  • src/main/ssh/ssh-host-server-on-connect.test.ts
  • src/main/ssh/ssh-host-server-on-connect.ts

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

📝 Walkthrough

Managed Orcad deployment can adopt a version that is already running, unless force or migration is set. If adoption does not occur, deployment follows its own deployment path. The selected version and readiness are used for tunnel setup and environment registration. When deployment reports already-current, the connection path checks for server updates and records the outcome in the decision trace.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 7e56b

The adoption and update paths have no identified merge-blocking issue. Normal checks remain appropriate before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main SSH behavior change: connecting to a host that already runs a different Orca server version.
Description check Passed The description is mostly complete. It explains the user impact, implementation, rationale, compatibility considerations, testing, and known limitations. It marks visual proof as not applicable and do…
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.
  • Fix all pre-merge checks with AI
✨ 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.

@OrcaWin
OrcaWin merged commit 8400aa5 into main Oct 14, 2026
56 of 75 checks passed
registered2nd pushed a commit to registered2nd/orca that referenced this pull request Oct 14, 2026
…rent Orca server version (stablyai#28642)

A first connect onto a host whose managed server another Orca version
started deferred the update (its terminal count needs pairing) and failed
the connect. Pair with the running build as it is, before uploading
anything, then let the linked update check ask it for its terminals.

Co-authored-by: m4air <[email protected]>
(cherry picked from commit 8400aa5)
registered2nd pushed a commit to registered2nd/orca that referenced this pull request Oct 14, 2026
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