fix: slash command prefix matching

This commit is contained in:
Nate 2025-07-13 18:59:31 -07:00
parent c62cbdc21e
commit 0a402010d9

View file

@ -61,10 +61,17 @@ const SlashCommandUI: React.FC<SlashCommandUIProps> = ({
const allCommands = getSlashCommands(); const allCommands = getSlashCommands();
// Filter commands based on the current filter // Filter commands based on the current filter
const filteredCommands = allCommands.filter((cmd) => const filteredCommands = allCommands
cmd.name.toLowerCase().includes(filter.toLowerCase()) .filter((cmd) => cmd.name.toLowerCase().includes(filter.toLowerCase()))
); .sort((a, b) => {
const aStartsWith = a.name.toLowerCase().startsWith(filter.toLowerCase());
const bStartsWith = b.name.toLowerCase().startsWith(filter.toLowerCase());
if (aStartsWith && !bStartsWith) return -1;
if (!aStartsWith && bStartsWith) return 1;
return a.name.localeCompare(b.name);
});
if (filteredCommands.length === 0) { if (filteredCommands.length === 0) {
return ( return (
<Box <Box