fix: deduplicate slash command collisions

This commit is contained in:
Ibrahim Khan
2026-07-30 01:18:15 +00:00
parent a4c7bac303
commit 2dd0171ee5
4 changed files with 233 additions and 5 deletions
@@ -10,6 +10,7 @@ import { useI18n } from '@/lib/i18n';
import { useUIStore } from '@/stores/useUIStore';
import { isVSCodeRuntime } from '@/lib/desktop';
import { useMobileAutocompleteMaxHeight } from './useMobileAutocompleteMaxHeight';
import { commandMatchesSearch, mergeCommandAutocompleteItems } from './commandAutocompleteItems';
type CommandSource = 'openchamber' | 'opencode' | 'skill';
@@ -18,6 +19,7 @@ export interface CommandInfo {
name: string;
source: CommandSource;
description?: string;
searchAliases?: string[];
agent?: string;
model?: string;
isBuiltIn?: boolean;
@@ -191,14 +193,11 @@ export const CommandAutocomplete = React.forwardRef<CommandAutocompleteHandle, C
: []
),
];
const allCommands = [...builtInCommands, ...customCommands, ...skillCommands];
const allCommands = mergeCommandAutocompleteItems(builtInCommands, customCommands, skillCommands);
const allowInitCommand = !hasMessagesInCurrentSession;
const filtered = (searchQuery
? allCommands.filter(cmd =>
fuzzyMatch(cmd.name, searchQuery) ||
(cmd.description && fuzzyMatch(cmd.description, searchQuery))
)
? allCommands.filter(cmd => commandMatchesSearch(cmd, searchQuery))
: allCommands).filter(cmd => allowInitCommand || cmd.name !== 'init');
filtered.sort((a, b) => {