NEWS

GitHub rebuilds Copilot's diff engine to open 1-million-line PRs without freezing

GitHub rebuilds Copilot's diff engine to open 1-million-line PRs without freezing
Image: Redação iMasters
News
Reading
5 min
Code
1
In short

GitHub rewrote how the Copilot app measures and renders diffs, separating static code from dynamic comments to open a pull request with 2,200 files and more than 1 million changed lines without freezing.

Giant PR became routine, not exception

GitHub's engineering team published a detailed account of how it rebuilt the diff surface of the Copilot app to open a pull request with 2,200 files, more than 1 million changed lines, and more than 400 inline comments without turning the review into a waiting game. The post is signed by Alberto Gimeno, Principal Design Engineer at GitHub, according to reporting by InfoQ.

The timing is no accident. AI coding agents now produce far more pull requests than human reviewers can absorb. The bottleneck, which used to be writing code, has shifted to reading it. An app that freezes when opening a large diff isn't just uncomfortable: it's a performance ceiling in an era when that scenario has stopped being rare.

Why a PR isn't a single list

The team's central decision was to stop treating the pull request as a uniform list of lines. Code lines have known height in a known font: you can calculate the entire geometry upfront and never recalculate it. Comments don't have that luxury.

A markdown body wraps differently at every screen width. <details> sections can be opened and closed at any moment. The reply composer grows as the person types. Images change height once they finish loading. Forcing a single variable-height virtualizer to absorb both behaviors is asking it to get one of the two wrong.

Two domains, one scroll bar

The solution was to split the document into two independent domains: one deterministic (the code) and one dynamic (the comments). The surface's total height came to be calculated like this:

total height = deterministic code height
  + sum of effective heights of each dynamic block
  + scroll padding

Dynamic blocks are identified by logical key (file, line, side), not by pixel position, using a kind of fingerprint that tracks content, open state, and measurement width. A single measurement pass, triggered during idle screen time, batch-reads blocks that are already mounted, scoped to roughly 2,400 pixels around the visible area. Height corrections are anchored to the point the reader is looking at, so the surface never fights an ongoing scroll.

The mistake the team admits to making

Gimeno is direct about the first instinct that didn't work: a ResizeObserver per block, writing heights back into the layout on every change. It's a classic feedback loop, one whose cost grows along with the number of blocks mounted on screen.

The design that ultimately shipped to production keeps the observer but changes its default role: it signals changes instead of writing directly into the layout. The deliberate exception is when the user expands a <details> or a reply composer: in that specific case, the write happens synchronously with the frame, so the code below moves along with it, with no perceptible jump.

Where this problem comes from

This work didn't start from scratch. It builds on an April 2026 post from github.com's core files-changed team, which reported that each diff line in the unified view rendered as roughly eight React components and ten DOM elements, and managed to cut both numbers nearly in half.

GitHub also attacked the problem from another angle: the stacked pull requests feature entered public preview on July 30, 2026, as an explicit response to what the team calls AI-generated monsters. A piece from the DEV community cited by InfoQ reinforces why this matters: Microsoft research found a sharp drop in review quality once a pull request passes roughly 200 lines, a number that becomes a rounding error next to the 1-million-line test case used by the Copilot app.

The review tooling market is racing too

Third-party tools have been trying to fill this gap from the review side, each with a different bet for the agent era: Graphite, Pullfrog, and CodeRabbit. Jay Hack, CEO of Codegen, argues that the teams that win this phase will be the ones who redesign their workflows around one fact: review, not code writing, is now the bottleneck.

In short: the problem GitHub solved inside its own app is the same one any team building developer tools will run into if it keeps treating code review as secondary throughput.

What this teaches interface builders

The lesson from the rebuild holds outside the pull request context. Any surface that mixes content with predictable height (rendered chat messages, log lines, code) with content of unpredictable height (rich markdown, media, expandable components) suffers from the same single-virtualizer problem.

Three design decisions generalize well to this kind of interface:

  • Separate what's deterministic from what's dynamic into distinct calculation models, instead of forcing a single algorithm to cover both cases.
  • Key blocks by logical identity, not pixel position, to survive reorderings and state changes without recalculating everything.
  • Prefer signaling over direct writes in resize observers, reserving synchronous writes only for the user's own interactions that demand a response within the same frame.

Measuring so it doesn't regress

The team also describes how it ensures the gain doesn't erode over time. The surface carries permanent structured probes for its own performance invariants, which run as CI budgets against a synthetic giant-pull-request fixture. An autopilot drives the real desktop app through a scripted flow, cold and warm, so that an agent can read the log generated on disk and detect regressions without anyone at the keyboard.

The closing line of Gimeno's post sums up the invitation:

Open the worst pull request you have got.

Alberto Gimeno, Principal Design Engineer at GitHub

For anyone building internal code review tools or any dashboard that needs to display large volumes of mixed content, the test Gimeno proposes is literal and reproducible: grab the heaviest artifact that exists in the real environment and see if the interface holds up, instead of validating only against the average day-to-day cases.

Translated from the Brazilian Portuguese original · Read the original