@devries-cameron20 / t3code Mirror · read-only / commits / 25123c28d4
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 19:45 UTC

fix(shared): html_render pages from OpenCode 2 Code Mode show and are cleaned up (#35022)

Julius Marminge committed Nov 12, 2026 at 02:29 UTC 25123c28d46c49a990b7d0119db683dd9a3fd719
3 files changed +26 -1
apps/server/src/attachmentStore.test.ts
+15
@@ -176,6 +176,21 @@ describe("threadHtmlRenderAttachmentIds", () => {
176 ).toEqual([own]);
177 });
178
179 + it("includes pages an OpenCode Code Mode execute script returned", () => {
180 + const own = createAttachmentId("thread-a", "html")!;
181 + expect(
182 + threadHtmlRenderAttachmentIds("thread-a", [
183 + {
184 + toolName: "execute",
185 + output: JSON.stringify({
186 + htmlRender: { attachmentId: own, title: "x", height: 300 },
187 + message: "Shown to the reader above your reply.",
188 + }),
189 + },
190 + ]),
191 + ).toEqual([own]);
192 + });
193 +
194 it("includes captured MCP App documents from any tool", () => {
195 const app = createAttachmentId("thread-a", "html")!;
196 expect(
packages/shared/src/htmlRender.test.ts
+2
@@ -167,6 +167,8 @@ describe("htmlRenderFromToolItem", () => {
167 ["t3-code.html_render", { structuredContent: result, content: [] }],
168 ["t3-code-thread_1_html_render", JSON.stringify(result)],
169 ["html_render", result],
170 + // OpenCode 2 Code Mode reports a script's nested html_render call as one `execute` item.
171 + ["execute", JSON.stringify(result)],
172 ] as const) {
173 expect(htmlRenderFromToolItem({ toolName, output })).toEqual(reference);
174 }
packages/shared/src/toolOutput.ts
+9 -1
@@ -187,11 +187,19 @@ export function compactDynamicToolOutput(value: unknown): CompactToolOutput | un
187 return Object.keys(output).length === 0 ? undefined : output;
188 }
189
190 +// OpenCode 2 Code Mode reports a script's nested T3 tool calls as one item with the script's result.
191 +const OPENCODE_CODE_MODE_TOOL_NAME = "execute";
192 +
193 export function htmlRenderFromToolItem(item: {
194 readonly toolName: string | null | undefined;
195 readonly output?: unknown;
196 }): HtmlRenderReference | undefined {
194 - if (resolveT3McpToolId(item.toolName) !== HTML_RENDER_TOOL_NAME) return undefined;
197 + if (
198 + item.toolName !== OPENCODE_CODE_MODE_TOOL_NAME &&
199 + resolveT3McpToolId(item.toolName) !== HTML_RENDER_TOOL_NAME
200 + ) {
201 + return undefined;
202 + }
203 const output = compactDynamicToolOutput(item.output);
204 return output?.isError ? undefined : output?.htmlRender;
205 }