fix: stabilize xterm session restore rendering#282
Merged
Conversation
Restore snapshots depend on xterm serialize semantics for wrapped lines. In upstream SerializeAddon, wrapped rows normally serialize with an empty row separator instead of an explicit CRLF, relying on DECAWM to overflow naturally; only fallback cases inject extra wrap-forcing sequences. That means writing CSI ? 7 l before replay can overlap wrapped restore content on a single row. Also guard the restore/live-output boundary in SessionManager: when a session becomes active, buffer PTY chunks that arrive during snapshot replay and flush them only after the restore event completes. This preserves ordering and removes a race where live output could interleave with the serialized snapshot and corrupt the screen. References: - xterm.js SerializeAddon wrapped-row separator logic (pinned to the addon version bundled here): https://github.com/xtermjs/xterm.js/blob/f447274f430fd22513f6adbf9862d19524471c04/addons/addon-serialize/src/SerializeAddon.ts#L163-L170 - xterm.js SerializeAddon fallback wrap injection: https://github.com/xtermjs/xterm.js/blob/f447274f430fd22513f6adbf9862d19524471c04/addons/addon-serialize/src/SerializeAddon.ts#L210-L214 - xterm.js SerializeAddon mode serialization for wraparoundMode: https://github.com/xtermjs/xterm.js/blob/f447274f430fd22513f6adbf9862d19524471c04/addons/addon-serialize/src/SerializeAddon.ts#L495-L496
Restore up to 200 lines of normal-buffer scrollback on session re-entry while keeping alternate-screen restores viewport-only. Track a restore baseline after clear-screen sequences so stale pre-clear content is not replayed. Also append an explicit CUP cursor reposition after bounded range restores. xterm's SerializeAddon omits the final cursor restoration when serializing an explicit range, so live input could resume at the wrong location without this correction.
…rm-rendering-glitch # Conflicts: # src/components/Session.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification
Notes