Skip to content

fix(ssh): let a second desktop move onto a host another desktop already set up - #35879

Merged
nwparker merged 1 commit into
mainfrom
fix/35585-shared-host-focus
Oct 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/35585-shared-host-focus

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​56
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8

ELI5

When two computers use the same SSH host, each remembers which project it had selected. The host's Orca server treated a different selection from the second computer as a conflict, so it refused to set the second computer up at all. A selection isn't saved work, so the host now keeps its own selection and takes the second computer's projects.

What Changed

  • Before: a desktop moving its SSH state onto the host's Orca server (orcad) sends its focus along with its projects: the selected project, worktree, workspace, host, and tab. The server refused with orcad_migration_dormant_focus_conflict:<field> whenever it already had a different focus. Another desktop's focus always differs, so the second desktop failed on every retry, and only a plain SSH terminal worked.
  • After: the server no longer treats focus as conflicting saved state. A host that already has focus keeps all five focus fields together, clearing any it never set, so none is borrowed from the incoming desktop. A host with no focus still takes the desktop's focus, as before. Real conflicts are refused exactly as before: ids, sessions, worktree metadata, automations.

Why

Focus is per-desktop UI state. Each desktop writes its own focus into the host's session and reads its own local copy back first. So the host's stored focus is just whichever desktop wrote last, and the server only uses it as a hint. Refusing a migration over it blocked every second desktop and protected nothing. mergeWorkspaceSessions already preferred the host's focus for the fields it merged. This change makes that hold for all of the focus fields together.

The WSL project mover already strips desktop focus for the same reason. Its comment no longer cites this refusal.

Linked Issue

Fixes #35585

Thanks to the reporter for the clear two-desktop setup and the exact error code.

Visual Proof

N/A. This is server-side migration validation. The visible change is that the second desktop connects instead of showing the conflict error.

Testing

  • Automated tests added/updated
    • New test with two desktops and one host, through the real stage and commit path. Desktop A migrates first. The host names only a project, with its optional focus fields unset. Desktop B then migrates a different project with its own focus. On main this fails with exactly orcad_migration_dormant_focus_conflict:activeRepoId. With the fix, it commits, imports B's project, and leaves the host's focus whole. The test also fails if only the fields the host set are kept.
  • Ran src/main/persistence/migrating-orcad-catalog, src/main/persistence/moving-wsl-projects, and the runtime migration-catalog tests. They all pass, apart from three WSL timing tests that time out the same way on main on this heavily loaded machine.
  • pnpm check:changed --maxWorkers=2 passes.
  • Not run locally: the Docker managed-orcad e2e lane. Its Linux orcad template build doesn't run on this Mac; CI covers that lane.

Review

  • Codex review: clean on the final head. The first pass found that optional focus fields the host never set were still borrowed from the desktop; that's fixed and covered by the test.
  • Independent review: no P0 or P1.

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

  • Mixed versions: the refusal happens on the server, so a new desktop on an older server is still refused until that server updates. A new server accepts manifests from old and new desktops unchanged. I didn't add a desktop-side workaround that strips focus and retries: the manifest is digest-checked and recomputed during cutover, and the root fix belongs on the server.
  • Remote and folder workspaces: the focus fields cover worktree and folder workspace keys alike.

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)

…dy set up

Moving a desktop's SSH state onto the host's Orca server refused with
orcad_migration_dormant_focus_conflict whenever the host already had a
focused project from another desktop. Focus is each desktop's own
selection, not saved state, so two desktops always differ and the second
could never move, on every retry.

The host now keeps its own focus as a unit and takes a desktop's focus
only when it has none, which is what the merge already did for the
fields it borrowed. Older servers still refuse until they update.

Fixes #35585
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Lets a second desktop migrate projects onto a host with a different selection.

  • A host keeps its own selection when another desktop imports projects.

nwparker explicitly describes clearing unset host focus fields as intentional. The new test covers that behavior.

Reviews (1) · Last reviewed commit: "fix(ssh): let a second desktop move onto..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Session preparation no longer rejects differing focus fields between the host and incoming sessions. If the host has any focus fields set, preparation preserves those values and sets its unset focus fields to null. A migration test checks that a second desktop’s repository is added while the host’s existing project focus remains and optional workspace and execution-host focus remain unset.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 156f0

