on main help sign in
chore: add more commands
commit28f4f2151667020b37da1650ce09efb743b4308c authorKujtim Hoxha <kujtimii.h@gmail.com> dateMon 28 Jul 2025, 22:07 (1 year ago) parentf77aa2a
3 files changed+62−20
internal/tui/components/dialogs/commands/commands.go+51−15 internal/tui/page/chat/chat.go+2−3 internal/tui/tui.go+9−2
internal/tui/components/dialogs/commands/commands.go+51−15
@@ -60,6 +60,9 @@ type commandDialogCmp struct {
6060type (
6161 SwitchSessionsMsg struct{}
6262 SwitchModelMsg struct{}
63+ QuitMsg struct{}
64+ OpenFilePickerMsg struct{}
65+ ToggleHelpMsg struct{}
6366 ToggleCompactModeMsg struct{}
6467 ToggleThinkingMsg struct{}
6568 CompactMsg struct {
@@ -248,13 +251,20 @@ func (c *commandDialogCmp) Position() (int, int) {
248251func (c *commandDialogCmp) defaultCommands() []Command {
249252 commands := []Command{
250253 {
251− ID: "init",
252− Title: "Initialize Project",
253− Description: "Create/Update the CRUSH.md memory file",
254+ ID: "switch_session",
255+ Title: "Switch Session",
256+ Description: "Switch to a different session",
257+ Shortcut: "ctrl+s",
254258 Handler: func(cmd Command) tea.Cmd {
255− return util.CmdHandler(chat.SendMsg{
256− Text: prompt.Initialize(),
257− })
259+ return util.CmdHandler(SwitchSessionsMsg{})
260+ },
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{})
258268 },
259269 },
260270 }
@@ -307,23 +317,49 @@ func (c *commandDialogCmp) defaultCommands() []Command {
307317 },
308318 })
309319 }
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+ }
310335
311336 return append(commands, []Command{
312337 {
313− ID: "switch_session",
314− Title: "Switch Session",
315− Description: "Switch to a different session",
316− Shortcut: "ctrl+s",
338+ ID: "toggle_help",
339+ Title: "Toggle Help",
340+ Shortcut: "ctrl+g",
341+ Description: "Toggle help",
317342 Handler: func(cmd Command) tea.Cmd {
318− return util.CmdHandler(SwitchSessionsMsg{})
343+ return util.CmdHandler(ToggleHelpMsg{})
319344 },
320345 },
321346 {
322− ID: "switch_model",
323− Title: "Switch Model",
324− Description: "Switch to a different model",
347+ ID: "init",
348+ Title: "Initialize Project",
349+ Description: "Create/Update the CRUSH.md memory file",
325350 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{})
327363 },
328364 },
329365 }...)
internal/tui/page/chat/chat.go+2−3
@@ -37,8 +37,7 @@ import (
3737var ChatPageID page.PageID = "chat"
3838
3939type (
40− OpenFilePickerMsg struct{}
41− ChatFocusedMsg struct {
40+ ChatFocusedMsg struct {
4241 Focused bool
4342 }
4443 CancelTimerExpiredMsg struct{}
@@ -299,7 +298,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
299298 agentCfg := config.Get().Agents["coder"]
300299 model := config.Get().GetModelByType(agentCfg.Model)
301300 if model.SupportsImages {
302− return p, util.CmdHandler(OpenFilePickerMsg{})
301+ return p, util.CmdHandler(commands.OpenFilePickerMsg{})
303302 } else {
304303 return p, util.ReportWarn("File attachments are not supported by the current model: " + model.Name)
305304 }
internal/tui/tui.go+9−2
@@ -170,7 +170,14 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
170170 return a, util.CmdHandler(dialogs.OpenDialogMsg{
171171 Model: compact.NewCompactDialogCmp(a.app.CoderAgent, msg.SessionID, true),
172172 })
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)
174181 // Model Switch
175182 case models.ModelSelectedMsg:
176183 config.Get().UpdatePreferredModel(msg.ModelType, msg.Model)
@@ -187,7 +194,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
187194 return a, util.ReportInfo(fmt.Sprintf("%s model changed to %s", modelTypeName, msg.Model.Model))
188195
189196 // File Picker
190− case chat.OpenFilePickerMsg:
197+ case commands.OpenFilePickerMsg:
191198 if a.dialog.ActiveDialogID() == filepicker.FilePickerID {
192199 // If the commands dialog is already open, close it
193200 return a, util.CmdHandler(dialogs.CloseDialogMsg{})