From 47b50d4622eb65862e5d10fe78d5b444ea13e442 Mon Sep 17 00:00:00 2001 From: Amolith Date: Wed, 10 Dec 2025 11:35:11 -0700 Subject: [PATCH] feat(tui): show / hint when editor is empty (#1512) --- internal/tui/components/chat/editor/editor.go | 7 ++++++- internal/tui/page/chat/chat.go | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/tui/components/chat/editor/editor.go b/internal/tui/components/chat/editor/editor.go index 8ae8ed3d7dd7b5f277b8d0076b97859b5c6aa73f..c3f4ff06d631c3df757d6a7a1d12428e66a3ae58 100644 --- a/internal/tui/components/chat/editor/editor.go +++ b/internal/tui/components/chat/editor/editor.go @@ -41,6 +41,7 @@ type Editor interface { SetSession(session session.Session) tea.Cmd IsCompletionsOpen() bool HasAttachments() bool + IsEmpty() bool Cursor() *tea.Cursor } @@ -261,7 +262,7 @@ func (m *editorCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) { curIdx := m.textarea.Width()*cur.Y + cur.X switch { // Open command palette when "/" is pressed on empty prompt - case msg.String() == "/" && len(strings.TrimSpace(m.textarea.Value())) == 0: + case msg.String() == "/" && m.IsEmpty(): return m, util.CmdHandler(dialogs.OpenDialogMsg{ Model: commands.NewCommandDialog(m.session.ID), }) @@ -542,6 +543,10 @@ func (c *editorCmp) HasAttachments() bool { return len(c.attachments) > 0 } +func (c *editorCmp) IsEmpty() bool { + return strings.TrimSpace(c.textarea.Value()) == "" +} + func normalPromptFunc(info textarea.PromptInfo) string { t := styles.CurrentTheme() if info.LineNumber == 0 { diff --git a/internal/tui/page/chat/chat.go b/internal/tui/page/chat/chat.go index a5cb757d7d4403b8b99c82f5941065037bf86c71..2fbeafb87349e1f21c2b01ed1269164aea22e350 100644 --- a/internal/tui/page/chat/chat.go +++ b/internal/tui/page/chat/chat.go @@ -1024,6 +1024,9 @@ func (p *chatPage) Help() help.KeyMap { key.WithKeys("ctrl+p"), key.WithHelp("ctrl+p", "commands"), ) + if p.focusedPane == PanelTypeEditor && p.editor.IsEmpty() { + commandsBinding.SetHelp("/ or ctrl+p", "commands") + } modelsBinding := key.NewBinding( key.WithKeys("ctrl+m", "ctrl+l"), key.WithHelp("ctrl+l", "models"),