Skip to content

fix(ssh): move the open workspace to its managed server after the cold-start scan - #29894

Merged
nwparker merged 1 commit into
mainfrom
nwparker/managed-rehome-after-startup-scan
Oct 17, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/managed-rehome-after-startup-scan

Conversation

@nwparker

@nwparker nwparker commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​32
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21

ELI5

When an SSH host moves to its own managed Orca server, Orca switches your open workspace over to that server so its terminals stop dialling the old relay. If this happened while Orca was still starting up, the switch was tried too early, before Orca knew the server's copy of the workspace existed, and it was never tried again. The workspace stayed attached to the retired SSH connection.

What Changed

  • Before: on a cold start where the managed server's catalog finishes loading before startup's worktree scan, the active workspace stays owned by ssh:<host>. Its panes keep pointing at the stopped relay.
  • After: once startup's worktree scan completes, the active workspace moves to runtime:<server>, as it already does for a conversion that happens while Orca is running.

Mechanism, in ssh-managed-server-state-effects.ts: during startup the catalog load deliberately skips its own worktree fetch, because startup scans every host once its catalogs are in. It then made a single rehomeActiveWorkspace attempt, which needs the server's worktree row and so found nothing. Now, if startupWorktreeRefreshCompleted is still false after that attempt, the load waits for the flag to flip and retries the rehome once. It stops waiting if the conversion is superseded, for example when the host goes back to the relay or gets a new server. The rehome keeps its existing checks: the workspace must still be on that SSH host, and the server must know it.

Why

Making the catalog load fetch worktrees during startup would duplicate the startup scan that the existing gate exists to avoid. Waiting for the scan's completion flag reuses the moment the rows actually exist, adds no extra requests, and covers git worktrees and folder workspaces alike through getKnownWorktreeById.

No wire change.

Linked Issue

Internal Codex SSH review, finding 11 (no GitHub issue).

Visual Proof

N/A: the change is to workspace ownership state, asserted directly in the test.

Testing

  • Automated test added: ssh-managed-server-converted-catalogs.test.ts "moves the open workspace once the cold-start scan delivers the server rows". It fails on main (the owner stays ssh:ssh-1) and passes now.
  • src/renderer/src/hooks/ipc-events passed single-worker (34 files), and the full static-analysis job steps pass locally.
  • Manually tested: verified only in unit tests, not live. A live repro needs a cold start that races a managed-server conversion against startup's scan.

Review

Codex review (gpt-6.1-sol, high): no findings.

Agent skill upstream boundary

  • Not applicable.

Notes

Security, cross-platform, SSH, mobile and compatibility impact considered: renderer-only.

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 pass locally; CI covers the rest

…d-start scan

On cold start the conversion skips its own worktree fetch and waits for
startup's scan, so the one rehome attempt found no server row and left
the active workspace on the retired SSH owner. Retry the move once the
startup scan completes, while the conversion is still current.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 17, 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: b847cbc4-2d0c-4bd3-a731-9c4e297afc5d
📥 Commits

Reviewing files that changed from the base of the PR and between 9aa5372 and afe107a.

📒 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

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

📝 Walkthrough

When startup worktree refresh is incomplete, loadManagedServerCatalogs subscribes to app-store updates. It unsubscribes if the catalog load is no longer current. When refresh completes, it unsubscribes and rehomes the active workspace. A test covers a server worktree row that arrives after the managed-server transition.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to afe10

The startup rehome change is ready to merge after normal checks; no material ownership regression was found.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the user impact, mechanism, rationale, testing, visual-proof status, and compatibility considerations. However, it does not provide the required linked issue; it states that n… Add an actual linked issue under “Linked Issue” and replace “Fixes #” with the issue reference. If the author is an internal maintainer and the repository permits the stated exception, explicitly identify that exception. Complete the AI Dis…
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the SSH cold-start fix and the workspace move to the managed server. It is concise and directly matches the main change.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.
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 explains the user impact, mechanism, rationale, testing, visual-proof status, and compatibility considerations. However, it does not provide the required linked issue; it states that no GitHub issue exists.

Resolution

Add an actual linked issue under “Linked Issue” and replace “Fixes #” with the issue reference. If the author is an internal maintainer and the repository permits the stated exception, explicitly identify that exception. Complete the AI Disclosure section when applicable; otherwise leave it omitted only under the repository’s internal-contributor rule.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 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 merged commit db0e62f into main Oct 17, 2026
37 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