Skip to content

Commit e309f78

Browse files
authored
Merge pull request #1521 from krissetto/theme-cmd-palette
Make /commands searchable in the command palette
2 parents 0cd93cf + 503494b commit e309f78

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

pkg/tui/commands/commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func builtInSessionCommands() []Item {
190190
ID: "settings.theme",
191191
Label: "Theme",
192192
SlashCommand: "/theme",
193-
Description: "Change the color theme (saved globally)",
193+
Description: "Change the color theme",
194194
Category: "Settings",
195195
Execute: func(string) tea.Cmd {
196196
return core.CmdHandler(messages.OpenThemePickerMsg{})

pkg/tui/dialog/command_palette.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ func (d *commandPaletteDialog) filterCommands() {
182182
for _, cmd := range cat.Commands {
183183
if strings.Contains(strings.ToLower(cmd.Label), query) ||
184184
strings.Contains(strings.ToLower(cmd.Description), query) ||
185-
strings.Contains(strings.ToLower(cmd.Category), query) {
185+
strings.Contains(strings.ToLower(cmd.Category), query) ||
186+
strings.Contains(strings.ToLower(cmd.SlashCommand), query) {
186187
d.filtered = append(d.filtered, cmd)
187188
}
188189
}

pkg/tui/dialog/command_palette_test.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ var categories = []commands.Category{
1414
Name: "Session",
1515
Commands: []commands.Item{
1616
{
17-
ID: "session.new",
18-
Label: "New Session",
19-
Description: "Start a new conversation session",
20-
Category: "Session",
21-
Execute: func(string) tea.Cmd { return nil },
17+
ID: "session.new",
18+
Label: "New Session",
19+
SlashCommand: "/new",
20+
Description: "Start a new conversation session",
21+
Category: "Session",
22+
Execute: func(string) tea.Cmd { return nil },
2223
},
2324
{
24-
ID: "session.compact",
25-
Label: "Compact Session",
26-
Description: "Summarize and compact the current conversation",
27-
Category: "Session",
28-
Execute: func(string) tea.Cmd { return nil },
25+
ID: "session.compact",
26+
Label: "Compact Session",
27+
SlashCommand: "/compact",
28+
Description: "Summarize and compact the current conversation",
29+
Category: "Session",
30+
Execute: func(string) tea.Cmd { return nil },
2931
},
3032
},
3133
},
@@ -45,6 +47,11 @@ func TestCommandPaletteFiltering(t *testing.T) {
4547
input: "new",
4648
expected: []string{"session.new"},
4749
},
50+
{
51+
name: "filter by slash command",
52+
input: "/new",
53+
expected: []string{"session.new"},
54+
},
4855
{
4956
name: "filter by compact",
5057
input: "compact",

0 commit comments

Comments
 (0)