From 2689348c0794e143ed0fd1576c45b60504d34610 Mon Sep 17 00:00:00 2001 From: Amolith Date: Tue, 25 Nov 2025 15:00:50 -0700 Subject: [PATCH] feat(tui): show / hint when editor is empty Assisted-by: Claude Opus 4.5 via Crush --- 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 de1a98b34595613594e83063cc12add4ba820c84..5dac392c12dd01cc8663ae38cea00a14c00e4e13 100644 --- a/internal/tui/components/chat/editor/editor.go +++ b/internal/tui/components/chat/editor/editor.go @@ -42,6 +42,7 @@ type Editor interface { SetSession(session session.Session) tea.Cmd IsCompletionsOpen() bool HasAttachments() bool + IsEmpty() bool Cursor() *tea.Cursor } @@ -265,7 +266,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), }) @@ -546,6 +547,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 f951de8677271dfbf034377afaa492f0d8824889..7d83124de2b0d44ad1011b89c6d75fd46f60c590 100644 --- a/internal/tui/page/chat/chat.go +++ b/internal/tui/page/chat/chat.go @@ -942,6 +942,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"),