Skip to content

Commit a70f796

Browse files
committed
fix(review): remount DiffViewer on mode switch to invalidate stale content
Switching between Branch diff and PR Diff for the same file and base didn't trigger a file-content refetch — the useEffect deps (filePath, oldPath, reviewBase) were all unchanged. But the two modes compute different "old" content (base tip vs merge-base ancestor), so Pierre could mismatch or show wrong expansion context. Fix: expose activeDiffBase through ReviewState and include it in the ReviewDiffPanel key. Mode changes now remount DiffViewer, which clears the cached content and fetches fresh. Same trade-off as the existing reviewBase-keyed remount (scroll position resets on mode switch). For provenance purposes, this commit was AI assisted.
1 parent ca11628 commit a70f796

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

packages/review-editor/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,7 @@ const ReviewApp: React.FC = () => {
11281128
(activeDiffBase === 'branch' || activeDiffBase === 'merge-base')
11291129
? committedBase ?? undefined
11301130
: undefined,
1131+
activeDiffBase,
11311132
feedbackDiffContext,
11321133
allAnnotations,
11331134
externalAnnotations,

packages/review-editor/dock/ReviewStateContext.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export interface ReviewState {
2929
fontSize?: string;
3030
/** User-selected base branch; feeds the `base` query param on file-content fetches. */
3131
reviewBase?: string;
32+
/** Active diff mode (e.g. "branch", "merge-base", "uncommitted"). Used as
33+
* part of the DiffViewer remount key so mode switches invalidate cached
34+
* file content — branch and merge-base compute different "old" sides. */
35+
activeDiffBase?: string;
3236
/** Diff context baked into exported feedback so downstream panels (agent job
3337
* detail, etc.) produce the same markdown the main feedback path sends. */
3438
feedbackDiffContext?: FeedbackDiffContext;

packages/review-editor/dock/panels/ReviewDiffPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const ReviewDiffPanel: React.FC<IDockviewPanelProps> = (props) => {
5656
// patch, and Pierre briefly reconciles old-patch + new-content → "trailing
5757
// context mismatch" warnings in the console.
5858
return (
59-
<div key={`${file.path}:${state.reviewBase ?? ''}`} className="h-full relative">
59+
<div key={`${file.path}:${state.reviewBase ?? ''}:${state.activeDiffBase ?? ''}`} className="h-full relative">
6060
<DiffViewer
6161
patch={file.patch}
6262
filePath={file.path}

0 commit comments

Comments
 (0)