Skip to content

fix(terminal): coordinate reveal atlas recovery - #11864

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/explain-orca-crash-restart
Aug 4, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/explain-orca-crash-restart

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • coalesce settled terminal reveal repaint requests across pane managers
  • reattach revealed WebGL renderers before one registry-wide atlas reset and repaint
  • cover sibling-manager recovery and concurrent reveal coalescing with regression tests

Root cause

xterm terminals with matching render configuration share a WebGL glyph atlas. After restart or background-worktree reveal, a delayed pane-local reset could clear that shared atlas after a sibling terminal had rebuilt, leaving stale glyph coordinates on screen until typing forced another render.

Reliability contract

  • Invariant — terminal-renderer.shared-atlas-convergence: revealing or restarting one pane must not leave any sibling renderer displaying stale or corrupt glyphs.
  • Failure source: STA-3122 and the reproduced delayed pane-local reset after restart/background reveal.
  • Oracle: deterministic multi-manager tests require every sibling to reset and repaint, concurrent reveals to coalesce to one registry-wide recovery, and a live Electron reference row to remain intact after tab and whole-workspace reveal while a sibling PTY streams.
  • Gate: xterm-addon.boundary-containment (experimental, partial). The broader terminal-render.pixel-refresh-repair visual-golden gate remains registered with protection none.
  • Provider/platform coverage: renderer-local behavior leaves local, daemon, SSH/remote, WSL, and mobile/relay PTY ownership and transport unchanged. Live Electron coverage is macOS; Linux and Windows GPU paths were not exercised in this PR review.
  • Performance budget: one settled registry-wide O(managers + panes) recovery is coalesced across concurrent reveal requests. No polling, subprocesses, output-path scans, or new per-write work were added; the count test pins one reset for concurrent requests.
  • Diagnostics: webgl-atlas-reset breadcrumbs include live-manager count and recovery reason; existing pane rendering diagnostics distinguish missed repaint from atlas corruption.
  • Residual gaps: no live Linux/Windows GPU run, and the broader pixel-refresh-repair gate still lacks a manifest command/red-green history.

Validation

  • latest origin/main merged into the branch
  • same-model senior review subagent: clean, no meaningful correctness, lifecycle, or performance findings
  • 86 focused terminal reliability tests across the registered gate and adjacent registry/lifecycle suites
  • changed-file oxlint
  • web TypeScript check
  • reliability-gate manifest validation and git diff --check
  • macOS Electron: exact PR worktree attached; reference glyph row remained intact after tab + whole-workspace hide/reveal while a sibling 135×59 PTY streamed; both PTYs stayed live and retained authoritative buffer markers

Electron evidence

Reference pane after workspace and tab reveal, with the sibling PTY still streaming:

Reference terminal after reveal

Formerly hidden live sibling after reveal, with the changing counter and mixed glyph set intact:

Live sibling terminal after reveal

Linear: https://linear.app/stably/issue/STA-3122/investigate-and-resolve-codex-workspace-sync-issues-after-updates

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Reveal repaint scheduling now batches pending pane getters and processes them after a settled frame. It reattaches live WebGL renderers and performs one registry-wide atlas reset when panes exist. The registry accepts an optional diagnostic reason. Tests now register fake pane managers and verify global recovery, request coalescing, teardown handling, failure isolation, and fallback behavior. Related terminal resume comments describe shared-atlas recovery and atlas-preserving refocus presentation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change and validation but omits the required Security Audit and Notes sections and the mandated explicit cross-platform review confirmation. Add the Security Audit and Notes sections, complete the Testing checklist, and explicitly confirm macOS, Linux, and Windows compatibility checks in the AI Review Report.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: coordinated terminal reveal atlas recovery.
✨ 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.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes a WebGL glyph atlas corruption race where a delayed pane-local reset after terminal restart or background-worktree reveal could clear the shared atlas after a sibling terminal had already rebuilt, leaving stale glyph coordinates until the next user keystroke. The fix coalesces all pending reveal repaint requests into a single registry-wide resetAndRefreshAllTerminalWebglAtlases call, ensuring every sibling renderer is reattached and reset atomically before the atlas is cleared.

  • pane-reveal-repaint.ts: replaces per-pane resetWebglTextureAtlas calls with a coalescing scheduler (pendingRevealRepaints + revealRepaintScheduled) that funnels all concurrent reveal requests into one resetAndRefreshAllTerminalWebglAtlases('settled-reveal') call after layout settles, guaranteeing no delayed pane-local clear can invalidate a sibling's rebuilt model.
  • pane-manager-registry.ts: adds an optional reason string to resetAndRefreshAllTerminalWebglAtlases and includes it in the webgl-atlas-reset breadcrumb for improved diagnostics.
  • Test files: new regression tests cover sibling-manager recovery, concurrent reveal coalescing, and the existing settled-frame guarantees; afterEach now unregisters fake managers from the live registry to prevent cross-test pollution via the module-level manager set.

Confidence Score: 5/5

Safe to merge — the coalescing logic is correct, the settled-frame invariant is preserved, and the registry-wide reset is properly guarded against empty pane sets.

