fix(desktop): strip ESC[3J to prevent terminal scrollback jump on reattach#963
fix(desktop): strip ESC[3J to prevent terminal scrollback jump on reattach#963
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 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 |
b9cc7e8 to
97e28d4
Compare
…ttach Claude Code emits clear-scrollback control sequences (ESC[3J) during long sessions and on paste/redraw. When persisted and replayed on reattach, these sequences clear scrollback and move the viewport, causing the terminal to "jump" to another position. The fix strips ESC[3J while preserving ESC[2J (clear screen) in both: - Renderer: filter before xterm.write() in stream and restore hooks - Persistence: filter before writing to headless terminal and history
Pending events are live PTY data queued during restore, not stored snapshots. They should pass through unfiltered like the live stream.
Remove stripping from persistence and snapshot replay paths. The only place that needs stripping is flushPendingEvents which processes buffered events during terminal reattach.
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
stripClearScrollbackSequence()function to strip ESC[3J (clear scrollback) sequences while preserving ESC[2J (clear screen) and other escape sequencesxterm.write()to prevent viewport jumps on live stream and restoreRoot Cause
Claude Code emits
ESC[2J(clear screen) plusESC[3J(clear scrollback) and cursor home during long sessions and on paste/redraw. WhenESC[3Jis persisted in snapshots/history and replayed on terminal reattach, it clears the scrollback buffer and resets the viewport, causing the terminal to "jump" to another position.Test plan
clearcommand and Cmd+K still work correctly (ESC[2J preserved)