Skip to content

Fix long-response fallback in Rich streaming#133

Open
tsint wants to merge 1 commit into
SafeRL-Lab:mainfrom
tsint:fix-rich-live
Open

Fix long-response fallback in Rich streaming#133
tsint wants to merge 1 commit into
SafeRL-Lab:mainfrom
tsint:fix-rich-live

Conversation

@tsint
Copy link
Copy Markdown
Contributor

@tsint tsint commented Jun 4, 2026

Summary

Fix Rich Live streaming fallback for long responses.

Problem

Large streamed responses can exceed the practical redraw area for Rich Live. In some terminals, this may leave stale or duplicated output while the response is still streaming. The previous fallback logic also did not fully isolate fallback mode to the current response.

Changes

  • Added per-response plain streaming fallback state.
  • Estimate rendered line count with Rich instead of relying only on newline counts.
  • Make the Live line limit aware of terminal height.
  • Stop and clear the active Live frame before falling back to plain output.
  • Clear the accumulated buffer after fallback to avoid duplicate output.
  • Reset fallback state in flush_response() so the next response can use Live again.
  • Added focused tests for normal Live streaming, first-chunk fallback, and active-Live fallback.

Test Plan

uv run pytest -q tests/test_render_streaming.py

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