Skip to content

Commit 4cbf532

Browse files
committed
fix(code-review): refresh branch/PR review diff on code updates
Generated-By: PostHog Code Task-Id: 6fa58d62-11d1-4326-aada-39af904ddb51
1 parent 915b2dd commit 4cbf532

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

packages/ui/src/features/code-review/components/ReviewPage.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,13 +428,23 @@ function RemoteReviewPage({
428428
const taskId = task.id;
429429
const isBranch = effectiveSource === "branch";
430430

431-
const { data: branchFiles = EMPTY_CHANGED_FILES, isLoading: branchLoading } =
432-
useLocalBranchChangedFiles(
433-
isBranch && isReviewOpen ? repoPath : null,
434-
isBranch && isReviewOpen ? branch : null,
435-
);
436-
const { data: prFiles = EMPTY_CHANGED_FILES, isLoading: prLoading } =
437-
usePrChangedFiles(!isBranch && isReviewOpen ? prUrl : null);
431+
const {
432+
data: branchFiles = EMPTY_CHANGED_FILES,
433+
isLoading: branchLoading,
434+
refetch: refetchBranch,
435+
} = useLocalBranchChangedFiles(
436+
isBranch && isReviewOpen ? repoPath : null,
437+
isBranch && isReviewOpen ? branch : null,
438+
);
439+
const {
440+
data: prFiles = EMPTY_CHANGED_FILES,
441+
isLoading: prLoading,
442+
refetch: refetchPr,
443+
} = usePrChangedFiles(!isBranch && isReviewOpen ? prUrl : null);
444+
445+
const onRefresh = useCallback(() => {
446+
void (isBranch ? refetchBranch() : refetchPr());
447+
}, [isBranch, refetchBranch, refetchPr]);
438448

439449
const files = isBranch ? branchFiles : prFiles;
440450
const isLoading = isBranch
@@ -479,6 +489,7 @@ function RemoteReviewPage({
479489
onExpandAll={reviewState.expandAll}
480490
onCollapseAll={reviewState.collapseAll}
481491
onUncollapseFile={reviewState.uncollapseFile}
492+
onRefresh={onRefresh}
482493
effectiveSource={effectiveSource}
483494
branchSourceAvailable={branchSourceAvailable}
484495
prSourceAvailable={prSourceAvailable}

packages/ui/src/features/git-interaction/gitCacheKeys.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export function invalidateGitBranchQueries(repoPath: string) {
5252
queryClient.invalidateQueries(
5353
provider.gitPathFilter("getLocalBranchChangedFiles"),
5454
);
55+
queryClient.invalidateQueries(provider.gitPathFilter("getPrChangedFiles"));
56+
queryClient.invalidateQueries(
57+
provider.gitPathFilter("getBranchChangedFiles"),
58+
);
5559
}
5660

5761
export function clearGitReviewQueries() {

0 commit comments

Comments
 (0)