The focus migration is mergeable; an additional test would strengthen coverage of fully populated host focus.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… 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 change: allowing a second desktop to migrate onto a host that another desktop already configured.
Description check Passed The description is complete and follows the repository template. It explains the user impact, implementation, rationale, linked issue, testing, compatibility considerations, and checklist status. It a…
Linked Issues check Passed Issue [#35585] requires a second desktop to use an SSH host after another desktop migrated it. prepareOrcadMigrationWorkspaceSession no longer rejects focus differences. When the host has any focus,…
Out of Scope Changes check Passed The changes stay within issue [#35585]. Production changes update SSH-state migration focus handling. The migration-catalog test covers the reported two-desktop case. The WSL test and comment remove a…
Full details: Description check

Explanation

The description is complete and follows the repository template. It explains the user impact, implementation, rationale, linked issue, testing, compatibility considerations, and checklist status. It also documents the unrun Docker e2e lane and known timing-test timeouts.

Full details: Linked Issues check

Explanation

Issue [#35585] requires a second desktop to use an SSH host after another desktop migrated it. prepareOrcadMigrationWorkspaceSession no longer rejects focus differences. When the host has any focus, sessionFocus preserves all SESSION_FOCUS_FIELDS and converts unset host fields to null. Other dormant-state conflict checks remain. The new migration-catalog test exercises stage and commit, imports the second repository, and verifies that the host focus remains intact. This implements the issue's coding requirement.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue [#35585]. Production changes update SSH-state migration focus handling. The migration-catalog test covers the reported two-desktop case. The WSL test and comment remove an obsolete focus-conflict expectation and document the updated behavior. No unrelated product behavior is changed.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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.

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

Nitpick comments: 1
src/main/persistence/migrating-orcad-catalog/persistence-orcad-migration-catalog.test.ts: 1

128-185: Trivial · Maintainability & Code Quality · Quick win

Add a case where the host has non-null focus in every focus field.

The new commit-path test only sets activeRepoId to a non-null value. It sets the host's activeWorktreeId and activeTabId to null, and it leaves the host's workspace key and execution-host focus unset. The overlay in prepareOrcadMigrationWorkspaceSession copies all five focus fields. The PR states that a host with focus keeps all five together. The current test does not exercise that overlay for non-null worktree, tab, workspace key, or execution-host values. A regression that drops a non-null host tab, for example, would still pass. This is a coverage gap, not a current production failure.

Keep the existing test unchanged and add this case beside it:

Suggested fix
+  it('keeps every non-null host focus field when a second desktop commits', () => {
+    const store = createStore()
+    const dormant = dormantState()
+    commitCatalog(store, manifest({ payload: { ...manifest().payload, dormantState: dormant } }))
+    const hostTab = dormant.workspaceSession!.tabsByWorktree[DORMANT_WORKTREE_ID][0]
+    store.setWorkspaceSession({
+      ...store.getWorkspaceSession(),
+      activeRepoId: REPOSITORY.id,
+      activeWorktreeId: DORMANT_WORKTREE_ID,
+      activeWorkspaceKey: worktreeWorkspaceKey(DORMANT_WORKTREE_ID),
+      activeWorkspaceExecutionHostId: 'runtime:host-focus',
+      activeTabId: hostTab.id
+    })
+
+    const secondRepo = { ...REPOSITORY, id: 'repo-2', path: '/srv/repo-2' }
+    const secondWorktree = `${secondRepo.id}::/srv/repo-2`
+    const second = manifest({
+      migrationId: 'migration-second-desktop-full-focus',
+      source: { sshTargetId: 'ssh-prod-b', sshTargetGeneration: 1, targetLabel: 'Production' },
+      payload: {
+        repositories: [secondRepo],
+        projectGroups: [PROJECT_GROUP],
+        folderWorkspaces: [],
+        dormantState: {
+          version: 1,
+          worktreeMeta: [],
+          worktreeLineage: [],
+          workspaceLineage: [],
+          sparsePresets: [],
+          retiredWorktreeNames: [],
+          retiredWorktreeNamespaces: [],
+          workspaceSession: {
+            ...getDefaultWorkspaceSession(),
+            activeRepoId: secondRepo.id,
+            activeWorktreeId: secondWorktree,
+            activeWorkspaceKey: worktreeWorkspaceKey(secondWorktree),
+            activeWorkspaceExecutionHostId: 'local'
+          }
+        }
+      }
+    })
+
+    expect(commitCatalog(store, second)).toMatchObject({ state: 'committed' })
+    expect(store.getWorkspaceSession()).toMatchObject({
+      activeRepoId: REPOSITORY.id,
+      activeWorktreeId: DORMANT_WORKTREE_ID,
+      activeWorkspaceKey: worktreeWorkspaceKey(DORMANT_WORKTREE_ID),
+      activeWorkspaceExecutionHostId: 'runtime:host-focus',
+      activeTabId: hostTab.id
+    })
+  })

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b5f80da6-0c38-488e-8ef9-6fd3fae43830
Commits

Reviewing files that changed from the base of the PR and between 552e281 and 156f027.

Files selected for processing: 4
  • src/main/persistence/migrating-orcad-catalog/orcad-destination-workspace-session.ts
  • src/main/persistence/migrating-orcad-catalog/persistence-orcad-migration-catalog.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-session-rewrite.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-session-rewrite.ts
Files with no reviewable changes: 1
  • src/main/persistence/moving-wsl-projects/wsl-move-session-rewrite.test.ts

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

@nwparker
nwparker merged commit 0ac328c into main Oct 29, 2026
53 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.

[Bug]: SSH host shared by two desktops: migration blocked with orcad_migration_dormant_focus_conflict:activeRepoId

1 participant