From 289a4d9b1826fd055d3640947fa4ddb4e13ec296 Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Wed, 23 Jul 2025 15:41:17 -0500 Subject: [PATCH] tweak: handle pasted attachment references (#1257) --- packages/tui/internal/components/chat/editor.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/tui/internal/components/chat/editor.go b/packages/tui/internal/components/chat/editor.go index 266df8f8..4a521278 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 {