Conversation
Jumping to a file asks the review stream to align that file to the viewport top, and viewport-follow selection is held off while the jump settles. That hold-off was a 160ms wall clock, but the thing it has to outlive is a coalesced read of the scroll box: the pane only sees the align land one read interval later, and on a loaded machine that lag runs into the hundreds of milliseconds. When the timer lost that race the pane read its own align as user scrolling and adopted the hunk under the viewport center, silently reverting the selection. For a short trailing file -- which can only clamp at the bottom edge, leaving the previous file centered -- the selection snapped straight back to where the jump started, so the following "previous file" press had nowhere to go and did nothing at all. Hold viewport-follow selection off until the coalesced viewport read agrees the align has landed, so the two now key off the same signal instead of racing. Requests that need no scrolling no longer register as pending either; they used to stay pending until an unrelated relayout cleared them, which yanked the next manual scroll back to the file top. Measured on a 2-CPU Linux container under 4 spinning load generators, running the pager file-navigation PTY test 30 times: 18/30 failures before, 0/30 after.
The test raced two things at once. It waited 200ms of PTY idle before its first keypress, but the key handler is bound after the first paint, so on a slow start the "next file" press was dropped outright and the review stream never moved. Prove a key landed with ensureKeyboardIsLive instead, the way the rest of the PTY suite does. The assertions were also loose enough to pass without navigating. second.ts is the last file and too short to own the viewport top, so the only correct landing spot is the bottom of the stream; assert that exact position rather than just that second.ts is on screen somewhere, and assert the same for the trip back. Re-enabled now that the align race behind it is fixed. Verified on a 2-CPU Linux container under load: 50/50 green with 12 spinning load generators, and the full pager file green three times over. Closes #650
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryFixes file-jump alignment races in the review stream.
Confidence Score: 4/5The stale no-travel check should be fixed before merging because it leaves a reachable loaded-machine path that can still undo file navigation. The new pending guard addresses delayed viewport observations in the usual case, but its initial registration can be skipped when the coalesced snapshot says the target is settled while the live scroll box has already moved elsewhere. Files Needing Attention: src/ui/components/panes/DiffPane.tsx Important Files Changed
Sequence DiagramsequenceDiagram
participant N as File navigation
participant D as DiffPane align effect
participant S as Scroll box
participant V as Coalesced viewport
participant F as Viewport-follow selection
N->>D: Increment align request ID
D->>D: Decide whether align is pending
D->>S: scrollTo(file target)
S-->>V: Delayed viewport observation
V->>D: Settle pending alignment
D-->>F: Re-enable viewport-follow
Note over D,V: The pending decision must account for live scroll position when the viewport snapshot is stale
Prompt To Fix All With AI### Issue 1
src/ui/components/panes/DiffPane.tsx:1670-1673
**Stale snapshot skips pending alignment**
When the coalesced viewport still reports the target but the live scroll box has moved elsewhere, this check omits the pending state before reissuing the alignment. If the delayed viewport read arrives after the 160 ms suppression expires under load, viewport-follow treats the alignment as user scrolling and can revert the file or hunk selection.
```suggestion
const desiredTop = resolveFileTopAlignScrollTop(selectedFileId);
const liveScrollTop = scrollRef.current?.scrollTop ?? scrollViewport.top;
if (
desiredTop === null ||
!isFileTopAlignSettled(desiredTop) ||
Math.abs(liveScrollTop - desiredTop) > 0.5
) {
pendingFileTopAlignFileIdRef.current = selectedFileId;
}
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "test(pager): re-enable the pager file-na..." | Re-trigger Greptile |
Review flagged the skip as unsafe when the coalesced read and the live scroll top disagree. It is not, but the reason is an invariant that is easy to miss: skipping requires the coalesced read to already sit on the target, and the align that follows puts the live position on that same target synchronously, so the next coalesced read can only report the value viewport-follow selection last recorded. Verified against both an unclamped target and a clamped short trailing file -- the review stream never moves and the selection never reverts. Write the invariant down so it does not get re-litigated.
This was referenced Jul 31, 2026
1 task
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #650.
The flaky pager test turned out to be reporting a real bug, not racing one. Fixes the product race, then re-enables the test it was skipped behind.
What was broken
Jumping to a file (
./,, or a sidebar click) asks the review stream to align that file to the viewport top, and viewport-follow selection is held off while the jump settles. That hold-off was a 160 ms wall-clock timer, but what it has to outlive is a coalesced read of the scroll box — the pane only observes the align one read interval later, and under load that lag runs 300-470 ms.When the timer lost that race, the pane read its own align scroll as user scrolling and adopted the hunk under the viewport center, silently reverting the selection it had just made. A short trailing file makes this worst: it can only clamp at the bottom edge with the previous file still centered, so the selection snapped straight back to where the jump started and the next "previous file" press had nowhere to go — it did nothing at all.
That is what CI kept catching: not a slow render, but navigation genuinely losing the file it had just jumped to.
The fix
Gate viewport-follow selection on the same signal the align uses — the coalesced viewport read agreeing with the align target — instead of a timer. The two now key off one signal rather than racing.
Also stop registering no-travel align requests as pending. Those used to stay pending until an unrelated relayout cleared them, which yanked the next manual scroll back to the file top.
Reproduction
Never reproduced on macOS (0/10 in isolation, 0/10 under 32 background spinners). Reproduces on Linux under constrained CPU:
18/30 failures (60%), matching CI's 4-of-5 rate, with the same failure snapshot.
Measured stability
30 runs each, 2 CPUs, 4 spinners:
waitIdle(200)waitIdle(200)ensureKeyboardIsLiveensureKeyboardIsLiveAt 12 spinners: 50/50 green. Full
pager.test.tsgreen 3x under load; full./test/pty86/86 on Linux.Note the third row: the test's own startup race could mask the product bug, which is why both are fixed rather than either alone.
Test changes
Two separate problems, both addressed:
waitIdle({timeout: 200})before its first keypress, but the key handler is bound after first paint — on a slow start the.press was dropped outright. Now uses the harness'sensureKeyboardIsLive, like the rest of the PTY suite..leg only checked thatsecond.tswas on screen somewhere, which is true whether or not any alignment landed. Both legs now assert the exact landing position.The short trailing file is deliberately kept. Making it tall enough to align properly makes the test pass 50/50 even with the bug present — that fixture shape is precisely what exercises the race.
Deterministic coverage
ui-components.test.tsxgains a DiffPane case for the no-travel align path that does not depend on timing at all: it requests an align that needs no scrolling, then scrolls manually and asserts the scroll sticks. Red on pre-fix code (scrollTop7 → 0), green after. Verified independently by running it againstmain's DiffPane.Verification
bun run typecheck,bun run lint,bun run format:checkclean.bun run test:integrationon macOS: 74 pass / 12 fail, identical to a clean-worktree baseline (4 extensions, 1 file-views, 7 piped-stdin pager tests that time out on this machine); the previously-skipped test now passes.bun test ./src/ui/components/ui-components.test.tsx: 68/68../,navigation and post-jump manual scrolling behave correctly. (test:tty-smokeitself can't run on macOS — BSDscriptrejects-f, unrelated to this change.)