Skip to content

Commit 34e3f7d

Browse files
committed
fix(review): preserve React Compiler rendering patterns
1 parent bbed4aa commit 34e3f7d

17 files changed

Lines changed: 323 additions & 494 deletions

‎apps/server/src/review/ReviewService.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as ServerSettings from "../serverSettings.ts";
2-
import * as ProjectStore from "../orchestration-v2/ProjectStore.ts";
31
import * as Context from "effect/Context";
42
import * as DateTime from "effect/DateTime";
53
import * as Effect from "effect/Effect";
@@ -61,8 +59,6 @@ export const make = Effect.gen(function* () {
6159
const git = yield* GitVcsDriver.GitVcsDriver;
6260
const knownWorkspaces = yield* KnownWorkspaces.KnownWorkspaces;
6361
const workflow = yield* GitWorkflowService.GitWorkflowService;
64-
const settings = yield* ServerSettings.ServerSettingsService;
65-
const projectStore = yield* ProjectStore.ProjectStoreV2;
6662

6763
const canonicalizePath = (value: string) => {
6864
const resolvedPath = path.resolve(value);

‎apps/web/src/components/DiffPanel.tsx‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useCallback, useMemo } from "react";
21
import { RefreshIcon } from "~/components/ui/refresh-icon";
32
import { useAtomValue } from "@effect/atom-react";
43
import type { FileDiffContentsLoader, FileDiffMetadata } from "@pierre/diffs";
@@ -365,10 +364,10 @@ export default function DiffPanel({
365364
);
366365
const refreshPreviewQuery = branchDiffPreview.refresh;
367366
const [workingRefresh, setWorkingRefresh] = useState(0);
368-
const refreshDiffFromUserAction = useCallback(() => {
367+
const refreshDiffFromUserAction = () => {
369368
setWorkingRefresh((value) => value + 1);
370369
refreshPreviewQuery();
371-
}, [refreshPreviewQuery]);
370+
};
372371

373372
const preview = branchDiffPreview.data;
374373
const gitDiff = selectedGitSource?.diff;
@@ -488,12 +487,8 @@ export default function DiffPanel({
488487
: undefined,
489488
preview: renderablePatch,
490489
});
491-
const renderableFiles = useMemo(
492-
() =>
493-
unorderedFiles.toSorted((left, right) =>
490+
const renderableFiles = unorderedFiles.toSorted((left, right) =>
494491
compareReviewFilePaths(resolveFileDiffPath(left), resolveFileDiffPath(right)),
495-
),
496-
[unorderedFiles],
497492
);
498493
const refreshBranchDiffPreview = refreshDiffFromUserAction;
499494
const previewOpenHandledRef = useRef(false);

‎apps/web/src/components/diffs/AnnotatableCodeView.tsx‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
} from "@pierre/diffs";
99
import type { CodeViewHandle } from "@pierre/diffs/react";
1010
import type { ScopedThreadRef } from "@t3tools/contracts";
11-
import { useCallback, useEffect, useMemo, useState, type ReactNode, type Ref } from "react";
11+
import { useEffect, useState, type ReactNode, type Ref } from "react";
1212

1313
import { type DraftId, useComposerDraftStore } from "~/composerDraftStore";
1414
import { fnv1a32, resolveFileDiffPath, resolveFileDiffPreviousPath } from "~/lib/diffRendering";
@@ -202,8 +202,7 @@ export function AnnotatableCodeView({
202202
setDraftText("");
203203
setSelectedLines(null);
204204
}
205-
const items = useMemo<CodeViewDiffItem<DiffCommentAnnotationGroup>[]>(
206-
() =>
205+
const items = ((): CodeViewDiffItem<DiffCommentAnnotationGroup>[] =>
207206
files.map(({ fileDiff, filePath, fileKey, fileVersion, collapsed }) => {
208207
const persisted = reviewComments
209208
.filter(
@@ -223,8 +222,7 @@ export function AnnotatableCodeView({
223222
text: comment.text,
224223
});
225224
}, []);
226-
const annotations =
227-
draft?.fileKey === fileKey ? [...persisted, draft.annotation] : persisted;
225+
const annotations = draft?.fileKey === fileKey ? [...persisted, draft.annotation] : persisted;
228226
if (renderHunkAction) {
229227
fileDiff.hunks.forEach((hunk, hunkIndex) => {
230228
const change = hunk.hunkContent.findLast((content) => content.type === "change");
@@ -263,9 +261,7 @@ export function AnnotatableCodeView({
263261
.join(":")}`,
264262
),
265263
};
266-
}),
267-
[draft, files, reviewComments, sectionId, renderHunkAction],
268-
);
264+
}))();
269265

270266
const removeEntry = (entryId: string) => {
271267
setSelectedLines(null);

‎apps/web/src/components/diffs/useCodeViewFileReveal.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useCallback } from "react";
21
import type { CodeViewScrollTarget } from "@pierre/diffs";
32
import { useEffect, useRef, useState } from "react";
43

@@ -32,9 +31,6 @@ export function useCodeViewFileReveal<TScope>(
3231
handledRequest.current = request;
3332
}, [request, scope, viewer, readyFileKeys]);
3433

35-
return useCallback(
36-
(fileKey: string, target?: CodeViewScrollTarget) =>
37-
setRequest({ fileKey, scope, ...(target ? { target } : {}) }),
38-
[scope],
39-
);
34+
return (fileKey: string, target?: CodeViewScrollTarget) =>
35+
setRequest({ fileKey, scope, ...(target ? { target } : {}) });
4036
}

‎apps/web/src/components/files/FileBrowserPanel.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger";
1313
import * as AsyncResult from "effect/reactivity/AsyncResult";
1414
import * as Cause from "effect/Cause";
1515
import { ChevronsDownUp, ChevronsUpDown } from "lucide";
16-
import { useEffect, useMemo, useRef, useState } from "react";
16+
import { useEffect, useRef, useState } from "react";
1717

1818
import { Button } from "~/components/ui/button";
1919
import { InputGroup, InputGroupInput } from "~/components/ui/input-group";
@@ -158,7 +158,7 @@ export default function FileBrowserPanel({
158158
const panelPath = (relativePath: string) =>
159159
hostFolder ? joinHostPath(cwd, relativePath) : relativePath;
160160
const { resolvedTheme } = useTheme();
161-
const selectionCSS = useMemo(() => {
161+
const selectionCSS = (() => {
162162
if (!selectedPath) return PIERRE_TREE_UNSAFE_CSS;
163163
const path = selectedPath.replace(/\/$/, "");
164164
return `${PIERRE_TREE_UNSAFE_CSS}
@@ -173,7 +173,7 @@ export default function FileBrowserPanel({
173173
border-radius: var(--radius-md);
174174
}
175175
`;
176-
}, [selectedPath]);
176+
})();
177177
const composerRef = useComposerHandleContext();
178178
const fileContextMenu = useFileContextMenu(environmentId);
179179
const {

‎apps/web/src/components/pullRequest/PullRequestAttachments.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export function PullRequestAttachments({
4848
transfer.current.abort?.();
4949
}
5050
},
51+
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- A new PR or environment must cancel the previous upload.
5152
[environmentId, reference.projectId, reference.repository, reference.host, reference.number],
5253
);
5354
const canAttach =

0 commit comments

Comments
 (0)