summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packages/tui/internal/components/chat/editor.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go
index 266df8f86..4a5212786 100644
--- a/packages/tui/internal/components/chat/editor.go
+++ b/packages/tui/internal/components/chat/editor.go
@@ -128,6 +128,22 @@ func (m *editorComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
case tea.PasteMsg:
text := string(msg)
+
+ if filePath := strings.TrimSpace(strings.TrimPrefix(text, "@")); strings.HasPrefix(text, "@") && filePath != "" {
+ statPath := filePath
+ if !filepath.IsAbs(filePath) {
+ statPath = filepath.Join(m.app.Info.Path.Cwd, filePath)
+ }
+ if _, err := os.Stat(statPath); err == nil {
+ attachment := m.createAttachmentFromPath(filePath)
+ if attachment != nil {
+ m.textarea.InsertAttachment(attachment)
+ m.textarea.InsertString(" ")
+ return m, nil
+ }
+ }
+ }
+
text = strings.ReplaceAll(text, "\\", "")
text, err := strconv.Unquote(`"` + text + `"`)
if err != nil {