Coalesce redraws to fix 100% CPU from full-screen agent TUIs#49
Merged
Conversation
Full-screen agent TUIs (notably OpenCode) repaint continuously with byte-identical frames and never go output-quiet, which pinned the render loop at its 60 fps frame cap and burned a full core even when idle. Two feedback paths forced this: - Every SessionBytes chunk flagged a redraw via the blanket needs_redraw at the end of handle_event. - The PTY reader emits a SessionCurrentLine heartbeat every ~20ms per session, each also flagging a redraw. Gate both on real change, keyed on rendered content rather than session type so Claude/Codex benefit identically: - process_bytes hashes contents_formatted() and reports whether the visible frame changed; handle_session_bytes redraws only when a *visible* session's screen changed. - handle_session_current_line redraws only when state inference flips the session (its text is already carried by the vt100 screen). State inference on the line path is untouched, so Waiting/Error detection is unchanged for all agents. Co-Authored-By: Claude Opus 4.8 <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.
Full-screen agent TUIs (notably OpenCode) repaint continuously with byte-identical frames and never go output-quiet, which pinned the render loop at its 60 fps frame cap and burned a full core even when idle.
Two feedback paths forced this:
Gate both on real change, keyed on rendered content rather than session type so Claude/Codex benefit identically:
State inference on the line path is untouched, so Waiting/Error detection is unchanged for all agents.