From d4ea48eee7132a1d784ac854ee84f29c5579338f Mon Sep 17 00:00:00 2001 From: Daniel Riccio Date: Fri, 25 Jul 2025 16:43:47 -0500 Subject: [PATCH] fix: prevent duplicate command patterns by trimming full command - Trim the full command before adding it to the pattern list in CommandPatternSelector - This prevents duplicates when the command has trailing whitespace - Ensures consistency with patterns extracted by extractPatternsFromCommand which are already trimmed - Fixes issue introduced in PR #5798 --- webview-ui/src/components/chat/CommandPatternSelector.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webview-ui/src/components/chat/CommandPatternSelector.tsx b/webview-ui/src/components/chat/CommandPatternSelector.tsx index 431141fa326..b79d86ccfea 100644 --- a/webview-ui/src/components/chat/CommandPatternSelector.tsx +++ b/webview-ui/src/components/chat/CommandPatternSelector.tsx @@ -33,11 +33,13 @@ export const CommandPatternSelector: React.FC = ({ // Create a combined list with full command first, then patterns const allPatterns = useMemo(() => { - const fullCommandPattern: CommandPattern = { pattern: command } + // Trim the command to ensure consistency with extracted patterns + const trimmedCommand = command.trim() + const fullCommandPattern: CommandPattern = { pattern: trimmedCommand } // Create a set to track unique patterns we've already seen const seenPatterns = new Set() - seenPatterns.add(command) // Add the full command first + seenPatterns.add(trimmedCommand) // Add the trimmed full command first // Filter out any patterns that are duplicates or are the same as the full command const uniquePatterns = patterns.filter((p) => {