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
57 changes: 25 additions & 32 deletions apps/web/src/components/files/ProjectFilePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useAtomValue } from "@effect/atom-react";
import { useMemo, useState, type ReactNode } from "react";
import { useState, type ReactNode } from "react";

import { useActiveProjectTarget, type ActiveProjectTarget } from "~/hooks/useActiveProjectTarget";
import { useTheme } from "~/hooks/useTheme";
Expand Down Expand Up @@ -80,38 +80,31 @@ function OpenProjectFilePicker(props: ProjectFilePickerProps & { target: ActiveP
);
const { resolvedTheme } = useTheme();
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
const matches = useMemo(
() => getProjectFilePickerMatches(result.entries, result.matchedQuery),
[result.entries, result.matchedQuery],
);
const matches = getProjectFilePickerMatches(result.entries, result.matchedQuery);
const hasMatchedQuery = /\S/.test(result.matchedQuery);
const items = useMemo<CommandPaletteActionItem[]>(
() =>
matches.map((match) => ({
kind: "action",
value: `file:${match.path}`,
searchTerms: [match.name, match.path],
title: (
<HighlightedFuzzyText
active={hasMatchedQuery}
value={match.name}
indices={match.nameMatchIndices}
/>
),
description: (
<HighlightedFuzzyText
active={hasMatchedQuery}
value={match.path}
indices={match.pathMatchIndices}
/>
),
icon: <PierreEntryIcon pathValue={match.path} kind="file" theme={resolvedTheme} />,
run: async () => {
useRightPanelStore.getState().openFile(target.threadRef, match.path);
},
})),
[hasMatchedQuery, matches, resolvedTheme, target.threadRef],
);
const items: CommandPaletteActionItem[] = matches.map((match) => ({
kind: "action",
value: `file:${match.path}`,
searchTerms: [match.name, match.path],
title: (
<HighlightedFuzzyText
active={hasMatchedQuery}
value={match.name}
indices={match.nameMatchIndices}
/>
),
description: (
<HighlightedFuzzyText
active={hasMatchedQuery}
value={match.path}
indices={match.pathMatchIndices}
/>
),
icon: <PierreEntryIcon pathValue={match.path} kind="file" theme={resolvedTheme} />,
run: async () => {
useRightPanelStore.getState().openFile(target.threadRef, match.path);
},
}));

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

Expand Down
Loading