Skip to content

Commit 476410e

Browse files
perf(web): file breadcrumbs compile with the React Compiler
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 70d60e0 commit 476410e

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎apps/web/reactCompiledFiles.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ export const REACT_COMPILED_FILES = [
9696
"apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx",
9797
"apps/web/src/components/ThreadTerminalDrawer.tsx",
9898
"apps/web/src/components/settings/SettingsPanels.tsx",
99+
"apps/web/src/components/files/FileBreadcrumbs.tsx",
99100
] as const;

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { RefreshIcon } from "~/components/ui/refresh-icon";
22
import { Spinner } from "~/components/ui/spinner";
33
import type { EnvironmentId } from "@t3tools/contracts";
44
import { ArrowLeftIcon, ChevronRightIcon } from "lucide-react";
5-
import { useEffect, useMemo, useState } from "react";
5+
import { useState } from "react";
66

77
import { PierreEntryIcon } from "~/components/chat/PierreEntryIcon";
88
import {
@@ -94,10 +94,7 @@ function BreadcrumbMenuContent(props: {
9494
const { resolvedTheme } = useTheme();
9595
const entries = entriesQuery.data?.entries ?? [];
9696
const entriesTruncated = entriesQuery.data?.truncated ?? false;
97-
const children = useMemo(
98-
() => fileBreadcrumbChildren(entries, props.directoryPath),
99-
[entries, props.directoryPath],
100-
);
97+
const children = fileBreadcrumbChildren(entries, props.directoryPath);
10198
const directoryAvailable = entriesQuery.data !== null;
10299
const parentPath = fileBreadcrumbParent(props.directoryPath);
103100
const canGoBack =
@@ -222,11 +219,16 @@ function BreadcrumbMenuContent(props: {
222219
function FolderContentsMenu(props: FileBreadcrumbsProps & { readonly crumb: FileBreadcrumb }) {
223220
const [open, setOpen] = useState(false);
224221
const [directoryPath, setDirectoryPath] = useState(props.crumb.path);
225-
226-
useEffect(() => {
222+
// Opening another file or moving the crumb closes the menu and returns it to the crumb's folder.
223+
const [shownFor, setShownFor] = useState({
224+
crumbPath: props.crumb.path,
225+
relativePath: props.relativePath,
226+
});
227+
if (shownFor.crumbPath !== props.crumb.path || shownFor.relativePath !== props.relativePath) {
228+
setShownFor({ crumbPath: props.crumb.path, relativePath: props.relativePath });
227229
setOpen(false);
228230
setDirectoryPath(props.crumb.path);
229-
}, [props.crumb.path, props.relativePath]);
231+
}
230232

231233
const handleOpenChange = (nextOpen: boolean) => {
232234
setOpen(nextOpen);
@@ -299,10 +301,7 @@ function FolderBreadcrumb(props: {
299301
*/
300302
export function FileBreadcrumbs(props: FileBreadcrumbsProps) {
301303
const hostPath = isAbsolutePath(props.relativePath);
302-
const breadcrumbs = useMemo(
303-
() => fileBreadcrumbs(props.projectName, props.trail),
304-
[props.projectName, props.trail],
305-
);
304+
const breadcrumbs = fileBreadcrumbs(props.projectName, props.trail);
306305
const currentPath = breadcrumbPathOf(props.relativePath);
307306
const currentIndex = breadcrumbs.findIndex((crumb) => crumb.path === currentPath);
308307

0 commit comments

Comments
 (0)