diff --git a/cli/internal/tui/commands.go b/cli/internal/tui/commands.go index 7b6ad30bd..b98cf0629 100644 --- a/cli/internal/tui/commands.go +++ b/cli/internal/tui/commands.go @@ -109,10 +109,7 @@ func (m CommandMenuModel) Matches(input string, cursor int) []ChatCommand { argumentIndex-- partial = words[argumentIndex] } - prefix := name + " " - if partial != "" { - prefix += strings.TrimSuffix(rest, partial) - } + prefix := strings.TrimSuffix(input, partial) seen := make(map[string]bool) var direct, others []ChatCommand for _, command := range m.Catalog { diff --git a/cli/internal/tui/commands_test.go b/cli/internal/tui/commands_test.go index cc5ba4a3e..f0125f895 100644 --- a/cli/internal/tui/commands_test.go +++ b/cli/internal/tui/commands_test.go @@ -11,6 +11,7 @@ func TestCommandMenuMatchesArgumentChoices(t *testing.T) { menu := CommandMenuModel{Catalog: []daemon.SessionCommand{ {Name: "/reload", Arguments: []daemon.CommandArgument{{Name: "target", Description: "reload target", Choices: []string{"session", "models", "both"}}}}, {Name: "/reload", Arguments: []daemon.CommandArgument{{Name: "target", Choices: []string{"models", "other"}}}}, + {Name: "/paint", Arguments: []daemon.CommandArgument{{Name: "color"}, {Name: "city", Choices: []string{"東京"}}}}, {Name: "/research", Arguments: []daemon.CommandArgument{{Name: "prompt"}}}, }} tests := []struct { @@ -20,6 +21,7 @@ func TestCommandMenuMatchesArgumentChoices(t *testing.T) { {input: "/reload ", want: []string{"/reload session", "/reload models", "/reload both", "/reload other"}}, {input: "/reload m", want: []string{"/reload models"}}, {input: "/reload both", want: []string{"/reload both"}}, + {input: "/paint red ", want: []string{"/paint red 東京"}}, {input: "/research some words"}, {input: "/unknown "}, {input: "/reload\n", want: nil},