diff --git a/frontend/src/components/command-menu.tsx b/frontend/src/components/command-menu.tsx index 5753d0a38..9d4cb9442 100644 --- a/frontend/src/components/command-menu.tsx +++ b/frontend/src/components/command-menu.tsx @@ -194,7 +194,20 @@ function CommandMenu() { - + { + const searchLower = search.toLowerCase().trim(); + if (!searchLower) + return 1; + const valueLower = value.toLowerCase(); + const searchWords = searchLower.split(/\s+/).filter(Boolean); + // All search words must appear somewhere in the value (name + description) + const allWordsMatch = searchWords.every((word: string) => valueLower.includes(word)); + return allWordsMatch ? 1 : 0; + }} + > Search scripts @@ -204,7 +217,7 @@ function CommandMenu() { {scripts.map(script => ( { setOpen(false); router.push(`/scripts?id=${script.slug}`); diff --git a/frontend/src/components/ui/command.tsx b/frontend/src/components/ui/command.tsx index 8fd9b91ed..265a4064f 100644 --- a/frontend/src/components/ui/command.tsx +++ b/frontend/src/components/ui/command.tsx @@ -24,13 +24,18 @@ const Command = React.forwardRef< )); Command.displayName = CommandPrimitive.displayName; -type CommandDialogProps = {} & DialogProps; +type CommandDialogProps = { + filter?: (value: string, search: string, keywords?: string[]) => number; +} & DialogProps; -function CommandDialog({ children, ...props }: CommandDialogProps) { +function CommandDialog({ children, filter, ...props }: CommandDialogProps) { return ( - + {children}