Repository navigation
fix(agents): stop the wake sweep from forking sessions that live SSH panes still own - #12702
robertnisipeanu wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to Recovery may skip an older session after its pane is reused. The affected sequence is narrow, so the change is mergeable with owner awareness. Pre-merge checks |
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/lib/sleeping-agent-pane-ownership.ts (1)
124-128: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the new explanatory comments.
Keep one line for each non-obvious rule.
src/renderer/src/lib/sleeping-agent-pane-ownership.ts#L124-L128: state that stale worktree IDs require global tab lookup.src/renderer/src/lib/sleeping-agent-pane-ownership.ts#L183-L188: state that a detached SSH relay remains owned by its bound pane.src/renderer/src/lib/resume-sleeping-agent-session.ts#L232-L234: state that provider sessions can be owned across worktrees.As per coding guidelines, comments must be concise, non-obvious, and brief; prefer one line.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0c6eb61c-37d4-4f33-882d-ecd17fefefcf
📥 Commits
Reviewing files that changed from the base of the PR and between eea0bb6 and 989016c21f3df0b8cf35961b09dbd8b392cd45b5.
📒 Files selected for processing (3)
src/renderer/src/lib/resume-sleeping-agent-session-live-ssh-dedupe.test.tssrc/renderer/src/lib/resume-sleeping-agent-session.tssrc/renderer/src/lib/sleeping-agent-pane-ownership.ts
989016c to
6ff633b
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Status update: the SSH relay is gone (#27214/#27215), but the disconnect path still clears direct-SSH PTY bindings ( |
…panes still own Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…s unreachable A connected target's live-PTY map is authoritative: sleep kills the PTY but keeps its id. Cross-worktree session dedupe ignores finished and invalid records, the same records claim-key dedupe skips. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
6ff633b to
67271e9
Compare
|
Rebased onto main. The SSH-binding check now only claims ownership while the leaf's target is unreachable ( |
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:
f67d4346-d3ad-4293-83e9-46c72b5032c3
📥 Commits
Reviewing files that changed from the base of the PR and between 6ff633b3045acc6b531d1772bca1f77648a6c73a and 67271e9.
📒 Files selected for processing (3)
src/renderer/src/lib/resume-sleeping-agent-session-live-ssh-dedupe.test.tssrc/renderer/src/lib/resume-sleeping-agent-session.tssrc/renderer/src/lib/sleeping-agent-pane-ownership.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…ng ssh ownership In a split tab the tab-level pty can belong to another leaf. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Thanks, @robertnisipeanu! This was rebuilt on current main and merged in #29454 (your approach was used). Closing as superseded. |
ELI5
When Orca wakes up a sleeping agent, it first checks whether a terminal pane is already running that agent's conversation. In three situations that check got it wrong and said "nobody has it", so Orca opened a second copy of the same conversation in a new tab. Two agents then wrote to one transcript. This PR fixes those three checks.
What Changed
All changes are in the wake sweep (
resumeSleepingAgentSessionsForWorktree) and its pane-ownership check (recordPaneIsOwnedByPreservedPane).tab.ptyIdfor that host (clearDirectSshTargetPtyBindings), but the agent keeps running on the remote machine. The pane's saved layout still names its SSH pty. Before: the sweep saw no live terminal and launched a duplicateclaude --resume. After: a pane bound to an SSH pty whose host is not connected counts as still owning its session. The tab-level pty is only used as a fallback for a single-pane tab, so in a split one pane is never credited with another pane's terminal. When the host is connected, the live-terminal map decides, so a workspace the user put to sleep (terminal killed, id kept) still resumes normally.findPreservedTabOwner).providerSessionOwnedElsewhere). Finished and invalid records never count as owners, matching the existing same-workspace rule.Why
A duplicate
--resumecannot be undone: both processes append to the same transcript. Each fix answers "who owns this conversation?" from evidence the app already has, instead of adding new state or IPC.Linked Issue
Fixes #12699
Visual Proof
N/A. The fix decides whether a background resume happens; there is no new UI. The visible effect is the absence of a duplicate agent tab.
Testing
New tests in
src/renderer/src/lib/resume-sleeping-agent-session-live-ssh-dedupe.test.ts:Each fix's test fails without the fix.
Platforms: unit tests on macOS. Not manually reproduced against a live SSH host.
AI Disclosure
Written with Claude Code (Claude Fable 5 and Claude Opus 5.5); reviewed with independent Claude review agents.
Review
Self-reviewed plus an independent code review of the full diff and a review of each follow-up fix.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code