Repository navigation
Conversation
…1791) After laptop sleep, clearDirectSshTargetPtyBindings nulls tab.ptyId/ptyIds but left lastKnown unused by pty-connection. Remounts with SSH already connected then spawned blank shells instead of reattaching. - Seed deferredSshSessionIdsByTabId from live/lastKnown session ids - Merge seeds on clear and stale-invalidate paths for the target - Cover disconnect clear, invalidate, and connected+deferred gate
…blyai#11791) After SSH reconnect, agent hooks and OSC titles lag while PTYs are already live. Blank titles dropped OMP/Codex tabs from the worktree card so the sidebar showed fewer agents than open tabs. - Fall back to tab.launchAgent for live PTYs with non-classifiable titles - Leave plain shell tabs without launchAgent hidden
📝 WalkthroughWalkthroughThe change preserves deferred SSH relay session IDs during direct SSH binding cleanup, stale-binding invalidation, and target-scoped state updates. Reconnect gating can reattach deferred sessions when the target is already connected. Title-derived agent rows now use launch metadata to create idle rows for blank-title terminal tabs, while split-pane siblings and plain-shell tabs remain without inferred rows. Regression tests cover reconnect recovery, agent-row behavior, and two-tab end-to-end recovery. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/store/slices/direct-ssh-terminal-recovery.test.ts (1)
112-128: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd tracked PTY fallback coverage.
This test covers live-tab and last-known IDs. It does not cover
ptyIdsByTabId[tab.id]?.[0].Add a tab with
ptyId: null, a tracked PTY ID, and a different last-known ID. Assert that the tracked PTY ID wins.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 58311eb5-878a-4cd3-8518-882a189837b5
📒 Files selected for processing (8)
src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.test.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/terminal-pane/ssh-pane-connect-gate.test.tssrc/renderer/src/store/slices/direct-ssh-terminal-recovery-types.tssrc/renderer/src/store/slices/direct-ssh-terminal-recovery.test.tssrc/renderer/src/store/slices/direct-ssh-terminal-recovery.tssrc/renderer/src/store/slices/direct-ssh-terminal-retry.test.tssrc/renderer/src/store/slices/terminals.ts
Greptile SummaryThis PR fixes a terminal session restore bug (#11791) where SSH terminals would spawn a blank shell after disconnect/reconnect instead of reattaching to their previous session. It seeds
Confidence Score: 5/5Safe to merge — the change is a targeted fix that adds a deferred-reattach seed during disconnect cleanup and a blank-title fallback in the sidebar, both well-guarded against multi-pane and foreign-target edge cases. The disconnect-to-reattach path is clearly correct: session ids are captured before bindings are cleared, foreign-connection ids are filtered out by target, and Zustand state updates are skipped when nothing actually changes. The launchAgent fallback in the sidebar is gated to single-leaf tabs and falls through cleanly for splits. Unit tests cover the priority ordering, foreign-session no-op, second-clear re-seed, and split-sibling attribution guard. The E2E test exercises the full two-tab reconnect flow with sidebar row verification. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/store/slices/direct-ssh-terminal-recovery.ts | Adds resolveDirectSshReconnectSessionId and seeds deferredSessionIdsByTabId before clearing bindings; logic and priority order (ptyId → ptyIdsByTabId[0] → lastKnown) are correct. |
| src/renderer/src/store/slices/terminals.ts | clearDirectSshTargetPtyBindings and invalidateStaleDirectSshTargetPtyBindings now merge deferred session ids with proper early-return guards; foreign-target filtering via mergeDeferredSshSessionIdsForTarget is correct. |
| src/renderer/src/components/sidebar/worktree-title-derived-agent-rows.ts | allowLaunchAgentFallback correctly guards the launchAgent fallback to single-leaf tabs only; isTerminalLeafId check is correctly moved to an early-exit position. |
| src/renderer/src/store/slices/direct-ssh-terminal-recovery-types.ts | Adds deferredSessionIdsByTabId field to DirectSshTerminalBindingClearResult with clear documentation; backward-compatible addition. |
| tests/e2e/ssh-docker-relay-perf.spec.ts | E2E test expanded from 1 to 2 agent tabs, adds sidebar row count assertion, and simplifies the recovery script; changes are appropriate and reduce flakiness risk. |
Sequence Diagram
sequenceDiagram
participant SSH as SSH Target
participant Store as Zustand Store
participant Recovery as clearDirectSshTerminalBindings
participant Deferred as deferredSshSessionIdsByTabId
participant Gate as resolveSshPaneConnectGate
participant Pane as Terminal Pane
SSH->>Store: disconnect event
Store->>Recovery: clearDirectSshTargetPtyBindings(targetId)
Recovery->>Recovery: resolveDirectSshReconnectSessionId(state, tab)
Recovery-->>Store: "{ patch, deferredSessionIdsByTabId }"
Store->>Store: mergeDeferredSshSessionIdsForTarget(current, seeds, targetId)
Store->>Deferred: "write deferredSshSessionIdsByTabId[tabId] = sessionId"
Note over Store: tab.ptyId is now null
SSH->>Store: reconnect event
Store->>Pane: remount terminal pane
Pane->>Gate: "resolveSshPaneConnectGate({ sshStatus: connected, deferredTabSessionId })"
Gate-->>Pane: "{ pendingSessionId, enterDeferredFlow: true }"
Pane->>SSH: reattach to existing relay session
Reviews (2): Last reviewed commit: "fix(ssh): harden reconnect recovery edge..." | Re-trigger Greptile
| const entry: AgentStatusEntry = { | ||
| paneKey, | ||
| state: 'working', | ||
| prompt: rowLabel, | ||
| updatedAt: args.now, | ||
| stateStartedAt: args.now, | ||
| stateHistory: [], | ||
| agentType, | ||
| terminalTitle: title, | ||
| lastAssistantMessage: 'Idle', | ||
| ...(orchestration ? { orchestration } : {}) | ||
| } | ||
| return { | ||
| paneKey, | ||
| entry, | ||
| tab: args.tab, | ||
| agentType, | ||
| rowSource: 'live', | ||
| state: 'idle', | ||
| startedAt: 0 | ||
| } |
There was a problem hiding this comment.
Fallback entry has
state: 'working' while the row has state: 'idle'
The synthesised AgentStatusEntry sets state: 'working' while the outer DashboardAgentRow sets state: 'idle'. This matches the existing non-fallback idle path (where entryState is always 'working' even for idle rows), but any consumer that inspects entry.state directly—rather than row.state—will see the agent as actively working during the reconnect window. If any badge or notification logic uses entry.state, it could surface a spurious "working" indicator until the real title arrives.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Avoid no-op disconnect publications, keep launch-agent fallback tab-scoped for split panes, and cover multi-tab SSH reconnect sidebar parity.
|
Thanks @siddqamar for the fix and the extended Docker reconnect test. #11791 was closed as fixed, and since then the SSH relay has been removed: SSH terminals now live on Orca's managed remote server and reattach to it on reconnect. Closing; if tabs still go missing after a reconnect on a current build, please open a new issue with details. |
Summary
Fixes #11791.
launchAgentfallback to single-pane tabs so blank split panes are not misclassified as duplicate agents.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildFocused checks completed
pnpm run typecheck:nodepnpm run typecheck:weboxlint --deny-warningsoxfmt --checkpnpm run check:max-lines-ratchetpnpm exec electron-vite build --mode e2eThe Docker-backed test body could not execute locally because this host is Windows and the Docker Desktop daemon was unavailable.
AI Review Report
Reviewed the implementation against #11791 and the automated PR feedback.
The review checked:
lastKnownIDs.launchAgentmetadata can incorrectly attribute blank split panes.The no-op publication feedback was valid and has been fixed with focused regression coverage.
idle: The derived row state remainsidlefor sidebar presentation.Cross-platform behavior was reviewed for macOS, Linux, and Windows. This change does not introduce platform-specific shortcuts, labels, paths, shell commands, or Electron execution-world changes. The production changes remain platform-neutral; only the Docker SSH E2E fixture is POSIX-gated.
Security Audit
No security follow-up is currently required.
Notes
The PR now contains three commits: