Repository navigation
fix(remote): a paired client reopening a slept agent tab resumes its conversation - #29272
Conversation
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
…its session When a paired client opened a pane whose PTY was gone, the host started a bare shell (or a fresh agent) instead of resuming the agent session it had recorded for that pane. Resume from the pane-owned record the way the host window's cold restore does.
eaf7e08 to
d8a8c5b
Compare
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-09.spec.ts: 1
216-249: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert the provider-session metadata in the Codex mobile resume test.
The mobile tests stop at a mocked
spawn. They can pass ifresumeProviderSessionis dropped while the generated command andspawnIntentremain unchanged. The Codex preflight requires this metadata to prepare the originating Codex home. Assert it on the Codex-specific case.Suggested fix
expect(firstSpawnArgs(spawn).command).toContain('codex-session-1') - expect(spawn.mock.calls[0]?.[0]).toMatchObject({ launchAgent: 'codex' }) + expect(spawn.mock.calls[0]?.[0]).toMatchObject({ + launchAgent: 'codex', + resumeProviderSession: { key: 'session_id', id: 'codex-session-1' } + })
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2808392f-311b-4346-9e73-af5af38ae2e2
📒 Files selected for processing: 5
src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-09.spec.tssrc/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.tssrc/main/runtime/session-lifecycle/projection/perform-mobile-session-pty-records-refresh.tssrc/main/runtime/terminal/launch/mobile-terminal-owned-create.tssrc/main/runtime/terminal/launch/mobile-terminal-startup.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
ELI5
Say an agent such as Claude Code ran in a tab on a Remote Orca Server, and that tab later lost its terminal. Maybe Orca put the idle agent to sleep, the workspace was slept, or the host restarted. When a paired client (a desktop app connected to the host) opened that tab again, the host started a plain shell, or a brand-new agent. The conversation looked lost. The host window resumes it with
claude --resume <id>. After this change, the paired client gets the same resume.What Changed
Before: a paired client opens the tab. The pane shows the old scrollback, including Claude's "Resume this session with: claude --resume …" exit text, then a bare prompt. If the tab knew its agent, the host started a fresh agent instead. That new session's status then replaced the saved resume record, so the old conversation could no longer be resumed from the tab on any device.
After: the pane comes back running
<agent> --resume <recorded id>. It uses the args, env and command the session was launched with.Mechanism: when a paired client opens a pane that has no live terminal, the host runtime (
activateMobileSessionTab) builds the pane's startup command. Before, it built either nothing or a fresh launch (buildAgentStartupPlanwith an empty prompt). It never read the resume record the host keeps for that pane insleepingAgentSessionsByPaneKey. Now it reads the record first and builds the resume launch with the sharedbuildAgentResumeStartupPlan, the same function the host window's cold restore uses. It also passesresumeProviderSessionthrough to the spawn.It only resumes records the pane itself owns:
liveandquitrecords, and finished (done) sleep or hibernation records. The host window's worktree activation relaunches a sleep record of a still-running agent in a new tab, so resuming that record in the pane as well could run one conversation twice. Those records keep today's behavior. A record captured on another execution host (a different SSH target) is not resumed, because its session id names a transcript on that machine. The pane gets a plain shell and the record is kept, as the window does.Duplicate-writer and correctness guards (from review). The pane gets a plain shell with its record kept, instead of a resume, when:
live,unverifiable, or not yet hydrated after a restart all block);All comparisons use the full provider-session identity (
agentProviderSessionsEqual), including the transcript path for Pi. The spawn carriesspawnIntent(automatic-restorefor a reconnect,user-resumefor a tap) so restore admission and paused automatic work apply, and it is labeled with the resumed agent so Codex home routing works.Follow-up: #29303 (originless legacy
donerecords).Why
The record and the resume command already exist. Only the paired-client path skipped them. Reusing the window's resume builder keeps both paths producing the same command.
Alternatives considered:
Linked Issue
Fixes #27147
Fixes #27777
Related, not fixed here: #26296. Its pane is recreated without a resume in the same way, and with this change that recreated pane would resume when the host holds a pane-owned record for it. But the root problem there is a different one: the old daemon's live session is killed during a daemon-version handover, and the record in that report was filed under another worktree.
Visual Proof
N/A. A host-side launch-command change, covered by runtime tests that assert the spawned command. Nothing in the UI changes apart from the agent coming back.
Testing
src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-09.spec.ts: a paired client opening a slept pane (host window attached) spawnsclaude … --resume provider-session-1with the recorded args into the same session id; aliveanchor resumes; a record from another execution host does not. The first two failed before the fix: the spawn had no command (bare shell).pnpm test src/main/runtime/orca-runtime.test.ts(1372 passed),pnpm tc:node,pnpm run check:code-quality:changed.Review
Agent skill upstream boundary
Notes
orca serve: gets the resume too, but nothing there spends the record (fix(runtime): resume terminal agents in headless serve after a daemon loss or sleep #27527 covers the headless anchors).Checklist
N/Awith reason for visuals