on main help sign in
feat(tui): editor: change textarea placeholder based on CoderAgent state (#263)

* feat(tui): change textarea placeholder based on CoderAgent state * fix(tui): editor: cache random placeholders for editor Make sure we update the editor's placeholder text when a new message is sent. * fix(tui): editor: update editor placeholder on new message send --------- Co-authored-by: Raphael Amorim <rapha850@gmail.com>

commit334dafcf9496e4700a2e66f5a0168c10df1c3b51 authorAyman Bagabas <ayman.bagabas@gmail.com> dateTue 29 Jul 2025, 10:02 (1 year ago) parent30d2c82
2 files changed+45−10
internal/tui/components/chat/editor/editor.go+44−10 internal/tui/page/chat/chat.go+1
internal/tui/components/chat/editor/editor.go+44−10
@@ -2,6 +2,7 @@ package editor
22
33import (
44 "fmt"
5+ "math/rand"
56 "net/http"
67 "os"
78 "os/exec"
@@ -48,14 +49,16 @@ type FileCompletionItem struct {
4849}
4950
5051type editorCmp struct {
51− width int
52− height int
53− x, y int
54− app *app.App
55− session session.Session
56− textarea textarea.Model
57− attachments []message.Attachment
58− deleteMode bool
52+ width int
53+ height int
54+ x, y int
55+ app *app.App
56+ session session.Session
57+ textarea textarea.Model
58+ attachments []message.Attachment
59+ deleteMode bool
60+ readyPlaceholder string
61+ workingPlaceholder string
5962
6063 keyMap EditorKeyMap
6164
@@ -157,6 +160,10 @@ func (m *editorCmp) send() tea.Cmd {
157160 if value == "" {
158161 return nil
159162 }
163+
164+ // Change the placeholder when sending a new message.
165+ m.randomizePlaceholders()
166+
160167 return tea.Batch(
161168 util.CmdHandler(chat.SendMsg{
162169 Text: value,
@@ -379,8 +386,31 @@ func (m *editorCmp) Cursor() *tea.Cursor {
379386 return cursor
380387}
381388
389+var readyPlaceholders = [...]string{
390+ "Ready!",
391+ "Ready...",
392+ "Ready?",
393+}
394+
395+var workingPlaceholders = [...]string{
396+ "Working!",
397+ "Working...",
398+ "Working?",
399+}
400+
401+func (m *editorCmp) randomizePlaceholders() {
402+ m.workingPlaceholder = workingPlaceholders[rand.Intn(len(workingPlaceholders))]
403+ m.readyPlaceholder = readyPlaceholders[rand.Intn(len(readyPlaceholders))]
404+}
405+
382406func (m *editorCmp) View() string {
383407 t := styles.CurrentTheme()
408+ // Update placeholder
409+ if m.app.CoderAgent.IsBusy() {
410+ m.textarea.Placeholder = m.workingPlaceholder
411+ } else {
412+ m.textarea.Placeholder = m.readyPlaceholder
413+ }
384414 if len(m.attachments) == 0 {
385415 content := t.S().Base.Padding(1).Render(
386416 m.textarea.View(),
@@ -510,14 +540,18 @@ func New(app *app.App) Editor {
510540 })
511541 ta.ShowLineNumbers = false
512542 ta.CharLimit = -1
513− ta.Placeholder = "Tell me more about this project..."
514543 ta.SetVirtualCursor(false)
515544 ta.Focus()
516545
517− return &editorCmp{
546+ e := &editorCmp{
518547 // TODO: remove the app instance from here
519548 app: app,
520549 textarea: ta,
521550 keyMap: DefaultEditorKeyMap(),
522551 }
552+
553+ e.randomizePlaceholders()
554+ e.textarea.Placeholder = e.readyPlaceholder
555+
556+ return e
523557}
internal/tui/page/chat/chat.go+1
@@ -254,6 +254,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
254254 p.chat = u.(chat.MessageListCmp)
255255 cmds = append(cmds, cmd)
256256 }
257+
257258 return p, tea.Batch(cmds...)
258259
259260 case pubsub.Event[history.File], sidebar.SessionFilesMsg: