Skip to content

fix(terminal): adopted daemon terminals take title and output from their stream - #38760

Merged
nwparker merged 1 commit into
mainfrom
fix/22809-adopted-terminal-facts
Nov 6, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/22809-adopted-terminal-facts

Conversation

@nwparker

@nwparker nwparker commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

After orca serve restarts, terminals that kept running come back. Some of them came back named "shell" instead of their real title, and a terminal picked up again by a retried create never showed new output, so it looked idle and its agent status was unknown.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

What Changed

Before: a surviving terminal could be titled "shell" (a name Orca made up) and, when a terminal.create retry adopted it after a restart, its stream was never attached, so lastOutputAt stayed empty and its real title never arrived. After: surviving terminals take their title and output from their own stream, the same way for every adoption path.

  • The daemon adapter's session listing no longer invents a "shell" title; the listing carries no title, so it reports none. The attach snapshot's last title and the live stream stay the single source.
  • A terminal.create retry that adopts a survivor now attaches its stream through the same main-process attachment that inventory adoption already uses (mainDaemonAttachments.reconcile), which de-duplicates with any attach already in flight.
  • A new runtime record treats an empty title as unknown, as updates already do, so it never reads as a manual title.

Inventory adoption already attaches survivors (#36137); this closes the create-retry path and drops the made-up title.

Why

The made-up title and the missing attach were the two remaining causes after #36137. Reusing the existing attachment path keeps one owner for "attach a surviving session", instead of a second attach path for create retries.

This takes over #22834 by @mmarabel, who also reported the issue and found the inventory-title cause. Thank you @mmarabel! The core of that PR landed through #36137; this PR covers what was left.

Supersedes #22834

Linked Issue

Fixes #22809

Visual Proof

N/A: the fix is in how the host restores terminal records after a server restart; covered by runtime tests.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

  • terminal-subscriber-driven-daemon-attach.test.ts: a survivor adopted by a terminal.create retry gets attached, streams output and shows its real title.

  • daemon-pty-adapter-session-adoption.test.ts: the listing reports no made-up title.

  • Both fail on main and pass here. pnpm tc, lint and the changed-code quality gate pass.

Risk

Level: Low

No wire change: old and new daemons send the same listing. Consumers of the listing title already fall back (cwd/worktree label) when it is empty; nothing matched on "shell". SSH-relay sessions are not touched (reconcile skips them). Back out with a plain revert.

Review

Independent Opus review: no P0-P2. Codex review: no findings.

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

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change assigns empty titles to listed PTYs and converts empty PTY record titles to null. It reconciles main-daemon attachments after remote terminal-create adoption. A new restart-adoption test verifies that the runtime adopts and attaches a surviving session without spawning a replacement, then lists its handle, title, live-output preview, and last-output time.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 5d770

The change appears ready to merge after normal checks. The existing test-coverage concern about an idle survivor’s preview remains a useful follow-up.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#22809] The PR removes the invented inventory title, treats an empty title as unknown, and reconciles attachments for create-retry adoption. The tests cover the empty listing title and title and live… Provide reviewable production code or automated test evidence that idle surviving terminals restore their pre-restart preview, title, agent identity, and status without new output.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title clearly describes the main change to adopted daemon terminals.
Description check Passed The description is mostly complete and explains the change, issue, tests, and risk. It does not identify tested platforms, and the visual proof section does not show the user-visible behavior change.
Out of Scope Changes check Passed [#22809] The inventory title change, empty-title handling, attachment reconciliation, and supporting tests address restoration of surviving terminals. The available change summary shows no unrelated c…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Out of Scope Changes check

Explanation

[#22809] The inventory title change, empty-title handling, attachment reconciliation, and supporting tests address restoration of surviving terminals. The available change summary shows no unrelated changes.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. 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 0 functions across 5 files.

Full details: Linked Issues check

Explanation

[#22809] The PR removes the invented inventory title, treats an empty title as unknown, and reconciles attachments for create-retry adoption. The tests cover the empty listing title and title and live output after retry adoption. The available evidence does not establish that inventory or retry adoption restores the pre-restart preview and title-based agent identity and status without new output. The runtime test model seeds the title itself, so it does not establish the production snapshot behavior.

Resolution

Provide reviewable production code or automated test evidence that idle surviving terminals restore their pre-restart preview, title, agent identity, and status without new output.

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

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: 2693e221-b747-487b-a4dc-14181dbcf2a1
Commits

Reviewing files that changed from the base of the PR and between fc6e960 and 5d770b7.

Files selected for processing: 2

  • src/main/daemon/providers/adapter/testing/daemon-pty-adapter-session-adoption.test.ts
  • src/main/runtime/terminal-subscriber-driven-daemon-attach.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 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.

Nitpick comments: 1

src/main/runtime/terminal-subscriber-driven-daemon-attach.test.ts: 1

440-488: Trivial · Maintainability & Code Quality · Quick win

Cover the survivor’s preview before new output.

The test can pass when an idle survivor’s prior preview is lost. Use a nonempty attach snapshot and assert the listing’s preview before emitting data. Exercise the production attach-result seeding path rather than seeding only in the mock.

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: 3d9f560c-bbed-4157-bef4-7786910d45e5
Commits

Reviewing files that changed from the base of the PR and between 6ff6b39 and fc6e960.

Files selected for processing: 5

  • src/main/daemon/providers/adapter/daemon-pty-session-inventory.ts
  • src/main/daemon/providers/adapter/testing/daemon-pty-adapter-session-adoption.test.ts
  • src/main/runtime/terminal-subscriber-driven-daemon-attach.test.ts
  • src/main/runtime/terminal/identity/pty-worktree-record.ts
  • src/main/runtime/terminal/launch/terminal-create-deduplication.ts

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

…eir stream

The daemon adapter's inventory listing reported every surviving session's
title as "shell", though the listing carries no title. That made-up value
became the fallback tab title when adoption ran before the attach seed, and a
terminal.create retry that adopted a survivor after a restart recorded it as
the terminal's observed title and returned it.

That create-retry adoption also never attached the session's stream, so the
adopted terminal's output never reached main: lastOutputAt stayed null and its
real title never landed until some later inventory refresh attached it.

- The daemon listing reports no title. The attach snapshot's lastTitle and the
  stream stay the single source, as for every other terminal.
- A create retry that adopts a survivor attaches it through the same main
  attachment inventory adoption uses.
- A new runtime record treats an empty title as unknown, as an update already
  does, so it never reads as a manual title.

Inventory adoption already attaches survivors (#36137); this closes the create
retry path and drops the made-up title. No wire change: old and new daemons
send the same listing.

Fixes #22809
@nwparker
nwparker force-pushed the fix/22809-adopted-terminal-facts branch from fc6e960 to 5d770b7 Compare November 6, 2026 05:49
@nwparker
nwparker merged commit 9f9dbcf into main Nov 6, 2026
60 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.

[Bug]: After an orca serve restart, surviving terminals come back with no title and unknown agent status

1 participant