From 8723e87682bd19beadd253bc472d2917e69e987b Mon Sep 17 00:00:00 2001 From: Ayyan Date: Wed, 14 Jan 2026 20:23:18 -0500 Subject: [PATCH] fix(ui/chat): display names of all attached files (#706) --- internal/ui/chat/message_input.go | 7 ++++++- internal/ui/chat/util.go | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 internal/ui/chat/util.go diff --git a/internal/ui/chat/message_input.go b/internal/ui/chat/message_input.go index 2100970..eb20262 100644 --- a/internal/ui/chat/message_input.go +++ b/internal/ui/chat/message_input.go @@ -658,5 +658,10 @@ func (mi *messageInput) openFilePicker() { func (mi *messageInput) attach(name string, reader io.Reader) { mi.sendMessageData.Files = append(mi.sendMessageData.Files, sendpart.File{Name: name, Reader: reader}) - mi.SetFooter("Attached " + name) + + var names []string + for _, file := range mi.sendMessageData.Files { + names = append(names, file.Name) + } + mi.SetFooter("Attached " + humanJoin(names)) } diff --git a/internal/ui/chat/util.go b/internal/ui/chat/util.go new file mode 100644 index 0000000..e822f1a --- /dev/null +++ b/internal/ui/chat/util.go @@ -0,0 +1,17 @@ +package chat + +import "strings" + +func humanJoin(items []string) string { + count := len(items) + switch count { + case 0: + return "" + case 1: + return items[0] + case 2: + return items[0] + " and " + items[1] + default: + return strings.Join(items[:count-1], ", ") + ", and " + items[count-1] + } +}