mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-09 22:25:02 +03:00
fix(app): stop omitted tool images from keeping their payload alive (#58560)
This commit is contained in:
committed by
GitHub
Unverified
parent
d9ef1ce722
commit
d7cea3d66e
@@ -167,12 +167,11 @@ function optimisticFiles(files: SessionPromptInput["files"]) {
|
||||
return items?.length ? items : undefined
|
||||
}
|
||||
|
||||
// Keeps the `data:<mime>;base64,` header so the item still says what it was.
|
||||
// Keeps an empty `data:<mime>;base64,` URI so the item still says what it was. It is built from `mime` because any
|
||||
// slice of the original URI is a V8 sliced string that keeps the whole payload alive.
|
||||
function omitFileData(content: [ToolContent, ...ToolContent[]]): [ToolContent, ...ToolContent[]] {
|
||||
const omit = (item: ToolContent): ToolContent =>
|
||||
item.type === "file" && item.uri.startsWith("data:")
|
||||
? { ...item, uri: item.uri.slice(0, item.uri.indexOf(",") + 1) }
|
||||
: item
|
||||
item.type === "file" && item.uri.startsWith("data:") ? { ...item, uri: `data:${item.mime};base64,` } : item
|
||||
return [omit(content[0]), ...content.slice(1).map(omit)]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user