on main help sign in
feat: allow to send the prompt if its empty but has text attachments (#1809)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

commit030c8fc58ea90cdf796827a8eb69b1e9f02cb5c6 authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateFri 9 Jan 2026, 14:04 (9 months ago) parent1e83e66
4 files changed+18−4
internal/agent/agent.go+1−1 internal/message/attachment.go+11−1 internal/ui/chat/user.go+5−1 internal/ui/model/ui.go+1−1
internal/agent/agent.go+1−1
@@ -134,7 +134,7 @@ func NewSessionAgent(
134134}
135135
136136func (a *sessionAgent) Run(ctx context.Context, call SessionAgentCall) (*fantasy.AgentResult, error) {
137− if call.Prompt == "" {
137+ if call.Prompt == "" && !message.ContainsTextAttachment(call.Attachments) {
138138 return nil, ErrEmptyPrompt
139139 }
140140 if call.SessionID == "" {
internal/message/attachment.go+11−1
@@ -1,6 +1,9 @@
11package message
22
3−import "strings"
3+import (
4+ "slices"
5+ "strings"
6+)
47
58type Attachment struct {
69 FilePath string
@@ -11,3 +14,10 @@ type Attachment struct {
1114
1215func (a Attachment) IsText() bool { return strings.HasPrefix(a.MimeType, "text/") }
1316func (a Attachment) IsImage() bool { return strings.HasPrefix(a.MimeType, "image/") }
17+
18+// ContainsTextAttachment returns true if any of the attachments is a text attachment.
19+func ContainsTextAttachment(attachments []Attachment) bool {
20+ return slices.ContainsFunc(attachments, func(a Attachment) bool {
21+ return a.IsText()
22+ })
23+}
internal/ui/chat/user.go+5−1
@@ -60,7 +60,11 @@ func (m *UserMessageItem) Render(width int) string {
6060
6161 if len(m.message.BinaryContent()) > 0 {
6262 attachmentsStr := m.renderAttachments(cappedWidth)
63− content = strings.Join([]string{content, "", attachmentsStr}, "\n")
63+ if content == "" {
64+ content = attachmentsStr
65+ } else {
66+ content = strings.Join([]string{content, "", attachmentsStr}, "\n")
67+ }
6468 }
6569
6670 height = lipgloss.Height(content)
internal/ui/model/ui.go+1−1
@@ -872,7 +872,7 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
872872
873873 attachments := m.attachments.List()
874874 m.attachments.Reset()
875− if len(value) == 0 {
875+ if len(value) == 0 && !message.ContainsTextAttachment(attachments) {
876876 return nil
877877 }
878878