Skip to content

Commit 562f067

Browse files
authored
fix: deduplicate file refs in sent prompts (anomalyco#8303)
1 parent 1ff46c7 commit 562f067

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,28 @@ export function Autocomplete(props: {
159159
})
160160

161161
props.setPrompt((draft) => {
162+
if (part.type === "file") {
163+
const existingIndex = draft.parts.findIndex(
164+
(p) => p.type === "file" && "url" in p && p.url === part.url,
165+
)
166+
if (existingIndex !== -1) {
167+
const existing = draft.parts[existingIndex]
168+
if (
169+
part.source?.text &&
170+
existing &&
171+
"source" in existing &&
172+
existing.source &&
173+
"text" in existing.source &&
174+
existing.source.text
175+
) {
176+
existing.source.text.start = extmarkStart
177+
existing.source.text.end = extmarkEnd
178+
existing.source.text.value = virtualText
179+
}
180+
return
181+
}
182+
}
183+
162184
if (part.type === "file" && part.source?.text) {
163185
part.source.text.start = extmarkStart
164186
part.source.text.end = extmarkEnd

0 commit comments

Comments
 (0)