Skip to content

feat(ssh): add SSH remote workspace sync - #1690

Closed
MuathJ wants to merge 4 commits into
stablyai:mainfrom
MuathJ:feat/ssh-sync-remote-workspace
Closed

MuathJ wants to merge 4 commits into
stablyai:mainfrom
MuathJ:feat/ssh-sync-remote-workspace

Conversation

@MuathJ

@MuathJ MuathJ commented May 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Today, SSH work in Orca is tied too closely to the current local app session. If a user connects to a remote machine, works in Claude/Codex, closes Orca, and reconnects later, those coding sessions can be lost or require manual discovery and resume. Connecting to the same SSH target from another device is even more disconnected: Orca starts a fresh local workspace with none of the tabs, terminals, browser tabs, agents, or workspace context from the first device.

This PR closes that gap by making remote SSH workspaces persistent and real-time synced. Reconnecting to the same SSH target, or opening it from another Orca client, restores the workspace and coding agents instead of starting over.

Summary

This adds synced SSH workspaces: a remote target can persist Orca workspace state on the SSH host and hydrate it from another Orca client, making remote development feel continuous across machines.

  • Adds a dedicated Remote Workspace Sync mode that is separate from normal SSH. Users can keep standard SSH behavior, or explicitly enable workspace sync for targets where they want cross-device continuity.
  • Syncs remote workspace state in real time across devices: opening tabs, switching tabs, typing into terminals, moving between workspaces, and layout/session changes propagate as the workspace changes.
  • Preserves the full remote workspace shape, including tabs, panes, selected workspace state, terminal bindings, restored SSH PTYs, scoped workspace/session data, agent resume metadata, and cache timer state.
  • Keeps synced remote state scoped to the target so one device does not clobber local-only state outside the synced remote workspace.
  • Adds sync status and connected-device presence in the SSH status bar so users can see whether a target is syncing and which other clients are connected.
  • Adds workspace-sync relay persistence with a 0 grace period for synced targets, which disables relay auto-shutdown so the remote workspace can persist even after a client closes.
  • Restores remote terminal sessions after app restart or reconnect using persisted SSH PTY IDs, relay replay, cold-restore data, and terminal bindings.
  • Keeps terminal dimensions safe across multiple devices by letting only the active local client drive shared SSH PTY size, preventing another device from silently resizing an active TUI.
  • Preserves agent workflow context across synced remote sessions, including agent statuses and resume commands for Claude/Codex sessions.
  • Makes SSH relay deployment production-ready in packaged apps by bundling relay assets for macOS, Linux, and Windows and resolving them from Electron resources.
  • Improves startup and reconnect behavior so restored SSH workspaces wait for relay providers, avoid duplicate hydration/replay passes, and remain compatible with older relays.
  • Tested manually across three devices spanning macOS and Linux with multiple clients connected to the same synced remote workspace.

Screenshots

  • Sync remote workspace toggle and grace period settings added to SSH target card.
image
  • SSH connections status now shows sync status and connected-device presence.
1

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Additional validation run during review/fix pass:

  • pnpm vitest run --config config/vitest.config.ts src/main/window/createMainWindow.test.ts
  • pnpm vitest run --config config/vitest.config.ts src/main/ssh/ssh-relay-deploy.test.ts
  • pnpm vitest run --config config/vitest.config.ts src/main/ssh/ssh-channel-multiplexer.test.ts
  • pnpm vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • pnpm vitest run --config config/vitest.config.ts src/cli/orchestration.subprocess.test.ts src/relay/git-handler-staging.test.ts src/relay/git-handler.test.ts
  • pnpm vitest run --config config/vitest.config.ts src/main/attribution/terminal-attribution.test.ts src/main/daemon/node-pty-fd-leak.test.ts
  • pnpm vitest run --config config/vitest.config.ts --maxWorkers=1

Notes:

  • The default parallel pnpm test run hit timing-sensitive failures in subprocess/git/node-pty tests on this machine. Those files passed when rerun directly, and the full suite passed with --maxWorkers=1 (417 files, 5076 tests, 9 skipped).
  • pnpm lint passed with existing React hook warnings in GitHub project components.
  • pnpm build passed. It printed a non-fatal /usr/local/bin/orca-dev symlink permission warning.

AI Review Report

AI review covered the three SSH remote workspace sync commits:

  • 4288ccc8 feat: add SSH remote workspace sync
  • 1c5a3711 fix: preserve synced SSH workspaces and restore remote terminals
  • 0a24e6dc fix: preserve synced SSH terminals and package relay assets

Main risks checked:

  • remote workspace hydration should not duplicate reconnect/replay work
  • synced target state should not overwrite local-only workspace/session state outside the target scope
  • restored SSH PTYs should survive app restart/reconnect and preserve relay replay/cold-restore behavior
  • remote PTY dimensions should not be driven by an unfocused/background device
  • older relays that do not expose workspace.presence should not break SSH connect
  • packaged macOS/Linux/Windows builds should include and locate relay bundles
  • normal SSH multiplexer shutdown should not log scary error-like stack traces

