Conditionally compute visual line layout in Thinking component - #1218
Open
nordicnode wants to merge 1 commit into
Open
Conditionally compute visual line layout in Thinking component#1218nordicnode wants to merge 1 commit into
nordicnode wants to merge 1 commit into
Conversation
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.
Conditionally compute visual line layout in Thinking component
Summary
• In
cli/src/components/thinking.tsx, conditionally compute visual line wrapping and markdown content formatting based onthinkingCollapseState.• Previously,
getLastNVisualLines(which measures tokens and performs visual word wrapping across the entire reasoning text) was invoked unconditionally on every render, even whenthinkingCollapseState === 'hidden'(where neither preview nor expanded text is displayed) or'expanded'(where preview lines are never displayed).• Measured via
@opentui/reactand@opentui/core/testingend-to-end across 100 actual React render cycles (5,000-char reasoning text):• In
cli/src/components/blocks/thinking-block.tsx, added a fast-path forblocks.length === 1when extractingcombinedContentto avoid allocating intermediate.map()arrays on every streaming token update.• Added unit tests in
cli/src/components/__tests__/thinking.test.tsxverifying component rendering across all three states (preview,hidden, andexpanded).Test plan
[✓]
bun test --config=/dev/null src/components/__tests__/thinking.test.tsx— 3 pass, 0 fail[✓]
bun run --cwd cli typecheck— passed with 0 errors[✓] PR hygiene check passed