From 07712923360749a01f1de5d9b9e5c555dc8cd59c Mon Sep 17 00:00:00 2001 From: BB-fat <1056871944@qq.com> Date: Thu, 13 Aug 2026 18:06:57 +0000 Subject: [PATCH] fix(dsh-plugin-browserskill): keep the terminal result card for multi-block results browser_screenshot on an image-capable route returns text + image blocks; the shared result presenter required exactly one text block and bailed to the generic card (tool name + raw args). Project the first text block instead so the terminal card shows in both modes. --- packages/dsh-plugin-browserskill/src/tools.ts | 4 +++- .../dsh-plugin-browserskill/tests/tools.test.ts | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/dsh-plugin-browserskill/src/tools.ts b/packages/dsh-plugin-browserskill/src/tools.ts index 7ca2059..416517b 100644 --- a/packages/dsh-plugin-browserskill/src/tools.ts +++ b/packages/dsh-plugin-browserskill/src/tools.ts @@ -81,7 +81,9 @@ function cmdline(deps: ToolDeps, args: string[]): string { /** Shared completed-card presenter: terminal card with the rendered text. */ function presentTerminalResult(_args: never, result: ToolResult) { - const block = result.content.length === 1 ? result.content[0] : undefined; + // Multi-block results (e.g. screenshot text + image) still project their + // text block onto the terminal card. + const block = result.content.find((b) => b.type === "text"); if (block === undefined || block.type !== "text") return undefined; if (result.isError) return undefined; return { card: "terminal" as const, output: block.text, exitCode: 0 }; diff --git a/packages/dsh-plugin-browserskill/tests/tools.test.ts b/packages/dsh-plugin-browserskill/tests/tools.test.ts index e234f68..9b6aa60 100644 --- a/packages/dsh-plugin-browserskill/tests/tools.test.ts +++ b/packages/dsh-plugin-browserskill/tests/tools.test.ts @@ -524,4 +524,17 @@ describe("presentation", () => { } as never) as { card: string; output: string; exitCode: number }; expect(view).toMatchObject({ card: "terminal", output: "clicked", exitCode: 0 }); }); + + it("projects the text block of multi-block results (screenshot text + image)", () => { + const { tools } = setup({}); + const screenshot = tools.get("browser_screenshot"); + const view = screenshot?.presentResult?.({}, { + content: [ + { type: "text", text: "[session s1] screenshot of tab 7" }, + { type: "image", attachment: { attachmentId: "a1" } }, + ], + isError: false, + } as never) as { card: string; output: string }; + expect(view).toMatchObject({ card: "terminal", output: "[session s1] screenshot of tab 7" }); + }); });