Skip to content

The open source coding agent.

TypeScript

fix: deduplicate command suggestions (#934)

John Henry Ruddenf04a5e50ee77
diff --git a/packages/tui/internal/completions/commands.go b/packages/tui/internal/completions/commands.go
index bb48d540ca3..d7e21419bc3 100644
--- a/packages/tui/internal/completions/commands.go
+++ b/packages/tui/internal/completions/commands.go
@@ -96,11 +96,16 @@ func (c *CommandCompletionProvider) GetChildEntries(
// Sort by score (best matches first)
sort.Sort(matches)
- // Convert matches to completion items
+ // Convert matches to completion items, deduplicating by command name
items := []dialog.CompletionItemI{}
+ seen := make(map[string]bool)
for _, match := range matches {
if item, ok := commandMap[match.Target]; ok {
- items = append(items, item)
+ // Use the command's value (name) as the deduplication key
+ if !seen[item.GetValue()] {
+ seen[item.GetValue()] = true
+ items = append(items, item)
+ }
}
}
return items, nil