diff options
| author | Aiden Cline <[email protected]> | 2025-07-23 15:41:17 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-23 15:41:17 -0500 |
| commit | 289a4d9b1826fd055d3640947fa4ddb4e13ec296 (patch) | |
| tree | aa6cb96b4648a48c391436b095d0b73c6f7b791e | |
| parent | 12bf5f641d3f09c68c83f35c2fd13947091417ed (diff) | |
| download | opencode-289a4d9b1826fd055d3640947fa4ddb4e13ec296.tar.gz opencode-289a4d9b1826fd055d3640947fa4ddb4e13ec296.zip | |
tweak: handle pasted attachment references (#1257)
| -rw-r--r-- | packages/tui/internal/components/chat/editor.go | 16 |
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 { |
