@@ -207,27 +207,13 @@ func (m *messageCmp) renderUserMessage() string {
208 attachments := make([]string, len(m.message.BinaryContent()))
208 attachments := make([]string, len(m.message.BinaryContent()))
209 for i, attachment := range m.message.BinaryContent() {
209 for i, attachment := range m.message.BinaryContent() {
210+ const maxFilenameWidth = 10
210 filename := filepath.Base(attachment.Path)
211 filename := filepath.Base(attachment.Path)
211− var displayFilename string
212− runes := []rune(filename)
214− const truncateAtChars = 7
215− const truncateSuffix = "..."
217− // If the filename is too long, truncate it to fit within the maximum
218− // width we’ve chosen.
219− if lipgloss.Width(filename) > truncateAtChars+lipgloss.Width(truncateSuffix) {
220− displayFilename = fmt.Sprintf(
222− styles.DocumentIcon,
223− string(runes[0:truncateAtChars]),
227− displayFilename = fmt.Sprintf(" %s %s ", styles.DocumentIcon, filename)
230− attachments[i] = attachmentStyles.Render(displayFilename)
212+ attachments[i] = attachmentStyles.Render(fmt.Sprintf(
214+ styles.DocumentIcon,
215+ ansi.Truncate(filename, maxFilenameWidth, "..."),
233 if len(attachments) > 0 {
219 if len(attachments) > 0 {