-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: add collapsible functionality to ReasoningBlock for better performance (#8066) #8068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rmance - Added expand/collapse functionality to ReasoningBlock component - Integrated with existing ChatRow expand/collapse state management - Uses ToolUseBlock for consistent UI styling - Improves performance by reducing DOM rendering for large thinking sections - Fixes issue #8066 where reasoning sections caused sluggish UI performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed my own code. Found it suspiciously functional. Must be a bug.
| </div> | ||
| </ToolUseBlock> | ||
| ) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage for this component. Since this is a critical performance fix, would it be worth adding tests to ensure the collapsible functionality works correctly and prevents regression?
| <ToolUseBlock> | ||
| <div | ||
| className="flex items-center justify-between px-3 py-2 cursor-pointer hover:bg-vscode-list-hoverBackground" | ||
| onClick={toggleExpand}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we improve accessibility here? The clickable div doesn't have keyboard navigation support. Consider adding tabIndex={0}, role="button", aria-expanded={isExpanded}, and keyboard event handlers for Enter/Space keys.
| const [elapsed, setElapsed] = useState<number>(0) | ||
|
|
||
| // Use internal state if no external control is provided | ||
| const [internalIsExpanded, setInternalIsExpanded] = useState(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the performance issues mentioned in #8066, should we consider starting with collapsed state by default? Currently it starts expanded (false becomes expanded) when using internal state. This might provide better initial performance, especially for large thinking sections.
| </span> | ||
| )} | ||
| {hasContent && | ||
| (isExpanded ? <ChevronUp className="w-4 h-4" /> : <ChevronDown className="w-4 h-4" />)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding aria-labels for better screen reader support on the chevron icons. For example: aria-label="Collapse" for ChevronUp and aria-label="Expand" for ChevronDown.
| {(content?.trim()?.length ?? 0) > 0 && ( | ||
| <div className="px-3 italic text-vscode-descriptionForeground"> | ||
| {hasContent && isExpanded && ( | ||
| <div className="px-4 py-2 italic text-vscode-descriptionForeground border-t border-vscode-panel-border"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the nested padding intentional? The ToolUseBlock wrapper adds p-2, and then this content area has px-4 py-2. This might create inconsistent spacing compared to other tool blocks. Consider aligning the padding strategy.
Description
This PR addresses Issue #8066 by adding collapsible functionality to the ReasoningBlock component, which resolves the performance issues users were experiencing with reasoning model thinking sections.
Problem
Solution
Changes
Testing
Performance Impact
The collapsible functionality should significantly improve UI responsiveness by:
Fixes #8066
Important
Adds collapsible functionality to
ReasoningBlockfor improved performance by reducing DOM nodes when collapsed, integrated withChatRowstate management.ReasoningBlockinReasoningBlock.tsx.ChatRowinChatRow.tsxfor expand/collapse state management.ToolUseBlockfor consistent styling.This description was created by
for 66598d5. You can customize this summary. It will automatically update as commits are pushed.