GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): preserve PR review position across updates by juliusmarminge · Pull Request #22930 · pingdotgg/t3code

fix(web): preserve PR review position across updates #22930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
juliusmarminge wants to merge 13 commits into main
base: main
Loading
Loading
from fix/issue-22886
+873 −97
Open

fix(web): preserve PR review position across updates #22930

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
7012033
fix(web): preserve pull request code review position
juliusmarminge Oct 21, 2026
8ab69a5
fix(web): restore paginated PR review positions safely
juliusmarminge Oct 21, 2026
0dbd89a
fix(web): revalidate paginated PR diffs and settle scroll restoration
juliusmarminge Oct 21, 2026
4679d48
fix(web): honor PR review navigation during scroll restoration
juliusmarminge Oct 21, 2026
8786925
fix(web): keep pending PR position across refresh and find
juliusmarminge Oct 21, 2026
0a986b2
fix(web): scope PR restore cancellation to viewer input
juliusmarminge Oct 21, 2026
45032b2
Merge remote-tracking branch 'origin/main' into fix/issue-22886
juliusmarminge Oct 22, 2026
2b388c2
test(web): pass codeViewKey in the merged PR Code tab browser test
juliusmarminge Oct 22, 2026
8d5bc57
chore(web): add PR review restore evidence scripts
juliusmarminge Oct 22, 2026
a5566fc
Merge remote-tracking branch 'origin/main' into fix/issue-22886
juliusmarminge Nov 11, 2026
201ed64
style(web): format PR review restore changes
juliusmarminge Nov 11, 2026
55f056b
fix(web): keep an unfinished inline PR comment across panel switches
juliusmarminge Nov 11, 2026
5f48aa8
fix(web): PR refresh keeps selected lines and leaves the scroll alone
juliusmarminge Nov 11, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
fix(web): keep pending PR position across refresh and find
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@juliusmarminge
juliusmarminge committed Oct 21, 2026
commit 8786925e523e31c32091ab7fb0c6107cad95b3ef

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

