Skip to content

Reopen a closed terminal worker from its orchestration card - #37210

Merged
Jinwoo-H merged 12 commits into
mainfrom
orch-closed-worker-opens-as-chat
Nov 2, 2026
Merged

Jinwoo-H merged 12 commits into
mainfrom
orch-closed-worker-opens-as-chat

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​184 $\color{#cf222e}{\Huge{\mathbf{−}}}$​22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​162
Prod 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​183 $\color{#cf222e}{\Huge{\mathbf{−}}}$​63 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​120

Summary

Symptom. In a native chat, an orchestration card ("Started worker" / "Update from worker") links the worker's name. For a terminal worker (Claude Code or Codex in a terminal), Orca closes the terminal about two minutes after the worker reports, so clicking the name almost always ends in "Agent's pane is no longer available."

Cause. The host's sender lookup (orchestration.partyLocation) still answers with the terminal handle (or "lost terminal") after Orca closed the terminal, so desktop and phone try to focus a pane that no longer exists. The worker's conversation is saved on its resource row (resume_session), but nothing used it on this path.

Fix. A new host call, orchestration.partyOpen, answers like the lookup, except when it finds a terminal worker that Orca released and whose terminal is no longer connected. Then it resumes the worker's saved conversation in a new terminal in the worker's workspace and answers with that terminal, which desktop and phone already focus. It uses the same resume path a coordinator follow-up uses to reopen a closed worker.

  • If a terminal already holds that conversation (one this call opened, or one the user resumed), it answers with that terminal instead of opening a second one.
  • The reopened terminal is the user's: Orca does not track it as the worker's terminal or auto-close it. A later coordinator send to that worker finds it through the existing "the user already has it open" check and delivers there; follow-up placement is unchanged from main.
  • partyLocation is unchanged and stays a pure lookup. Desktop and phone call partyOpen only for a sender click. When an older host refuses the call (method_not_found / forbidden), they fall back to partyLocation, so mixed versions keep today's behaviour.

Unchanged / limits. These keep today's answer: a worker with no saved conversation, a conversation recorded on a different execution host than the workspace's (the resume path's host match rule), and workers whose terminal is still connected. SSH workspaces resume over SSH where the resume path already supports them. If the resume is refused for another reason (the workspace is asleep in a window, another pane holds the conversation, or the create fails), the click shows the existing "try again" failure instead of the pane-gone toast. Chat workers are unaffected. No new UI or copy.

Testing

  • New closed-worker-terminal.test.ts, through the real partyOpen handler and SQLite: a closed worker's click resumes its conversation in a new terminal and a second click reuses it; no saved conversation, or a conversation recorded on another host, keeps the partyLocation answer; a later follow-up is placed into the reopened terminal, not a second one; an uncertain resume retries as the same request; once the agent left the reopened terminal, a click resumes again.
  • Updated for the new call: open-agent-message-sender.test.ts, NativeChatAgentMessageCard.test.tsx, native-chat-agent-message-sender-host.test.tsx, mobile use-mobile-agent-message-navigation.test.ts (each also covers the older-host fallback to partyLocation), and the orchestration method census.
  • Affected suites with --maxWorkers=2: src/main/runtime/rpc, src/main/runtime/orchestration, src/main/runtime/runtime-rpc, src/main/runtime/session-lifecycle, src/main/native-chat, src/shared, renderer native-chat, lib and AI vault, and the whole mobile suite.
  • pnpm tc (all projects), mobile typecheck, oxlint, oxfmt, anti-slop lint, and the pr.yml check scripts.
  • Real app (dev build in the background, Claude workers, native chat coordinator). Before (main): clicking a closed terminal worker's name showed "Agent's pane is no longer available." After: the click opened a terminal with the worker's conversation resumed; a second click reused it; a coordinator follow-up landed in that terminal (delivery=follow_up) with no second terminal. Not run on a phone; the phone uses the same host call and its existing terminal handling.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 64eb91b6-3441-4f73-8dd5-b21f16889eb9
Commits

Reviewing files that changed from the base of the PR and between 091799b and d24b172.

Files selected for processing: 2
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-terminal.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-terminal.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

The change adds orchestration.partyOpen for structured-session opening. The RPC performs party lookup and can reopen an eligible closed worker terminal. Desktop and mobile session openers use the new RPC and fall back to location lookup when the host reports that opening is unsupported. Tests update their RPC expectations and cover closed-terminal recovery.

Merge Risk: Moderate · previous review d24b1

After a reopened agent exits, clicking its orchestration card can repeatedly open a shell instead of resuming the saved conversation. Fix cached-handle reuse before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description clearly explains the symptom, cause, fix, limits, compatibility behavior, and testing. However, it does not follow the required template and omits a linked issue, Visual Proof section … Rewrite the description using the repository template. Add an actual linked issue, provide the required before/after visual proof or a valid N/A justification, document risk level and rollback, complete the remaining required sections, and …
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: reopening a closed terminal worker from its orchestration card.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 8 functions across 15 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Full details: Description check

Explanation

The description clearly explains the symptom, cause, fix, limits, compatibility behavior, and testing. However, it does not follow the required template and omits a linked issue, Visual Proof section or required attachment/N/A statement, Risk section with level and rollback plan, AI Disclosure, Review, Notes, Agent skill boundary, and checklist confirmations.

Resolution

Rewrite the description using the repository template. Add an actual linked issue, provide the required before/after visual proof or a valid N/A justification, document risk level and rollback, complete the remaining required sections, and mark the applicable checklist items.

Finishing Touches
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

@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.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 34a116b4-dab0-494e-acff-c55b792fbdd2
Commits

Reviewing files that changed from the base of the PR and between 70dae97 and 325a659.

Files selected for processing: 14
  • mobile/src/session/open-mobile-structured-session.ts
  • src/main/runtime/orchestration/orchestration-party-location.test.ts
  • src/main/runtime/orchestration/orchestration-party-location.ts
  • src/main/runtime/rpc/methods/orchestration/caller-show.ts
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-chat.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-chat.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-follow-up-choice.ts
  • src/main/runtime/rpc/methods/structured-agent-session-create.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-resume-in-chat-workspace.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-resume-in-chat.ts
  • src/renderer/src/lib/open-agent-message-sender.test.ts
  • src/renderer/src/lib/open-existing-structured-session.ts
  • src/shared/rpc-contract/orchestration-params.ts
  • src/shared/structured-agent-cli-conversation-adoption.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Keep partyLocation a pure lookup; clients call partyOpen for a sender and fall
back to partyLocation on older hosts. Adopt from the closed pane's recorded
transcript, test terminal liveness by its PTY, keep follow-ups free of chat-host
installation, and report a possibly-created chat as retryable.
…y identity only

A follow-up to a worker whose conversation a chat holds reveals that chat in
the background when its tab was closed, so the follow-up is delivered there
instead of being refused. Recorded-source adoption passes only the pane identity
and conversation fields source matching reads.

@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.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d4bff55a-d5fd-42c4-b556-694b63dd1a80
Commits

Reviewing files that changed from the base of the PR and between 810f69c and e6c0add.

Files selected for processing: 6
  • src/main/native-chat/structured-agent-cli-source.ts
  • src/main/native-chat/structured-agent-session-source-admission.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-chat.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-chat.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-follow-up-choice.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-follow-up-placement.ts
Files with no reviewable changes: 2
  • src/main/native-chat/structured-agent-session-source-admission.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-chat.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

partyOpen now resumes the closed worker's saved conversation in a new terminal
through the follow-up resume path, reusing a terminal that already holds it, and
answers with the terminal location. Removes the chat conversion and everything
only it needed; follow-up placement is as on main.
@Jinwoo-H Jinwoo-H changed the title Open a closed terminal worker as a chat from its orchestration card Reopen a closed terminal worker from its orchestration card Nov 2, 2026

@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.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 443e5174-5bba-4cca-916f-9a74c9c27ab9
Commits

Reviewing files that changed from the base of the PR and between e6c0add and 091799b.

Files selected for processing: 4
  • src/main/runtime/rpc/methods/orchestration/caller-show.ts
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-terminal.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-terminal.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-follow-up-choice.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@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.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 64eb91b6-3441-4f73-8dd5-b21f16889eb9
Commits

Reviewing files that changed from the base of the PR and between 091799b and d24b172.

Files selected for processing: 2
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-terminal.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/closed-worker-terminal.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@Jinwoo-H
Jinwoo-H merged commit 5e02b47 into main Nov 2, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant