fix: clear terminal scrollback when switching between sessions#43
Draft
omrisavra wants to merge 1 commit into
Draft
fix: clear terminal scrollback when switching between sessions#43omrisavra wants to merge 1 commit into
omrisavra wants to merge 1 commit into
Conversation
Previously, only the visible screen was cleared (\x1b[2J) when attaching/detaching tmux sessions. This left previous session content in the terminal's scrollback buffer, visible when scrolling up. Added \x1b[3J (clear scrollback) alongside \x1b[2J in all screen transition points: attachSessionSync, attachWithPty, SSH attach, and updater. Also added refresh-client after switch-client in tmux.conf to force clean redraws when switching sessions via Ctrl+]/Ctrl+\. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fd30a17 to
37e19a5
Compare
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
\x1b[3J(clear scrollback buffer) alongside existing\x1b[2J(clear visible screen) in all screen transition pointsrefresh-clientafterswitch-clientfor clean redraws on Ctrl+]/Ctrl+\Root cause
When attaching/detaching tmux sessions, the code only cleared the visible screen (
\x1b[2J) but not the terminal's scrollback buffer. This meant the terminal emulator's scrollback retained output from the previous session since it was never cleared.The fix adds
\x1b[3Jwhich is the standard ANSI escape sequence for clearing the terminal scrollback buffer. Supported by iTerm2, Terminal.app, and all modern terminal emulators.For in-tmux session switching (Ctrl+]/Ctrl+),
refresh-clientforces tmux to fully redraw after switching.Changes
src/core/tmux.ts—\x1b[3JinattachSessionSync()andattachWithPty()cleanupsrc/core/ssh.ts—\x1b[3Jinattach()andattachSync()src/core/updater.ts—\x1b[3JinperformUpdateSync()src/core/tmux.conf—refresh-clientafterswitch-clientTest plan