22 changes: 14 additions & 8 deletions 22 apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,10 @@ function PullRequestCodeTab({
appliedRefreshToken.current = refreshToken;
const saved = readPullRequestCodeView(codeViewKey);
setScrollRestoration(
new PullRequestCodeScrollRestoration({
scrollTop: viewer?.getInstance()?.getScrollTop() ?? saved.scrollTop,
loadedPageCount: Math.max(loadedSlices.length, saved.loadedPageCount),
}),
scrollRestoration.restart(
viewer?.getInstance()?.getScrollTop() ?? saved.scrollTop,
Math.max(loadedSlices.length, saved.loadedPageCount),
),
);
// Numeric cursors do not identify content: an unchanged first page says nothing
// about later pages. Explicit refresh reloads the saved depth from page one.
Expand All @@ -459,6 +459,7 @@ function PullRequestCodeTab({
refreshFilesViewed();
}, [
refreshToken,
scrollRestoration,
refreshFilesViewed,
codeViewKey,
viewer,
Expand Down Expand Up @@ -1395,7 +1396,11 @@ function PullRequestCodeTab({
savePullRequestCodeScroll(current, instance.getScrollTop(), loadedSlices.length),
);
};
const stopObservingIntent = observePullRequestCodeScrollIntent(surface, cancel);
const stopObservingIntent = observePullRequestCodeScrollIntent(
surface,
cancel,
surface.ownerDocument,
);
restore();
return () => {
stopObserving();
Expand Down Expand Up @@ -1596,11 +1601,12 @@ function PullRequestCodeTab({
renderHeaderMetadata={renderHeaderMetadata}
renderAnnotation={renderAnnotation}
// Find can ask again before the unfolded file arrives, so this unfolds and never folds.
onRevealSearchMatch={(item) =>
onRevealSearchMatch={(item) => {
scrollRestoration.cancel();
setToggledFiles((current) =>
toggleFileDiffFoldForViewed(item.id, false, effectiveFoldOverride, current),
)
}
);
}}
unsafeCSSExtra={REPLACE_FILE_COUNTS_CSS}
/>
</FileViewedToggleContext>
Expand Down
19 changes: 18 additions & 1 deletion 19 apps/web/src/components/pullRequest/pullRequestCodeScroll.logic.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export class PullRequestCodeScrollRestoration {
this.pending = false;
}

restart(scrollTop: number, loadedPageCount: number) {
return new PullRequestCodeScrollRestoration({
scrollTop: this.pending ? this.saved.scrollTop : scrollTop,
loadedPageCount: Math.max(this.pending ? this.saved.loadedPageCount : 0, loadedPageCount),
});
}

restore(
surface: ScrollSurface | undefined,
loadedPageCount: number,
Expand Down Expand Up @@ -81,7 +88,15 @@ export function pullRequestCodeScrollSurface(
};
}

export function observePullRequestCodeScrollIntent(surface: EventTarget, cancel: () => void) {
export function observePullRequestCodeScrollIntent(
surface: EventTarget,
cancel: () => void,
keyboardTarget: EventTarget = surface,
) {
const cancelOnFind = (event: Event) => {
const key = event as KeyboardEvent;
if ((key.ctrlKey || key.metaKey) && key.key.toLowerCase() === "f") cancel();
};
const cancelOnKey = (event: Event) => {
if (
event instanceof KeyboardEvent &&
Expand All @@ -102,11 +117,13 @@ export function observePullRequestCodeScrollIntent(surface: EventTarget, cancel:
// Native scrollbar interactions can emit mouse events without a pointer event.
surface.addEventListener("mousedown", cancel, { capture: true });
surface.addEventListener("keydown", cancelOnKey);
keyboardTarget.addEventListener("keydown", cancelOnFind, { capture: true });
return () => {
surface.removeEventListener("wheel", cancel);
surface.removeEventListener("touchmove", cancel);
surface.removeEventListener("pointerdown", cancel, { capture: true });
surface.removeEventListener("mousedown", cancel, { capture: true });
surface.removeEventListener("keydown", cancelOnKey);
keyboardTarget.removeEventListener("keydown", cancelOnFind, { capture: true });
};
}
46 changes: 46 additions & 0 deletions 46 apps/web/src/components/pullRequest/pullRequestCodeViewState.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
isFileDiffCollapsed,
mergePullRequestDiffSlices,
restartPullRequestDiffPagination,
toggleFileDiffFoldForViewed,
type DiffSlice,
} from "./pullRequestDiff.logic";
import {
Expand Down Expand Up @@ -250,6 +251,51 @@ describe("pull request file keys", () => {
});

describe("pull request scroll restoration", () => {
it("keeps a pending target when refresh arrives before its saved pages", () => {
const initial = new PullRequestCodeScrollRestoration({ scrollTop: 1800, loadedPageCount: 3 });
const surface = { scrollTop: 0, scrollHeight: 600, clientHeight: 400 };
expect(initial.restore(surface, 1, true)).toBe("load-more");
const refreshed = initial.restart(surface.scrollTop, 1);
expect(refreshed.restore(surface, 1, true)).toBe("load-more");
surface.scrollHeight = 3000;
expect(refreshed.restore(surface, 3, false)).toBe("restored");
expect(surface.scrollTop).toBe(1800);
surface.scrollTop = 2000;
const later = refreshed.restart(surface.scrollTop, 3);
surface.scrollTop = 0;
expect(later.restore(surface, 3, false)).toBe("restored");
expect(surface.scrollTop).toBe(2000);
});

it.each(["expanded", "folded"] as const)(
"keeps a keyboard Find match in a %s file when saved pages arrive",
(foldOverride) => {
const restore = new PullRequestCodeScrollRestoration({ scrollTop: 1800, loadedPageCount: 3 });
const surface = Object.assign(new EventTarget(), {
scrollTop: 0,
scrollHeight: 600,
clientHeight: 400,
});
const keyboardTarget = new EventTarget();
const stop = observePullRequestCodeScrollIntent(
surface,
() => restore.cancel(),
keyboardTarget,
);
expect(restore.restore(surface, 1, true)).toBe("load-more");
keyboardTarget.dispatchEvent(
Object.assign(new Event("keydown"), { key: "f", ctrlKey: true }),
);
const toggled = toggleFileDiffFoldForViewed("match", false, foldOverride, new Set());
expect(isFileDiffCollapsed("match", foldOverride, toggled)).toBe(false);
surface.scrollTop = 120;
surface.scrollHeight = 3000;
expect(restore.restore(surface, 3, false)).toBe("waiting");
expect(surface.scrollTop).toBe(120);
stop();
},
);

it.each([570, 20_000_000, 29_999_590])(
"restores logical offset %s without sticky drift or physical window clamping",
(savedTop) => {
Expand Down
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.
You are visitor 01402809 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.