Skip to content

Prevent hidden terminal TUI overlap - #7054

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/overlapping-tui-output
Jul 1, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/overlapping-tui-output

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Hidden terminal TUI redraws now request the existing bounded global WebGL atlas recovery after their hidden xterm write parses. Hidden bytes still stay on the hidden/background write path; this does not add hidden foreground painting, fitting, PTY resizing, or replay clearing behavior.

Boundary: this targets renderer pixel recovery for hidden regular terminal tabs. It does not change PTY byte transport, disable WebGL, or alter Claude Code itself.

Summary

  • Added neutral terminal-output onParsed callbacks that work for foreground and background writes.
  • Kept background callbacks notification-only, including for 16 KiB scheduler slicing.
  • Added independent hidden DEC 2026 / TUI-redraw risk state so hidden Claude-like redraws can schedule atlas recovery after parse.
  • Added regression coverage for hidden synchronized frames, split markers, skipped hidden output, ordinary hidden rich text/metadata, and the foreground boundary.

Design and review

Design review completed clean after tightening hidden-output data flow, background callback invariants, split DEC marker parsing, skipped-byte state reset, and validation coverage.

Completeness verification returned verified. Headline behavior status: implemented.

Perf audit returned clean. The recovery uses the existing coalesced burst and adds no polling, subprocesses, resize path, or unbounded timer fanout.

Code review loop completed in 3 rounds. Two medium findings were fixed before the final round returned clean from both reviewers:

  • hidden DEC detection had short-circuited hidden rewrite state advancement
  • foreground plain DEC 2026 frames were accidentally widened into global atlas recovery

Broad app consistency

Source of truth: xterm's parsed buffer is canonical, and renderer pixels should refresh from that buffer after risky output/replay/paste/visibility transitions.

Compared surfaces: desktop terminal output path, regular terminal tabs, split panes, shared pane-manager WebGL atlas registry, image paste recovery, light/heavy visibility resume, wake recovery, SSH/remote bytes after they reach xterm, and terminal actions/settings surfaces.

Mismatch fixed: hidden background TUI output can now request the same post-parse shared WebGL atlas recovery that foreground risky output and visibility recovery already use, without turning hidden bytes into foreground output.

Manual validation

Verdict from merge-confidence validation: land.

Electron identity:

  • devRepoRoot=/Users/thebr/orca/workspaces/orca/dottyback
  • devBranch=brennanb2025/overlapping-tui-output
  • devLabel=dottyback @ brennanb2025/overlapping-tui-output

Product scenario:

  • Launched exact worktree via CDP port 9335; renderer port 5175 because 5173 was occupied.
  • demo-project was unavailable in the fresh profile, so a disposable non-Orca repo was registered and removed afterward.
  • Used two regular terminal tabs in one tab group, no split panes, one visible at a time.
  • Ran concurrent deterministic Node TUI streams emitting DEC 2026 synchronized-output frames and clear/redraw controls.
  • While Terminal 1 was hidden, Terminal 2 displayed only ORCA_STREAM_B_ONLY.
  • After switching back without scroll/resize, Terminal 1 displayed only ORCA_STREAM_A_ONLY.
  • Serialized buffers had no cross-tab markers: Terminal 1 hasA=true, hasB=false; Terminal 2 hasA=false, hasB=true.
  • Renderer delivery debug settled with pendingPtyCount=0, pendingChars=0.

Screenshot evidence kept out of git:

  • .tmp/orca-hidden-tui-terminal2-active-clean.png
  • .tmp/orca-hidden-tui-terminal1-after-switch-clean.png
  • .tmp/orca-hidden-tui-terminal1-final-context.png

Console/log inspection:

  • Renderer console had 0 errors.
  • Warnings were dev/tooling noise plus one xterm task-queue deadline warning during intentional redraw stress.
  • Electron logs showed normal dev startup warnings only.

Cleanup:

  • Closed Playwright.
  • Terminated only the Electron process group started for validation.
  • Confirmed CDP/render ports cleared.
  • Removed temp profile, scratch Vite config, and disposable repo.

Accepted validation gap: live Claude Code sessions were not run; validation used Claude-like deterministic TUI streams through the real Orca terminal renderer.

Checks

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.test.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts src/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.test.ts passed, 323 tests.
  • pnpm exec oxlint src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.ts src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.test.ts src/renderer/src/components/terminal-pane/pty-connection.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts passed.
  • pnpm run typecheck passed.
  • pnpm run lint passed with existing warnings only during manual validation.
  • git diff --check passed.

Post-PR stabilization

Not run per Brennan's explicit instruction to skip post-PR validation and only do manual testing. This PR has not been merged.

Made with Orca 🐋


Open in Stage

@ghost

ghost commented Jul 1, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 5 individual chapters for you:

Title
1 Generalize terminal output parsed callbacks
2 Define synchronized output constants and state
3 Implement hidden TUI risk detection logic
4 Trigger atlas recovery for hidden TUI
5 Verify hidden TUI recovery behavior
Open in Stage

Chapters generated by Stage for commit 84da95d on Jul 1, 2026 11:05pm UTC.

@brennanb2025
brennanb2025 merged commit e0de46f into main Jul 1, 2026
5 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/overlapping-tui-output branch July 1, 2026 23:10
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

This PR unifies the terminal output scheduler's parsed-callback handling by renaming onForegroundParsed to onParsed and propagating it consistently through queueing, draining, and flushing for both foreground and background writes. It also introduces PTY-scoped "hidden renderer risk" state tracking with new synchronized-output marker constants and analysis helpers to decide when WebGL atlas recovery should occur after parsing hidden output, wiring resets into various restore/skip code paths. Corresponding tests were added or updated for both areas.

Sequence Diagram(s)

Diagrams included above within the hidden review stack artifact illustrate the onParsed callback propagation and hidden output atlas recovery decision flow.

Related PRs: None specified.

Suggested labels: area:terminal, area:testing

Suggested reviewers: None specified.

🐰 A callback hopped through queues so neat,
Hidden markers scanned, recovery complete,
Foreground and background, now unified as one,
Atlas restored before the parsing's done.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has useful details but is missing required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Rewrite the PR description to match the template, adding Screenshots, the testing checklist, AI Review Report, Security Audit, and Notes sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and matches the main change: preventing hidden terminal TUI overlap.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

🧹 Nitpick comments (1)
src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.ts (1)

486-542: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the multi-fire semantics of onParsed for split chunks.

When a single queued write exceeds the take limit, the split remainder retains chunk.onParsed via the { ...chunk, ... } spread (Line 512-515), so the same caller-supplied onParsed gets pushed into parsedCallbacks again on the next takeQueuedChunk call. A single logical write can therefore invoke the caller's onParsed more than once (once per underlying terminal.write split), which is non-obvious from reading the code and differs from "notified once when my data is parsed" intuition. This is exercised by the new "keeps parsed callbacks on large background chunks split by the scheduler" test, so it's intentional — but a short comment here would save future readers from re-deriving this.

📝 Suggested comment
     data += chunk.data.slice(0, remaining)
+    // Why: keep onParsed on the retained remainder so large writes that get
+    // split across multiple terminal.write calls still fire once per split
+    // segment (callers must tolerate multiple invocations for one write()).
     if (chunk.onParsed) {
       parsedCallbacks.push(chunk.onParsed)
     }

As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 16cc3043-b1d4-4fe5-b6d2-ac182c79a444

📥 Commits

Reviewing files that changed from the base of the PR and between 126aae7 and 84da95d.

📒 Files selected for processing (4)
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.test.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.ts

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