Size inline widget panel to rendered (not source) line count#273
Merged
Conversation
`inline_widget_rows` counted source markdown lines, which under-counts any line long enough to wrap at the panel's content width. The result: wide widgets rendered into a too-short panel and the content got clipped — the webui's CSS auto-sizing does the right thing, but the TUI did not. Measure the actual rendered Line vec (`render_agentd_markdown_lines` with a throwaway hits buffer) and feed it through `visual_line_count` at the real content width. The real render later does the same parse against the real panel area and registers hits then. One extra markdown parse per frame per widget — widget markdown is short, so the cost is negligible. Co-Authored-By: Claude Opus 4.7 (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.
Problem
The TUI's inline widget panel was nominally content-aware (
inline_widget_rowscounted non-empty source markdown lines and added 2 for borders) but used the wrong metric: source line count, not rendered line count. Any line long enough to wrap at the panel's content width counted as 1 source line but rendered to multiple terminal rows, so wide widgets got a too-short panel and the content was clipped.Meanwhile the webui's
.session-widgets.inline-open { max-height: min(45vh, 280px); }plus defaultheight: automakes the browser auto-size to actual rendered content up to the cap — which is the behavior you'd expect.Fix
Measure the actual rendered
Vec<Line>(render_agentd_markdown_lineswith a throwaway hits buffer + dummy position) and feed it through the existingvisual_line_countat the real content width. The real render later does the same parse against the real panel area and registers hits then.Test
crates/cli/src/ui.rs— three unit tests:inline_widget_rows_floors_at_three— empty markdown still gets the minimum row budget.inline_widget_rows_accounts_for_wrapping_long_lines— a 200-char single line needs more rows at width 40 than at width 220. This is the regression the old source-count missed.inline_widget_rows_caps_at_available_height— a 500-line widget never exceedsavailable_height.🤖 Generated with Claude Code