perf(vscode): optimize large session load times and eliminate reactive cascades - #13154
Merged
Merged
Conversation
chrarnoldus
approved these changes
Aug 17, 2026
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.
Opening large sessions (500+ messages and thousands of parts) previously caused main-thread hitches and latency spikes during first-time loading in the webview.
Root Causes
getParts(messageID)accessedstore.parts[messageID]inside layout memos (turns,rows,partitionRows,railEntries), subscribing every message in the session tostore.parts. When virtualized rows hydrated parts on mount, mutatingstore.partsinvalidated all memoized rows across the entire transcript, triggering recomputation cascades for every mounted row.rebuildToolPartsalways passed the full tool list throughreconcile(tools, { key: "id" })on coldreplaceloads, recursively traversing and creating reactive proxies for hundreds of tool calls that were not visible on screen.tasktool outputs were not routed throughslimmers, resulting in multi-megabyte payloads being serialized and passed across the extension IPC bridge.sessionIDs,visibleToolParts, andactiveUserMessageIDran full message scans and allocated sets during idle session opens even when sessions had zero subagent tasks.Changes
store.parts[messageID]reads inuntrack()and prioritizedstash.peek(), allowing layout memos to read parts without establishing reactive dependencies that get invalidated during part hydration.modetorebuildToolParts/setToolsand assigned tools directly onreplaceloads, bypassing recursive store reconciliation.task: slimOutputto metadata slimmers to cap historical task outputs over the IPC bridge.visibleToolParts,sessionIDs, andactiveUserMessageIDfor idle sessions with no task tools.Performance Profile & Benchmark
First-time cold load of session
wt-1786000915486-13(544 messages, 2,800+ parts) in the VS Code webview: