Skip to content

The open source coding agent.

TypeScript

feat(tui): treat pasted text file paths as file references (#809)

Timo Clasenf22021187dec
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go
index 6053c9c013c..4f624972261 100644
--- a/packages/tui/internal/components/chat/editor.go
+++ b/packages/tui/internal/components/chat/editor.go
@@ -96,7 +96,16 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case ".pdf":
mediaType = "application/pdf"
default:
- mediaType = "text/plain"
+ attachment := &textarea.Attachment{
+ ID: uuid.NewString(),
+ Display: "@" + filePath,
+ URL: fmt.Sprintf("file://./%s", filePath),
+ Filename: filePath,
+ MediaType: "text/plain",
+ }
+ m.textarea.InsertAttachment(attachment)
+ m.textarea.InsertString(" ")
+ return m, nil
}
fileBytes, err := os.ReadFile(filePath)