Repository navigation
fix(terminal): replay remount state only into the PTY it was taken from - #360
Merged
amirlehmam merged 1 commit intoOct 25, 2026
Conversation
Since amirlehmam#346 a surface's xterm lives as long as the surface, so the remount snapshot is mostly taken when a pane is really closed. That snapshot stayed cached and was replayed into the next terminal with the same surface id, and Load session keeps saved ids. Since amirlehmam#348 the snapshot carries the alternate screen, so closing a pane that ran vim or Claude Code fullscreen and then loading a session that held it put the new shell's prompt on the alternate buffer, with its output kept out of scrollback. The cache is now RemountSnapshotCache (utils/remount-snapshot.ts): - A terminal whose surface has left the store is not serialized, and any earlier entry for it is dropped. A close no longer serializes the whole scrollback during unmount. - The replay waits for the PTY lookup and runs only when the PTY was reused (pty.has, or create's `reused` for StrictMode's second mount). A fresh PTY drops the entry. The per-surface mouse modes had the same flaw: a closed TUI's modes were replayed into a fresh shell on its id, which then tracked the mouse in SGR, and the wheel handler forwarded scrolling to the shell as escape codes. They are now replayed on the same reuse decision (takeMouseModeReplay), and a fresh PTY forgets the surface's modes and wheel remainder. The machinery stays for terminals rebuilt on a live PTY: the root ErrorBoundary's retry remounts every terminal in production, and StrictMode and Fast Refresh do it in dev. Because the hold now starts after the async lookup, the write callback re-fits whatever the pane size is instead of only when a sync was refused. Refs amirlehmam#345
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.
Refs #345. Follow-up to #348. Since #346 a surface's xterm lives as long as the surface, so the remount snapshot was mostly taken when a pane was really closed. It stayed cached and was replayed into the next terminal with the same surface id, which Load session reuses. Because #348 made the snapshot carry the alternate screen, closing a pane that ran vim or Claude Code fullscreen and then loading a session that held it put the new shell's prompt on the alternate buffer, kept its output out of scrollback, and left mouse tracking on.
What changes
pty.has, orcreate'sreused). A fresh PTY gets neither. The preload type forpty.createnow includesreused, which main already returned.Design choices
Manual verification
In a
wmux-dev.ps1 -Previewinstance:qrestores the shell screen.