diff --git a/internal/ui/model/keys.go b/internal/ui/model/keys.go index cf2fdcaa431b2a9c43a9612ef99ec8ce696216ca..a42b1e7aa0ac9ac474de626b55ceb3a91824cdff 100644 --- a/internal/ui/model/keys.go +++ b/internal/ui/model/keys.go @@ -10,6 +10,7 @@ type KeyMap struct { Newline key.Binding AddImage key.Binding MentionFile key.Binding + Commands key.Binding // Attachments key maps AttachmentDeleteMode key.Binding @@ -123,6 +124,10 @@ func DefaultKeyMap() KeyMap { key.WithKeys("@"), key.WithHelp("@", "mention file"), ) + km.Editor.Commands = key.NewBinding( + key.WithKeys("/"), + key.WithHelp("/", "commands"), + ) km.Editor.AttachmentDeleteMode = key.NewBinding( key.WithKeys("ctrl+r"), key.WithHelp("ctrl+r+{i}", "delete attachment at index i"), diff --git a/internal/ui/model/ui.go b/internal/ui/model/ui.go index e100b6605fceceded84da8cd6cfb16507ddf64a4..9eb7f01f881e70ad82597820dac8e3161f4cd684 100644 --- a/internal/ui/model/ui.go +++ b/internal/ui/model/ui.go @@ -1542,6 +1542,10 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd { if cmd != nil { cmds = append(cmds, cmd) } + case key.Matches(msg, m.keyMap.Editor.Commands) && m.textarea.Value() == "": + if cmd := m.openCommandsDialog(); cmd != nil { + cmds = append(cmds, cmd) + } default: if handleGlobalKeys(msg) { // Handle global keys first before passing to textarea. @@ -1865,7 +1869,7 @@ func (m *UI) ShortHelp() []key.Binding { k := &m.keyMap tab := k.Tab commands := k.Commands - if m.focus == uiFocusEditor && m.textarea.LineCount() == 0 { + if m.focus == uiFocusEditor && m.textarea.Value() == "" { commands.SetHelp("/ or ctrl+p", "commands") } @@ -1941,7 +1945,7 @@ func (m *UI) FullHelp() [][]key.Binding { hasAttachments := len(m.attachments.List()) > 0 hasSession := m.hasSession() commands := k.Commands - if m.focus == uiFocusEditor && m.textarea.LineCount() == 0 { + if m.focus == uiFocusEditor && m.textarea.Value() == "" { commands.SetHelp("/ or ctrl+p", "commands") }