Findings and fixes applied:

  • Review flagged that tab/sidebar activation could miss local resize ownership because pointer input fired before the new pane became active. Fixed by recording trusted local window input first, then only allowing the pane to resize once it becomes foreground.
  • Logs showed Relay package for darwin-arm64 not found at null; fixed by copying out/relay into Electron extraResources and resolving relay assets from process.resourcesPath.
  • Logs showed noisy pty:spawn provider errors during restored SSH startup; fixed by letting main wait once for relay provider registration instead of renderer-side retry spam.
  • Logs showed normal multiplexer shutdown with an error-like stack trace; adjusted logging so only connection-loss disposal keeps the warning/trace.
  • Merge with latest main conflicted in agent-hooks/server.ts and createMainWindow.ts; resolved by taking main's shared listener pipeline and preserving the guarded webContents cleanup behavior.

Cross-platform review:

  • File paths use Node/Electron path utilities (path.join, process.resourcesPath) rather than hard-coded app bundle assumptions.
  • Relay packaging was added for macOS, Linux, and Windows extraResources.
  • SSH remote workspace code avoids local-only assumptions and explicitly accounts for stale/old relay behavior.
  • No keyboard shortcut behavior was added in this PR. Existing shortcut platform policies remain in place.
  • Shell/command execution paths were reviewed for remote-vs-local boundaries; host-local env injection remains guarded away from SSH PTY spawns.

Security Audit

Reviewed areas:

  • IPC boundaries for remote workspace get/set/presence APIs
  • relay JSON-RPC requests for workspace session and device presence
  • filesystem/git/PTY provider registration timing over SSH
  • relay asset lookup and packaging paths
  • remote workspace namespace and target scoping
  • SSH terminal resize/input ownership
  • agent hook relay/shared listener merge from latest main

Security notes:

  • Remote workspace presence normalizes client IDs, names, and timestamps before exposing them to the renderer.
  • Device presence is best-effort and does not escalate stale relay errors into SSH connection failures.
  • Relay package lookup only reads from explicit override/dev/resource locations and reports searched paths for diagnostics.
  • Remote PTY resize ownership is gated by focused local intent, reducing cross-device interference.
  • Existing shell escaping and remote $HOME validation in relay deploy remain in place.
  • No new secrets or credentials are introduced.

@Jinwoo-H
Jinwoo-H self-requested a review May 14, 2026 00:40
@Jinwoo-H

Copy link
Copy Markdown
Contributor

Thanks for putting this together. The direction was valuable and helped clarify the shape of SSH remote workspace sync.

I’m going to close this PR because the branch has gone stale and the surrounding SSH PTY/session code changed substantially while it was open. Rather than merge or rebase this directly, I rewrote the feature in a fresh PR that incorporated the core ideas here while fitting the current architecture and the newer SSH persistence work: #1876.

The rewrite covers the main product boundary from this PR: opt-in remote workspace sync, relay-side workspace snapshots, remote workspace IPC, target-scoped session projection, relay asset packaging, provider dispatch, hydration guards, and explicit disconnect behavior. I intentionally did not take the renderer terminal restore / auto-resume parts wholesale because that area had become fragile and was stabilized separately.

There are still a few ideas from this PR that may be worth follow-up issues, especially device presence polish, explicit user-driven agent resume affordances, and resize ownership semantics. But those should be handled as smaller changes on top of the current implementation rather than by reviving this branch.

Thanks again for the thoughtful work here.

@MuathJ

MuathJ commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for putting this together. The direction was valuable and helped clarify the shape of SSH remote workspace sync.
...

@Jinwoo-H, thank you for all the work on your rewrite PR #1876.

I've opened a follow-up issue #2323 tracking what didn't carry across: the three you flagged (device presence, agent-resume affordance, resize ownership) plus cold reattach, agent-resume binding storage, shared relay process across devices, conflict auto-recovery, re-hydrate on structural changes, and browser/editor/tab-group sync.

I want to flag honestly that the original motivation of this PR - making remote development feel continuous across machines - isn't yet delivered by #1876 from a user perspective. Testing across two devices:

  • Opening from another device doesn't sync or retrieve the agents or terminal sessions that were running on Device A (even though the SSH status segment shows "Synced").
  • Agent sessions aren't actually shared - each device launches its own relay process on the host, so the "claude" tab that appears on Device B opens a fresh empty shell rather than continuing the Claude session still running on
    Device A.
  • Even on the same device, closing Orca with Claude/Codex running and reopening later doesn't reliably reattach to the running session - the renderer can race the SSH provider and silently spawn a fresh shell instead. And if a session dies, restarts, or expires, nothing helps the user resume.

These were the exact pain points that motivated this PR and were all addressed by the implementation here.
Happy to pick up any of the follow-ups as smaller PRs on top of the rewrite. C1 (shared relay process) is probably the highest-impact for the original use case.

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.

2 participants