Repository navigation
fix(runtime): resume pending headless agents from host session identity - #23919
JustTalDevelops wants to merge 1 commit into
Conversation
|
| resumeProviderSession?: AgentProviderSessionMetadata | ||
| } = {} | ||
| const status = publicTab?.type === 'terminal' ? publicTab.agentStatus : null | ||
| const paneKey = this.getLeafKey(tab.parentTabId, tab.leafId) |
There was a problem hiding this comment.
Hook pane key does not match When a pending headless terminal has a saved provider session, this code looks it up with
tabId::leafId, but terminal hook rows use tabId:leafId. The lookup finds no session, so activation starts a fresh agent instead of resuming the conversation. If the saved agent type is also missing, it opens a plain shell. The new tests miss this because their hook-row mock returns a row regardless of the requested key.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughPending mobile terminal activation can now use eligible provider-session metadata to resume a TUI agent when the tab has no saved launch agent. The runtime checks the selected hook identity, session metadata, eligibility flag, and agent settings before building startup data. Terminal creation receives the resume metadata when available. Tests cover Codex session resumption with and without a saved launch agent, and a Claude tab with a Codex session identity. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to A resumed agent can bypass the workspace-trust prompt when its tab has no saved launch agent. Restrict pre-granting trust before merging. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Resuming the right conversation is useful, but the recovered identity can also cause the host to start an agent and pre-approve its workspace. The new path checks agent compatibility; it is not yet clear that every retained or remote identity has sufficient authority for that decision. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Hardening Proposals
🚥 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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 8fcdddaa-0bd1-4b0d-99d0-d1c8eb91f9ba
📒 Files selected for processing (4)
src/main/runtime/orca-runtime-create-runtime-owned-mobile-session-terminal.tssrc/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.tssrc/main/runtime/orca-runtime-test-scenario-builders.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-07.spec.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.
| // bare materialize would put a plain shell under the agent icon. | ||
| // Re-resolve the launch like the create path; providers skip startup | ||
| // commands when attaching to live sessions, so this cannot double-launch. | ||
| let agentStartup: Awaited< | ||
| ReturnType<OrcaRuntimeService['resolveMobileSessionTerminalCommand']> | ||
| > = {} | ||
| if (tab.launchAgent) { | ||
| let agentStartup: { | ||
| command?: string | ||
| env?: Record<string, string> | ||
| launchConfig?: SleepingAgentLaunchConfig | ||
| launchAgent?: TuiAgent | ||
| startupCommandDelivery?: WorktreeStartupLaunch['startupCommandDelivery'] | ||
| resumeProviderSession?: AgentProviderSessionMetadata | ||
| } = {} | ||
| const status = publicTab?.type === 'terminal' ? publicTab.agentStatus : null | ||
| const paneKey = this.getLeafKey(tab.parentTabId, tab.leafId) | ||
| const hookRows = | ||
| this.getAgentProviderSessionRowsForPaneFn?.(paneKey) ?? | ||
| this.getAgentProviderSessionSnapshotFn?.().filter((row) => row.paneKey === paneKey) ?? | ||
| [] | ||
| const hook = selectRuntimeHookAgentRowForPane(hookRows) | ||
| const agent = | ||
| tab.launchAgent ?? | ||
| (isResumableTuiAgent(hook.providerSessionAgentType) | ||
| ? hook.providerSessionAgentType | ||
| : undefined) | ||
| const providerSession = | ||
| agent && | ||
| hook.providerSessionAgentType === agent && | ||
| status?.terminalResumeEligible !== false | ||
| ? normalizeAgentProviderSession(hook.providerSession) | ||
| : null | ||
| // A hook's provider identity can restore tabs that lost launchAgent without mixing agents. | ||
| if (agent) { | ||
| try { | ||
| const workspace = await this.resolveTerminalWorkspaceLaunchScope(`id:${worktreeId}`) | ||
| agentStartup = await this.resolveMobileSessionTerminalCommand(workspace, { | ||
| agent: tab.launchAgent | ||
| }) | ||
| const settings = this.store?.getSettings() | ||
| const canResume = | ||
| settings && | ||
| providerSession && | ||
| isResumableTuiAgent(agent) && | ||
| isTuiAgentEnabled(agent, settings.disabledTuiAgents) | ||
| const resume = canResume | ||
| ? buildAgentResumeStartupPlan({ | ||
| ...resolveAgentStartupPlanInputs({ | ||
| agent, | ||
| settings, | ||
| platform: this.getAgentLaunchPlatformForWorkspace(workspace), | ||
| isRemote: Boolean(workspace.connectionId) | ||
| }), | ||
| providerSession | ||
| }) | ||
| : null | ||
| if (resume) { | ||
| await this.markWorkspaceTrustedForAgent(agent, workspace.connectionId, workspace.path) | ||
| agentStartup = { | ||
| command: resume.launchCommand, | ||
| env: resume.env, | ||
| launchConfig: resume.launchConfig, | ||
| launchAgent: agent, | ||
| startupCommandDelivery: resume.startupCommandDelivery, | ||
| resumeProviderSession: providerSession | ||
| } | ||
| } else if (tab.launchAgent) { | ||
| agentStartup = await this.resolveMobileSessionTerminalCommand(workspace, { | ||
| agent: tab.launchAgent | ||
| }) | ||
| } | ||
| } catch { | ||
| // Why: a disabled or unresolvable agent must not make the tab | ||
| // untappable; fall back to the plain-shell materialize. |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n 'markWorkspaceTrusted|ensureWorkspaceTrusted|workspaceTrusted|trustedWorkspace' src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts src/main/runtime | head -100
Repository: stablyai/orca
Length of output: 2478
🏁 Script executed:
set -eu
printf '%s\n' '--- target function ---'
sed -n '120,280p' src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts
printf '%s\n' '--- trust helper ---'
sed -n '130,215p' src/main/runtime/orca-runtime-activate-managed-worktree.ts
printf '%s\n' '--- create-agent caller ---'
sed -n '130,195p' src/main/runtime/orca-runtime-create-agent-session.ts
printf '%s\n' '--- mobile command caller ---'
sed -n '1,105p' src/main/runtime/orca-runtime-resolve-mobile-session-terminal-command.ts
printf '%s\n' '--- target symbols and tests ---'
rg -n -C 4 'selectRuntimeHookAgentRowForPane|providerSessionAgentType|terminalResumeEligible|launchAgent|markWorkspaceTrustedForAgent|getAgentProviderSessionRowsForPaneFn|getAgentProviderSessionSnapshotFn' src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts src/main/runtime/orca-runtime-tests src/main/runtime/*test.ts
printf '%s\n' '--- base target function ---'
git show a5c7dd9671e9f3675ac36c2e99f1c5cecddda853:src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts | sed -n '120,280p'
Repository: stablyai/orca
Length of output: 42206
🏁 Script executed:
printf '%s\n' '--- target function ---'
sed -n '120,280p' src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts
printf '%s\n' '--- trust helper ---'
sed -n '130,215p' src/main/runtime/orca-runtime-activate-managed-worktree.ts
printf '%s\n' '--- create-agent caller ---'
sed -n '130,195p' src/main/runtime/orca-runtime-create-agent-session.ts
printf '%s\n' '--- mobile command caller ---'
sed -n '1,105p' src/main/runtime/orca-runtime-resolve-mobile-session-terminal-command.ts
printf '%s\n' '--- target symbols and tests ---'
rg -n -C 4 'selectRuntimeHookAgentRowForPane|providerSessionAgentType|terminalResumeEligible|launchAgent|markWorkspaceTrustedForAgent|getAgentProviderSessionRowsForPaneFn|getAgentProviderSessionSnapshotFn' src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts src/main/runtime/orca-runtime-tests src/main/runtime/*test.ts
printf '%s\n' '--- base target function ---'
git show a5c7dd9671e9f3675ac36c2e99f1c5cecddda853:src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts | sed -n '120,280p'
Repository: stablyai/orca
Length of output: 41917
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 22652
🏁 Script executed:
set -eu
sed -n '120,280p' src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts
sed -n '130,215p' src/main/runtime/orca-runtime-activate-managed-worktree.ts
git show a5c7dd9671e9f3675ac36c2e99f1c5cecddda853:src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts | sed -n '120,280p'
rg -n -C 5 'selectRuntimeHookAgentRowForPane|terminalResumeEligible|providerSessionAgentType|launchAgent|markWorkspaceTrustedForAgent' src/main/runtime/orca-runtime-tests src/main/runtime
Repository: stablyai/orca
Length of output: 45663
🏁 Script executed:
set -eu
printf '%s\n' '--- mobile hook-only activation fixture ---'
sed -n '630,735p' src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-07.spec.ts
printf '%s\n' '--- hook identity contract fixtures ---'
sed -n '60,185p' src/main/runtime/orca-runtime-tests/terminal-handles-and-agent-status-part-05.spec.ts
printf '%s\n' '--- trust marking definitions and focused tests ---'
rg -n -C 5 'function mark(Local|Remote)WorktreeTrusted|const mark(Local|Remote)WorktreeTrusted|markLocalWorktreeTrusted|markRemoteWorktreeTrusted|workspace.*trust|trusted.*worktree' src/main src/shared src/main/runtime/orca-runtime-tests
Repository: stablyai/orca
Length of output: 42214
🏁 Script executed:
set -eu
rg -n -C 8 'markLocalWorktreeTrusted|markRemoteWorktreeTrusted|markWorkspaceTrustedForAgent|launch-trust|trust.*agent|agent.*trust' src/main src/shared --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- launch trust tests ---'
sed -n '1,180p' src/main/runtime/agent-terminal-launch-trust-host.test.ts
printf '%s\n' '--- hook-only mobile fixture ---'
sed -n '640,730p' src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-07.spec.ts
Repository: stablyai/orca
Length of output: 42423
🏁 Script executed:
set -eu
sed -n '1,80p' src/main/runtime/runtime-worktree-agent-startup.ts
sed -n '170,245p' src/main/runtime/runtime-worktree-agent-startup.ts
sed -n '1,125p' src/main/agent-trust-presets.ts
sed -n '1,70p' src/main/agent-trust-write-deadline.ts
rg -n -C 8 'trust|preflight|markWorkspaceTrustedForAgent|resumeProviderSession|buildAgentResumeStartupPlan' src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-07.spec.ts src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-07.spec.ts src/main/runtime/runtime-worktree-agent-startup.ts src/main/startup/codex-session-resume-launch.ts
Repository: stablyai/orca
Length of output: 41989
Do not pre-grant workspace trust for hook-only recovery.
When tab.launchAgent is absent, the hook row supplies agent. A valid resume plan then calls markWorkspaceTrustedForAgent before materialization. That writer pre-creates the provider’s trust artifact and bypasses the user’s workspace-trust prompt. The hook row establishes agent identity and session metadata, but it does not establish that the user accepted workspace trust.
Keep hook-based resume, but pre-mark trust only for tabs with the existing explicit launchAgent authorization.
Suggested fix
if (resume) {
- await this.markWorkspaceTrustedForAgent(agent, workspace.connectionId, workspace.path)
+ if (tab.launchAgent) {
+ await this.markWorkspaceTrustedForAgent(
+ agent,
+ workspace.connectionId,
+ workspace.path
+ )
+ }
agentStartup = {
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // bare materialize would put a plain shell under the agent icon. | |
| // Re-resolve the launch like the create path; providers skip startup | |
| // commands when attaching to live sessions, so this cannot double-launch. | |
| let agentStartup: Awaited< | |
| ReturnType<OrcaRuntimeService['resolveMobileSessionTerminalCommand']> | |
| > = {} | |
| if (tab.launchAgent) { | |
| let agentStartup: { | |
| command?: string | |
| env?: Record<string, string> | |
| launchConfig?: SleepingAgentLaunchConfig | |
| launchAgent?: TuiAgent | |
| startupCommandDelivery?: WorktreeStartupLaunch['startupCommandDelivery'] | |
| resumeProviderSession?: AgentProviderSessionMetadata | |
| } = {} | |
| const status = publicTab?.type === 'terminal' ? publicTab.agentStatus : null | |
| const paneKey = this.getLeafKey(tab.parentTabId, tab.leafId) | |
| const hookRows = | |
| this.getAgentProviderSessionRowsForPaneFn?.(paneKey) ?? | |
| this.getAgentProviderSessionSnapshotFn?.().filter((row) => row.paneKey === paneKey) ?? | |
| [] | |
| const hook = selectRuntimeHookAgentRowForPane(hookRows) | |
| const agent = | |
| tab.launchAgent ?? | |
| (isResumableTuiAgent(hook.providerSessionAgentType) | |
| ? hook.providerSessionAgentType | |
| : undefined) | |
| const providerSession = | |
| agent && | |
| hook.providerSessionAgentType === agent && | |
| status?.terminalResumeEligible !== false | |
| ? normalizeAgentProviderSession(hook.providerSession) | |
| : null | |
| // A hook's provider identity can restore tabs that lost launchAgent without mixing agents. | |
| if (agent) { | |
| try { | |
| const workspace = await this.resolveTerminalWorkspaceLaunchScope(`id:${worktreeId}`) | |
| agentStartup = await this.resolveMobileSessionTerminalCommand(workspace, { | |
| agent: tab.launchAgent | |
| }) | |
| const settings = this.store?.getSettings() | |
| const canResume = | |
| settings && | |
| providerSession && | |
| isResumableTuiAgent(agent) && | |
| isTuiAgentEnabled(agent, settings.disabledTuiAgents) | |
| const resume = canResume | |
| ? buildAgentResumeStartupPlan({ | |
| ...resolveAgentStartupPlanInputs({ | |
| agent, | |
| settings, | |
| platform: this.getAgentLaunchPlatformForWorkspace(workspace), | |
| isRemote: Boolean(workspace.connectionId) | |
| }), | |
| providerSession | |
| }) | |
| : null | |
| if (resume) { | |
| await this.markWorkspaceTrustedForAgent(agent, workspace.connectionId, workspace.path) | |
| agentStartup = { | |
| command: resume.launchCommand, | |
| env: resume.env, | |
| launchConfig: resume.launchConfig, | |
| launchAgent: agent, | |
| startupCommandDelivery: resume.startupCommandDelivery, | |
| resumeProviderSession: providerSession | |
| } | |
| } else if (tab.launchAgent) { | |
| agentStartup = await this.resolveMobileSessionTerminalCommand(workspace, { | |
| agent: tab.launchAgent | |
| }) | |
| } | |
| } catch { | |
| // Why: a disabled or unresolvable agent must not make the tab | |
| // untappable; fall back to the plain-shell materialize. | |
| // bare materialize would put a plain shell under the agent icon. | |
| // Re-resolve the launch like the create path; providers skip startup | |
| // commands when attaching to live sessions, so this cannot double-launch. | |
| let agentStartup: { | |
| command?: string | |
| env?: Record<string, string> | |
| launchConfig?: SleepingAgentLaunchConfig | |
| launchAgent?: TuiAgent | |
| startupCommandDelivery?: WorktreeStartupLaunch['startupCommandDelivery'] | |
| resumeProviderSession?: AgentProviderSessionMetadata | |
| } = {} | |
| const status = publicTab?.type === 'terminal' ? publicTab.agentStatus : null | |
| const paneKey = this.getLeafKey(tab.parentTabId, tab.leafId) | |
| const hookRows = | |
| this.getAgentProviderSessionRowsForPaneFn?.(paneKey) ?? | |
| this.getAgentProviderSessionSnapshotFn?.().filter((row) => row.paneKey === paneKey) ?? | |
| [] | |
| const hook = selectRuntimeHookAgentRowForPane(hookRows) | |
| const agent = | |
| tab.launchAgent ?? | |
| (isResumableTuiAgent(hook.providerSessionAgentType) | |
| ? hook.providerSessionAgentType | |
| : undefined) | |
| const providerSession = | |
| agent && | |
| hook.providerSessionAgentType === agent && | |
| status?.terminalResumeEligible !== false | |
| ? normalizeAgentProviderSession(hook.providerSession) | |
| : null | |
| // A hook's provider identity can restore tabs that lost launchAgent without mixing agents. | |
| if (agent) { | |
| try { | |
| const workspace = await this.resolveTerminalWorkspaceLaunchScope(`id:${worktreeId}`) | |
| const settings = this.store?.getSettings() | |
| const canResume = | |
| settings && | |
| providerSession && | |
| isResumableTuiAgent(agent) && | |
| isTuiAgentEnabled(agent, settings.disabledTuiAgents) | |
| const resume = canResume | |
| ? buildAgentResumeStartupPlan({ | |
| ...resolveAgentStartupPlanInputs({ | |
| agent, | |
| settings, | |
| platform: this.getAgentLaunchPlatformForWorkspace(workspace), | |
| isRemote: Boolean(workspace.connectionId) | |
| }), | |
| providerSession | |
| }) | |
| : null | |
| if (resume) { | |
| if (tab.launchAgent) { | |
| await this.markWorkspaceTrustedForAgent( | |
| agent, | |
| workspace.connectionId, | |
| workspace.path | |
| ) | |
| } | |
| agentStartup = { | |
| command: resume.launchCommand, | |
| env: resume.env, | |
| launchConfig: resume.launchConfig, | |
| launchAgent: agent, | |
| startupCommandDelivery: resume.startupCommandDelivery, | |
| resumeProviderSession: providerSession | |
| } | |
| } else if (tab.launchAgent) { | |
| agentStartup = await this.resolveMobileSessionTerminalCommand(workspace, { | |
| agent: tab.launchAgent | |
| }) | |
| } | |
| } catch { | |
| // Why: a disabled or unresolvable agent must not make the tab | |
| // untappable; fall back to the plain-shell materialize. |
There was a problem hiding this comment.
Caution
activateMobileSessionTab looks up the pane's hook row under the wrong pane key, so the lookup returns nothing in production and the resume behavior this PR adds never runs.
Reviewed changes
- Hook-identity resume on pending activation —
activateMobileSessionTabreads the pane's agent-hook row, recovers the agent type when the persisted tab lackslaunchAgent, and rebuilds a provider resume command viabuildAgentResumeStartupPlanoverresolveAgentStartupPlanInputs. - Resume metadata threaded to spawn —
resumeProviderSessionis added tocreateRuntimeOwnedMobileSessionTerminal's options and forwarded throughcreateTerminaltoptyController.spawn. - Gating — resume requires the hook's
providerSessionAgentTypeto equal the resolved agent,terminalResumeEligible !== false, and the agent to be enabled. - Tests — the pending-tab scenario builder gains hook-row wiring; new specs cover saved vs. missing
launchAgentand the Claude-tab-with-Codex-id guard.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| resumeProviderSession?: AgentProviderSessionMetadata | ||
| } = {} | ||
| const status = publicTab?.type === 'terminal' ? publicTab.agentStatus : null | ||
| const paneKey = this.getLeafKey(tab.parentTabId, tab.leafId) |
There was a problem hiding this comment.
getLeafKey builds the runtime's internal tabId::leafId key, but agent-hook rows are indexed by the single-colon makePaneKey value (tabId:leafId). Both this per-pane lookup and the snapshot fallback (row.paneKey === paneKey) therefore miss on every host, so hook is always empty, providerSession is always null, and the resume path never runs — the exact bug this PR sets out to fix.
Technical details
# Pending-terminal resume reads hooks under the wrong pane key
## Affected sites
- `src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts:182` — `this.getLeafKey(tab.parentTabId, tab.leafId)` returns `${tabId}::${leafId}` (see `orca-runtime-resolve-waiter.ts:25`).
- `src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts:183-198` — passes that key to `getAgentProviderSessionRowsForPaneFn` and filters the snapshot by `row.paneKey === paneKey`.
- Production wiring: `src/main/startup/main-process-runtime-service.ts:113` and `src/main/orcad/orcad-entry.ts:227` -> `AgentHookServer.getStatusSnapshotForPane` (`src/main/agent-hooks/server/server-listeners.ts:212`), which looks the key up verbatim in `lastStatusByPaneKey`.
- Hooks/PTY env use `makePaneKey` = `${tabId}:${leafId}` (`src/shared/stable-pane-id.ts:22-30`; `ORCA_PANE_KEY`).
- Canonical derivation: `getMobileTerminalPaneKey` (`src/main/runtime/orca-runtime-prune-mobile-session-tab-group-layout.ts:201-207`) and `projectRuntimeMobileSessionTabs` (`src/main/runtime/runtime-mobile-session-projection.ts:133-143`).
- Test masking: `src/main/runtime/orca-runtime-test-scenario-builders.spec.ts:346` ignores the passed key; the row uses the single-colon form at `:321`.
## Required outcome
- The pane key used for the hook lookup must equal the key hooks are stored under, on desktop, `orca serve`/orcad, and SSH relays.
- Tabs with a saved `launchAgent` resume their provider session; tabs that lost `launchAgent` recover the agent type and resume.
## Suggested approach
- `getMobileTerminalPaneKey` is defined on `OrcaRuntimeWithPruneMobileSessionTabGroupLayout`, a subclass of this mixin, so it is not in scope here. Derive the key inline as that helper does, importing `isTerminalLeafId`/`makePaneKey` from `../../shared/stable-pane-id`:
`isTerminalLeafId(tab.leafId) ? makePaneKey(tab.parentTabId, tab.leafId) : `${tab.parentTabId}:${legacyPaneId ?? tab.leafId}``
| statusRow | ||
| ? { | ||
| getAgentStatusSnapshot: () => [statusRow], | ||
| getAgentProviderSessionRowsForPane: () => [statusRow] |
There was a problem hiding this comment.
The fixture ignores the key it is handed, and the row it returns uses the single-colon makePaneKey form. That is why the suite stays green even though the activation path passes a :: key; filtering the mock on the argument (or asserting through the snapshot fallback) would give this path real coverage.

ELI5
If a headless server has to recreate an agent tab after its terminal disappears, it can start a new empty conversation even though the server still knows the old conversation ID. Reopen that conversation when the ID is available.
What Changed
launchAgent. Keep the current launch behavior when no matching resume identity exists.Why
The host already owns the provider identity. Using its pane-scoped record preserves the intended conversation without guessing from titles, transcript directories, or a paired client's state. Checking the hook's agent type prevents a session ID from crossing agents.
Linked Issue
Related to #21743. This addresses pending tab activation when the host still has a pane-scoped provider ID; it does not add headless capture for IDs absent from the hook store.
Visual Proof
N/A for screenshots: this is a headless server activation path with no renderer. The focused tests compare the before and after terminal launch requests: a fresh agent command becomes a provider-specific resume command with the same tab and pane identity.
Testing
On macOS: three focused Vitest cases pass; node TypeScript check, changed-code quality gate, formatting and
git diff --checkpass. I inspected a Linuxorca servehost where a reopened Codex tab was empty and confirmed its original Codex transcript remained on disk. Windows and SSH execution were considered through the existing shared resume-plan builder but were not run against this patch.AI Disclosure
OpenAI Codex assisted with investigation, implementation, and tests.
Review
Agent skill upstream boundary
Notes
The observed Linux host has active terminals inside the Orca service cgroup, so I did not restart or upgrade it to test this patch. The change adds no RPC fields or platform-specific command construction.
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildremain for CI; focused local checks pass.