Skip to content

fix(terminal): seed list preview from daemon snapshots after restart (STA-4326) - #15679

Open
brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/sta-4326-list-freshness-fix
Open

brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/sta-4326-list-freshness-fix

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​225 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​225
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​95

ELI5

After Orca restarts, orca terminal list said a still-running agent pane had never produced output, while orca terminal read of the same pane showed the live TUI. List was looking at a blank in-memory notepad this process never wrote to. It now copies a small screen snapshot from the daemon that kept the pane alive, once, when listing rediscovers that pane. That listing snapshot is a short preview only — it does not steal the deeper scrollback terminal read and legacy worker reveal still fetch.

What Changed

  • listTerminals seeds a listing-only preview from a 24-row provider snapshot for never-attached local daemon PTYs. It does not write the shared restore tail.
  • lastOutputAt is not invented from that snapshot. Snapshot bytes are historical screen state, not a recency event.
  • If the daemon snapshot cannot be consulted, list adds optional activityObservation: "unverifiable" and leaves lastOutputAt null. That is not idle and not exited.
  • Seed is once per PTY, capped at the 200-row listing limit, 24 rows, 750ms timeout. Attached PTYs that already ingested live bytes are not round-tripped.
  • Recovered legacy workers skip the listing seed so their own 120-row provider read still runs.

Why

onPtyData was the only writer of lastOutputAt / preview. A pane whose PTY survived restart is discovered only through controller inventory, so this main never attached and never ingested a byte. terminal read already fell back to the provider snapshot; terminal list did not. Callers treat a null lastOutputAt as idle/dead and conclude a live worker is finished.

A first version of this seed wrote the shared restore tail. That spent the one-shot restore budget at 24 rows, so the legacy provider-reveal never issued its own 120-row fetch and the revealed worker showed a truncated scrollback. Listing preview and restore tail are different products with different depths; they stay separate.

Linked Issue

Fixes #14523
Linear: STA-4326

Visual Proof

N/A — CLI listing contract in the main process. No layout, chrome, or renderer styling change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Commands:

pnpm vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts -t "fences provider resume and reveals one exact live legacy worker without stealing focus"
pnpm vitest run --config config/vitest.config.ts src/main/runtime/terminal-list-inventory-activity-seed.test.ts
pnpm typecheck
node config/scripts/check-changed-code-quality.mjs -- 4e058d4a52ea4653a5cf86fac271c8010334361e

Legacy-worker reveal (serializeProviderBuffer at 120 rows), unmodified expectation:

  • Pre-fix: FAIL. toHaveBeenCalledWith('pty-legacy', { scrollbackRows: 120 }) received { scrollbackRows: 24 }, number of calls: 1.
  • Post-fix: PASS.
  • Neutered (listing seed wrote the restore tail again from shared inventory): FAIL, same 24-vs-120 assertion.

Listing seed suite (5 tests):

  • Pre-fix (STA-4326): 3 failed / 1 passed. Inventory-discovered PTY listed preview: ""; activityObservation absent.
  • Post-fix: 5 passed, including a new assertion that a later read still fetches at 120 rows.
  • Neutered (list seed call removed, tests kept): 4 failed / 1 passed (attached live-bytes row still passes).

Covered: (a) never-attached PTY reports the provider screen through list; (b) attached PTY with live bytes is unchanged and does not call serializeProviderBuffer; (c) missing snapshot is activityObservation: unverifiable with lastOutputAt still null; (d) four unattached rows seed once, the attached row is skipped, and a second list does not round-trip again; (e) listing seed does not consume the restore-tail budget.

pnpm typecheck passed. Changed-code quality gate passed since 4e058d4a52ea.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

lastOutputAt after this change: epoch ms of the last byte this main ingested via onPtyData. Null means this main has not ingested live output — not idle, not exited, and never a synthesized snapshot timestamp. A seeded listing preview is retained screen. activityObservation: "unverifiable" means the provider snapshot could not be asked; inventory still proved the PTY live.

SSH-scoped PTYs are not seeded here (they have their own lease/reattach path). Folder workspaces use the same inventory record. New optional JSON field only; old clients ignore it. No new stream opcode.

Author: @BrennanKB5

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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)

…(STA-4326)

`orca terminal list` reported lastOutputAt:null and preview:"" for local
daemon PTYs this main never attached to, because inventory recorded the
session at construction defaults and only onPtyData wrote those fields.

Seed the listing once from the same provider snapshot `terminal read`
already consults. Do not fabricate recency; if the snapshot cannot be
consulted, list activityObservation:unverifiable instead of pretending
the pane was idle.
@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@brennanb2025, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 66bd448f-e00e-4b5f-bdf6-18e38dfe7d69

📥 Commits

Reviewing files that changed from the base of the PR and between 012e9f4 and 6d7ef11.

📒 Files selected for processing (3)
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/terminal-list-inventory-activity-seed.test.ts
  • src/shared/runtime-types.ts

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.

Listing seed wrote the shared restore tail at 24 rows, spending the one-shot
seed and blocking the legacy provider-reveal's own 120-row fetch.

Store listing preview in a listing-only field, seed from listTerminals rather
than shared inventory, and skip recovered legacy workers so they keep their
own serialize.

This branch has not been deployed

No deployments
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]: terminal list preview is the raw output tail, not the rendered screen

1 participant