BlockEdge

Technology and digital life

How GitHub Copilot’s diff viewer handles a million changed lines

GitHub rebuilt the Copilot app’s diff viewer to open a test pull request spanning 2,200 files, more than a million changed lines and over 400 inline review comments. Principal design engineer Alberto Gimeno described the key change: the viewer calculates the space code needs in advance and measures comments separately, so a growing discussion does not force it to recalculate the code layout.

Why code and comments need different treatment

At a given font size, a line of code has a known height. A comment does not. Markdown wraps differently as the window width changes, images can alter a comment’s height after loading, and a reply editor grows as the reviewer types.

The viewer identifies each variable-height block by its file, line and side of the diff rather than by its pixel position. It tracks the block’s content, expansion state and the width at which it was measured. When the browser is idle, the viewer measures mounted blocks in a batch, looking only about 2,400 pixels beyond the viewport in either direction. It anchors layout corrections to the content the reviewer is reading, so they do not compete with active scrolling.

Gimeno said the team initially gave each block a ResizeObserver that wrote its measured height directly back into the layout. That created a feedback loop that grew more costly as more blocks were mounted. In the shipped design, an observer normally just marks a block for another measurement. Deliberate user actions are an exception: when a reviewer expands a reply editor or toggles a collapsible section, the code below moves in the same frame.

Testing the viewer, not the reviewer

GitHub keeps a synthetic oversized pull request in continuous integration to check the viewer against a performance budget. Built-in probes check that its layout rules still hold. An automated runner also drives the desktop app through cold and warm starts, writing logs to disk so an agent can check for regressions without a person operating the app.

The work builds on an April 2026 report from the team responsible for the Files changed view on github.com. In its unified diff view, each line had previously required about eight React components and ten DOM elements. That team reported cutting both counts by roughly half.

Opening a large change and reviewing it well remain different problems. A DEV Community article citing Microsoft research reported that review quality fell sharply beyond roughly 200 lines; that figure was not a result of GitHub’s million-line test. GitHub has also taken a workflow approach to large AI-generated changes: its stacked pull requests entered public preview on July 30, 2026.