summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-07-04 11:13:09 -0500
committeradamdottv <[email protected]>2025-07-04 11:13:09 -0500
commitf6108b7be87c06e8fbebb7f52c71ad54438742af (patch)
tree44f7d38c51e056387dd84897b4ce09211ca381be
parent94ef341c9dfd59a070ed4c855e973f99009bcf7e (diff)
downloadopencode-f6108b7be87c06e8fbebb7f52c71ad54438742af.tar.gz
opencode-f6108b7be87c06e8fbebb7f52c71ad54438742af.zip
fix(tui): handle pdf and image @ files
-rw-r--r--packages/tui/internal/components/chat/editor.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go
index 595fd4d57..427fcc3cf 100644
--- a/packages/tui/internal/components/chat/editor.go
+++ b/packages/tui/internal/components/chat/editor.go
@@ -93,12 +93,24 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// The cursor is now at `atIndex` after the replacement.
filePath := msg.CompletionValue
fileName := filepath.Base(filePath)
+ extension := filepath.Ext(filePath)
+ mediaType := ""
+ switch extension {
+ case ".jpg":
+ mediaType = "image/jpeg"
+ case ".png", ".jpeg", ".gif", ".webp":
+ mediaType = "image/" + extension[1:]
+ case ".pdf":
+ mediaType = "application/pdf"
+ default:
+ mediaType = "text/plain"
+ }
attachment := &textarea.Attachment{
ID: uuid.NewString(),
Display: "@" + fileName,
URL: fmt.Sprintf("file://%s", filePath),
Filename: fileName,
- MediaType: "text/plain",
+ MediaType: mediaType,
}
m.textarea.InsertAttachment(attachment)
m.textarea.InsertString(" ")