mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
fix(tui): full paths for attachments
This commit is contained in:
parent
ee01f01271
commit
b8d276a049
2 changed files with 7 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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...,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue