on main help sign in
feat(ui): ctrl+l/ctrl+m to open model switcher (#1274)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

commit530690734d636ea62d6092f4adad1278fe6d7d1b authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateThu 6 Nov 2025, 12:58 (1 year ago) parente3cea7b
4 files changed+32−5
internal/tui/components/dialogs/commands/commands.go+1 internal/tui/keys.go+5 internal/tui/page/chat/chat.go+9−1 internal/tui/tui.go+17−4
internal/tui/components/dialogs/commands/commands.go+1
@@ -335,6 +335,7 @@ func (c *commandDialogCmp) defaultCommands() []Command {
335335 ID: "switch_model",
336336 Title: "Switch Model",
337337 Description: "Switch to a different model",
338+ Shortcut: "ctrl+l",
338339 Handler: func(cmd Command) tea.Cmd {
339340 return util.CmdHandler(SwitchModelMsg{})
340341 },
internal/tui/keys.go+5
@@ -9,6 +9,7 @@ type KeyMap struct {
99 Help key.Binding
1010 Commands key.Binding
1111 Suspend key.Binding
12+ Models key.Binding
1213 Sessions key.Binding
1314
1415 pageBindings []key.Binding
@@ -32,6 +33,10 @@ func DefaultKeyMap() KeyMap {
3233 key.WithKeys("ctrl+z"),
3334 key.WithHelp("ctrl+z", "suspend"),
3435 ),
36+ Models: key.NewBinding(
37+ key.WithKeys("ctrl+l", "ctrl+m"),
38+ key.WithHelp("ctrl+l", "models"),
39+ ),
3540 Sessions: key.NewBinding(
3641 key.WithKeys("ctrl+s"),
3742 key.WithHelp("ctrl+s", "sessions"),
internal/tui/page/chat/chat.go+9−1
@@ -942,11 +942,18 @@ func (p *chatPage) Help() help.KeyMap {
942942 key.WithKeys("ctrl+p"),
943943 key.WithHelp("ctrl+p", "commands"),
944944 )
945+ modelsBinding := key.NewBinding(
946+ key.WithKeys("ctrl+m", "ctrl+l"),
947+ key.WithHelp("ctrl+l", "models"),
948+ )
949+ if p.keyboardEnhancements.SupportsKeyDisambiguation() {
950+ modelsBinding.SetHelp("ctrl+m", "models")
951+ }
945952 helpBinding := key.NewBinding(
946953 key.WithKeys("ctrl+g"),
947954 key.WithHelp("ctrl+g", "more"),
948955 )
949− globalBindings = append(globalBindings, commandsBinding)
956+ globalBindings = append(globalBindings, commandsBinding, modelsBinding)
950957 globalBindings = append(globalBindings,
951958 key.NewBinding(
952959 key.WithKeys("ctrl+s"),
@@ -963,6 +970,7 @@ func (p *chatPage) Help() help.KeyMap {
963970 shortList = append(shortList,
964971 // Commands
965972 commandsBinding,
973+ modelsBinding,
966974 )
967975 fullList = append(fullList, globalBindings)
968976
internal/tui/tui.go+17−4
@@ -127,6 +127,9 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
127127 }
128128 return a, nil
129129 case tea.KeyboardEnhancementsMsg:
130+ if msg.SupportsKeyDisambiguation() {
131+ a.keyMap.Models.SetHelp("ctrl+m", "models")
132+ }
130133 for id, page := range a.pages {
131134 m, pageCmd := page.Update(msg)
132135 a.pages[id] = m
@@ -477,6 +480,20 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
477480 return util.CmdHandler(dialogs.OpenDialogMsg{
478481 Model: commands.NewCommandDialog(a.selectedSessionID),
479482 })
483+ case key.Matches(msg, a.keyMap.Models):
484+ // if the app is not configured show no models
485+ if !a.isConfigured {
486+ return nil
487+ }
488+ if a.dialog.ActiveDialogID() == models.ModelsDialogID {
489+ return util.CmdHandler(dialogs.CloseDialogMsg{})
490+ }
491+ if a.dialog.HasDialogs() {
492+ return nil
493+ }
494+ return util.CmdHandler(dialogs.OpenDialogMsg{
495+ Model: models.NewModelDialogCmp(),
496+ })
480497 case key.Matches(msg, a.keyMap.Sessions):
481498 // if the app is not configured show no sessions
482499 if !a.isConfigured {
@@ -489,10 +506,6 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
489506 return nil
490507 }
491508 var cmds []tea.Cmd
492− if a.dialog.ActiveDialogID() == commands.CommandsDialogID {
493− // If the commands dialog is open, close it first
494− cmds = append(cmds, util.CmdHandler(dialogs.CloseDialogMsg{}))
495− }
496509 cmds = append(cmds,
497510 func() tea.Msg {
498511 allSessions, _ := a.app.Sessions.List(context.Background())