-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Implement lazy rendering for collapsible chat tool parts #289241
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
base: main
Are you sure you want to change the base?
Conversation
- Modified ChatCollapsibleContentPart to defer initContent() call until expanded - Modified ChatCollapsibleInputOutputContentPart to defer createMessageContents() until expanded - Content now renders only when: 1. Tool is running (initially expanded) 2. User clicks to expand a complete tool call - Applies to tool result lists, MCP output editors, and input/output parts Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>
- Updated ChatInputOutputMarkdownProgressPart to expand by default when tool is not complete - This ensures content is rendered for running tools - Complete tools remain collapsed by default (lazy rendering) Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>
|
@copilot hatListItemRenderer#renderChatContentPart: error rendering content Cannot read properties of undefined (reading 'classList'): TypeError: Cannot read properties of undefined (reading 'classList') |
Added guards to check if wrapper exists before accessing its properties. With lazy rendering, wrapper may not be created until content is expanded. Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>
Fixed in 075f1ac. Added guards to check if |
|
@copilot This is not lazy enough. We must avoid calling toCodePart and creating a text model until the thing is expanded. Also fix your build errors |
- Changed IChatCollapsibleIOCodePart.textModel to accept string | ITextModel - Text models are now created lazily in addCodeBlock when content is expanded - Added IModelService and ILanguageService to ChatCollapsibleInputOutputContentPart constructor - Updated ChatInputOutputMarkdownProgressPart to pass input data as string instead of creating models eagerly Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>
Fixed in f19edb9. Text models are now created lazily:
Build errors checking in progress. |
- Changed uriPromise from undefined to Promise.resolve(undefined) to match expected type Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>
|
@copilot Can you think of any way to simplify/streamline this code? Just seems like it should be simpler. A little refactoring is fine |
- Changed IChatCollapsibleIOCodePart to use simple 'data: string' field instead of 'textModel: ITextModel | string' - Removed codeBlockInfo from interface, using simpler fields (codeBlockIndex, ownerMarkdownPartId) - Simplified createCodePart to a cleaner object literal - Removed conditional logic from addCodeBlock - always creates model from data - Streamlined codeblocks getter to delegate directly to collapsibleListPart - Removed redundant _codeblocks array tracking Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>
Simplified in 0ee1ce3: Interface simplification:
Code simplification:
Result: 21 fewer lines, cleaner interface, same lazy behavior. |
Collapsible tool parts (lists, MCP output editors, input/output sections) now defer rendering until expanded, reducing resource usage for collapsed tools. Text models are created lazily only when content is expanded, avoiding expensive model creation for collapsed tools.
Changes
ChatCollapsibleContentPart
initContent()call intoautorunblock, gated onexpanded && !_contentInitializedChatCollapsibleInputOutputContentPart
createMessageContents()(input editors, output sub-parts) to expansion timeaddCodeBlockwhen content is actually renderedIModelServiceandILanguageServicefor lazy model creationIChatCollapsibleIOCodePartinterface to usedata: stringfield instead of complex model/string unioncodeBlockInfoobject in favor of simplecodeBlockIndexandownerMarkdownPartIdfieldsChatInputOutputMarkdownProgressPart
initiallyExpanded = true(content renders immediately)initiallyExpanded = false(lazy render on user click)createCodePartto clean object literal without placeholder valuesChatThinkingContentPart
wrapperexists before accessing its propertieswrapperis only created when content is expandedCannot read properties of undefined (reading 'classList')error infinalizeTitleIfDefault()Behavior
Code Quality
Original prompt
Created from VS Code.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.