on main help sign in
chore: add more commands
28f4f21Kujtim Hoxha
internal/tui/components/dialogs/commands/commands.go+51−15
@@ -60,6 +60,9 @@ type commandDialogCmp struct {
60type (
60type (
61 SwitchSessionsMsg struct{}
61 SwitchSessionsMsg struct{}
62 SwitchModelMsg struct{}
62 SwitchModelMsg struct{}
63+ QuitMsg struct{}
64+ OpenFilePickerMsg struct{}
65+ ToggleHelpMsg struct{}
63 ToggleCompactModeMsg struct{}
66 ToggleCompactModeMsg struct{}
64 ToggleThinkingMsg struct{}
67 ToggleThinkingMsg struct{}
65 CompactMsg struct {
68 CompactMsg struct {
@@ -248,13 +251,20 @@ func (c *commandDialogCmp) Position() (int, int) {
248func (c *commandDialogCmp) defaultCommands() []Command {
251func (c *commandDialogCmp) defaultCommands() []Command {
249 commands := []Command{
252 commands := []Command{
250 {
253 {
251− ID: "init",
254+ ID: "switch_session",
252− Title: "Initialize Project",
255+ Title: "Switch Session",
253− Description: "Create/Update the CRUSH.md memory file",
256+ Description: "Switch to a different session",
257+ Shortcut: "ctrl+s",
254 Handler: func(cmd Command) tea.Cmd {
258 Handler: func(cmd Command) tea.Cmd {
255− return util.CmdHandler(chat.SendMsg{
259+ return util.CmdHandler(SwitchSessionsMsg{})
256− Text: prompt.Initialize(),
260+ },
257− })
261+ },
262+ {
263+ ID: "switch_model",
264+ Title: "Switch Model",
265+ Description: "Switch to a different model",
266+ Handler: func(cmd Command) tea.Cmd {
267+ return util.CmdHandler(SwitchModelMsg{})
258 },
268 },
259 },
269 },
260 }
270 }
@@ -307,23 +317,49 @@ func (c *commandDialogCmp) defaultCommands() []Command {
307 },
317 },
308 })
318 })
309 }
319 }
320+ if c.sessionID != "" {
321+ agentCfg := config.Get().Agents["coder"]
322+ model := config.Get().GetModelByType(agentCfg.Model)
323+ if model.SupportsImages {
324+ commands = append(commands, Command{
325+ ID: "file_picker",
326+ Title: "Open File Picker",
327+ Shortcut: "ctrl+f",
328+ Description: "Open file picker",
329+ Handler: func(cmd Command) tea.Cmd {
330+ return util.CmdHandler(OpenFilePickerMsg{})
331+ },
332+ })
333+ }
334+ }
310
335
311 return append(commands, []Command{
336 return append(commands, []Command{
312 {
337 {
313− ID: "switch_session",
338+ ID: "toggle_help",
314− Title: "Switch Session",
339+ Title: "Toggle Help",
315− Description: "Switch to a different session",
316− Shortcut: "ctrl+s",
340+ Shortcut: "ctrl+g",
341+ Description: "Toggle help",
317 Handler: func(cmd Command) tea.Cmd {
342 Handler: func(cmd Command) tea.Cmd {
318− return util.CmdHandler(SwitchSessionsMsg{})
343+ return util.CmdHandler(ToggleHelpMsg{})
319 },
344 },
320 },
345 },
321 {
346 {
322− ID: "switch_model",
347+ ID: "init",
323− Title: "Switch Model",
348+ Title: "Initialize Project",
324− Description: "Switch to a different model",
349+ Description: "Create/Update the CRUSH.md memory file",
325 Handler: func(cmd Command) tea.Cmd {
350 Handler: func(cmd Command) tea.Cmd {
326− return util.CmdHandler(SwitchModelMsg{})
351+ return util.CmdHandler(chat.SendMsg{
352+ Text: prompt.Initialize(),
353+ })
354+ },
355+ },
356+ {
357+ ID: "quit",
358+ Title: "Quit",
359+ Description: "Quit",
360+ Shortcut: "ctrl+c",
361+ Handler: func(cmd Command) tea.Cmd {
362+ return util.CmdHandler(QuitMsg{})
327 },
363 },
328 },
364 },
329 }...)
365 }...)
internal/tui/page/chat/chat.go+2−3
@@ -37,8 +37,7 @@ import (
37var ChatPageID page.PageID = "chat"
37var ChatPageID page.PageID = "chat"
38
38
39type (
39type (
40− OpenFilePickerMsg struct{}
41− ChatFocusedMsg struct {
40+ ChatFocusedMsg struct {
42 Focused bool
41 Focused bool
43 }
42 }
44 CancelTimerExpiredMsg struct{}
43 CancelTimerExpiredMsg struct{}
@@ -299,7 +298,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
299 agentCfg := config.Get().Agents["coder"]
298 agentCfg := config.Get().Agents["coder"]
300 model := config.Get().GetModelByType(agentCfg.Model)
299 model := config.Get().GetModelByType(agentCfg.Model)
301 if model.SupportsImages {
300 if model.SupportsImages {
302− return p, util.CmdHandler(OpenFilePickerMsg{})
301+ return p, util.CmdHandler(commands.OpenFilePickerMsg{})
303 } else {
302 } else {
304 return p, util.ReportWarn("File attachments are not supported by the current model: " + model.Name)
303 return p, util.ReportWarn("File attachments are not supported by the current model: " + model.Name)
305 }
304 }
internal/tui/tui.go+9−2
@@ -170,7 +170,14 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
170 return a, util.CmdHandler(dialogs.OpenDialogMsg{
170 return a, util.CmdHandler(dialogs.OpenDialogMsg{
171 Model: compact.NewCompactDialogCmp(a.app.CoderAgent, msg.SessionID, true),
171 Model: compact.NewCompactDialogCmp(a.app.CoderAgent, msg.SessionID, true),
172 })
172 })
173−
173+ case commands.QuitMsg:
174+ return a, util.CmdHandler(dialogs.OpenDialogMsg{
175+ Model: quit.NewQuitDialog(),
176+ })
177+ case commands.ToggleHelpMsg:
178+ a.status.ToggleFullHelp()
179+ a.showingFullHelp = !a.showingFullHelp
180+ return a, a.handleWindowResize(a.wWidth, a.wHeight)
174 // Model Switch
181 // Model Switch
175 case models.ModelSelectedMsg:
182 case models.ModelSelectedMsg:
176 config.Get().UpdatePreferredModel(msg.ModelType, msg.Model)
183 config.Get().UpdatePreferredModel(msg.ModelType, msg.Model)
@@ -187,7 +194,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
187 return a, util.ReportInfo(fmt.Sprintf("%s model changed to %s", modelTypeName, msg.Model.Model))
194 return a, util.ReportInfo(fmt.Sprintf("%s model changed to %s", modelTypeName, msg.Model.Model))
188
195
189 // File Picker
196 // File Picker
190− case chat.OpenFilePickerMsg:
197+ case commands.OpenFilePickerMsg:
191 if a.dialog.ActiveDialogID() == filepicker.FilePickerID {
198 if a.dialog.ActiveDialogID() == filepicker.FilePickerID {
192 // If the commands dialog is already open, close it
199 // If the commands dialog is already open, close it
193 return a, util.CmdHandler(dialogs.CloseDialogMsg{})
200 return a, util.CmdHandler(dialogs.CloseDialogMsg{})