Skip to content

Expand arrows on the Inbox's PR page and guided reviews - #2635

Merged
backnotprop merged 21 commits into
mainfrom
feat/pr-page-expand-context
Nov 6, 2026
Merged

backnotprop merged 21 commits into
mainfrom
feat/pr-page-expand-context

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Targets main, with #2640 and #2661 merged in. This branch doesn't depend on #2639, which is on hold.

Adds the "N unmodified lines" rows and arrows from Plannotator's code review to the Inbox's PR page and guided reviews, up to the whole file. In the Inbox a file's box is as tall as its content, with no height limit, and the page scrolls.

No height limit

In the fitFileHeights hosts (the PR page and a thread's guided review) there is no MAX_DIFF_HEIGHT and no scroller inside the box. Hosts without fitFileHeights are unchanged.

The approach comes from diffshub: it has one CodeView whose root is the page's scroller, and it stays fast because CodeView only draws the rows near the viewport. Our chain has a page with many CodeViews in it, so scrollWithPage (packages/review-editor/utils/scrollWithPage.ts) makes each CodeView read .ib-gbody's scroll position instead of its own. The browser scrolls, and headers stick with plain CSS. We don't position rows, and we add no virtualizer.

  • An opened file stays mounted while it is off screen, and its whole-file text is kept, so a gap doesn't close and the file below doesn't jump.
  • The trailing band is gone: the box holds the padding, and the code draws what the layout counts.
  • A file header shows a 1 px line under it only while it is stuck. Browsers without scroll-state queries draw no line.
  • Comment reveal scrolls the page to the row. After a reload an opened line is closed again, so going to its comment reads the file, opens the range, then scrolls.
  • The row being read stays put. .ib-gbody turns browser scroll anchoring off (it never helped here, and Safari has none), the first estimate matches what is drawn, and a box wholly above the viewport adds its change in height to the page's scroll.
  • Folding a file from its stuck header brings that file's header to the top of the page.
  • A rail jump is instant in these readers: a smooth one would aim at heights still changing on the way.

Nothing is read until someone opens an arrow

Mounting a file used to read its whole text and tokenize it on the main thread, which froze the page on real code even if nobody opened a gap. Now GuideReader mounts ReviewWorkerPoolProvider, so highlighting is off the main thread, and whole files come through Pierre's loadDiffFiles, called on the first arrow click. The pool's workers start with the first reader on screen and end with the last, so a page with no diff holds none. While a first read runs, the file's arrows pulse.

Two consequences, both from not asking until someone opens an arrow:

  • A file whose blobs can't be read shows arrows until the first click, which then removes them quietly. A forge that didn't answer keeps them, and the next click asks again.
  • Every changed file has an arrow row after its last hunk, since its size isn't known yet. If the last hunk already reaches the end of the file, that row goes on the first click and the box shrinks about 32 px.

Arrows for everyone

GET /api/inbox/messages/:id/guide/file no longer needs Code review (with it on, it reads through the forge only for a PR of the message's own project), and GuidePane no longer takes codeReview or swaps its key. It reads only the repo's own blobs, so no gh or glab. With Code review off, a guide whose blobs aren't local has no arrows and makes no forge call. A tailnet guest gets no reader, so no silent 403s.

Server (Bun only, the Inbox)

  • GET /api/inbox/pulls/file?key&scope&path&old&new: only a path that diff changes; one file at the head of the patch on screen and at the merge base, from a local clone that has the commit, else gh api / glab api. Guards are the same as /api/inbox/pulls/diff: owner or local, same origin, Code review off answers 409. Cap is 5 MB per file, with a 64 MB in-memory cache and at most 6 reads at once.
  • The client sends the blob ids from the patch's index line (patchBlobIds). If the text read doesn't hash to them, that file has no arrows. This covers a push after the stack list loaded, a merged PR whose merge base equals its head, and a head that moved during the read. The cache key includes the bases, for a retarget with the same head. A whole-stack GitLab patch with no index line has no arrows.
  • The arrows' rate-limit hold is separate from diff()'s.
  • diff() answers head_sha in both scopes, and remembers a head only when it held still during the read (the same rule as fix(inbox): keep a PR review's unsent comments and Viewed until a new commit #2640, so the two merge cleanly). A file read uses that head, else the list's. The client asks for nothing when an answer has no head_sha.
  • GET /api/inbox/messages/:id/guide/file?path: owner or local and same origin. It reads only a path the guide's patch changes, and only the blobs its index line names. The new side may come from the working tree while its bytes hash to that id.

Comments on opened lines

No forge takes an inline comment outside the PR's diff, so a comment on an opened line carries outsideDiff and the code, and the review posts it in its main comment. The store skips the hunk check for those comments but still checks that the file is in the patch. The export labels them "(not in the diff)" with a **Code:** block, as the review app does. An old-side opened line in the submission dialog names its side and has no link.

When arrows don't open

Forks and renamed files open like any other file: a fork's commits are reachable by id from the base repository, on GitHub and on GitLab, and a renamed file's old side is read at its old path. An old path that leaves the repository reads nothing. The server keeps only texts and commits it got: an empty answer or a 404 is not kept, so a passing sign-in problem doesn't leave a file without arrows.

No arrows at all:

  • Added or deleted files
  • A tailnet guest, the phone surface and Shape

Arrows that go away on the first click, because only a read can tell:

  • Binary or too-large files
  • A blob that isn't there, or text that doesn't match the patch on screen
  • Code review off, when the guide's blobs aren't local and the only source is the forge

Arrows that stay, so the next click retries: a failed forge read, offline, or a rate limit (which holds the host). Pierre logs the failure to the console.

Measured

Headless Chromium on the built binaries, with a fake gh, against #2632 at 014185e14. Other work was running on the machine, so treat small differences as noise. Fixtures: the first 5,000 lines of packages/inbox/App.tsx with every line changed, and 100 real repo files. On #2632 the long file is capped at its height limit, so its frames column has nothing to measure.

First row, #2632 First row, here Longest task, #2632 Longest task, here Heap after GC, #2632 Heap after GC, here Frames p95 / max, here
5,000-line file, thread 6,826 ms 422 ms 5,080 ms 61 ms 80 MB 20 MB 18.5 / 66 ms
5,000-line file, PR page 8,006 ms 1,208 ms 5,037 ms 60 ms 77 MB 16 MB 18.3 / 89 ms
100 files, thread 1,929 ms 390 ms 235 ms 58 ms 61 MB 22 MB 18.4 / 19 ms
100 files, PR page 2,283 ms 1,752 ms 236 ms 57 ms 63 MB 23 MB 18.4 / 24 ms

The #2632 columns are from an earlier run of the same scripts, before main's later merges, so they are not a same-moment comparison.

No whole file was read in any of these runs. Long tasks at reading pace: 3-4 on #2632 for 100 files (202-227 ms in all), 0-1 here (at most 98 ms). The long file: 1 here, 68-75 ms.

First arrow click on a real 5,000-line file: 509-840 ms in six clicks, longest task 143-279 ms. One earlier run, on a busy machine, took 2.2-2.4 s.

Workers: 0 on a page with no diff, 3 with a reader on screen. Opening a guide again after leaving it starts them again: first row 122-196 ms.

Scrolling 240 steps each way: 0 shifts of the row being read (Chromium on 100 files and on 100 real files, WebKit on 100 files), 0 movement standing still for 8 s, and a rail jump up lands at 16 px.

For the reviewer

  • scrollWithPage overrides scrollTop, scrollTo and getBoundingClientRect on the root element. It depends on CodeView asking only those and the scroll event, and that's the same in 1.5.2 and diffshub's 1.6.4. guideScrollsWithPage.test.tsx mounts the real CodeView and checks the rows drawn follow the page, so a Pierre change that stops asking those is caught there. scrollWithPage.test.ts only covers the adapter's rules, on plain elements.
  • With wrapped lines, heights are estimates until drawn, so the box and scrollbar change as you read. The row you're reading doesn't move.
  • "More unchanged context may be available": Pierre draws this row after the last hunk of any file it hasn't read, since it can't know the file's length. It offers no per-file way to drop it, and hiding it by CSS would leave CodeView counting a row that isn't drawn, a 32 px blank band. Once the file is read Pierre gives it a count or removes it.
  • A window that grows past the screen's height leaves blank space until the next resize, since CodeView rereads its height only then and the adapter answers the larger of the window and the screen. This happens only when moving to a taller monitor, or headless.
  • A file with no hunks (binary, mode change) keeps the old estimate and shrinks about 99 px when it mounts. Above the viewport the page compensates.
  • With 100 files, the walkthrough's file list is still its own scroller. It's a side panel, not a diff box.
  • review-core.ts: readGitObjectBytes is extracted from readDiffSideBytes, with no behaviour change.

Testing

  • packages/review-editor/utils/scrollWithPage.test.ts (DOM): the adapter's rules.
  • packages/inbox/guideScrollsWithPage.test.tsx (DOM, real CodeView): rows drawn follow the page's position.
  • packages/server/inbox-file-contents.test.ts: guards, cap, cache eviction, fork, rate limit, blob mismatch, whole stack, GitLab, the guide route with Code review off, Code review turned off with the PR still listed, a guide in another project, a path the diff doesn't change, a comment in no hunk, on real git in a temp folder.
  • packages/server/inbox-pulls.test.ts: a guest is refused on guide/file.
  • packages/inbox/guideExpandContext.test.tsx, packages/guide-viewer/GuideView.test.tsx (DOM, real Pierre): no read before the first click, arrows, box height, degrade cases, a failed read keeps the arrows and retries, renamed files open, a pending read shows, a guest asks nothing, the reader's place on growth and fold.
  • packages/inbox/guide/wholeFileReader.test.ts: only texts are kept; "none" and a failure ask again.
  • tests/e2e/inbox-guides.spec.ts, two new tests: a thread with Code review off (arrows, no scroller inside the box, sticky header and its line, a comment on an opened line) and a guide with its blobs missing (first click removes the arrows, no console errors).
  • tests/e2e/inbox-pull-requests.spec.ts: arrows from a fake forge with no read before the click, a worker running, a comment on an opened line posts in the main comment, an old-side comment quotes the old text, going to a comment after a reload opens its line (old side at its old number, with the sides 30 lines apart), and no workers on a page with no diff.

The tests never run real gh or glab, only scripted CLIs. By hand, the fork reads were checked read-only against public forges: GitHub's contents and compare on a fork PR's head from the base repository, and GitLab's repository/files/…/raw on a fork MR's head from the target project. The arrow-opening flow on ReviewPane shares GuideReader and the store save, and has no browser run of its own; its guest path has a DOM test.

The diffs on the PR page and in a thread's guided review showed only the
patch's hunks. Modified files now get the "N unmodified lines" rows code review
has, up to the whole file, and the box grows with what opens.

Server (Bun only, the Inbox):
- GET /api/inbox/pulls/file: one file at the head of the patch on screen and at
  the merge base, from a local clone that has the commit, else gh/glab. Same
  guards as /api/inbox/pulls/diff. 5 MB per file, cached by commit up to 64 MB,
  at most 6 reads at once.
- GET /api/inbox/messages/:id/guide/file: only a path the guide's patch changes,
  only the blobs its index line names, so a tree that moved on shows no arrows
  rather than the wrong lines.

Viewer: AllFilesCodeView takes an optional fetchFileContent; absent, it behaves
as before. GuideReader takes fileContents and passes it through.

A comment on an opened line carries outsideDiff and the code, because no forge
takes an inline comment outside the PR's diff: it posts in the review's main
comment. The store keeps both fields.

Forks, binary or huge files, renamed, added or deleted files, and Code review
off degrade to no arrows.
backnotprop added a commit that referenced this pull request Nov 5, 2026
…the review app's fill

The owner decided there is no height limit in the Inbox: #2635 removes the cap for
fitted hosts, so this drops --guide-file-fit-max, its 100cqh rule, GuideFileCard's
max-height and their tests. GuideFileCard is back to #2632's. The pane stays an
inline-size container for the note's room on the controls' row.

From REVIEW_FOLD_PANEL_BELOW up the comments column takes the review app's bg-card/30
over --background; folded, the sheet stays a card over the diff.
backnotprop and others added 4 commits November 4, 2026 20:02
…s for everyone, and only the patch's own text opens

Boxes: a fitted file box is as tall as its content, with no scroller of its own. scrollWithPage answers what
CodeView asks its root from the page, so Pierre's windowing, anchoring and line jumps run against the page.
A file whose gap was opened stays mounted past the outer window.

Arrows: the guide file route no longer needs Code review (no forge while it is off). The PR route checks both
texts against the blob ids of the patch on screen, so a push behind the list, a merged PR or a retarget opens
nothing. Comments on opened lines save; the arrows' rate limit no longer holds the next diff.

Co-Authored-By: Claude <[email protected]>
…parator; a line under a stuck header

Co-Authored-By: Claude <[email protected]>
@backnotprop backnotprop added the ci:full Run the heavy CI tier on this PR (added by the merge script) label Nov 5, 2026
…he page

Mounting a guided review read every whole file and highlighted it on the main
thread, so real code froze the page even if nobody opened a gap. The Inbox now
mounts the review worker pool, and whole files reach Pierre through its
loadDiffFiles seam on the first arrow click. Opening a comment on an opened line
starts the same read, opens the range, then scrolls.

The page holds the row being read itself: scroll anchoring is off on .ib-gbody,
the first estimate matches what is drawn, and a box wholly above the viewport
adds its change to the page's scroll. Folding from a stuck header brings the
file to the top of the page.

A tailnet guest's review asks nothing. A guide reads only a PR of its own
project, and pulls/file only a path its diff changes.

Co-Authored-By: Claude <[email protected]>
@backnotprop
backnotprop changed the base branch from fix/pr-page-diff-padding to main November 5, 2026 04:36
backnotprop and others added 10 commits November 4, 2026 23:42
Takes #2640's rule early so the two merge cleanly: head_sha in both scopes, and
readHeads holds only heads that held still. A file read uses that head, else the
list's, and the client asks nothing when an answer has no head_sha, in either
scope.

Co-Authored-By: Claude <[email protected]>
…r-page-expand-context

# Conflicts:
#	packages/server/inbox.ts
…ontext

# Conflicts:
#	packages/inbox/components/GuidePane.tsx
#	packages/inbox/pulls/PullReview.tsx
… start with a reader

A fork's commits are reachable by id from the base repository on both forges, so
its files read like any other. A renamed and edited file opens too, its old side
read at its old path. A forge that did not answer is no longer taken for "no such
file": the arrows stay and the next click asks again, and nothing empty is kept.

The worker pool moves from the Inbox's root to GuideReader, so a page with no diff
holds none. A first read now shows on the arrows while it runs. Arrow rows with one
button and with two now size alike, on the phone too.

Co-Authored-By: Claude <[email protected]>
…mber under -U0

`oldPath` comes from the guide's patch, so a `rename from ../../../../user`
reached the forge route with the owner's token: fileContents now validates it.
An empty answer or a 404 stays out of fileTexts and mergeBases, so a passing
sign-in problem doesn't leave a file without arrows until restart.
newLineOf treats git's zero-count side as the line before the hunk.

Co-Authored-By: Claude <[email protected]>
Keeps both sides in ReviewPane (guest and onAsk), GuideReader (the worker
pool wrapper with main's new props) and the imports of inbox-guides and inbox.

Co-Authored-By: Claude <[email protected]>
Conflicts kept both sides: `guest` and `codeReview`, the outside-diff and
outdated labels together, `fetchFileContent`/`fileContents` with `fileOpenIn`,
#2640's readHead comment with hasCommit and fileContents, its key comment over
ReaderPart, the union of imports, and both e2e tests (main's first).

Co-Authored-By: Claude <[email protected]>
The push test leaves the Inbox's last read head on a commit the fake forge has
no file texts for, so the arrows' read found nothing after it.

Co-Authored-By: Claude <[email protected]>
@backnotprop
backnotprop marked this pull request as ready for review November 5, 2026 18:59
With the page as the scroller, every page scroll reached Pierre's CodeView as a
scroll of its own root, and Pierre turned its rows' pointer events off for
120 ms after each one. The Viewed and fold buttons on a file header stuck at
the top missed a click right after a scroll (inbox-code-review.spec.ts:883 at
scroll 216). Views that scroll with the page keep pointer events on.
@backnotprop
backnotprop merged commit 12a8085 into main Nov 6, 2026
81 of 86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Run the heavy CI tier on this PR (added by the merge script)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant