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

View file

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