Skip to content

fix(ssh): bind reattached SSH panes into the target's own session partition - #26088

Merged
Jinwoo-H merged 5 commits into
mainfrom
fix/ssh-reattach-home-partition
Oct 7, 2026
Merged

Jinwoo-H merged 5 commits into
mainfrom
fix/ssh-reattach-home-partition

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​171 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​171
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​18 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

ELI5

Orca saves each SSH workspace's terminal layout under that SSH host. After an SSH reconnect, Orca also wrote a second, stripped-down copy under "this computer". If nothing overwrote that copy before the next launch, Orca loaded it instead of the real one. That launch was missing the workspace's open files, and its paused agent sessions could no longer be resumed. This PR saves the reconnected terminal under the SSH host, where it belongs.

What Changed

Before. When an SSH connection drops and comes back, Orca reattaches each still-running remote terminal. The reattach saved the terminal into the local session store, so every reattached SSH tab got a minimal copy there: generic title, default split. With a window open, the window's next save deleted that copy within about a second. With no window open, the copy stayed on disk. That happens on macOS, where Orca keeps running after its window closes and reconnects SSH by itself. On the next launch, startup sees local holding tabs for the workspace and skips the SSH host's saved rows for it. The user sees:

After. The reattach saves into ssh:<target>, the same store the terminal's original spawn wrote to. No local copy is created, so startup has nothing to prefer over the real one.

Mechanism. restoreReattachedPtyRuntime (src/main/ssh/ssh-relay-session.ts) now passes ssh:<targetId> to persistPtyBinding. It also decides "does this pane still exist?" from that store instead of from local. local is still checked for the pane, so a pane that only an older build's leftover local rows hold is not refused. Other changes: four comments that described the old behavior, a unit assertion, and a new Docker SSH e2e spec, registered in run-ssh-docker-e2e.mjs.

Not changed. local copies that older builds already wrote are not migrated. Startup still prefers such a copy one more time; the window's first save then moves that workspace home and clears it.

Why

This is the narrowest change at the source of the bug: the only path that kept writing SSH panes into local. The spawn path and the window already write SSH workspaces to ssh:<target>. Alternatives considered:

  • Changing the startup rule to prefer the SSH copy. That treats the symptom, and it changes which copy wins for every existing profile, which is a separate decision.
  • A shared "home partition" resolver used by main, the window's save routing and the spawn path. That moves the folder-workspace and catalog-not-loaded fallbacks, which behave differently today, so it is not behavior-neutral. It is left for a follow-up.

Linked Issue

Fixes #25616
Refs #23390 (this stops new local copies; it does not change the startup rule that issue describes)

Visual Proof

N/A: there is no UI change. The behavior is pinned by tests/e2e/ssh-reattach-home-partition.spec.ts (real sshd container and relay; hidden window; three launches on one profile):

  • on main: local holds 2 SSH tabs after the reattach, and the relaunched workspace shows {"tabs":2,"files":[]} (the open README.md tab is missing);
  • with this PR: local holds no SSH tabs, and the workspace relaunches with {"tabs":2,"files":["README.md"]}.

Testing

  • tests/e2e/ssh-reattach-home-partition.spec.ts: fails on main, passes here. Also passing here: ssh-restart-tab-accumulation, ssh-reconnect-tab-destruction, ssh-docker-reconnect-pane-restore, ssh-lost-kill-tab-resurrection (7 tests, macOS + Docker sshd).

  • ssh-relay-session-reconnect-incarnation.test.ts asserts the reattach binds into ssh:target-1; it fails on main.

  • pnpm test src/main/ssh src/main/persistence/terminal-topology: green apart from 3 tests that depend on this machine (fish config, real-SQLite integration).

  • pnpm run test:e2e:terminal-layout-parity -- --base origin/main --head HEAD: PASS: all 9 local scenarios identical to main (base 358e4f92e0c). No SSH parity scenario: the parity harness has no Docker lifecycle yet (listed as a follow-up in tests/e2e/AGENTS.md), so the SSH scenario is the dedicated spec above.

  • pnpm tc and pnpm run check:code-quality:changed pass.

  • I manually tested these changes locally

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

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: this only affects SSH. Local terminals and remote-server (runtime:) workspaces do not use this path.
  • Backwards compatibility: no state migration. Existing local copies are handled as described above.
  • Performance: no change. It is the same single write, to a different partition.
  • Cross-platform: no platform-specific code.

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)

