Replies: 1 comment
-
|
One concern with the alternate screen approach: it wipes all conversation history on exit, which kind of defeats the purpose of a terminal-based tool. A hybrid approach would be ideal — use the alternate screen while running (keeping tmux scrollback clean), but dump the conversation log back to the main screen buffer on exit, similar to how That way you get the best of both worlds:
This is a problem none of the AI TUIs have solved well yet — could be a real differentiator for pi-tui. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
When running pi-tui inside tmux, scrolling up in tmux copy-mode reveals garbled TUI frames stacked in the scrollback buffer. This happens even on brand new tmux sessions with no prior scrollback — the TUI's own startup renders are the only content in the scrollback, and they appear duplicated/garbled when scrolling up.
The issue is most visible at session startup (initial header, auth status, and model info frames appear stacked), but since all rendering goes to the main screen buffer, any TUI frame can end up in tmux's scrollback.
Root cause
pi-tui renders directly on the main screen buffer rather than switching to the terminal's alternate screen buffer. This means every frame pi-tui renders gets captured into tmux's scrollback history.
Most full-screen TUI applications (vim, htop, less, etc.) use the alternate screen buffer via
\x1b[?1049h(smcup) on start and\x1b[?1049l(rmcup) on exit. This keeps TUI rendering completely separate from the scrollback and cleanly restores the previous terminal content when the app exits.Current behavior
\x1b[2J\x1b[H(clear screen + home cursor) and synchronized output (CSI 2026) for rendering\x1b[3J(scrollback clear) during full re-renders triggered by width changesPrior art
On this repo
\x1b[3Jscrollback clear and add viewport scroll controls. Auto-closed by contributor gate. Includes repro evidence confirming pi-tui emits\x1b[3Jduring full re-renders.a6f9c3c.Same problem in other AI TUI tools
Suggested fix
Add alternate screen buffer support to
ProcessTerminal:\x1b[?1049hduringstart()to switch to the alternate screen\x1b[?1049lduringstop()to restore the normal screenThis would solve both problems:
This could be behind a flag (e.g.,
useAlternateScreen: trueor--alt-screen) for users who prefer the current behavior of preserving output after exit.Environment
Beta Was this translation helpful? Give feedback.
All reactions