@@ -193,30 +193,33 @@ func (m *messageCmp) renderAssistantMessage() string {
193193 return m.style().Render(joined)
194194}
195195
196−// renderUserMessage renders user messages with file attachments.
197−// Displays message content and any attached files with appropriate icons.
196+// renderUserMessage renders user messages with file attachments. It displays
197+// message content and any attached files with appropriate icons.
198198func (m *messageCmp) renderUserMessage() string {
199199 t := styles.CurrentTheme()
200200 parts := []string{
201201 m.toMarkdown(m.message.Content().String()),
202202 }
203+
203204 attachmentStyles := t.S().Text.
204205 MarginLeft(1).
205206 Background(t.BgSubtle)
206− attachments := []string{}
207− for _, attachment := range m.message.BinaryContent() {
208− file := filepath.Base(attachment.Path)
209− var filename string
210− if len(file) > 10 {
211− filename = fmt.Sprintf(" %s %s... ", styles.DocumentIcon, file[0:7])
212− } else {
213− filename = fmt.Sprintf(" %s %s ", styles.DocumentIcon, file)
214− }
215− attachments = append(attachments, attachmentStyles.Render(filename))
207+
208+ attachments := make([]string, len(m.message.BinaryContent()))
209+ for i, attachment := range m.message.BinaryContent() {
210+ const maxFilenameWidth = 10
211+ filename := filepath.Base(attachment.Path)
212+ attachments[i] = attachmentStyles.Render(fmt.Sprintf(
213+ " %s %s ",
214+ styles.DocumentIcon,
215+ ansi.Truncate(filename, maxFilenameWidth, "..."),
216+ ))
216217 }
218+
217219 if len(attachments) > 0 {
218220 parts = append(parts, "", strings.Join(attachments, ""))
219221 }
222+
220223 joined := lipgloss.JoinVertical(lipgloss.Left, parts...)
221224 return m.style().Render(joined)
222225}