…tition

A relay reattach persisted the pane binding into the local partition, minting a
minimal copy of every reattached SSH tab there. When nothing saved over it (a
reconnect with no window open), the next startup kept that copy and skipped the
SSH partition's rows for the workspace: its open editor tabs were missing for a
launch and its agent-resume records were dropped (STA-9544).

Bind into ssh:<target>, where the spawn bound the same pane.
@coderabbitai

coderabbitai Bot commented Oct 7, 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: e578ca12-0a88-4552-bbe6-fbd3a0699d1b
📥 Commits

Reviewing files that changed from the base of the PR and between e1f7c1a and 8b19c3e.

📒 Files selected for processing (1)
  • tests/e2e/ssh-reattach-home-partition.spec.ts

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


📝 Walkthrough

Walkthrough

restoreReattachedPtyRuntime now persists PTY bindings in the SSH execution host partition. It checks the host session for the pane’s current tab before checking the legacy local session and lease tab ID. A reconnect test and a Docker-backed restart test cover the change. The SSH Docker E2E runner includes the new test, and the older-ref fallback excludes it from general changed-spec execution.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 8b19c

This change adds an end-to-end test for SSH relay reattachment that runs only when the SSH Docker flag is enabled. No merge-blocking risk was found in the supplied material.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #25616 requires SSH recovery state to survive startup after relay reattachment. The new path passes ssh:<targetId> to persistPtyBinding, and the unit and Docker E2E tests cover new reattachm… Handle legacy local rows for SSH-owned workspaces so they cannot shadow SSH recovery state during startup, or preserve the SSH recovery fields when startup adopts such rows. Add a regression test with pre-existing legacy local rows.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: reattached SSH panes now bind to the target session partition.
Description check ✅ Passed The description substantially follows the repository template. It explains the user impact, mechanism, rationale, linked issue, testing, visual proof status, compatibility considerations, and checklis…
Out of Scope Changes check ✅ Passed The source change, unit assertion, comments, Docker E2E test, and test-runner registration support issue #25616. The changes stay within SSH relay reattachment and its regression coverage. No unrelate…
Full details: Linked Issues check

Explanation

Issue #25616 requires SSH recovery state to survive startup after relay reattachment. The new path passes ssh:&lt;targetId&gt; to persistPtyBinding, and the unit and Docker E2E tests cover new reattachments. However, existing local rows from older builds remain authoritative for one startup. The PR states that startup can still skip the SSH rows and lose recovery fields before the first save clears the legacy rows. The added E2E test does not cover this pre-existing-row case.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

Waits for the SSH partition to persist the open file and for main's SSH
state to report the reattached connection, instead of fixed 3s/30s sleeps
that could pass vacuously on a slow reconnect.
@Jinwoo-H
Jinwoo-H merged commit d68f3bb into main Oct 7, 2026
122 of 126 checks passed
ph47s74x pushed a commit to mercurai/orca that referenced this pull request Oct 8, 2026
…tition (stablyai#26088)

* fix(ssh): bind reattached SSH panes into the target's own session partition

A relay reattach persisted the pane binding into the local partition, minting a
minimal copy of every reattached SSH tab there. When nothing saved over it (a
reconnect with no window open), the next startup kept that copy and skipped the
SSH partition's rows for the workspace: its open editor tabs were missing for a
launch and its agent-resume records were dropped (STA-9544).

Bind into ssh:<target>, where the spawn bound the same pane.

* test(e2e): run the reattach home-partition spec only in the Docker SSH lane

* test(e2e): keep Electron running after its last window closes on Linux in the reattach spec

* test(e2e): sync the SSH reattach spec on state, not sleeps

Waits for the SSH partition to persist the open file and for main's SSH
state to report the reattached connection, instead of fixed 3s/30s sleeps
that could pass vacuously on a slow reconnect.

(cherry picked from commit d68f3bb)
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 relay reattach writes tabs into the LOCAL session partition; on the next start those workspaces lose all agent-resume state

1 participant