@@ -23,6 +23,7 @@ import (
23 "github.com/charmbracelet/crush/internal/tui/exp/list"
23 "github.com/charmbracelet/crush/internal/tui/exp/list"
24 "github.com/charmbracelet/crush/internal/tui/styles"
24 "github.com/charmbracelet/crush/internal/tui/styles"
25 "github.com/charmbracelet/crush/internal/tui/util"
25 "github.com/charmbracelet/crush/internal/tui/util"
26+ "github.com/charmbracelet/crush/internal/uicmd"
@@ -44,13 +45,11 @@ const (
44type listModel = list.FilterableList[list.CompletionItem[Command]]
45type listModel = list.FilterableList[list.CompletionItem[Command]]
46// Command represents a command that can be executed
47// Command represents a command that can be executed
47−type Command struct {
48+type (
48− ID string
49+ Command = uicmd.Command
49− Title string
50+ CommandRunCustomMsg = uicmd.CommandRunCustomMsg
50− Description string
51+ ShowMCPPromptArgumentsDialogMsg = uicmd.ShowMCPPromptArgumentsDialogMsg
51− Shortcut string // Optional shortcut for the command
52+)
52− Handler func(cmd Command) tea.Cmd
55// CommandsDialog represents the commands dialog.
54// CommandsDialog represents the commands dialog.
56type CommandsDialog interface {
55type CommandsDialog interface {
@@ -121,12 +120,12 @@ func NewCommandDialog(sessionID string) CommandsDialog {
123func (c *commandDialogCmp) Init() tea.Cmd {
122func (c *commandDialogCmp) Init() tea.Cmd {
124− commands, err := LoadCustomCommands()
123+ commands, err := uicmd.LoadCustomCommands()
125 if err != nil {
124 if err != nil {
126 return util.ReportError(err)
125 return util.ReportError(err)
128 c.userCommands = commands
127 c.userCommands = commands
129− c.mcpPrompts.SetSlice(loadMCPPrompts())
128+ c.mcpPrompts.SetSlice(uicmd.LoadMCPPrompts())
130 return c.setCommandType(c.selected)
129 return c.setCommandType(c.selected)
@@ -142,7 +141,7 @@ func (c *commandDialogCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
142 case pubsub.Event[mcp.Event]:
141 case pubsub.Event[mcp.Event]:
143 // Reload MCP prompts when MCP state changes
142 // Reload MCP prompts when MCP state changes
144 if msg.Type == pubsub.UpdatedEvent {
143 if msg.Type == pubsub.UpdatedEvent {
145− c.mcpPrompts.SetSlice(loadMCPPrompts())
144+ c.mcpPrompts.SetSlice(uicmd.LoadMCPPrompts())
146 // If we're currently viewing MCP prompts, refresh the list
145 // If we're currently viewing MCP prompts, refresh the list
147 if c.selected == MCPPrompts {
146 if c.selected == MCPPrompts {
148 return c, c.setCommandType(MCPPrompts)
147 return c, c.setCommandType(MCPPrompts)