@github: Rendering a million-line diff is the easy part. Comments are what break it. Their height depends on markdown wrapping, …
Summary
GitHub explains how they rebuilt the pull request view in the GitHub Copilot app, tackling the hard problem of rendering million-line diffs along with dynamic comment heights from markdown, reply boxes, and loading images. 附带一条 🧵 线程标志的技术分享。
View Cached Full Text
Cached at: 10/12/26, 07:31 PM
Rendering a million-line diff is the easy part. 👀
Comments are what break it. Their height depends on markdown wrapping, expanded details, open reply boxes, and images still loading (none of which you know until you render).
Here’s how we rebuilt the PR view in the GitHub Copilot app 🧵
A code row is a line at a known height. You can compute the whole geometry up front and never have to correct it.
Comments don’t have a predictable height. So we stopped forcing one geometry to serve both, and split the document into two independent height domains.
For the first design, we gave every dynamic block a ResizeObserver that wrote measured heights back into the layout.
We built it, then rejected it. An observer that writes a height back into the layout it’s watching can retrigger itself, and the cost grows with every mounted block.
What we shipped is a recurring measurement pass, gated on idle and scoped to roughly 2400px around the viewport. Mounted blocks are ground truth. Observers normally only flag a block for the pass. They don’t write heights themselves.
There’s one exception: a visible block resizing because of the user’s action can apply one synchronous correction before paint. That keeps the comment and code below it moving together without reopening the feedback loop.
One bug that held us back was “don’t correct while you’re scrolling.” It was a timestamp guard, and our own programmatic scrolls refreshed it.
Toggle the sidebar, and the diff pane changes width. Wrapped lines reflow, and the surface emits a small scroll as it settles. The guard read that as your input and skipped the correction meant to keep your place. The file you were reading drifted off screen.
Any “is the user interacting?” check has to distinguish real user input from scrolls caused by your own side effects.
Open the worst pull request you’ve got and try it out 👇
Similar Articles
@github: A pull request with 2,200 files, 1M+ changed lines, and 400+ inline comments. Impossible to review? Not if you have the…
GitHub Copilot app now features an improved pull request view designed to handle extremely large code reviews with thousands of files and millions of changes efficiently.
On Rendering Diffs
A blog post announcing CodeView, a virtualization-first React component for efficiently rendering large code diffs, part of the Diffs library released six months ago.
@github: With stacked pull requests, each layer tackles one concern, like data, API, application wiring, or UI, and builds on th…
The article explains how stacked pull requests in GitHub break changes into smaller, focused layers, improving code review with clearer context and smaller diffs.
Show HN: Diffle, a keyboard-centric diff viewer with LSP support
Diffle 是一个键盘优先的浏览器端 Git diff 查看工具,支持按行、块或文件添加评论,并可将评论作为 prompt 交给 AI agent 或提交为 GitHub 待处理评审,内置 LSP 支持且可通过 pixi、npm 或独立二进制安装。
@gimenete: Coming soon to the GitHub Copilot desktop app: editable diffs!! Agent got you most of the way there? Make those last tw…
GitHub Copilot desktop app is adding editable diffs, allowing users to make direct tweaks in the code review interface.