This repository was archived by the owner on May 20, 2026. It is now read-only.
Improve request log tree performance#1671
Open
sibidharan wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the ChatRequestProvider class to improve performance by introducing incremental tree updates instead of rebuilding the entire tree on every request log change. The key optimization is caching prompt/root nodes and only refreshing affected tree items when new entries are added.
Key Changes:
- Introduced state caching (
rootItems,seenChatRequests,processedCount,currentPrompt) to track processed entries - Replaced full tree rebuild with incremental
appendNewEntries()method that only processes new log entries - Added automatic cache reset when request log shrinks to prevent stale UI state
Author
|
@microsoft-github-policy-service agree |
b198148 to
da80e7b
Compare
f6a0a6f to
68c0391
Compare
68c0391 to
d48b206
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 slowdown were seen when chat gets big and big and big, traced back to the request log view inside the Copilot Chat extension. Every time a new chat request or tool call arrived, the old code rebuilt the entire tree of prompts and children from scratch—reflattening the full history and firing a full refresh event. In long chat sessions that tree gets big, so each update became progressively heavier and the UI stuttered.
I fixed it by making ChatRequestProvider incremental and introduced ThrottledMarkdownStream:
It now tracks how many log entries have already been processed, keeps the existing prompt nodes in a cache, and only appends new children. If the log ever shrinks (e.g., on reload) it resets cleanly, but otherwise it avoids rebuilding everything.
Refresh events are fired only for the nodes that genuinely changed; a root-level refresh happens once when structure changes, instead of on every update. Once that change is in, the request log will stop rebuilding itself over and over, so the chat UI stayed responsive even during long-running sessions.
While fixing the request log tree made the sidebar responsive, the chat panel still stuttered because every streamed token triggered a full markdown re-render. I now throttle those markdown events so the renderer receives batched chunks instead of repainting the entire transcript on every token.
Fix Summary
ChatRequestProviderso it caches prompt/root nodes, appends new log entries incrementally, and only refreshes affected tree itemssrc/extension/log/vscode-node/requestLogTree.tsandsrc/extension/prompt/node/defaultIntentRequestHandler.tsintroduced ThrottledMarkdownStream so the chat renderer receives batched markdown chunks instead of a flood of markdown() calls.Testing