Fix long-response fallback in Rich streaming#133
Merged
Conversation
yanfeng98
pushed a commit
to yanfeng98/pycode
that referenced
this pull request
Jun 5, 2026
Follow-up to the long-response Rich Live fallback (PR SafeRL-Lab#133). ui/render.py: _rendered_line_count now uses a cheap per-line wrap estimate to short-circuit the expensive full console.render_lines() measurement while a response stays comfortably under the limit. Normal responses no longer pay an extra full Markdown re-render on every streamed chunk (was O(n^2) on the hot path); the precise render only runs as output nears the fallback limit. On render failure it now falls back to the cheap estimate instead of 0 so oversized content still triggers the plain-streaming fallback. Docs: document the automatic per-response plain-streaming fallback (wrap- / terminal-height aware) across README News, docs/news.md, features.md, advanced.md, and the 7 i18n READMEs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
flush_response()so the next response can use Live again.Test Plan