fixup! fix: improve submit

Carlos Alexandro Becker created

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Change summary

internal/tui/components/dialogs/commands/commands.go | 40 ++++++++-----
1 file changed, 23 insertions(+), 17 deletions(-)

Detailed changes

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