Skip to content

Add scrollback history review - #61

Open
Deon588 wants to merge 1 commit into
tspivey:masterfrom
Deon588:scrollback
Open

Deon588 wants to merge 1 commit into
tspivey:masterfrom
Deon588:scrollback

Conversation

@Deon588

@Deon588 Deon588 commented Jun 26, 2026

Copy link
Copy Markdown

This adds review of terminal scrollback history — lines that scroll off the top of the screen, which were previously lost (until now the only way to review long output was to pipe it through less).

What it does

  • Reading the previous line (alt u) past the top of the screen now continues up into captured history instead of stopping at "top".
  • alt t jumps to the start of the session's output; alt b jumps back to the bottom of the live screen.
  • Line, word, character review and copy all work on history lines exactly as they do on the visible screen.
  • Copying a selection that spans multiple rows now copies whole lines (it previously truncated the last line at the review cursor's column), so copying a range of lines comes out in full.

How it works

  • Lines are captured as they scroll off the top, via a single hook in pyte's index() (which both linefeed() and scroll-up route through). History is a bounded collections.deque.
  • The review cursor uses negative row indices for history; one review_line() accessor routes every read to either history or the live buffer, so the existing review/copy code works unchanged.
  • Alternate-screen programs (vim, less, htop) are not recorded, and clear / tput reset drop the history — matching how a normal terminal behaves.

Configuration

  • scrollback_lines under [speech] sets how many lines to keep (default 10000), also settable live from the config menu (alt c, then b).

Tested on macOS (Terminal.app); ruff check passes.

@GueRue

GueRue commented Jun 26, 2026 via email

Copy link
Copy Markdown

@Deon588
Deon588 force-pushed the scrollback branch 3 times, most recently from 5537321 to 7313612 Compare June 27, 2026 08:13
Capture lines that scroll off the top of the screen so they can be
reviewed later instead of being lost. Reading the previous line (alt u)
past the top of the screen now continues up into history; alt t jumps to
the start of the session and alt b back to the bottom of the live screen.
Line, word, character review and copy all work on history lines exactly
as they do on the visible screen.

History is a bounded ring buffer captured at pyte's scroll chokepoint
(index, which linefeed and scroll-up both route through). The review
cursor uses negative row indices for history, and a single review_line()
accessor routes every read to history or the live buffer. Alternate-screen
apps (vim/less/htop) are not recorded, and clear / tput reset drop the
history, matching a normal terminal.

The buffer size is set by scrollback_lines in the [speech] section
(default 10000) or live from the config menu (alt c, then b).

A multi-row copy selection now copies whole lines instead of truncating
the last line at the review cursor's column, so copying a range of
history lines (e.g. 1-10) yields them in full.
@tspivey

tspivey commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Thanks!

Current bugs:

  1. Scroll past the top of the screen, type clear to erase the scrollback, then read the current line. tdsr crashes.
  2. Terminal resize isn't handled well. If the terminal resizes, lines disappear from the top of the screen without being able to get them back.
  3. Alt b isn't needed. We already have alt shift o which moves to the bottom of the screen.

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.

3 participants