Jelajahi Sumber

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

Timo Clasen 7 bulan lalu
induk
melakukan
f22021187d
1 mengubah file dengan 10 tambahan dan 1 penghapusan
  1. 10 1
      packages/tui/internal/components/chat/editor.go

+ 10 - 1
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)