summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorshuv <[email protected]>2025-11-22 10:47:57 -0800
committerGitHub <[email protected]>2025-11-22 12:47:57 -0600
commitbdcf864678cc79679d65acebd053b3e2b1b7d0c5 (patch)
tree863f39232843b3bf428e8d8fc86249b70baa6bc6
parent0dd5039668a52d340ebe97f8ff0a7829ed65eb5b (diff)
downloadopencode-bdcf864678cc79679d65acebd053b3e2b1b7d0c5.tar.gz
opencode-bdcf864678cc79679d65acebd053b3e2b1b7d0c5.zip
proper fix for image attachments (#4562)
Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
-rw-r--r--packages/opencode/src/session/prompt.ts34
-rw-r--r--packages/plugin/package.json2
-rw-r--r--packages/sdk/js/package.json2
3 files changed, 24 insertions, 14 deletions
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index b2816c0ef..08c3d7809 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -907,22 +907,32 @@ export namespace SessionPrompt {
extra: { bypassCwdCheck: true, ...info.model },
metadata: async () => {},
})
- pieces.push(
- {
- id: Identifier.ascending("part"),
- messageID: info.id,
- sessionID: input.sessionID,
- type: "text",
- synthetic: true,
- text: result.output,
- },
- {
+ pieces.push({
+ id: Identifier.ascending("part"),
+ messageID: info.id,
+ sessionID: input.sessionID,
+ type: "text",
+ synthetic: true,
+ text: result.output,
+ })
+ if (result.attachments?.length) {
+ pieces.push(
+ ...result.attachments.map((attachment) => ({
+ ...attachment,
+ synthetic: true,
+ filename: attachment.filename ?? part.filename,
+ messageID: info.id,
+ sessionID: input.sessionID,
+ })),
+ )
+ } else {
+ pieces.push({
...part,
id: part.id ?? Identifier.ascending("part"),
messageID: info.id,
sessionID: input.sessionID,
- },
- )
+ })
+ }
})
.catch((error) => {
log.error("failed to read file", { error })
diff --git a/packages/plugin/package.json b/packages/plugin/package.json
index b158923d6..c3572c5da 100644
--- a/packages/plugin/package.json
+++ b/packages/plugin/package.json
@@ -24,4 +24,4 @@
"typescript": "catalog:",
"@typescript/native-preview": "catalog:"
}
-} \ No newline at end of file
+}
diff --git a/packages/sdk/js/package.json b/packages/sdk/js/package.json
index 5fbfb5eb0..f739788f6 100644
--- a/packages/sdk/js/package.json
+++ b/packages/sdk/js/package.json
@@ -26,4 +26,4 @@
"publishConfig": {
"directory": "dist"
}
-} \ No newline at end of file
+}