Rendering huge pull requests in the GitHub Copilot app
Source
Alberto Gimeno
Author
Alberto Gimeno
Date
Key takeaways · AI-distilled
GitHub's Copilot app keeps code diffs fast with virtualization built on a rule that every code row's height is known before paint; review comments break that rule because their height is only known after rendering.
The fix splits geometry in two: an exact, prefix-summed code-height index that never rebuilds, plus a separate index of comment blocks keyed by identity and file/line anchor, holding measured, cached, or estimated heights.
GitHub rejected one ResizeObserver per block writing heights back, since that creates a feedback loop. Instead a single idle, scroll-gated pass measures blocks within about 2,400px of the viewport; observers by default only flag blocks for re-measurement.
Scroll corrections are anchored by identity: capture the row or block the user is looking at, apply height changes, then restore that anchor. A bug arose when the surface's own programmatic scrolls were mistaken for user scrolling.
Bugs were found with an unattended change, measure, improve loop: permanent in-app probes (mounted rows, frame cost, correction sizes, observer teardown) asserted as budgets in CI, plus an autopilot driving the real app through a huge PR.
Why it matters
As agents generate ever-larger diffs, review tooling needs to keep up; this explains the concrete architecture GitHub used to keep massive AI-scale PRs reviewable, including how it handles variable-height comment rendering.