Skip to content

Commit b0debac

Browse files
perf(web): the project file picker compiles without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a702563 commit b0debac

1 file changed

Lines changed: 25 additions & 32 deletions

File tree

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

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useAtomValue } from "@effect/atom-react";
2-
import { useMemo, useState, type ReactNode } from "react";
2+
import { useState, type ReactNode } from "react";
33

44
import { useActiveProjectTarget, type ActiveProjectTarget } from "~/hooks/useActiveProjectTarget";
55
import { useTheme } from "~/hooks/useTheme";
@@ -80,38 +80,31 @@ function OpenProjectFilePicker(props: ProjectFilePickerProps & { target: ActiveP
8080
);
8181
const { resolvedTheme } = useTheme();
8282
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
83-
const matches = useMemo(
84-
() => getProjectFilePickerMatches(result.entries, result.matchedQuery),
85-
[result.entries, result.matchedQuery],
86-
);
83+
const matches = getProjectFilePickerMatches(result.entries, result.matchedQuery);
8784
const hasMatchedQuery = /\S/.test(result.matchedQuery);
88-
const items = useMemo<CommandPaletteActionItem[]>(
89-
() =>
90-
matches.map((match) => ({
91-
kind: "action",
92-
value: `file:${match.path}`,
93-
searchTerms: [match.name, match.path],
94-
title: (
95-
<HighlightedFuzzyText
96-
active={hasMatchedQuery}
97-
value={match.name}
98-
indices={match.nameMatchIndices}
99-
/>
100-
),
101-
description: (
102-
<HighlightedFuzzyText
103-
active={hasMatchedQuery}
104-
value={match.path}
105-
indices={match.pathMatchIndices}
106-
/>
107-
),
108-
icon: <PierreEntryIcon pathValue={match.path} kind="file" theme={resolvedTheme} />,
109-
run: async () => {
110-
useRightPanelStore.getState().openFile(target.threadRef, match.path);
111-
},
112-
})),
113-
[hasMatchedQuery, matches, resolvedTheme, target.threadRef],
114-
);
85+
const items: CommandPaletteActionItem[] = matches.map((match) => ({
86+
kind: "action",
87+
value: `file:${match.path}`,
88+
searchTerms: [match.name, match.path],
89+
title: (
90+
<HighlightedFuzzyText
91+
active={hasMatchedQuery}
92+
value={match.name}
93+
indices={match.nameMatchIndices}
94+
/>
95+
),
96+
description: (
97+
<HighlightedFuzzyText
98+
active={hasMatchedQuery}
99+
value={match.path}
100+
indices={match.pathMatchIndices}
101+
/>
102+
),
103+
icon: <PierreEntryIcon pathValue={match.path} kind="file" theme={resolvedTheme} />,
104+
run: async () => {
105+
useRightPanelStore.getState().openFile(target.threadRef, match.path);
106+
},
107+
}));
115108

116109
const emptyStateMessage = getEmptyStateMessage(query, result.error, result.isPending);
117110

0 commit comments

Comments
 (0)