fix(tui): full paths for attachments

This commit is contained in:
adamdottv 2025-07-04 11:42:22 -05:00
parent ee01f01271
commit b8d276a049
No known key found for this signature in database
GPG key ID: 9CB48779AF150E75
2 changed files with 7 additions and 6 deletions

View file

@ -109,7 +109,7 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
ID: uuid.NewString(),
Display: "@" + fileName,
URL: fmt.Sprintf("file://./%s", filePath),
Filename: fileName,
Filename: filePath,
MediaType: mediaType,
}
m.textarea.InsertAttachment(attachment)
@ -238,7 +238,8 @@ func (m *editorComponent) Submit() (tea.Model, tea.Cmd) {
}
if len(value) > 0 && value[len(value)-1] == '\\' {
// If the last character is a backslash, remove it and add a newline
m.textarea.SetValue(value[:len(value)-1] + "\n")
m.textarea.ReplaceRange(len(value)-1, len(value), "")
m.textarea.InsertString("\n")
return m, nil
}
@ -284,7 +285,7 @@ func (m *editorComponent) Paste() (tea.Model, tea.Cmd) {
// }
// m.attachments = append(m.attachments, attachment)
// } else {
m.textarea.SetValue(m.textarea.Value() + text)
m.textarea.InsertString(text)
// }
return m, nil
}

View file

@ -156,10 +156,11 @@ func (m *messagesComponent) renderView(width int) {
mediaType = "txt"
case "image/png", "image/jpeg", "image/gif", "image/webp":
mediaType = "img"
mediaTypeStyle = mediaTypeStyle.Background(t.Accent())
case "application/pdf":
mediaType = "pdf"
mediaTypeStyle = mediaTypeStyle.Background(t.Primary())
}
flexItems = append(flexItems, layout.FlexItem{
View: mediaTypeStyle.Render(mediaType) + fileStyle.Render(filePart.Filename),
})
@ -170,8 +171,7 @@ func (m *messagesComponent) renderView(width int) {
layout.FlexOptions{
Background: &bgColor,
Width: width - 6,
Direction: layout.Row,
Gap: 3,
Direction: layout.Column,
},
flexItems...,
)