diff --git a/apps/web/src/components/pr-review/PrWorkspace.tsx b/apps/web/src/components/pr-review/PrWorkspace.tsx
index 27417f642..e071f0320 100644
--- a/apps/web/src/components/pr-review/PrWorkspace.tsx
+++ b/apps/web/src/components/pr-review/PrWorkspace.tsx
@@ -77,36 +77,42 @@ export function PrWorkspace({
[dashboard?.pullRequest.number, patch],
);
- if (!dashboard) {
- return (
-
- Select a pull request to load the review cockpit.
-
- );
- }
-
- const threadsByPath = dashboard.threads.reduce>(
- (acc, thread) => {
+ const threadsByPath = useMemo>(() => {
+ if (!dashboard) return {};
+ return dashboard.threads.reduce>((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 (
+
+ Select a pull request to load the review cockpit.
+
+ );
+ }
+
return (
{/* Compact header toolbar — single line */}