Repository navigation
fix(terminal): coordinate reveal atlas recovery - #11864
Conversation
📝 WalkthroughWalkthroughReveal 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)
✅ Passed checks (4 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 |
Greptile SummaryThis 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
Confidence Score: 5/5Safe 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.
|
| 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()
Reviews (5): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile
| const pendingRevealRepaints = new Set<PaneGetter>() | ||
| let revealRepaintScheduled = false |
There was a problem hiding this comment.
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.
…orca-crash-restart
…orca-crash-restart
|
Final-head note: |
…orca-crash-restart
|
Final-head validation for
Reference terminal after final-head workspace + tab reveal: Live sibling after final-head reveal: |
…orca-crash-restart
…orca-crash-restart # Conflicts: # src/renderer/src/lib/pane-manager/pane-manager-registry.ts
…orca-crash-restart
|
Final-head validation after merging latest
Reference terminal after reveal: Live sibling after the same recovery cycle: |




Summary
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
terminal-renderer.shared-atlas-convergence: revealing or restarting one pane must not leave any sibling renderer displaying stale or corrupt glyphs.xterm-addon.boundary-containment(experimental, partial). The broaderterminal-render.pixel-refresh-repairvisual-golden gate remains registered with protectionnone.webgl-atlas-resetbreadcrumbs include live-manager count and recovery reason; existing pane rendering diagnostics distinguish missed repaint from atlas corruption.Validation
origin/mainmerged into the branchgit diff --checkElectron evidence
Reference pane after workspace and tab reveal, with the sibling PTY still streaming:
Formerly hidden live sibling after reveal, with the changing counter and mixed glyph set intact:
Linear: https://linear.app/stably/issue/STA-3122/investigate-and-resolve-codex-workspace-sync-issues-after-updates