@@ -15,16 +15,23 @@ import (
1515 "github.com/charmbracelet/crush/internal/agent"
1616 "github.com/charmbracelet/crush/internal/config"
1717 "github.com/charmbracelet/crush/internal/csync"
18− "github.com/charmbracelet/crush/internal/tui/components/chat"
19− "github.com/charmbracelet/crush/internal/tui/util"
18+ "github.com/charmbracelet/crush/internal/message"
2019 "github.com/charmbracelet/crush/internal/ui/common"
2120 "github.com/charmbracelet/crush/internal/ui/list"
2221 "github.com/charmbracelet/crush/internal/uicmd"
22+ "github.com/charmbracelet/crush/internal/uiutil"
2323)
2424
2525// CommandsID is the identifier for the commands dialog.
2626const CommandsID = "commands"
2727
28+// SendMsg represents a message to send a chat message.
29+// TODO: Move to chat package?
30+type SendMsg struct {
31+ Text string
32+ Attachments []message.Attachment
33+}
34+
2835// Messages for commands
2936type (
3037 SwitchSessionsMsg struct{}
@@ -323,7 +330,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
323330 Description: "start a new session",
324331 Shortcut: "ctrl+n",
325332 Handler: func(cmd uicmd.Command) tea.Cmd {
326− return util.CmdHandler(NewSessionsMsg{})
333+ return uiutil.CmdHandler(NewSessionsMsg{})
327334 },
328335 },
329336 {
@@ -332,7 +339,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
332339 Description: "Switch to a different session",
333340 Shortcut: "ctrl+s",
334341 Handler: func(cmd uicmd.Command) tea.Cmd {
335− return util.CmdHandler(SwitchSessionsMsg{})
342+ return uiutil.CmdHandler(SwitchSessionsMsg{})
336343 },
337344 },
338345 {
@@ -341,7 +348,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
341348 Description: "Switch to a different model",
342349 Shortcut: "ctrl+l",
343350 Handler: func(cmd uicmd.Command) tea.Cmd {
344− return util.CmdHandler(SwitchModelMsg{})
351+ return uiutil.CmdHandler(SwitchModelMsg{})
345352 },
346353 },
347354 }
@@ -353,7 +360,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
353360 Title: "Summarize Session",
354361 Description: "Summarize the current session and create a new one with the summary",
355362 Handler: func(cmd uicmd.Command) tea.Cmd {
356− return util.CmdHandler(CompactMsg{
363+ return uiutil.CmdHandler(CompactMsg{
357364 SessionID: c.sessionID,
358365 })
359366 },
@@ -379,7 +386,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
379386 Title: status + " Thinking Mode",
380387 Description: "Toggle model thinking for reasoning-capable models",
381388 Handler: func(cmd uicmd.Command) tea.Cmd {
382− return util.CmdHandler(ToggleThinkingMsg{})
389+ return uiutil.CmdHandler(ToggleThinkingMsg{})
383390 },
384391 })
385392 }
@@ -391,7 +398,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
391398 Title: "Select Reasoning Effort",
392399 Description: "Choose reasoning effort level (low/medium/high)",
393400 Handler: func(cmd uicmd.Command) tea.Cmd {
394− return util.CmdHandler(OpenReasoningDialogMsg{})
401+ return uiutil.CmdHandler(OpenReasoningDialogMsg{})
395402 },
396403 })
397404 }
@@ -405,7 +412,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
405412 Title: "Toggle Sidebar",
406413 Description: "Toggle between compact and normal layout",
407414 Handler: func(cmd uicmd.Command) tea.Cmd {
408− return util.CmdHandler(ToggleCompactModeMsg{})
415+ return uiutil.CmdHandler(ToggleCompactModeMsg{})
409416 },
410417 })
411418 }
@@ -420,7 +427,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
420427 Shortcut: "ctrl+f",
421428 Description: "Open file picker",
422429 Handler: func(cmd uicmd.Command) tea.Cmd {
423− return util.CmdHandler(OpenFilePickerMsg{})
430+ return uiutil.CmdHandler(OpenFilePickerMsg{})
424431 },
425432 })
426433 }
@@ -435,7 +442,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
435442 Shortcut: "ctrl+o",
436443 Description: "Open external editor to compose message",
437444 Handler: func(cmd uicmd.Command) tea.Cmd {
438− return util.CmdHandler(OpenExternalEditorMsg{})
445+ return uiutil.CmdHandler(OpenExternalEditorMsg{})
439446 },
440447 })
441448 }
@@ -446,7 +453,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
446453 Title: "Toggle Yolo Mode",
447454 Description: "Toggle yolo mode",
448455 Handler: func(cmd uicmd.Command) tea.Cmd {
449− return util.CmdHandler(ToggleYoloModeMsg{})
456+ return uiutil.CmdHandler(ToggleYoloModeMsg{})
450457 },
451458 },
452459 {
@@ -455,7 +462,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
455462 Shortcut: "ctrl+g",
456463 Description: "Toggle help",
457464 Handler: func(cmd uicmd.Command) tea.Cmd {
458− return util.CmdHandler(ToggleHelpMsg{})
465+ return uiutil.CmdHandler(ToggleHelpMsg{})
459466 },
460467 },
461468 {
@@ -465,9 +472,9 @@ func (c *Commands) defaultCommands() []uicmd.Command {
465472 Handler: func(cmd uicmd.Command) tea.Cmd {
466473 initPrompt, err := agent.InitializePrompt(*c.com.Config())
467474 if err != nil {
468− return util.ReportError(err)
475+ return uiutil.ReportError(err)
469476 }
470− return util.CmdHandler(chat.SendMsg{
477+ return uiutil.CmdHandler(SendMsg{
471478 Text: initPrompt,
472479 })
473480 },
@@ -478,7 +485,7 @@ func (c *Commands) defaultCommands() []uicmd.Command {
478485 Description: "Quit",
479486 Shortcut: "ctrl+c",
480487 Handler: func(cmd uicmd.Command) tea.Cmd {
481− return util.CmdHandler(QuitMsg{})
488+ return uiutil.CmdHandler(QuitMsg{})
482489 },
483490 },
484491 }...)