Repository navigation
Prevent stale terminal pixels on tab reveal - #7058
Conversation
|
Ready to review this PR? Stage has broken it down into 3 individual chapters for you:
Chapters generated by Stage for commit d03f972 on Jul 2, 2026 5:07am UTC. |
📝 WalkthroughWalkthroughThis PR separates terminal WebGL recovery for output redraws from visibility-driven tab resume recovery. Related PRs: None identified. Suggested labels: terminal, testing, e2e Suggested reviewers: None identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.ts (1)
59-77: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueVisibility scheduler intentionally uses a narrower coalescing window than output recovery — worth a one-line clarifying note.
terminalOutputRecoveryScheduledstaystruefor the entire burst (cleared inonComplete), butterminalVisibilityRecoveryScheduledis cleared as soon as the first (next-frame) reset fires (onFirstReset). This means a rapid second tab reveal can start a second full burst of delayed resets that overlaps with the first burst's still-pending timers — this is what the "allows another tab reveal after the previous reveal reaches its first reset" test confirms is intended, but the existing "Why" comment only explains why output recovery must not suppress the reveal, not that overlapping delayed-timer bursts are an accepted tradeoff. A short addition would help future maintainers who touchATLAS_RECOVERY_DELAYS_MSor add new callers avoid mistaking this for a bug.📝 Suggested comment addition
// Why: tab reveal is a separate repaint boundary from hidden-output parsing, // so an in-flight output recovery must not suppress the returned tab's repaint. + // Note: clearing the flag on the first reset (not burst completion) means rapid + // consecutive reveals can run overlapping delayed-reset bursts; this is intentional. scheduleAtlasRecoveryBurst({Source: Coding guidelines
tests/e2e/terminal-tab-switch-overlap-repro.spec.ts (1)
613-628: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winName or briefly document the visual/timing thresholds.
Values like
140,150,+ 100,180,330, and0.035encode regression heuristics. Please extract them into named constants or add one-line “why” comments so future threshold changes stay intentional.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.”
Also applies to: 713-723, 781-781
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 23a5a724-76bd-4040-8d9c-2b8cfeb15805
📒 Files selected for processing (5)
src/renderer/src/components/terminal-pane/terminal-visibility-resume.test.tssrc/renderer/src/components/terminal-pane/terminal-visibility-resume.tssrc/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.test.tssrc/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.tstests/e2e/terminal-tab-switch-overlap-repro.spec.ts
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: da1b593f-d26a-4bb9-b83e-0ef36ed62791
📒 Files selected for processing (5)
src/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.test.tssrc/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.tstests/e2e/terminal-recovery-reset-counters.tstests/e2e/terminal-recovery-timeout-stretch.tstests/e2e/terminal-tab-switch-overlap-repro.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.test.ts
| if (corrupted > 0) { | ||
| break | ||
| } | ||
| } | ||
| gl.activeTexture(gl.TEXTURE0) | ||
| if (corrupted > 0) { | ||
| break | ||
| } | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Document the early-break rationale.
The two added breaks stop corruption after the first successfully-written texture unit/canvas, relying on the (non-obvious) assumption that the glyph atlas is shared across same-config terminals, so further canvases don't need separate corruption. As per coding guidelines, **/*.{ts,tsx,js,jsx}: "add a comment explaining why the code behaves the way it does" for non-obvious constraints.
📝 Proposed comment addition
+ // Why: the glyph atlas is shared across same-config terminals, so
+ // corrupting one bound texture is sufficient; no need to touch every
+ // canvas/unit once corruption is confirmed.
if (corrupted > 0) {
break
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (corrupted > 0) { | |
| break | |
| } | |
| } | |
| gl.activeTexture(gl.TEXTURE0) | |
| if (corrupted > 0) { | |
| break | |
| } | |
| } | |
| if (corrupted > 0) { | |
| break | |
| } | |
| } | |
| gl.activeTexture(gl.TEXTURE0) | |
| // Why: the glyph atlas is shared across same-config terminals, so | |
| // corrupting one bound texture is sufficient; no need to touch every | |
| // canvas/unit once corruption is confirmed. | |
| if (corrupted > 0) { | |
| break | |
| } | |
| } |
Source: Coding guidelines
Co-authored-by: Orca <[email protected]>
Summary
This PR prevents stale WebGL terminal pixels from surviving a regular terminal tab reveal when hidden-output recovery is already in flight.
The previous fix covered hidden TUI output parsing, but the reproduced failure is visual-only at the reveal boundary: the canonical terminal buffer is clean while the returned tab can keep stale rendered pixels until another repaint source repairs it.
Design Approach
resetAndRefreshAllTerminalWebglAtlases()call.Design-review result: Brennan's PR process reviewed the design and tightened the gate around proving the visual-only failure before treating deterministic WebGL injection as regression coverage.
Implementation
terminal-webgl-atlas-recovery.tsnow has separate output and visibility recovery latches.terminal-visibility-resume.tscalls the visibility-specific recovery path for light tab resumes.Headline behavior status: implemented.
Repro Evidence
.tmp/live-overlap-captures/orca-window-bad-pane-returned.pngterm_c4f457e2-c569-4800-ad99-a2571392b706/Users/thebr/orca/workspaces/orca/auto-discord-feedback-triage-7am-3pm-pt-run-2-20260630T2200orca terminal readfor the same terminal returned only blank/status content while the screenshot showed stale Claude transcript pixels.That proves the failure is not PTY routing or xterm buffer contamination.
Consistency And Reliability
Source-of-truth behavior: terminal pixels must be a projection of that pane's xterm buffer.
Compared surfaces: regular terminal tabs, split panes sharing the global atlas reset path, heavy worktree/window resume, terminal GPU settings, floating terminal recovery, and non-terminal tabs. The PR changes only regular terminal tab reveal recovery; labels, actions, tab order, command palette behavior, terminal menus, and non-terminal surfaces are unchanged.
Reliability classes:
xterm-addon.boundary-containment,terminal-visibility.hidden-to-visible-resume, andrenderer-gpu.recovery-containment.Invariant: revealing a regular terminal tab repaints from that tab's own xterm buffer and is not coalesced away by hidden-output recovery already in progress.
Performance
Perf audit result: pass.
The change adds no hidden-byte loop, polling, foreground flush, fit, PTY resize, or provider call. Work remains a bounded atlas reset/refresh burst on tab reveal, independently coalesced for rapid switches.
Validation
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.test.ts src/renderer/src/components/terminal-pane/terminal-visibility-resume.test.tspnpm exec oxlint src/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.ts src/renderer/src/components/terminal-pane/terminal-visibility-resume.ts src/renderer/src/components/terminal-pane/terminal-webgl-atlas-recovery.test.ts src/renderer/src/components/terminal-pane/terminal-visibility-resume.test.ts tests/e2e/terminal-tab-switch-overlap-repro.spec.tsgit diff --checkpnpm exec playwright test tests/e2e/terminal-tab-switch-overlap-repro.spec.ts --config tests/playwright.config.ts --project=electron-headful -g "repairs returned tab pixels"pnpm run typecheckpnpm run lintMerge-confidence validation result: land after PR hygiene. Exact PR worktree was launched and identified; console check reported 0 errors and 2 warnings.
Manual/E2E artifact evidence:
.tmp/live-overlap-captures/orca-window-bad-pane-returned.pngplaywright-report/data/e2b51aa62c8692f868e64d8d04b75d78c0672a3d.pngScreenshots
No app UI controls or layouts change. Screenshot evidence is terminal-renderer validation:
.tmp/live-overlap-captures/orca-window-bad-pane-returned.pngplaywright-report/data/e2b51aa62c8692f868e64d8d04b75d78c0672a3d.pngAI Review Report
3f5582b81.Security Audit
No new IPC surface, permissions, network calls, filesystem access, shell execution, auth handling, telemetry, or provider contract is introduced. The E2E creates temporary local test scripts in the disposable Playwright repo only.
Gaps And Non-Goals
Post-PR Stabilization
Round 1: CodeRabbit reported three actionable E2E hardening comments and one PR-description warning. The E2E hardening comments were fixed in
3f5582b81; this body now includes the requested screenshots, AI review, security, and notes sections.Final stabilization result: refreshed CodeRabbit review reported no actionable comments, and PR check
verifypassed.Notes
The PR is intentionally scoped to the renderer/reveal boundary. It does not change terminal byte routing, hidden output parsing, backlog restore, or provider behavior.