diff --git a/internal/tui/components/dialogs/commands/commands.go b/internal/tui/components/dialogs/commands/commands.go index 664158fc392a87d8a7725bfa964748f7ef4f8e67..e0f9ac004daddc7b4071f43050862f6ce34d924d 100644 --- a/internal/tui/components/dialogs/commands/commands.go +++ b/internal/tui/components/dialogs/commands/commands.go @@ -281,6 +281,7 @@ func (c *commandDialogCmp) defaultCommands() []Command { ID: "switch_model", Title: "Switch Model", Description: "Switch to a different model", + Shortcut: "alt+m", Handler: func(cmd Command) tea.Cmd { return util.CmdHandler(SwitchModelMsg{}) }, diff --git a/internal/tui/keys.go b/internal/tui/keys.go index d618063e1ec0d51a1a9f8a15a1b83216f7d251e8..bda3b04bce651bda2f5e6b25d0302354696d0be4 100644 --- a/internal/tui/keys.go +++ b/internal/tui/keys.go @@ -9,6 +9,7 @@ type KeyMap struct { Help key.Binding Commands key.Binding Suspend key.Binding + Models key.Binding Sessions key.Binding pageBindings []key.Binding @@ -32,6 +33,10 @@ func DefaultKeyMap() KeyMap { key.WithKeys("ctrl+z"), key.WithHelp("ctrl+z", "suspend"), ), + Models: key.NewBinding( + key.WithKeys("alt+m"), + key.WithHelp("alt+m", "models"), + ), Sessions: key.NewBinding( key.WithKeys("ctrl+s"), key.WithHelp("ctrl+s", "sessions"), diff --git a/internal/tui/page/chat/chat.go b/internal/tui/page/chat/chat.go index 2918925068cb2f012bead47bbf44260c6255288c..c261924b4e34bc1ba76728cd3810c42ede1cf238 100644 --- a/internal/tui/page/chat/chat.go +++ b/internal/tui/page/chat/chat.go @@ -927,11 +927,15 @@ func (p *chatPage) Help() help.KeyMap { key.WithKeys("ctrl+p"), key.WithHelp("ctrl+p", "commands"), ) + modelsBinding := key.NewBinding( + key.WithKeys("alt+m"), + key.WithHelp("alt+m", "models"), + ) helpBinding := key.NewBinding( key.WithKeys("ctrl+g"), key.WithHelp("ctrl+g", "more"), ) - globalBindings = append(globalBindings, commandsBinding) + globalBindings = append(globalBindings, commandsBinding, modelsBinding) globalBindings = append(globalBindings, key.NewBinding( key.WithKeys("ctrl+s"), @@ -948,6 +952,7 @@ func (p *chatPage) Help() help.KeyMap { shortList = append(shortList, // Commands commandsBinding, + modelsBinding, ) fullList = append(fullList, globalBindings) diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 26d23f46ee62aafe07d1bb6209a4fedea929c6e1..5dc12a8e88c20c05bdba3b74157416d34bb6d236 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -459,6 +459,21 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd { return util.CmdHandler(dialogs.OpenDialogMsg{ Model: commands.NewCommandDialog(a.selectedSessionID), }) + case key.Matches(msg, a.keyMap.Models): + // if the app is not configured show no commands + if !a.isConfigured { + return nil + } + if a.dialog.ActiveDialogID() == models.ModelsDialogID { + return util.CmdHandler(dialogs.CloseDialogMsg{}) + } + if a.dialog.HasDialogs() { + return nil + } + return util.CmdHandler(dialogs.OpenDialogMsg{ + Model: models.NewModelDialogCmp(), + }) + case key.Matches(msg, a.keyMap.Sessions): // if the app is not configured show no sessions if !a.isConfigured { @@ -471,10 +486,6 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd { return nil } var cmds []tea.Cmd - if a.dialog.ActiveDialogID() == commands.CommandsDialogID { - // If the commands dialog is open, close it first - cmds = append(cmds, util.CmdHandler(dialogs.CloseDialogMsg{})) - } cmds = append(cmds, func() tea.Msg { allSessions, _ := a.app.Sessions.List(context.Background())