From 06dba28bd69134535ad4a1482b7bbda9f26f96d6 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Fri, 4 Jul 2025 12:50:41 -0400 Subject: [PATCH] wip: fix media type --- packages/opencode/src/session/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index 437ce09b..2afba471 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -374,7 +374,7 @@ export namespace Session { start: url.searchParams.get("start"), end: url.searchParams.get("end"), } - if (range.start != null) { + if (range.start != null && part.mediaType === "text/plain") { const lines = content.split("\n") const start = parseInt(range.start) const end = range.end ? parseInt(range.end) : lines.length @@ -382,8 +382,8 @@ export namespace Session { } return { type: "file", - url: "data:text/plain;base64," + btoa(content), - mediaType: "text/plain", + url: `data:${part.mediaType};base64,` + btoa(content), + mediaType: part.mediaType, filename: part.filename, } } @@ -406,7 +406,7 @@ export namespace Session { { role: "user", content: "", - ...toParts(input.parts), + parts: toParts(input.parts).parts, }, ]), ],