From a06091b4023c161402a2eabc79a6feb4d4adbcbe 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 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 f09f9782b0c77207fc9b96209f5714263236c11f..6ce02db3248c47df20df56cd2b212fe574d3fe7f 100644 --- a/internal/tui/page/chat/chat.go +++ b/internal/tui/page/chat/chat.go @@ -1015,6 +1015,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"),