Browse Source

Image tag fix for real this time (#4540)

Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
shuv 3 months ago
parent
commit
eb975bb89c

+ 2 - 1
packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx

@@ -124,9 +124,10 @@ export function Autocomplete(props: {
             (item): AutocompleteOption => ({
               display: Locale.truncateMiddle(item, width),
               onSelect: () => {
+                const mime = Bun.file(item).type || "text/plain"
                 insertPart(item, {
                   type: "file",
-                  mime: "text/plain",
+                  mime,
                   filename: item,
                   url: `file://${process.cwd()}/${item}`,
                   source: {

+ 5 - 1
packages/opencode/src/session/message-v2.ts

@@ -638,7 +638,11 @@ export namespace MessageV2 {
                 state: "output-available",
                 toolCallId: part.callID,
                 input: part.state.input,
-                output: part.state.time.compacted ? "[Old tool result content cleared]" : part.state.output,
+                output: part.state.attachments?.length
+                  ? "[Image content moved to user message]"
+                  : part.state.time.compacted
+                    ? "[Old tool result content cleared]"
+                    : part.state.output,
                 callProviderMetadata: part.metadata,
               })
             }