on main help sign in
feat(tui/chat): use @ for files, / for commands (#1377)
757d823Amolith
internal/tui/components/chat/editor/editor.go+7−2
@@ -264,8 +264,13 @@ func (m *editorCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
264 cur := m.textarea.Cursor()
264 cur := m.textarea.Cursor()
265 curIdx := m.textarea.Width()*cur.Y + cur.X
265 curIdx := m.textarea.Width()*cur.Y + cur.X
266 switch {
266 switch {
267+ // Open command palette when "/" is pressed on empty prompt
268+ case msg.String() == "/" && len(strings.TrimSpace(m.textarea.Value())) == 0:
269+ return m, util.CmdHandler(dialogs.OpenDialogMsg{
270+ Model: commands.NewCommandDialog(m.session.ID),
271+ })
267 // Completions
272 // Completions
268− case msg.String() == "/" && !m.isCompletionsOpen &&
273+ case msg.String() == "@" && !m.isCompletionsOpen &&
269 // only show if beginning of prompt, or if previous char is a space or newline:
274 // only show if beginning of prompt, or if previous char is a space or newline:
270 (len(m.textarea.Value()) == 0 || unicode.IsSpace(rune(m.textarea.Value()[len(m.textarea.Value())-1]))):
275 (len(m.textarea.Value()) == 0 || unicode.IsSpace(rune(m.textarea.Value()[len(m.textarea.Value())-1]))):
271 m.isCompletionsOpen = true
276 m.isCompletionsOpen = true
@@ -337,7 +342,7 @@ func (m *editorCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
337 cmds = append(cmds, util.CmdHandler(completions.CloseCompletionsMsg{}))
342 cmds = append(cmds, util.CmdHandler(completions.CloseCompletionsMsg{}))
338 } else {
343 } else {
339 word := m.textarea.Word()
344 word := m.textarea.Word()
340− if strings.HasPrefix(word, "/") {
345+ if strings.HasPrefix(word, "@") {
341 // XXX: wont' work if editing in the middle of the field.
346 // XXX: wont' work if editing in the middle of the field.
342 m.completionsStartIndex = strings.LastIndex(m.textarea.Value(), word)
347 m.completionsStartIndex = strings.LastIndex(m.textarea.Value(), word)
343 m.currentQuery = word[1:]
348 m.currentQuery = word[1:]
internal/tui/page/chat/chat.go+2−2
@@ -1037,8 +1037,8 @@ func (p *chatPage) Help() help.KeyMap {
1037 key.WithHelp("ctrl+f", "add image"),
1037 key.WithHelp("ctrl+f", "add image"),
1038 ),
1038 ),
1039 key.NewBinding(
1039 key.NewBinding(
1040− key.WithKeys("/"),
1040+ key.WithKeys("@"),
1041− key.WithHelp("/", "add file"),
1041+ key.WithHelp("@", "mention file"),
1042 ),
1042 ),
1043 key.NewBinding(
1043 key.NewBinding(
1044 key.WithKeys("ctrl+o"),
1044 key.WithKeys("ctrl+o"),