Skip to content

fix(ssh): a relay-era desktop can join the server another desktop on the same login runs - #28886

Merged
OrcaWin merged 7 commits into
mainfrom
OrcaWin/orcad-migration-adopt
Oct 15, 2026
Merged

OrcaWin merged 7 commits into
mainfrom
OrcaWin/orcad-migration-adopt

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​681 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​681
Prod 26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​648 $\color{#cf222e}{\Huge{\mathbf{−}}}$​140 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​508

ELI5

When two people share one login on a server, and one of them still had projects there from before Orca's managed server existed, that person's Orca could never connect again after updating. Now it joins the server the other person's Orca already runs, and a project both of them added is treated as the same project instead of as a conflict.

What Changed

Before (found in 1.4.225 release testing on a Docker SSH host):

  1. Desktop A (new version) connects first, so the host runs A's managed server, with a terminal open.
  2. Desktop B (1.4.224) connects, falls back to the old relay, and adds a project there.
  3. B updates and reconnects. Every retry fails with "Orca couldn't start its server on this host. Try connecting again." The project shows "Remote connection dropped", with only Retry and Remove Project.
  • Waiting until A's terminal closed didn't help.
  • Once both servers ran the same build, it still failed, now because the server already had the same repository path from A (orcad_migration_repository_path_conflict:/root/migrepo).
  • The only way out was Remove Project, and nothing told the user to do that.

After: B pairs with the server A already runs, without uploading or restarting it, so A's terminals keep running. B's project at the same host path is linked to A's project on the server. B's other projects move as usual. B connects.

Mechanism:

  • orcad-runtime-deployment.ts: a relay migration now also pairs with a running server of another Orca version (adoptRunningOrcadVersion, from fix(ssh): a new desktop can connect to a host already running a different Orca server version #28642), before any upload. Only --force skips it now. Before this, a migration always ran its own deploy. Without a paired server it can't count terminals, so it always deferred.
  • New orcad-migration-repository-link.ts: after pairing and before staging, the conversion lists the server's projects (repo.list, which every server has).
    • A project B is moving that the server holds at the same normalized host path under another id is "linked" (repositoriesHeldByServer).
    • The conversion first checks that the fenced source hasn't changed. It then asks the server to abort the old manifest, and continues only once the server proves it holds nothing of it.
    • Then it rewrites the journal under the same migration id, as one durable write, without the linked projects and the saved state that references them (the existing delta-move subtraction view). The journal now records linkedRepositoryIds, and sourceBaselineFingerprint keeps the whole fenced source.
    • Every later stage/commit check reads the source through the same view.
  • A project that still has a relay terminal the legacy bridge serves is never linked: the bridge can reattach a pane only into its own tab, and a linked project's tabs don't go to the server, so the terminal would keep running out of sight. The connect refuses instead, names the project and says to end those terminals.
  • orcad-migration-delta-plan.ts: a later delta move treats linked projects as already on the server, so it never offers them again.
  • ssh-host-server-on-connect.ts + orcad-migration-conflict-guidance.ts: a conversion the server will keep refusing (a catalog/state conflict) now reports refused with the real reason and the way out (remove that project from this desktop and connect again), instead of "Try connecting again". A staged claim from another desktop's in-flight move expires, so it stays a retry.

Why

  • Why adopt in a migration too? It's the same situation as a fresh desktop: only the running server can count its terminals, so a deploy-first path can never pass the update gate. Adoption never stops anything. It starts a server only when that server has provably exited, and it runs before any upload, so the host is left exactly as it was. The migration fence and journal are untouched: the deploy still requires the journaled fence.
  • When are two paths "the same repo"? The server is reached through this desktop's own SSH target and runs as the same login, so paths on both sides name the same files. Comparison uses normalizeRuntimePathForComparison, the same rule the server's own conflict check uses. POSIX paths stay case-sensitive, and only Windows paths fold case. A row with the same id is left to the import's existing same-row check. Two of B's own projects at one path, and id conflicts, are still refused, now with an explanation.
  • Why the server's project wins: this matches what the "Remove Project, then Connect" workaround produced, and that workaround proved the server's project usable. B's tabs and saved state for a linked project would collide with A's state for the same worktree on the server. So they stay in B's retained profile rows (kept for a downgrade, as every migrated row is), and nothing is deleted. There is no existing mechanism that remaps one project id onto another. Building one would be a much larger change to the server import.
  • Why on the desktop and not in the server's import? The server B adopts is often an older build than B. A server-side fix wouldn't reach it. A desktop-side fix works with any server.
  • Same migration id: two journals for one host break the chain check and would leave the host fenced. Rewriting the one record after the server proves it holds nothing keeps the swap safe if Orca crashes partway.
  • Wire compatibility: there's no new RPC or field on the wire. repo.list and the catalog calls already exist on every server. The new journal field is optional and local. Older builds ignore it, and the baseline fingerprint keeps a downgraded build from mistaking the linked rows for a change.
  • A 1.4.224 desktop still on its relay keeps working: adopting and linking never touch relay processes. Its live relay terminals still block another desktop's conversion only through the existing host-wide census, which is unchanged.

Linked Issue

Found in 1.4.225 release QA (follow-up to #28642).

Visual Proof

N/A: no layout change. The connect now succeeds. The remaining conflict case uses the existing "Not moved to a managed server" line, whose Details now name the conflict and the way out.

Testing

  • orcad-migration-repository-link.test.ts runs the conversion against a real server-side import (a second profile store standing in for orcad):

    • With no link, the server refuses with orcad_migration_repository_path_conflict (the QA failure).
    • With a link, only the projects the server lacks move. The linked project's saved state stays with the server and in the retained rows.
    • A restart doesn't mark the host changed, and a later delta move never offers the linked project.
    • A move the server had already staged before A added the same path is aborted on proof and rewritten under the same id.
    • A source edited after the fence is still refused, not linked over.
    • A bridged relay terminal in the linked project refuses the link. One in a project that moves doesn't.
    • Path rules: trailing slash, POSIX case, Windows case, same id, different path.
  • orcad-runtime-deployment.test.ts: a migration deploy onto a host another version runs pairs without uploading. An unverifiable host starts and registers nothing. I checked that both tests fail without the fix.

  • ssh-host-server-on-connect.test.ts: a path conflict becomes refused with the path and the way out. A staged claim stays a retry.

  • New Docker real-host e2e tests/e2e/ssh-orcad-shared-login-migration.spec.ts runs the exact QA sequence:

    • A runs a server under another content version, adds the repo and leaves a sleep terminal running.
    • B starts from a relay-era profile holding the same repo.
    • B connects. The test asserts the server version and process are unchanged, A's terminal is still running, the journal records the link, and the server lists that path once.
    • It runs in the orcad-ssh-docker lane.
  • pnpm tc:node, pnpm test src/main/ssh src/main/ipc src/shared src/main/persistence-orcad-migration-catalog.test.ts (1873 files passed; one known timing flake in orcad-state-snapshot-shell.test.ts passed on rerun), pnpm run check:code-quality:changed.

  • 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

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

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)

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 53db631b-e47e-4083-be02-ef6d7cee5b74
📥 Commits

Reviewing files that changed from the base of the PR and between 2a3f5c8 and 23b3905.

📒 Files selected for processing: 1
  • tests/e2e/ssh-orcad-shared-login-migration.spec.ts

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

📝 Walkthrough

SSH-target conversion now lists repositories held by the managed server and links incoming repositories that match by normalized path. Migration cutovers record linked repository IDs and exclude those repositories from the moved source. Conversion revalidates the source fence and retains the source after destination commit. Migration deployment can adopt a running version, and recognized migration conflicts produce refusal guidance. Tests cover repository linking, runtime reuse, conflict outcomes, and shared-login migration.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 23b39

The reviewed change strengthens the shared-login migration test, and no actionable regression is identified. It appears ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 44.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 15 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description is complete and directly explains the user impact, implementation, rationale, testing, compatibility considerations, and checklist status. It identifies the related issue as a follow-u…
Title check Passed The title is concise, specific, and accurately describes the main shared-login SSH migration fix.
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.
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • 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.

…the same login runs

A desktop that still had relay-era projects on a host whose managed server
another Orca version ran could never connect: its migration skipped the
running-version adoption, so it deferred on a terminal count only a paired
server can give. Once the versions matched it failed instead because the
server already held the same repository path, added by the other desktop.

The migration now pairs with the running server like a fresh desktop does,
before any upload. Projects the server already holds at the same host path
are linked to the server's project instead of imported twice: the journal
is re-cut without them, under the same migration id, only after the server
proves it holds nothing of the earlier manifest. A conflict the server will
keep refusing now says what conflicts and how to get past it.
The bridge reattaches a relay pane only into its own tab, which a linked
project never sends to the server, so linking would leave that terminal
running out of sight. Refuse the link instead, naming the project and how
to end the terminals.
@OrcaWin
OrcaWin force-pushed the OrcaWin/orcad-migration-adopt branch from d127c07 to effe6ca Compare October 14, 2026 23:44

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

🟠 Major · Preserve byte-distinct POSIX paths when matching… · orcad-migration-repository-link.ts:25-43

src/main/ssh/orcad-migration-repository-link.ts:25-43
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve byte-distinct POSIX paths when matching server repositories.

normalizeRuntimePathForComparison NFC-normalizes both paths. On a byte-exact Linux/SSH host, NFC and NFD names can identify different directories. repositoriesHeldByServer then treats those paths as one when their IDs differ. linkServerHeldRepositories removes the incoming repository from the source manifest, so migration can omit the distinct checkout and retain the server’s other checkout.

Use a byte-preserving POSIX key at this matching boundary. Preserve the existing Windows, separator, and trailing-slash behavior.

Suggested fix
-import { normalizeRuntimePathForComparison } from '../../shared/cross-platform-path'
+import {
+  isWindowsAbsolutePathLike,
+  normalizeRuntimePathForComparison
+} from '../../shared/cross-platform-path'
@@
 export type OrcadServerRepository = Pick<Repo, 'id' | 'path'>
 
+function repositoryPathKey(path: string): string {
+  const normalized = normalizeRuntimePathForComparison(path)
+  if (isWindowsAbsolutePathLike(path)) {
+    return normalized
+  }
+  const byteExact = path.replace(/\/+/g, '/').replace(/\/+$/, '') || '/'
+  return `${normalized}\u0000${byteExact}`
+}
+
 /** Incoming projects the server holds at the same host path under another id. */
 export function repositoriesHeldByServer(
@@
   const serverIdsByPath = new Map<string, Set<string>>()
   for (const repo of server) {
-    const key = normalizeRuntimePathForComparison(repo.path)
+    const key = repositoryPathKey(repo.path)
     serverIdsByPath.set(key, (serverIdsByPath.get(key) ?? new Set()).add(repo.id))
   }
   return incoming
     .filter((repo) => {
-      const ids = serverIdsByPath.get(normalizeRuntimePathForComparison(repo.path))
+      const ids = serverIdsByPath.get(repositoryPathKey(repo.path))

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 93835312-e5e8-46d5-b7ff-eec74b53a206
📥 Commits

Reviewing files that changed from the base of the PR and between 5556153 and 2a3f5c8.

📒 Files selected for processing: 1
  • tests/e2e/ssh-orcad-shared-login-migration.spec.ts

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

OrcaWin pushed a commit that referenced this pull request Oct 15, 2026
…the same login runs (#28886)

Ported to the v1.4.225 base. The base has no OrcadMigrationSourceCutoverPort or
createSshRelayMigrationSource, so the linked source view is passed as the
cutover context's existing `freshSource`, and the pre-relink fence check calls
assertOrcadMigrationSourceUnchanged directly. Only listRemoteOrcadRepositories
was taken from the catalog client; the blob-chunk staging from main is not
part of this release.
OrcaWin and others added 2 commits October 14, 2026 18:49
…or an unowned relay terminal

A project this desktop moved that the host's server already held is linked to the
server's copy, so its tabs and automations from this desktop stay behind. The
connect now carries those linked projects and the SSH host card says so, with the
automation count, instead of dropping them silently.

A bridged relay terminal of unknown or removed project still blocks a link, but its
guidance no longer names the linked project as where it runs. Both terminal
messages now offer removing the project from this desktop as the way out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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