actions.go

 1package dialog
 2
 3import (
 4	tea "charm.land/bubbletea/v2"
 5	"github.com/charmbracelet/catwalk/pkg/catwalk"
 6	"github.com/charmbracelet/crush/internal/commands"
 7	"github.com/charmbracelet/crush/internal/config"
 8	"github.com/charmbracelet/crush/internal/permission"
 9	"github.com/charmbracelet/crush/internal/session"
10)
11
12// ActionClose is a message to close the current dialog.
13type ActionClose struct{}
14
15// ActionQuit is a message to quit the application.
16type ActionQuit = tea.QuitMsg
17
18// ActionOpenDialog is a message to open a dialog.
19type ActionOpenDialog struct {
20	DialogID string
21}
22
23// ActionSelectSession is a message indicating a session has been selected.
24type ActionSelectSession struct {
25	Session session.Session
26}
27
28// ActionSelectModel is a message indicating a model has been selected.
29type ActionSelectModel struct {
30	Provider  catwalk.Provider
31	Model     config.SelectedModel
32	ModelType config.SelectedModelType
33}
34
35// Messages for commands
36type (
37	ActionNewSession        struct{}
38	ActionToggleHelp        struct{}
39	ActionToggleCompactMode struct{}
40	ActionToggleThinking    struct{}
41	ActionExternalEditor    struct{}
42	ActionToggleYoloMode    struct{}
43	// ActionInitializeProject is a message to initialize a project.
44	ActionInitializeProject struct{}
45	ActionSummarize         struct {
46		SessionID string
47	}
48	ActionPermissionResponse struct {
49		Permission permission.PermissionRequest
50		Action     PermissionAction
51	}
52	// ActionRunCustomCommand is a message to run a custom command.
53	ActionRunCustomCommand struct {
54		CommandID string
55		// Used when running a user-defined command
56		Content string
57		// Used when running a prompt from MCP
58		Client string
59	}
60	// ActionOpenCustomCommandArgumentsDialog is a message to open the custom command arguments dialog.
61	ActionOpenCustomCommandArgumentsDialog struct {
62		CommandID string
63		// Used when running a user-defined command
64		Content string
65		// Used when running a prompt from MCP
66		Client    string
67		Arguments []commands.Argument
68	}
69)
70
71// Messages for API key input dialog.
72type (
73	ActionChangeAPIKeyState struct {
74		State APIKeyInputState
75	}
76)
77
78// ActionCmd represents an action that carries a [tea.Cmd] to be passed to the
79// Bubble Tea program loop.
80type ActionCmd struct {
81	Cmd tea.Cmd
82}