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/oauth"
9 "github.com/charmbracelet/crush/internal/permission"
10 "github.com/charmbracelet/crush/internal/session"
11)
12
13// ActionClose is a message to close the current dialog.
14type ActionClose struct{}
15
16// ActionQuit is a message to quit the application.
17type ActionQuit = tea.QuitMsg
18
19// ActionOpenDialog is a message to open a dialog.
20type ActionOpenDialog struct {
21 DialogID string
22}
23
24// ActionSelectSession is a message indicating a session has been selected.
25type ActionSelectSession struct {
26 Session session.Session
27}
28
29// ActionSelectModel is a message indicating a model has been selected.
30type ActionSelectModel struct {
31 Provider catwalk.Provider
32 Model config.SelectedModel
33 ModelType config.SelectedModelType
34}
35
36// Messages for commands
37type (
38 ActionNewSession struct{}
39 ActionToggleHelp struct{}
40 ActionToggleCompactMode struct{}
41 ActionToggleThinking struct{}
42 ActionExternalEditor struct{}
43 ActionToggleYoloMode struct{}
44 // ActionInitializeProject is a message to initialize a project.
45 ActionInitializeProject struct{}
46 ActionSummarize struct {
47 SessionID string
48 }
49 ActionPermissionResponse struct {
50 Permission permission.PermissionRequest
51 Action PermissionAction
52 }
53 // ActionRunCustomCommand is a message to run a custom command.
54 ActionRunCustomCommand struct {
55 Content string
56 Arguments []commands.Argument
57 Args map[string]string // Actual argument values
58 }
59 // ActionRunMCPPrompt is a message to run a custom command.
60 ActionRunMCPPrompt struct {
61 Title string
62 Description string
63 PromptID string
64 ClientID string
65 Arguments []commands.Argument
66 Args map[string]string // Actual argument values
67 }
68)
69
70// Messages for API key input dialog.
71type (
72 ActionChangeAPIKeyState struct {
73 State APIKeyInputState
74 }
75)
76
77// Messages for OAuth2 device flow dialog.
78type (
79 // ActionInitiateOAuth is sent when the device auth is initiated
80 // successfully.
81 ActionInitiateOAuth struct {
82 DeviceCode string
83 UserCode string
84 ExpiresIn int
85 VerificationURL string
86 Interval int
87 }
88
89 // ActionCompleteOAuth is sent when the device flow completes successfully.
90 ActionCompleteOAuth struct {
91 Token *oauth.Token
92 }
93
94 // ActionOAuthErrored is sent when the device flow encounters an error.
95 ActionOAuthErrored struct {
96 Error error
97 }
98)
99
100// ActionCmd represents an action that carries a [tea.Cmd] to be passed to the
101// Bubble Tea program loop.
102type ActionCmd struct {
103 Cmd tea.Cmd
104}