1- import { useDiffViewerStore } from "@features/code-editor/stores/diffViewerStore" ;
21import {
32 useBranchChangedFiles ,
4- useGitQueries ,
53 usePrChangedFiles ,
64} from "@features/git-interaction/hooks/useGitQueries" ;
7- import { useLinkedBranchPrUrl } from "@features/git-interaction/hooks/useLinkedBranchPrUrl" ;
85import { makeFileKey } from "@features/git-interaction/utils/fileKey" ;
96import { usePanelLayoutStore } from "@features/panels/store/panelLayoutStore" ;
107import { useCwd } from "@features/sidebar/hooks/useCwd" ;
11- import { useWorkspace } from "@features/workspace/hooks/useWorkspace" ;
128import type { parsePatchFiles } from "@pierre/diffs" ;
139import { Flex , Text } from "@radix-ui/themes" ;
1410import { useReviewNavigationStore } from "@renderer/features/code-review/stores/reviewNavigationStore" ;
1511import { useTRPC } from "@renderer/trpc/client" ;
1612import type { ChangedFile , Task } from "@shared/types" ;
1713import { useQuery } from "@tanstack/react-query" ;
1814import { useMemo } from "react" ;
15+ import { useEffectiveDiffSource } from "../hooks/useEffectiveDiffSource" ;
1916import { useReviewDiffs } from "../hooks/useReviewDiffs" ;
2017import type { DiffOptions } from "../types" ;
21- import {
22- type ResolvedDiffSource ,
23- resolveDiffSource ,
24- } from "../utils/resolveDiffSource" ;
18+ import type { ResolvedDiffSource } from "../utils/resolveDiffSource" ;
2519import { InteractiveFileDiff } from "./InteractiveFileDiff" ;
2620import { LazyDiff } from "./LazyDiff" ;
2721import { RemoteDiffList } from "./RemoteDiffList" ;
@@ -44,36 +38,21 @@ interface ReviewPageProps {
4438export function ReviewPage ( { task } : ReviewPageProps ) {
4539 const taskId = task . id ;
4640 const repoPath = useCwd ( taskId ) ;
47- const workspace = useWorkspace ( taskId ) ;
48- const linkedBranch = workspace ?. linkedBranch ?? null ;
4941 const openFile = usePanelLayoutStore ( ( s ) => s . openFile ) ;
5042
5143 const isReviewOpen = useReviewNavigationStore (
5244 ( s ) => ( s . reviewModes [ taskId ] ?? "closed" ) !== "closed" ,
5345 ) ;
5446
55- const configuredSource = useDiffViewerStore (
56- ( s ) => s . diffSource [ taskId ] ?? null ,
57- ) ;
58-
5947 const {
60- repoInfo,
61- aheadOfDefault,
62- defaultBranch,
63- changedFiles : workspaceFiles ,
64- } = useGitQueries ( repoPath ) ;
65- const prUrl = useLinkedBranchPrUrl ( taskId ) ;
66- const hasLocalChanges = workspaceFiles . length > 0 ;
67- const branchSourceAvailable = ! ! linkedBranch && aheadOfDefault > 0 ;
68- const prSourceAvailable = ! ! prUrl ;
69-
70- const effectiveSource = resolveDiffSource ( {
71- configured : configuredSource ,
72- hasLocalChanges,
48+ effectiveSource,
49+ prUrl,
7350 linkedBranch,
74- aheadOfDefault,
51+ defaultBranch,
52+ repoSlug,
53+ branchSourceAvailable,
7554 prSourceAvailable,
76- } ) ;
55+ } = useEffectiveDiffSource ( taskId ) ;
7756
7857 const isLocalActive = isReviewOpen && effectiveSource === "local" ;
7958
@@ -118,7 +97,7 @@ export function ReviewPage({ task }: ReviewPageProps) {
11897 < BranchReviewPage
11998 task = { task }
12099 branch = { linkedBranch as string }
121- repoInfo = { repoInfo ?? undefined }
100+ repoSlug = { repoSlug }
122101 defaultBranch = { defaultBranch }
123102 isReviewOpen = { isReviewOpen }
124103 effectiveSource = { effectiveSource }
@@ -207,7 +186,7 @@ export function ReviewPage({ task }: ReviewPageProps) {
207186function BranchReviewPage ( {
208187 task,
209188 branch,
210- repoInfo ,
189+ repoSlug ,
211190 defaultBranch,
212191 isReviewOpen,
213192 effectiveSource,
@@ -216,17 +195,14 @@ function BranchReviewPage({
216195} : {
217196 task : Task ;
218197 branch : string ;
219- repoInfo : { organization : string ; repository : string } | undefined ;
198+ repoSlug : string | null ;
220199 defaultBranch : string | null ;
221200 isReviewOpen : boolean ;
222201 effectiveSource : ResolvedDiffSource ;
223202 branchSourceAvailable : boolean ;
224203 prSourceAvailable : boolean ;
225204} ) {
226205 const taskId = task . id ;
227- const repoSlug = repoInfo
228- ? `${ repoInfo . organization } /${ repoInfo . repository } `
229- : null ;
230206
231207 const { data : files = EMPTY_BRANCH_FILES , isLoading } = useBranchChangedFiles (
232208 isReviewOpen ? repoSlug : null ,
0 commit comments