From 7c150178e58f724a968efb1752d40bc81664f4d1 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Thu, 9 Oct 2025 17:42:18 -0300 Subject: [PATCH] fixup! fix: improve submit Signed-off-by: Carlos Alexandro Becker --- .../components/dialogs/commands/commands.go | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/internal/tui/components/dialogs/commands/commands.go b/internal/tui/components/dialogs/commands/commands.go index 480e3b0205d98dc40cf1a3bded3b66b92b4db120..cf60e03ff1b6cf1492d3d7d8cd6d5d22bd79fb3b 100644 --- a/internal/tui/components/dialogs/commands/commands.go +++ b/internal/tui/components/dialogs/commands/commands.go @@ -188,23 +188,7 @@ func (c *commandDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if len(c.userCommands) == 0 && len(c.mcpPrompts) == 0 { return c, nil } - switch c.selected { - case SystemCommands: - if len(c.userCommands) > 0 { - return c, c.SetCommandType(UserCommands) - } - if len(c.mcpPrompts) > 0 { - return c, c.SetCommandType(MCPPrompts) - } - return c, nil - case UserCommands: - if len(c.mcpPrompts) > 0 { - return c, c.SetCommandType(MCPPrompts) - } - return c, c.SetCommandType(SystemCommands) - case MCPPrompts: - return c, c.SetCommandType(SystemCommands) - } + return c, c.SetCommandType(c.next()) case key.Matches(msg, c.keyMap.Close): if c.cancel != nil { c.cancel() @@ -219,6 +203,28 @@ func (c *commandDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return c, nil } +func (c *commandDialogCmp) next() CommandType { + switch c.selected { + case SystemCommands: + if len(c.userCommands) > 0 { + return UserCommands + } + if len(c.mcpPrompts) > 0 { + return MCPPrompts + } + fallthrough + case UserCommands: + if len(c.mcpPrompts) > 0 { + return MCPPrompts + } + fallthrough + case MCPPrompts: + return SystemCommands + default: + return SystemCommands + } +} + func (c *commandDialogCmp) View() string { t := styles.CurrentTheme() listView := c.commandList