Skip to content

Commit 490538f

Browse files
authored
fix: prevent duplicate command patterns by trimming full command (#6224)
1 parent c61bd95 commit 490538f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

webview-ui/src/components/chat/CommandPatternSelector.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ export const CommandPatternSelector: React.FC<CommandPatternSelectorProps> = ({
3333

3434
// Create a combined list with full command first, then patterns
3535
const allPatterns = useMemo(() => {
36-
const fullCommandPattern: CommandPattern = { pattern: command }
36+
// Trim the command to ensure consistency with extracted patterns
37+
const trimmedCommand = command.trim()
38+
const fullCommandPattern: CommandPattern = { pattern: trimmedCommand }
3739

3840
// Create a set to track unique patterns we've already seen
3941
const seenPatterns = new Set<string>()
40-
seenPatterns.add(command) // Add the full command first
42+
seenPatterns.add(trimmedCommand) // Add the trimmed full command first
4143

4244
// Filter out any patterns that are duplicates or are the same as the full command
4345
const uniquePatterns = patterns.filter((p) => {

0 commit comments

Comments
 (0)