@devries-cameron20 / t3code Mirror · read-only / commits / 073a20ad19
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 01:45 UTC

fix(web): PR code view keeps its scroll when a turn finishes (#13835)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Sameer Rangwala committed Oct 20, 2026 at 01:54 UTC 073a20ad19570b01c96dde51d03fddbd278ce830
2 files changed +14 -3
apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
+12 -1
@@ -252,6 +252,7 @@ function PullRequestCodeTab({
252 onAddToAgentSelection,
253 onRefresh,
254 refreshToken = 0,
255 + backgroundRefreshToken = 0,
256 revealRequest = null,
257 }: {
258 scrollerRef: (node: HTMLDivElement | null) => void;
@@ -266,6 +267,7 @@ function PullRequestCodeTab({
267 onAddToAgentSelection?: (input: PullRequestAgentSelectionInput) => void;
268 onRefresh: () => void;
269 refreshToken?: number;
270 + backgroundRefreshToken?: number;
271 revealRequest?: { readonly path: string; readonly nonce: number } | null;
272 }) {
273 const { resolvedTheme } = useTheme();
@@ -308,7 +310,7 @@ function PullRequestCodeTab({
310
311 const referenceKey = pullRequestReviewKey(reference);
312 const commit = selectedCommitOid;
311 - const scopeKey = commit === null ? referenceKey : `${referenceKey}@${commit}`;
313 + const scopeKey = JSON.stringify([environmentId, referenceKey, commit]);
314 // The panel keeps this mounted across pull requests, so an open composer would otherwise
315 // survive the switch and attach its comment to whichever one is on screen when it is sent.
316 const [stateScopeKey, setStateScopeKey] = useState(scopeKey);
@@ -432,6 +434,15 @@ function PullRequestCodeTab({
434 refreshFirstDiffPage();
435 refreshFilesViewed();
436 }, [refreshToken, scopeKey, refreshFirstDiffPage, refreshFilesViewed]);
437 + const appliedBackgroundRefreshToken = useRef(backgroundRefreshToken);
438 + useEffect(() => {
439 + if (appliedBackgroundRefreshToken.current === backgroundRefreshToken) return;
440 + appliedBackgroundRefreshToken.current = backgroundRefreshToken;
441 + // Keeping slices mounted preserves scroll; the page merge invalidates changed pages.
442 + setSliceState((previous) => ({ ...previous, cursor: null }));
443 + refreshFirstDiffPage();
444 + refreshFilesViewed();
445 + }, [backgroundRefreshToken, refreshFirstDiffPage, refreshFilesViewed]);
446
447 // The sentinel is held as state rather than a ref because the viewer mounts its own footer:
448 // an effect reading a ref could run before that node exists and would never arm the observer.
apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+2 -2
@@ -831,7 +831,6 @@ export function PullRequestDetailPanel({
831 nativeStackQuery.refresh();
832 };
833 const [refreshToken, setRefreshToken] = useState(0);
834 - const codeRefreshToken = refreshToken + (turnRefresh ?? 0);
834 const [activityRevision, setActivityRevision] = useState<{
835 readonly key: string;
836 readonly updatedAt: string;
@@ -2878,7 +2877,8 @@ export function PullRequestDetailPanel({
2877 fixFindingLabel={handoffLabels.fixFinding}
2878 {...(canFixFindings ? { onFixFinding: startFixFinding } : {})}
2879 onRefresh={refreshDetail}
2881 - refreshToken={codeRefreshToken}
2880 + refreshToken={refreshToken}
2881 + backgroundRefreshToken={turnRefresh ?? 0}
2882 revealRequest={codeRevealRequest}
2883 />
2884 </Suspense>