Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { useDiffViewerStore } from "@features/code-editor/stores/diffViewerStore";
import {
useBranchChangedFiles,
usePrChangedFiles,
} from "@features/git-interaction/hooks/useGitQueries";
import { usePrDetails } from "@features/git-interaction/hooks/usePrDetails";
import { makeFileKey } from "@features/git-interaction/utils/fileKey";
import { usePanelLayoutStore } from "@features/panels/store/panelLayoutStore";
import { useCwd } from "@features/sidebar/hooks/useCwd";
Expand All @@ -15,6 +17,7 @@ import { useMemo } from "react";
import { useEffectiveDiffSource } from "../hooks/useEffectiveDiffSource";
import { useReviewDiffs } from "../hooks/useReviewDiffs";
import type { DiffOptions } from "../types";
import type { PrCommentThread } from "../utils/prCommentAnnotations";
import type { ResolvedDiffSource } from "../utils/resolveDiffSource";
import { InteractiveFileDiff } from "./InteractiveFileDiff";
import { LazyDiff } from "./LazyDiff";
Expand Down Expand Up @@ -54,6 +57,14 @@ export function ReviewPage({ task }: ReviewPageProps) {
prSourceAvailable,
} = useEffectiveDiffSource(taskId);

const showReviewComments = useDiffViewerStore((s) => s.showReviewComments);
const { commentThreads } = usePrDetails(prUrl, {
includeComments: isReviewOpen && showReviewComments,
});
const effectiveCommentThreads = showReviewComments
? commentThreads
: undefined;

const isLocalActive = isReviewOpen && effectiveSource === "local";

const {
Expand Down Expand Up @@ -108,6 +119,8 @@ export function ReviewPage({ task }: ReviewPageProps) {
effectiveSource={effectiveSource}
branchSourceAvailable={branchSourceAvailable}
prSourceAvailable={prSourceAvailable}
prUrl={prUrl}
commentThreads={effectiveCommentThreads}
/>
);
}
Expand All @@ -122,6 +135,7 @@ export function ReviewPage({ task }: ReviewPageProps) {
effectiveSource={effectiveSource}
branchSourceAvailable={branchSourceAvailable}
prSourceAvailable={prSourceAvailable}
commentThreads={effectiveCommentThreads}
/>
);
}
Expand All @@ -135,6 +149,8 @@ export function ReviewPage({ task }: ReviewPageProps) {
revealFile,
getDeferredReason,
openFile,
prUrl,
commentThreads: effectiveCommentThreads,
};

return (
Expand Down Expand Up @@ -201,6 +217,8 @@ function BranchReviewPage({
effectiveSource,
branchSourceAvailable,
prSourceAvailable,
prUrl,
commentThreads,
}: {
task: Task;
branch: string;
Expand All @@ -210,6 +228,8 @@ function BranchReviewPage({
effectiveSource: ResolvedDiffSource;
branchSourceAvailable: boolean;
prSourceAvailable: boolean;
prUrl: string | null;
commentThreads?: Map<number, PrCommentThread>;
}) {
const taskId = task.id;

Expand Down Expand Up @@ -244,11 +264,13 @@ function BranchReviewPage({
<RemoteDiffList
files={files}
taskId={taskId}
prUrl={prUrl}
options={reviewState.diffOptions}
collapsedFiles={reviewState.collapsedFiles}
toggleFile={reviewState.toggleFile}
revealFile={reviewState.revealFile}
getDeferredReason={reviewState.getDeferredReason}
commentThreads={commentThreads}
/>
</ReviewShell>
);
Expand All @@ -262,6 +284,7 @@ function PrReviewPage({
effectiveSource,
branchSourceAvailable,
prSourceAvailable,
commentThreads,
}: {
task: Task;
prUrl: string;
Expand All @@ -270,6 +293,7 @@ function PrReviewPage({
effectiveSource: ResolvedDiffSource;
branchSourceAvailable: boolean;
prSourceAvailable: boolean;
commentThreads?: Map<number, PrCommentThread>;
}) {
const taskId = task.id;

Expand Down Expand Up @@ -307,6 +331,7 @@ function PrReviewPage({
toggleFile={reviewState.toggleFile}
revealFile={reviewState.revealFile}
getDeferredReason={reviewState.getDeferredReason}
commentThreads={commentThreads}
/>
</ReviewShell>
);
Expand Down Expand Up @@ -334,6 +359,8 @@ interface FileDiffListProps {
revealFile: (key: string) => void;
getDeferredReason: (key: string) => DeferredReason | null;
openFile: (taskId: string, path: string, preview: boolean) => void;
prUrl: string | null;
commentThreads?: Map<number, PrCommentThread>;
}

function FileDiffList({
Expand All @@ -348,6 +375,8 @@ function FileDiffList({
revealFile,
getDeferredReason,
openFile,
prUrl,
commentThreads,
}: FileDiffListProps) {
return files.map((fileDiff) => {
const filePath = fileDiff.name ?? fileDiff.prevName ?? "";
Expand Down Expand Up @@ -382,6 +411,8 @@ function FileDiffList({
skipExpansion={skipExpansion}
options={{ ...diffOptions, collapsed: isCollapsed }}
taskId={taskId}
prUrl={prUrl}
commentThreads={commentThreads}
renderCustomHeader={(fd) => (
<DiffFileHeader
fileDiff={fd}
Expand Down
Loading