Skip to content

fix(ssh): move the open workspace to the server's linked project when joining an existing server - #30189

Merged
nwparker merged 3 commits into
mainfrom
nwparker/managed-join-linked-retarget
Oct 18, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/managed-join-linked-retarget

Conversation

@nwparker

@nwparker nwparker commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​146 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​146
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​140 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​121

ELI5

When your Orca joins a managed server that another desktop on the same login already runs, a project both desktops added is linked to the server's copy. The server's copy has its own id. Orca used to move your open workspace onto the server only when the ids matched, so for a linked project it never moved. The workspace kept pointing at the old SSH connection until you clicked it again yourself. Now Orca follows the link and opens the server's copy.

What Changed

  • Before: desktop B joins the server desktop A runs, and B's open project is linked to A's copy (fix(ssh): a relay-era desktop can join the server another desktop on the same login runs #28886). B's old project row disappears from the sidebar, but the open workspace stays owned by ssh:<host> under B's old id, so its panes keep dialling the retired relay.
  • After: the open workspace moves to the server's linked checkout (runtime:<server>, the server's id), and the active project follows it. If the server has no project for the workspace at all, nothing is selected rather than leaving a dead target.

Mechanism, in ssh-managed-server-state-effects.ts:

  • The managed status for the converting connect already carries linked, the paths of the projects linked during the move. Before the old rows are dropped, the catalog load maps each linked source project to the server project at the same normalized path (normalizeRuntimePathForComparison, the rule the link itself uses).
  • rehomeActiveWorkspace resolves the server's copy in this order: the same id (unchanged behaviour), then the same checkout path in the linked server project. It checks visible and detected rows, so a checkout the server's visibility settings hide still counts.
  • The selection moves with a state transition, so activeRepoId follows the new row instead of keeping the removed source id.
  • The workspace is cleared only when the server's catalog has no project for it. That is authoritative, because those lists load with throwOnError before this runs. If the project exists but its checkout row is still missing, for example because startup's scan has not run yet or the server's scan failed, the selection is kept and the effect watches for the row. This generalizes the cold-start retry from fix(ssh): move the open workspace to its managed server after the cold-start scan #29894.
  • Tabs are not moved. fix(ssh): a relay-era desktop can join the server another desktop on the same login runs #28886 deliberately leaves a linked project's tabs in this desktop's retained rows, and that is unchanged here, matching the same-id case, which moves only the selection.

Why

  • Main does not journal the server's project id for a link, only the source ids. The path match is exactly what created the link, so reusing it, limited to the projects the connect reported as linked, needs no wire, journal or IPC change.
  • A missing worktree row is not evidence that the server has no copy: fetchWorktrees swallows RPC failures, and startup marks its scan complete even when one host fails. So only project-level absence clears the selection.

No wire change: linked already reaches the renderer.

Linked Issue

Reviewer P2 on #28886 and #29894 (no GitHub issue).

Visual Proof

N/A: the change is to workspace selection state, asserted directly in the tests.

Testing

  • Automated tests in ssh-managed-server-converted-catalogs.test.ts drive the real effect against the real store:
    • the linked project with a different id moves the selection and the active repo (fails on main: the owner stays ssh:ssh-1)
    • the same, when the rows arrive with the cold-start scan (fails on main)
    • a checkout the server only detects (hidden by visibility settings) is still found
    • a failed scan keeps the selection, then moves it once the row arrives
    • no server project clears the selection and the stale active repo (fails on main)
  • src/renderer/src/hooks/ipc-events (36 files, 238 tests) single-worker, pnpm tc, and every step of the static-analysis job locally. The --compiler=bun typecheck variant doesn't run on this Mac, so pnpm tc stood in for it.
  • Not verified live. A live repro needs two desktops on different builds sharing one SSH login, with a relay-era project then linked by a conversion. Only the unit tests cover it.

Review

Codex review (gpt-6.1-sol, high), three rounds:

  1. Two findings, both fixed: activeRepoId stayed on the removed source project, and a checkout the server only detects was missed.
  2. One finding, fixed: a failed server scan cleared the selection. Clearing now needs project-level absence, and a missing row is watched for.
  3. No findings.

Agent skill upstream boundary

  • Not applicable.

Notes

Renderer-only. SSH and folder workspaces were considered: folder links keep the same id, so the existing same-id lookup covers them. Paths are compared with the cross-platform rule. No mobile or compatibility impact.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A with reason for visuals
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote impact considered
  • Targeted tests and the static-analysis steps pass locally; CI covers the rest

@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ddd7db7b-fe86-4d99-b0b1-cde35a0abd17
📥 Commits

Reviewing files that changed from the base of the PR and between b9b1b85 and 0ad5bd1.

📒 Files selected for processing: 2
  • src/renderer/src/hooks/ipc-events/ssh-managed-server-converted-catalogs.test.ts
  • src/renderer/src/hooks/ipc-events/ssh-managed-server-state-effects.ts
  • 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 merged commit d935683 into main Oct 18, 2026
38 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