The fix addresses a well-defined race (delayed pane-local atlas clear invalidating a sibling's rebuilt model) with a straightforward coalescing scheduler. The reattach-before-reset ordering is maintained, the livePanes.size > 0 guard prevents spurious registry-wide resets, and the concurrent-coalescing contract is proven by the new tests.

Files Needing Attention: No files require special attention — all changed files are consistent with each other and the new test coverage matches the behavioral contracts introduced by the coalescing scheduler.

Important Files Changed

Filename Overview
src/renderer/src/lib/pane-manager/pane-reveal-repaint.ts Core fix: replaces per-pane atlas reset with a coalescing scheduler that batches all concurrent reveal requests into one registry-wide recovery; logic is correct and matches the test contract
src/renderer/src/lib/pane-manager/pane-reveal-repaint.test.ts Adds sibling-manager and coalescing tests; afterEach properly unregisters fake managers; module-level singleton state (pendingRevealRepaints, revealRepaintScheduled) is not reset between tests but was flagged in a prior review thread
src/renderer/src/lib/pane-manager/pane-manager-registry.ts Minor additive change: optional reason parameter forwarded to the webgl-atlas-reset breadcrumb; no behavioral changes to existing callers
src/renderer/src/components/terminal-pane/terminal-visibility-resume.ts Comment-only updates to reflect that scheduleRevealRepaint now runs shared-atlas recovery rather than per-pane clears; no logic changes
src/renderer/src/components/terminal-pane/terminal-visibility-resume.test.ts Comment-only update matching the revised description of scheduleRevealRepaint; test logic unchanged

Sequence Diagram

sequenceDiagram
    participant A as Manager A (reveal)
    participant B as Manager B (sibling)
    participant R as pane-reveal-repaint
    participant Reg as pane-manager-registry

    A->>R: schedulePaneRevealRepaint(getPanesA)
    Note over R: pendingRevealRepaints.add(getPanesA)<br/>revealRepaintScheduled = true<br/>scheduleSettledFrame(flush)

    B->>R: schedulePaneRevealRepaint(getPanesB)
    Note over R: pendingRevealRepaints.add(getPanesB)<br/>revealRepaintScheduled already true

    Note over R: RAF frame 1 (layout may still be in flight)
    Note over R: RAF frame 2 - flushPaneRevealRepaints()
    R->>R: "revealRepaintScheduled = false"
    R->>R: collect livePanes from all pending getters
    R->>R: reattachWebglIfNeeded(paneA)
    R->>R: reattachWebglIfNeeded(paneB)
    R->>Reg: resetAndRefreshAllTerminalWebglAtlases
    Reg->>A: manager.resetWebglTextureAtlases()
    Reg->>B: manager.resetWebglTextureAtlases()
    Reg->>A: manager.refreshAllPanes()
    Reg->>B: manager.refreshAllPanes()
Loading

Reviews (5): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

Comment on lines +7 to +8
const pendingRevealRepaints = new Set<PaneGetter>()
let revealRepaintScheduled = false

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Module-level state not reset between tests

pendingRevealRepaints and revealRepaintScheduled are module singletons that persist across all it() blocks in the same test file. If any test in pane-reveal-repaint.test.ts fails before executing both flushFrame() calls, revealRepaintScheduled stays true while no RAF is actually pending (the stub is torn down by vi.unstubAllGlobals() in afterEach). Every subsequent test's schedulePaneRevealRepaint call will silently skip scheduling the flush, causing those tests to fail with assertions that never fire — cascading failures that look unrelated to the original failure.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final-head note: origin/main advanced once during QA, so 6e7ceafd07 was merged and pushed as final head ef0d28cbfb. The same gpt-5.6-sol xhigh reviewer session returned CLEAN again and proved the five terminal files are byte-identical to the Electron-validated head; the later upstream-only merge changes mobile/worktree-catalog code, so the attached desktop screenshots remain applicable.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final-head validation for 0dc02c6e28 (including latest origin/main c8a22ad0a6):

  • Same-model/xhigh senior review returned CLEAN with no edits. The final integration pass covered async snapshot capability + hidden parking against shared-atlas recovery; 95 focused renderer/lifecycle tests and all 573 adjacent snapshot-capability tests passed.
  • Electron QA attached to the exact cachalot @ brennanb2025/explain-orca-crash-restart dev instance. Two real 135×59 PTYs were exercised through a whole-workspace hide/reveal followed by a terminal-tab reveal while the hidden sibling continuously streamed output. Both PTYs remained live, both authoritative buffers retained their markers/glyph sets, and the sibling buffer advanced during the run.
  • Current-head GitHub Actions, Windows packaging, Node 24/26 shards, verify, and Greptile are green; GitHub reports the PR merge state as clean.
  • Mobile emulator QA is not applicable: this is a desktop renderer-only change.

Reference terminal after final-head workspace + tab reveal:

Final-head reference terminal after reveal

Live sibling after final-head reveal:

Final-head live sibling after reveal

…orca-crash-restart

# Conflicts:
#	src/renderer/src/lib/pane-manager/pane-manager-registry.ts
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final-head validation after merging latest origin/main (653deeb209):

  • Electron real-UI tab hide/reveal: hidden manager remained mounted but was excluded from atlas recovery; on reveal it became recovery-eligible, retained first/last/ready markers, and accepted post-reveal input.
  • Streaming sibling retained all 2,000 markers and remained interactive.
  • No renderer/page errors.
  • Docker-backed Linux SSH parking/reveal passed, including scrollback older than relay replay capacity.
  • Docker-backed Linux SSH stale-grid wake passed: injected 45×36, recovered to 64×43 in 79 ms, with the remote PTY alive and remote Git/worktree state clean.
  • 175 focused terminal/WebGL/wake tests, web typecheck, changed-file oxlint, Electron build, and relay build passed.

Reference terminal after reveal:

Final-head reference terminal after reveal

Live sibling after the same recovery cycle:

Final-head live sibling terminal

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