mirror of
https://github.com/sst/opencode.git
synced 2025-08-31 18:27:22 +00:00
fix: deduplicate attachments by path
This commit is contained in:
parent
81fb1b313e
commit
00b77572f0
1 changed files with 21 additions and 1 deletions
|
@ -440,7 +440,27 @@ func (m *editorComponent) Submit() (tea.Model, tea.Cmd) {
|
|||
var cmds []tea.Cmd
|
||||
attachments := m.textarea.GetAttachments()
|
||||
|
||||
prompt := app.Prompt{Text: value, Attachments: attachments}
|
||||
// Deduplicate by path
|
||||
seen := make(map[string]bool)
|
||||
deduped := make([]*attachment.Attachment, 0, len(attachments))
|
||||
for _, att := range attachments {
|
||||
var path string
|
||||
if fs, ok := att.GetFileSource(); ok {
|
||||
path = fs.Path
|
||||
} else if ss, ok := att.GetSymbolSource(); ok {
|
||||
path = ss.Path
|
||||
} else {
|
||||
// Not a file or symbol source, just add it
|
||||
deduped = append(deduped, att)
|
||||
continue
|
||||
}
|
||||
|
||||
if path != "" && !seen[path] {
|
||||
seen[path] = true
|
||||
deduped = append(deduped, att)
|
||||
}
|
||||
}
|
||||
prompt := app.Prompt{Text: value, Attachments: deduped}
|
||||
m.app.State.AddPromptToHistory(prompt)
|
||||
cmds = append(cmds, m.app.SaveState())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue