@@ -60,6 +60,9 @@ type commandDialogCmp struct {
type (
SwitchSessionsMsg struct{}
SwitchModelMsg struct{}
+ QuitMsg struct{}
+ OpenFilePickerMsg struct{}
+ ToggleHelpMsg struct{}
ToggleCompactModeMsg struct{}
ToggleThinkingMsg struct{}
CompactMsg struct {
@@ -248,13 +251,20 @@ func (c *commandDialogCmp) Position() (int, int) {
func (c *commandDialogCmp) defaultCommands() []Command {
commands := []Command{
{
- ID: "init",
- Title: "Initialize Project",
- Description: "Create/Update the CRUSH.md memory file",
+ ID: "switch_session",
+ Title: "Switch Session",
+ Description: "Switch to a different session",
+ Shortcut: "ctrl+s",
Handler: func(cmd Command) tea.Cmd {
- return util.CmdHandler(chat.SendMsg{
- Text: prompt.Initialize(),
- })
+ return util.CmdHandler(SwitchSessionsMsg{})
+ },
+ },
+ {
+ ID: "switch_model",
+ Title: "Switch Model",
+ Description: "Switch to a different model",
+ Handler: func(cmd Command) tea.Cmd {
+ return util.CmdHandler(SwitchModelMsg{})
},
},
}
@@ -307,23 +317,49 @@ func (c *commandDialogCmp) defaultCommands() []Command {
},
})
}
+ if c.sessionID != "" {
+ agentCfg := config.Get().Agents["coder"]
+ model := config.Get().GetModelByType(agentCfg.Model)
+ if model.SupportsImages {
+ commands = append(commands, Command{
+ ID: "file_picker",
+ Title: "Open File Picker",
+ Shortcut: "ctrl+f",
+ Description: "Open file picker",
+ Handler: func(cmd Command) tea.Cmd {
+ return util.CmdHandler(OpenFilePickerMsg{})
+ },
+ })
+ }
+ }
return append(commands, []Command{
{
- ID: "switch_session",
- Title: "Switch Session",
- Description: "Switch to a different session",
- Shortcut: "ctrl+s",
+ ID: "toggle_help",
+ Title: "Toggle Help",
+ Shortcut: "ctrl+g",
+ Description: "Toggle help",
Handler: func(cmd Command) tea.Cmd {
- return util.CmdHandler(SwitchSessionsMsg{})
+ return util.CmdHandler(ToggleHelpMsg{})
},
},
{
- ID: "switch_model",
- Title: "Switch Model",
- Description: "Switch to a different model",
+ ID: "init",
+ Title: "Initialize Project",
+ Description: "Create/Update the CRUSH.md memory file",
Handler: func(cmd Command) tea.Cmd {
- return util.CmdHandler(SwitchModelMsg{})
+ return util.CmdHandler(chat.SendMsg{
+ Text: prompt.Initialize(),
+ })
+ },
+ },
+ {
+ ID: "quit",
+ Title: "Quit",
+ Description: "Quit",
+ Shortcut: "ctrl+c",
+ Handler: func(cmd Command) tea.Cmd {
+ return util.CmdHandler(QuitMsg{})
},
},
}...)
@@ -37,8 +37,7 @@ import (
var ChatPageID page.PageID = "chat"
type (
- OpenFilePickerMsg struct{}
- ChatFocusedMsg struct {
+ ChatFocusedMsg struct {
Focused bool
}
CancelTimerExpiredMsg struct{}
@@ -299,7 +298,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
agentCfg := config.Get().Agents["coder"]
model := config.Get().GetModelByType(agentCfg.Model)
if model.SupportsImages {
- return p, util.CmdHandler(OpenFilePickerMsg{})
+ return p, util.CmdHandler(commands.OpenFilePickerMsg{})
} else {
return p, util.ReportWarn("File attachments are not supported by the current model: " + model.Name)
}
@@ -170,7 +170,14 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return a, util.CmdHandler(dialogs.OpenDialogMsg{
Model: compact.NewCompactDialogCmp(a.app.CoderAgent, msg.SessionID, true),
})
-
+ case commands.QuitMsg:
+ return a, util.CmdHandler(dialogs.OpenDialogMsg{
+ Model: quit.NewQuitDialog(),
+ })
+ case commands.ToggleHelpMsg:
+ a.status.ToggleFullHelp()
+ a.showingFullHelp = !a.showingFullHelp
+ return a, a.handleWindowResize(a.wWidth, a.wHeight)
// Model Switch
case models.ModelSelectedMsg:
config.Get().UpdatePreferredModel(msg.ModelType, msg.Model)
@@ -187,7 +194,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return a, util.ReportInfo(fmt.Sprintf("%s model changed to %s", modelTypeName, msg.Model.Model))
// File Picker
- case chat.OpenFilePickerMsg:
+ case commands.OpenFilePickerMsg:
if a.dialog.ActiveDialogID() == filepicker.FilePickerID {
// If the commands dialog is already open, close it
return a, util.CmdHandler(dialogs.CloseDialogMsg{})