Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/tui/components/dialogs/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ func (c *commandDialogCmp) defaultCommands() []Command {
ID: "switch_model",
Title: "Switch Model",
Description: "Switch to a different model",
Shortcut: "ctrl+l",
Handler: func(cmd Command) tea.Cmd {
return util.CmdHandler(SwitchModelMsg{})
},
Expand Down
5 changes: 5 additions & 0 deletions internal/tui/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,6 +33,10 @@ func DefaultKeyMap() KeyMap {
key.WithKeys("ctrl+z"),
key.WithHelp("ctrl+z", "suspend"),
),
Models: key.NewBinding(
key.WithKeys("ctrl+l", "ctrl+m"),
key.WithHelp("ctrl+l", "models"),
),
Sessions: key.NewBinding(
key.WithKeys("ctrl+s"),
key.WithHelp("ctrl+s", "sessions"),
Expand Down
10 changes: 9 additions & 1 deletion internal/tui/page/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,11 +927,18 @@ func (p *chatPage) Help() help.KeyMap {
key.WithKeys("ctrl+p"),
key.WithHelp("ctrl+p", "commands"),
)
modelsBinding := key.NewBinding(
key.WithKeys("ctrl+m", "ctrl+l"),
key.WithHelp("ctrl+l", "models"),
)
if p.keyboardEnhancements.SupportsKeyDisambiguation() {
modelsBinding.SetHelp("ctrl+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"),
Expand All @@ -948,6 +955,7 @@ func (p *chatPage) Help() help.KeyMap {
shortList = append(shortList,
// Commands
commandsBinding,
modelsBinding,
)
fullList = append(fullList, globalBindings)

Expand Down
21 changes: 17 additions & 4 deletions internal/tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

switch msg := msg.(type) {
case tea.KeyboardEnhancementsMsg:
if msg.SupportsKeyDisambiguation() {
a.keyMap.Models.SetHelp("ctrl+m", "models")
}
for id, page := range a.pages {
m, pageCmd := page.Update(msg)
if model, ok := m.(util.Model); ok {
Expand Down Expand Up @@ -459,6 +462,20 @@ 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 models
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 {
Expand All @@ -471,10 +488,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())
Expand Down
Loading