Skip to content

fix(vscode): speed up changes diff rendering - #10063

Merged
marius-kilocode merged 3 commits into
mainfrom
darkened-alto
May 8, 2026
Merged

fix(vscode): speed up changes diff rendering#10063
marius-kilocode merged 3 commits into
mainfrom
darkened-alto

Conversation

@marius-kilocode

@marius-kilocode marius-kilocode commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Make Agent Manager diff watching follow the selected worktree and ignore stale async diff results after switching.
  • Defer expensive @pierre/diffs rendering until diff bodies are near the viewport, using one shared observer and a per-frame render queue.
  • Keep review expansion policy untouched so this remains compatible with fix(agent-manager): expand reviewable diffs by default #10055.

What We Profiled

We profiled repeated Agent Manager worktree switches with the inline Changes panel open in the VS Code webview performance tools. The traces covered both mouse and keyboard-driven switching paths because both trigger the same Solid view updates and diff rendering work.

What We Found

The slow path was not primarily git diff collection. The UI blocked because switching worktrees with the inline diff open synchronously mounted and rendered many expanded Diff components. Each component invoked Pierre's DOM-heavy render path on the VS Code webview renderer thread, which showed up as long EventDispatch, FunctionCall, ParseHTML, UpdateLayoutTree, Layout, Commit, and Paint work.

We also found two secondary issues while iterating:

  • Diff watch requests could race across worktree switches and deliver stale results.
  • Creating one IntersectionObserver per deferred diff became its own hotspot, so the implementation now uses a shared observer.

What Changed

Expanded diff state is now separate from expensive body rendering. Expanded files still appear expanded, but offscreen diff bodies reserve estimated height and render only when near the viewport. Multiple visible diff renders are queued one per animation frame to avoid long single tasks.

The diff controller now uses an active-watch epoch so old summary/detail/poll results are ignored after switching worktrees.

Impact

The worst profiled input block improved from roughly 3.2s before the rendering fix to roughly 7ms after shared observation and queued near-viewport rendering. The remaining work is incremental rendering as diffs approach the viewport instead of one large synchronous render burst during worktree switch.

Fixes #9818

Testing

  • bun run typecheck from packages/kilo-vscode
  • bun run lint from packages/kilo-vscode
  • bun run typecheck from repo root
  • bun run lint from repo root, completed with existing warnings and 0 errors

Comment thread packages/kilo-ui/src/components/diff.tsx
@kilo-code-bot

kilo-code-bot Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • packages/kilo-ui/src/components/diff.tsx

Reviewed by gpt-5.5-2026-04-23 · 392,171 tokens

@marius-kilocode
marius-kilocode merged commit d08238d into main May 8, 2026
13 checks passed
@marius-kilocode
marius-kilocode deleted the darkened-alto branch May 8, 2026 10:49
jliounis pushed a commit to jliounis/kilocode that referenced this pull request May 19, 2026
* fix: speed up changes diff rendering

* fix: preserve deferred diff selection
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
* fix: speed up changes diff rendering

* fix: preserve deferred diff selection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changes tab is slow

2 participants