fix(vscode): stabilize Agent Manager inline diff scrolling - #13200
Merged
Conversation
marius-kilocode
enabled auto-merge
August 18, 2026 09:32
johnnyeric
approved these changes
Aug 18, 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.
Problem
The Agent Manager Changes button in the upper-right session toolbar opens an inline diff panel. In a sufficiently large review, scrolling from the bottom upward could cause the content and scrollbar position to jump unexpectedly. The issue was reported as #12699.
This was distinct from the existing edit/comment scroll-reset cases. Those paths already had preservation tests and continued to pass while this bug was present.
Reproduction
I reproduced the issue in the real VS Code extension, using an isolated Agent Manager instance and the top-right inline diff button on a large managed-worktree review.
The reproduction was instrumented at
.am-diff-contentwith:scrollTop,scrollHeight, and client height sampled every animation frameResizeObservernotifications for file rows and diff hostsThe deterministic reproduction moved to the settled bottom of the review, then scrolled upward in small increments. During the failing run:
scrollTopcorrections reached 8,160 pxThis isolated the symptom to virtualization and deferred diff layout, rather than Git polling, agent edits, browser scroll anchoring, or user input handling.
How It Was Introduced
The behavior came from the interaction of two earlier performance changes, rather than from one standalone regression:
fix(vscode): speed up changes diff rendering, introduced deferred Pierre rendering behind a shared intersection observer. Offscreen diffs render an estimated placeholder first and replace it with real Pierre DOM when they approach the viewport.perf(agent-manager): virtualize expanded diff reviews, introduced whole-file row virtualization for large Agent Manager reviews. Rows are unmounted outside Virtua's range and recreated as they come back into view.fix(agent-manager): preserve scroll position when agent edits files in diff viewer, correctly addressed Pierre DOM teardown and live edit/comment updates, but did not cover a previously measured file row being unmounted and later recreated by the outer virtualizer.The problematic sequence is therefore:
scrollTopto preserve its anchor.The issue is direction-sensitive because the problematic remounts happen above the viewport during the bottom-to-top traversal.
Fix
The shared
Diffcomponent now accepts a stable rendered-content identity and remembers measured body heights by exact content identity and panel width.When a virtualized row is recreated:
min-heightThe identity is generated from the review context, file, diff style, and exact
WorktreeFileDiffcontent references. Weak maps avoid retaining removed review data, and a small per-content width history prevents unbounded growth. SSR explicitly consumes the new prop without forwarding it to the DOM.The inline Agent Manager panel and the shared full-screen diff view both pass the identity so they receive the same stability guarantee.
A regression story and browser test cover a multi-file inline review, force a settled bottom-to-top traversal, assert that outer file rows actually remount, and fail if either
scrollToporscrollHeightchanges unexpectedly during the upward pass.Result
With the fix removed, the regression scenario produced a 5,520 px unexpected correction. With the fix restored, the same scenario completed with no unexpected correction and no scroll-range change.
The final self-test against the original large managed-worktree review completed 2,996 upward scroll steps with:
scrollTopcorrection: 0 pxThe fix preserves virtualization and deferred rendering. It does not disable the performance work from PRs #10063 or #11154, and it does not alter legitimate height changes caused by actual content edits.
Fixes #12699