Fix duplicate /clear in the slash command menu

A client command and a provider command can share a name (e.g. clear).
Both produced the same option id, which became a duplicate React key —
React then left stale rows and scrambled ordering, so /clear showed
twice and ranking broke as the query narrowed. Drop the colliding
provider command and keep the client one, which has extra affordances.
This commit is contained in:
Mohamed Boudra
2026-05-29 13:23:29 +07:00
parent 04fb0f9b82
commit d1eb976653
@@ -318,13 +318,14 @@ export function useAgentAutocomplete(input: UseAgentAutocompleteInput): AgentAut
const providerCommands = commands.map( const providerCommands = commands.map(
(command): AvailableCommand => ({ source: "provider", command }), (command): AvailableCommand => ({ source: "provider", command }),
); );
const clientCommandNames = new Set(CLIENT_SLASH_COMMANDS.map((command) => command.name));
const availableCommands: AvailableCommand[] = isDraftContext const availableCommands: AvailableCommand[] = isDraftContext
? providerCommands ? providerCommands
: [ : [
...CLIENT_SLASH_COMMANDS.map( ...CLIENT_SLASH_COMMANDS.map(
(command): AvailableCommand => ({ source: "client", command }), (command): AvailableCommand => ({ source: "client", command }),
), ),
...providerCommands, ...providerCommands.filter((entry) => !clientCommandNames.has(entry.command.name)),
]; ];
const matches = filterAndRankCommandAutocompleteEntries( const matches = filterAndRankCommandAutocompleteEntries(
availableCommands, availableCommands,