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
@@ -123,7 +102,7 @@ export function ReviewPage({ task }: ReviewPageProps) {
123102 < BranchReviewPage
124103 task = { task }
125104 branch = { linkedBranch as string }
126- repoInfo = { repoInfo ?? undefined }
105+ repoSlug = { repoSlug }
127106 defaultBranch = { defaultBranch }
128107 isReviewOpen = { isReviewOpen }
129108 effectiveSource = { effectiveSource }
@@ -216,7 +195,7 @@ export function ReviewPage({ task }: ReviewPageProps) {
216195function BranchReviewPage ( {
217196 task,
218197 branch,
219- repoInfo ,
198+ repoSlug ,
220199 defaultBranch,
221200 isReviewOpen,
222201 effectiveSource,
@@ -225,17 +204,14 @@ function BranchReviewPage({
225204} : {
226205 task : Task ;
227206 branch : string ;
228- repoInfo : { organization : string ; repository : string } | undefined ;
207+ repoSlug : string | null ;
229208 defaultBranch : string | null ;
230209 isReviewOpen : boolean ;
231210 effectiveSource : ResolvedDiffSource ;
232211 branchSourceAvailable : boolean ;
233212 prSourceAvailable : boolean ;
234213} ) {
235214 const taskId = task . id ;
236- const repoSlug = repoInfo
237- ? `${ repoInfo . organization } /${ repoInfo . repository } `
238- : null ;
239215
240216 const { data : files = EMPTY_BRANCH_FILES , isLoading } = useBranchChangedFiles (
241217 isReviewOpen ? repoSlug : null ,
0 commit comments