Repository navigation
fix(ssh): restore saved port forwards on managed hosts and show their Ports tab - #27361
Conversation
📝 Walkthrough
Priority: ⬇️ Low Severity of issue fixed: Low Merge Risk: 🟡 Moderate · up to Disconnecting a managed host can leave a restored local port listener open. Coordinate restoration with teardown before merging. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
3d778876-68f8-4a7f-b025-520a9841801e
📒 Files selected for processing (18)
src/main/ipc/ssh-connection-state-callbacks.tssrc/main/ipc/ssh-host-server-connect.tssrc/main/ipc/ssh-managed-host-port-forward-lifecycle.test.tssrc/main/ipc/ssh-managed-port-forward-restore.tssrc/main/ipc/ssh-port-forward-persistence.tssrc/main/ipc/ssh-port-forward-restore.test.tssrc/main/ipc/ssh-session-teardown.tssrc/main/ssh/ssh-port-forward-provider.tssrc/main/ssh/ssh-port-forward.test.tssrc/main/ssh/ssh-port-forward.tssrc/main/ssh/ssh2-port-forward-provider.tssrc/renderer/src/components/right-sidebar/activity-bar-buttons.tsxsrc/renderer/src/components/right-sidebar/ports-panel-host.test.tssrc/renderer/src/components/right-sidebar/ports-panel-host.tssrc/renderer/src/components/right-sidebar/right-sidebar-activity-visibility.test.tssrc/renderer/src/components/right-sidebar/right-sidebar-activity-visibility.tssrc/renderer/src/components/right-sidebar/use-right-sidebar-activity-items.tstests/e2e/ssh-orcad-workspace-tools.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| const previous = restoring.get(targetId) ?? Promise.resolve() | ||
| const next = previous | ||
| .then(() => restorePortForwards(targetId, getCurrentMainWindow)) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect connection retention and the disconnect, restore, and listener-removal paths.
rg -n -C 5 --type ts 'getConnection\s*\(|async disconnect\s*\(|disconnect\s*\(targetId|removeAllForwards\s*\(|restoreManagedHostPortForwards\s*\(' src/main/ssh src/main/ipcRepository: stablyai/orca
Length of output: 41817
🏁 Script executed:
set -e
nl -ba src/main/ipc/ssh-managed-port-forward-restore.ts
nl -ba src/main/ipc/ssh-port-forward-persistence.ts
nl -ba src/main/ipc/ssh-session-teardown.ts | sed -n '1,125p'
nl -ba src/main/ssh/ssh-connection-manager.ts | sed -n '1,125p'
rg -n -C 8 --type ts 'setSshHostServerStatus|disconnectRegisteredSshTarget|teardownSshTargetTransport|restoreManagedHostPortForwards' src/main/ipc src/main/sshRepository: stablyai/orca
Length of output: 42228
Cancel or fence queued restoration during managed-host teardown.
disconnectRegisteredSshTarget clears managed status, but it does not cancel an already queued restoration. teardownSshTargetTransport starts connectionManager.disconnect(targetId) concurrently with removeAllForwards(targetId). The connection remains registered until conn.disconnect() completes, so restorePortForwards can pass its identity check and add a listener after removeAllForwards has taken its snapshot.
Coordinate restoration with teardown, or recheck the lifecycle state immediately before each addForward call.
ELI5
If you forward a port from an SSH host that runs a managed Orca server, the forward now comes back after the host reconnects. And the Ports tab now appears for workspaces on those hosts.
What Changed
Saved port forwards after a reconnect
Ports tab
Why
Linked Issue
N/A (maintainer). Found by the managed-host e2e lane (#27323).
Visual Proof
N/A: the Ports tab already exists; it now also appears for managed-server workspaces. The forward behavior is covered by the e2e spec below.
Testing
New unit tests: stale forward detection, restore that closes stale forwards and skips live ones, queued managed restores, the managed connect and transport-recovery triggers, and listener cleanup on a managed disconnect. Also tab visibility by owner kind.
tests/e2e/ssh-orcad-workspace-tools.spec.ts: the "SSH forward reaches it across a reconnect" case is no longerfixmeand runs in theorcad-journeys-dockerlane.pnpm tc, pnpm lint, check:code-quality:changed, and focused main ssh/ipc suites pass.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
P0/P1 self review: none found.
Agent skill upstream boundary
Notes
SSH-only change. Nothing new crosses the wire; this is local listener management on the client.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)