fix(tui): double file content injection in commands using $ARGUMENTS

This commit is contained in:
verdverm 2026-06-07 08:11:32 -07:00
commit 5917aec929

View file

@ -1558,6 +1558,18 @@ export const layer = Layer.effect(
}
const templateParts = yield* resolvePromptParts(template)
const stripParams = (url: string) => {
const u = new URL(url)
u.search = ""
u.hash = ""
return u.href
}
const inputFileUrls = new Set(
(input.parts ?? []).flatMap((p) => (p.type === "file" ? [stripParams(p.url)] : [])),
)
const dedupedTemplateParts = templateParts.filter(
(p) => !(p.type === "file" && inputFileUrls.has(stripParams(p.url))),
)
const isSubtask = (agent.mode === "subagent" && cmd.subtask !== false) || cmd.subtask === true
const parts = isSubtask
? [
@ -1570,7 +1582,7 @@ export const layer = Layer.effect(
prompt: templateParts.find((y) => y.type === "text")?.text ?? "",
},
]
: [...templateParts, ...(input.parts ?? [])]
: [...dedupedTemplateParts, ...(input.parts ?? [])]
const userAgent = isSubtask ? (input.agent ?? (yield* agents.defaultInfo()).name) : agent.name
const userModel = isSubtask