Skip to content

fix(runtime): surface visible TUI output in terminal read and show - #8854

Closed
rodboev wants to merge 1 commit into
stablyai:mainfrom
rodboev:pr/terminal-visible-snapshot-fallback
Closed

rodboev wants to merge 1 commit into
stablyai:mainfrom
rodboev:pr/terminal-visible-snapshot-fallback

Conversation

@rodboev

@rodboev rodboev commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

terminal read and terminal show now surface the visible rows of active full-screen TUIs for provider-backed, headless, SSH, and remote-runtime terminals when no renderer serializer is mounted. First-call alternate-screen reads and previews now stay aligned even when retained transcript history is empty.

The runtime still reuses its existing provider, headless, and renderer snapshot authority, while cursor pagination, normal-screen output, renderer-only blank-tail fallback, and terminal list stay on their prior paths.

Closes #8746.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused validation:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts - passed, Test Files 1 passed (1), Tests 709 passed (709)
  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts -t "surfaces headless alternate-screen output through terminal read without renderer serializer" - passed
  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts -t "surfaces headless alternate-screen output through terminal show preview" - passed
  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts -t "keeps retained output when visible snapshots are unavailable" - passed
  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts -t "keeps first provider-backed alternate-screen read and show aligned when the retained transcript is empty" - passed
  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts -t "does not touch provider snapshots for first cursor reads on provider-preferred PTYs" - passed
  • pnpm run typecheck:node - passed
  • pnpm exec oxlint src/main/runtime/orca-runtime.ts src/main/runtime/orca-runtime.test.ts - passed
  • pnpm exec oxfmt --check src/main/runtime/orca-runtime.ts src/main/runtime/orca-runtime.test.ts - passed

AI Review Report

  • Adversarial review first caught stale first-call provider fallback behavior, proof drift, and missing alternate-screen coverage, then a second pass caught the empty-retained first-call read/show split and provider-I/O on first cursor reads. The branch fixed those findings before this final clean rerun.
  • Final review traced cursor exclusion, first-provider snapshot handling, read/show routing, alternate-screen detection, and provider-mode cleanup across the runtime and RPC terminal consumers.
  • Review explicitly checked macOS, Linux, and Windows terminal behavior for local, SSH, headless, and remote-runtime snapshots, plus cursor pagination, output bounds, renderer absence, and provider neutrality.
  • No browser, mobile UI, shortcut, path, shell-command, dependency, or Electron code changes were introduced.

Security Audit

The change only selects and parses terminal snapshot data already available inside the runtime. Review verified bounded read and preview output, fail-open handling for unavailable snapshots, unchanged IPC exposure, and the absence of new command execution, filesystem access, authentication, secret handling, dependency, or renderer-trust risk.

Notes

terminal list keeps its retained preview and does not serialize each listed terminal. Cursor-based reads remain transcript pagination. Full lint, full typecheck, full test, and build remain CI-gated. No UI or Electron code changes.

ELI5

terminal read / show often missed what a full-screen TUI was displaying. They now surface the visible alternate-screen rows for remote and headless terminals.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Refactors terminal visible-snapshot fallback handling to support alternate-screen PTYs through prepared snapshots and headless emulation. Updates fallback decisions while excluding cursor transcript reads. Live and leaf terminal summaries now derive previews from visible snapshot content when applicable. Tests expand coverage for provider snapshots, headless output, retained output, cursor reads, serialization failures, and line limits.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes align with #8746 by routing read/show through visible-screen fallback while preserving cursor and short blank-tail exclusions.
Out of Scope Changes check ✅ Passed The PR appears limited to runtime terminal logic and tests, with no unrelated feature or public API changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely summarizes the main runtime change to surface visible TUI output in terminal read/show.
Description check ✅ Passed The description covers all required sections and is mostly complete, though the AI Review Report is light on the template's cross-platform detail.

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.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/runtime/orca-runtime.test.ts (1)

12777-12780: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that the renderer serializer is never invoked.

not.toHaveBeenCalledWith permits calls with different arguments, allowing this regression coverage to pass despite an unintended snapshot request.

Proposed fix
-    expect(nonblankSerializeBuffer).not.toHaveBeenCalledWith('pty-1', {
-      scrollbackRows: 0,
-      altScreenForcesZeroRows: false
-    })
+    expect(nonblankSerializeBuffer).not.toHaveBeenCalled()

-    expect(shortBlankSerializeBuffer).not.toHaveBeenCalledWith('pty-1', {
-      scrollbackRows: 0,
-      altScreenForcesZeroRows: false
-    })
+    expect(shortBlankSerializeBuffer).not.toHaveBeenCalled()

Also applies to: 12905-12908

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)

7397-7411: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Large inline snapshot type is duplicated verbatim across two new functions.

The full snapshot shape (data, cols, rows, cwd, lastTitle, seq, source, oscLinks, alternateScreen, scrollbackAnsi, pendingEscapeTailAnsi) is repeated inline as both prepareVisibleSnapshotFallback's return type and readVisibleSnapshotLines's parameter type. Extracting a shared type alias would remove the drift risk if this shape changes later (e.g. a new field added to serializeTerminalBuffer's return type would need to be manually mirrored in both places).

♻️ Suggested extraction
+type VisibleTerminalBufferSnapshot = {
+  data: string
+  cols: number
+  rows: number
+  cwd?: string | null
+  lastTitle?: string
+  seq?: number
+  source?: 'headless' | 'renderer'
+  oscLinks?: TerminalOscLinkRange[]
+  alternateScreen?: boolean
+  scrollbackAnsi?: string
+  pendingEscapeTailAnsi?: string
+}
+
 private async prepareVisibleSnapshotFallback(ptyId: string): Promise<{
-    snapshot: { ... } | null
+    snapshot: VisibleTerminalBufferSnapshot | null
   isAlternateScreen: boolean
 }> { ... }

 private async readVisibleSnapshotLines(
   ptyId: string,
-    snapshot: { ... } | null = null
+    snapshot: VisibleTerminalBufferSnapshot | null = null
 ): Promise<string[]> { ... }

Also applies to: 7429-7442


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cd6169a8-c847-4dce-b1e1-a494feaf318a

📥 Commits

Reviewing files that changed from the base of the PR and between c12ade5 and 581ce02.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

Comment thread src/main/runtime/orca-runtime.ts Resolved
@AmethystLiang
AmethystLiang requested a review from Jinwoo-H July 15, 2026 16:48
@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:38
@nwparker nwparker added the bug Something isn't working label Jul 27, 2026
@nwparker

nwparker commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded — the linked issue(s) for this PR were fixed by another change that has already been merged.

Superseding merge: #9078

Thank you for the contribution! If anything remains unaddressed, please open a new issue or PR against current main.

@nwparker nwparker closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

4 participants