Skip to content

Rich Live: bounded tail-window for long responses (no stale frames)#135

Merged
chauncygu merged 1 commit into
mainfrom
rich-live-streaming
Jun 4, 2026
Merged

Rich Live: bounded tail-window for long responses (no stale frames)#135
chauncygu merged 1 commit into
mainfrom
rich-live-streaming

Conversation

@chauncygu
Copy link
Copy Markdown
Contributor

Replaces the plain-streaming fallback for long responses with a bounded tail window so live Markdown rendering is preserved at any length without the duplicate/stale frames some terminals leave behind.

ui/render.py:

  • Keep the Live region bounded to the viewport. A short response is shown in full; once it would overflow, render the whole response and feed Live only the last limit rendered lines (a tail window that always fits), so the cursor never has to redraw content that scrolled into the scrollback.
  • flush_response() commits the complete output once (full frame frozen in place; tail window cleared then re-printed in full), including on Ctrl-C.
  • Plain streaming kept only as a safety net (precise render failed, or the terminal is too small to bound a window).
  • _live_update() bails out if Live was disabled concurrently instead of dereferencing None (defensive).
  • Fast-path gate widened to 3x headroom so the cheap line estimate can't underestimate Markdown expansion (tables, block spacing) into an overflow.

tests/test_render_streaming.py: rewritten for the tail-window design — full-frame streaming, full->tail transition, tail-window commit-on-flush, real Segments rendering, and both safety-net fallbacks.

Docs: update README/news/features/advanced and the 7 i18n READMEs to
describe the bounded tail window (was: plain-streaming fallback).

Replaces the plain-streaming fallback for long responses with a bounded
tail window so live Markdown rendering is preserved at any length without
the duplicate/stale frames some terminals leave behind.

ui/render.py:
- Keep the Live region bounded to the viewport. A short response is shown
  in full; once it would overflow, render the whole response and feed Live
  only the last `limit` rendered lines (a tail window that always fits), so
  the cursor never has to redraw content that scrolled into the scrollback.
- flush_response() commits the complete output once (full frame frozen in
  place; tail window cleared then re-printed in full), including on Ctrl-C.
- Plain streaming kept only as a safety net (precise render failed, or the
  terminal is too small to bound a window).
- _live_update() bails out if Live was disabled concurrently instead of
  dereferencing None (defensive).
- Fast-path gate widened to 3x headroom so the cheap line estimate can't
  underestimate Markdown expansion (tables, block spacing) into an overflow.

tests/test_render_streaming.py: rewritten for the tail-window design —
full-frame streaming, full->tail transition, tail-window commit-on-flush,
real Segments rendering, and both safety-net fallbacks.

Docs: update README/news/features/advanced and the 7 i18n READMEs to
describe the bounded tail window (was: plain-streaming fallback).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chauncygu chauncygu merged commit 10d4036 into main Jun 4, 2026
6 checks passed
chauncygu added a commit that referenced this pull request Jun 4, 2026
Resolve README.md / docs/news.md conflicts from PR #135 (Rich Live) landing on
main while this branch added the context_window News entry — keep both June 4
items, context_window marked (latest).

Co-Authored-By: Claude Opus 4.8 (1M context) <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