Repository navigation
Conversation
…te (U3) Background-queued output during idle over SSH can carry in-place rewrites that leave stale renderer cells. Detect rewrites on the background path and force a viewport refresh on the first foreground chunk after the violation. Also fixes a broken @/ alias import in replay-guard.ts (changed to relative path) that was blocking pty-connection.test.ts from loading under vitest. Fixes part of stablyai#5969. Co-Authored-By: Claude <[email protected]> Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 1b6b9584-9860-4b66-b3fe-900be704478d
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/pty-connection.test.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/replay-guard.ts
CR feedback: pendingBackgroundRewriteRefresh was only set on !foreground chunks, so a CR-boundary rewrite straddling the background→foreground transition missed the refresh trigger. Now run the rewrite decision on the first foreground chunk that completes the pending CSI/CR state, and only consume the flag on genuine foreground writes (not hidden startup queries). Also hardens new tests with a null-callback guard per review. Fixes part of stablyai#5969. Co-Authored-By: Claude <[email protected]> Co-authored-by: Orca <[email protected]>
Summary
Display artifacts appear in agent TUIs (Codex, Claude Code, OpenCode) left open over SSH for extended periods. Resizing clears them. Issue #5969 originally scoped this to Codex, but it affects any agent whose output goes through Orca's renderer — Claude Code and OpenCode reproduce it identically.
This PR implements U3 of the fix plan (
docs/plans/2026-06-28-001-fix-tui-display-artifacts-ssh-idle-plan.md): detect in-place rewrites on background-queued output and force a viewport refresh on the first foreground chunk after idle.Units U1+U4 (atlas reset on visibility-resume) and U2 (SSH replay dedup) already landed. This closes the remaining trigger gap: background rewrites during idle that would otherwise leave stale cells until resize.
Root cause
writePtyOutputToXterminpty-connection.tsgates the render refresh decision onforegroundOutput. Background writes during idle carry in-place rewrites (\r,\b, erase sequences) that the gate ignores entirely. U1+U4 wired atlas reset on lifecycle events, but per-chunk rewrites still needed detection.Changes
pty-connection.ts: Added background rewrite detection using existingterminalRewriteOutputRenderRefreshDecisionwith separate tracking state. On first foreground chunk after a flagged background rewrite, forcerefresh: true, inPlaceRewrite: true. Flag auto-clears on PTY change (reuses existing lifecycle).replay-guard.ts: Fixed broken@/alias import → relative path. This was blockingpty-connection.test.tsfrom loading under vitest.pty-connection.test.ts: 2 new tests:Scope
Verification
tsc --noEmit→ cleanpnpm vitest run src/renderer/src/components/terminal-pane/→ 1258 tests pass across 105 filesFixes #5969
Made with Orca 🐋
ELI5
Long-lived SSH agent terminals could show visual garbage until you resized. Orca detects background in-place screen rewrites and forces a refresh so the TUI paints correctly again.