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
42 changes: 24 additions & 18 deletions apps/web/src/components/pr-review/PrWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,36 +77,42 @@ export function PrWorkspace({
[dashboard?.pullRequest.number, patch],
);

if (!dashboard) {
return (
<div className="flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground">
Select a pull request to load the review cockpit.
</div>
);
}

const threadsByPath = dashboard.threads.reduce<Record<string, PrReviewThread[]>>(
(acc, thread) => {
const threadsByPath = useMemo<Record<string, PrReviewThread[]>>(() => {
if (!dashboard) return {};
return dashboard.threads.reduce<Record<string, PrReviewThread[]>>((acc, thread) => {
if (!thread.path) return acc;
if (!acc[thread.path]) acc[thread.path] = [];
acc[thread.path]!.push(thread);
return acc;
},
{},
}, {});
}, [dashboard]);

const patchFiles = useMemo(
() => (renderablePatch?.kind === "files" ? renderablePatch.files : []),
[renderablePatch],
);

const patchFiles = renderablePatch?.kind === "files" ? renderablePatch.files : [];
const visibleFiles = useMemo(
() =>
fileViewMode === "single" && selectedFilePath
? patchFiles.filter((file) => resolveFileDiffPath(file) === selectedFilePath)
: patchFiles,
[fileViewMode, patchFiles, selectedFilePath],
);

// In single-file mode, filter to just the selected file
const visibleFiles =
fileViewMode === "single" && selectedFilePath
? patchFiles.filter((f) => resolveFileDiffPath(f) === selectedFilePath)
: patchFiles;
const renderedFiles = useMemo(
() => visibleFiles.map(withInferredFileDiffLanguage),
[visibleFiles],
);

if (!dashboard) {
return (
<div className="flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground">
Select a pull request to load the review cockpit.
</div>
);
}

return (
<div className="flex min-h-0 min-w-0 flex-1 flex-col bg-[radial-gradient(circle_at_top,_color-mix(in_srgb,var(--background)_86%,var(--foreground))_0%,transparent_54%)]">
{/* Compact header toolbar — single line */}
Expand Down
Loading