The open source coding agent.
TypeScript
fix(tui): help dialog sorting
adamdottv1d0bfc2b2ac2
diff --git a/packages/tui/internal/commands/command.go b/packages/tui/internal/commands/command.goindex 92e11c79fc6..ad7ccf30cef 100644--- a/packages/tui/internal/commands/command.go+++ b/packages/tui/internal/commands/command.go@@ -41,14 +41,12 @@ func (c Command) Keys() []string {type CommandRegistry map[CommandName]Command-func (r CommandRegistry) Matches(msg tea.KeyPressMsg, leader bool) []Command {- var matched []Command+func (r CommandRegistry) Sorted() []Command {+ var commands []Commandfor _, command := range r {- if command.Matches(msg, leader) {- matched = append(matched, command)- }+ commands = append(commands, command)}- slices.SortFunc(matched, func(a, b Command) int {+ slices.SortFunc(commands, func(a, b Command) int {if a.Name == AppExitCommand {return 1}@@ -57,6 +55,16 @@ func (r CommandRegistry) Matches(msg tea.KeyPressMsg, leader bool) []Command {}return strings.Compare(string(a.Name), string(b.Name))})+ return commands+}++func (r CommandRegistry) Matches(msg tea.KeyPressMsg, leader bool) []Command {+ var matched []Command+ for _, command := range r.Sorted() {+ if command.Matches(msg, leader) {+ matched = append(matched, command)+ }+ }return matched}diff --git a/packages/tui/internal/components/dialog/help.go b/packages/tui/internal/components/dialog/help.goindex 1886714e462..6041fd5e771 100644--- a/packages/tui/internal/components/dialog/help.go+++ b/packages/tui/internal/components/dialog/help.go@@ -15,7 +15,7 @@ type helpDialog struct {width intheight intmodal *modal.Modal- commands commands.CommandRegistry+ commands []commands.Command}func (h *helpDialog) Init() tea.Cmd {@@ -80,7 +80,7 @@ type HelpDialog interface {layout.Modal}-func NewHelpDialog(commands commands.CommandRegistry) HelpDialog {+func NewHelpDialog(commands []commands.Command) HelpDialog {return &helpDialog{commands: commands,modal: modal.New(),diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.goindex 3b6b44effca..9fe52cdab03 100644--- a/packages/tui/internal/tui/tui.go+++ b/packages/tui/internal/tui/tui.go@@ -284,7 +284,7 @@ func (a appModel) executeCommand(command commands.Command) (tea.Model, tea.Cmd)}switch command.Name {case commands.AppHelpCommand:- helpDialog := dialog.NewHelpDialog(a.app.Commands)+ helpDialog := dialog.NewHelpDialog(a.app.Commands.Sorted())a.modal = helpDialogcase commands.EditorOpenCommand:if a.app.IsBusy() {