Skip to content

Rewrite ty tail to use alternate screen buffer#501

Open
bborn wants to merge 1 commit intomainfrom
task/2008-implement-efficient-live-tail-display-wi
Open

Rewrite ty tail to use alternate screen buffer#501
bborn wants to merge 1 commit intomainfrom
task/2008-implement-efficient-live-tail-display-wi

Conversation

@bborn
Copy link
Owner

@bborn bborn commented Mar 9, 2026

Summary

  • Rewrites ty tail from raw ANSI escape codes to a Bubble Tea program with tea.WithAltScreen()
  • Eliminates scrollback pollution by rendering in the alternate screen buffer (like top/htop/watch)
  • Adds terminal-height-aware truncation and width-adaptive title rendering
  • Clean exit with q/esc/ctrl+c instead of only ctrl+c

What changed

The old implementation used \033[2J\033[H (clear screen + cursor home) on each 2s refresh, which pushed content into the terminal's scrollback buffer on every cycle. After a few minutes, the scrollback would be enormous.

The new implementation uses Bubble Tea's alternate screen mode, which is the standard approach used by top, htop, watch, and other terminal monitoring tools. Content is rendered in a separate buffer that doesn't affect scrollback at all. On exit, the terminal returns to its previous state cleanly.

Test plan

  • New unit tests for tailModel (Update + View): key handling, window resize, tick scheduling, task rendering, height truncation, done task filtering
  • All existing CLI tests pass
  • Manual: run ty tail and verify no scrollback growth
  • Manual: resize terminal and verify content adapts
  • Manual: press q/esc to exit cleanly

🤖 Generated with Claude Code

The tail command previously used raw ANSI escape codes (\033[2J\033[H) to
clear and redraw the screen on each refresh. This caused unbounded scrollback
growth in most terminal emulators, making it unusable for long monitoring.

Now uses a Bubble Tea program with tea.WithAltScreen(), which renders in the
alternate screen buffer (like top/htop/watch). This completely eliminates
scrollback pollution, adds proper terminal resize handling, and provides
clean exit with q/esc/ctrl+c.

Also adds terminal-height-aware truncation so the view fits the screen,
and adapts title width to terminal width.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant