Skip to content

fix(remote): a paired client reopening a slept agent tab resumes its conversation - #29272

Merged
nwparker merged 9 commits into
mainfrom
nwparker/paired-open-resumes-slept-agent
Oct 16, 2026
Merged

nwparker merged 9 commits into
mainfrom
nwparker/paired-open-resumes-slept-agent

Conversation

@nwparker

@nwparker nwparker commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​234 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​231
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​223 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​210

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 (buildAgentStartupPlan with an empty prompt). It never read the resume record the host keeps for that pane in sleepingAgentSessionsByPaneKey. Now it reads the record first and builds the resume launch with the shared buildAgentResumeStartupPlan, the same function the host window's cold restore uses. It also passes resumeProviderSession through to the spawn.

It only resumes records the pane itself owns: live and quit records, 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:

  • another pane's record names the same conversation;
  • the host hook store places the conversation in another pane that is not proven exited (live, unverifiable, or not yet hydrated after a restart all block);
  • the hook store shows this pane has since moved on to a different conversation.

All comparisons use the full provider-session identity (agentProviderSessionsEqual), including the transcript path for Pi. The spawn carries spawnIntent (automatic-restore for a reconnect, user-resume for 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 done records).

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:

  • Have the host window do the wake. This would reuse the window's mobile wake path. But headless hosts have no window, and the tab open must return a ready pane in the same call. Existing tests pin that contract.
  • Carry the record on the wire to the client. Rejected: the host owns execution and the records. This change touches the host only and adds no new wire fields, so older clients get the fix as soon as the host updates.

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

  • Automated tests added/updated
  • New cases in src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-09.spec.ts: a paired client opening a slept pane (host window attached) spawns claude … --resume provider-session-1 with the recorded args into the same session id; a live anchor 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: the record is read from the worktree's own execution-host partition. Quoting follows the launch runtime of the workspace (local, WSL or SSH). Cross-host records are refused.
  • Folder workspaces: resolved through the same workspace launch scope as before.
  • Wire compatibility: no wire change.
  • Headless 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

  • This PR is small and focused
  • I explained what changed and why
  • N/A with reason for visuals
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Typecheck, changed-code lint and targeted tests pass; CI covers the rest

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Mobile pane activation can resume an eligible recorded agent session. The flow checks pane ownership, other panes that may hold the session, the hook store, and workspace connection details. It passes resume metadata to terminal creation and sets spawn intent according to whether activation is automatic or user-initiated. Tests cover successful resumes and conditions that prevent them.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 4dd77

Saved-session resumption appears to work. Add an assertion for Codex session metadata so a future change cannot silently break its resume setup.

Pre-merge checks: Passed 3 · Failed 1 · Inconclusive 1

Failed Failed checks: 1 warning · 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check Inconclusive The change satisfies the coding requirement in #27777: it selects pane-owned live, quit, and completed records, uses buildAgentResumeStartupPlan with recorded launch settings, passes the provide… Provide evidence that the existing runtime satisfies #27147's still-running terminal reattachment and ended-session indication requirements, or identify and implement the missing behavior.
Passed Passed checks: 3 passed
Check name Status Explanation
Out of Scope Changes check Passed The changed runtime code, spawn metadata, resume safeguards, and automated tests directly support #27147 and #27777. The changes preserve wire compatibility and do not introduce unrelated product beha…
Title check Passed The title clearly and concisely describes the main change: resuming an agent conversation when a paired client reopens a slept tab.
Description check Passed The description is complete and directly matches the implementation. It includes the user impact, mechanism, rationale, linked issues, visual proof, testing, compatibility considerations, and checklis…
Full details: Linked Issues check

Explanation

The change satisfies the coding requirement in #27777: it selects pane-owned live, quit, and completed records, uses buildAgentResumeStartupPlan with recorded launch settings, passes the provider session and spawn intent, and adds tests for resume, duplicate-writer guards, stale identities, Pi transcript identity, and cross-host records. It also addresses the no-live-terminal subset of #27147. However, #27147 also requires reattachment to still-running terminals and a clear ended-session state. This diff does not change or test those behaviors, and the available evidence does not establish whether existing code already satisfies them.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker force-pushed the nwparker/paired-open-resumes-slept-agent branch from eaf7e08 to d8a8c5b Compare October 15, 2026 23:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-09.spec.ts: 1

216-249: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the provider-session metadata in the Codex mobile resume test.

The mobile tests stop at a mocked spawn. They can pass if resumeProviderSession is dropped while the generated command and spawnIntent remain 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
📥 Commits

Reviewing files that changed from the base of the PR and between de2a371 and 4dd777e.

📒 Files selected for processing: 5
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-09.spec.ts
  • src/main/runtime/session-lifecycle/projection/apply-mobile-session-tab-navigation.ts
  • src/main/runtime/session-lifecycle/projection/perform-mobile-session-pty-records-refresh.ts
  • src/main/runtime/terminal/launch/mobile-terminal-owned-create.ts
  • src/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant