Skip to content

Commit 352ea01

Browse files
committed
fix(chat): skip HTML previews without input
1 parent 2c1142d commit 352ea01

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎packages/client-runtime/src/work-log/itemDetail.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ const htmlTool = {
2626
};
2727

2828
describe("HTML tool inputs", () => {
29+
it.each([{}, null, undefined, "", { html: null }])(
30+
"does not offer an HTML preview when source is missing: %j",
31+
(args) => {
32+
expect(toolCallLines({ toolName: "mcp__t3-code__html_preview", args }).html).toBe(false);
33+
},
34+
);
35+
2936
it("keeps blank HTML visible without requesting a preview", () => {
3037
const html = " \n\t ";
3138
const lines = toolCallLines({ toolName: "mcp__t3-code__html_preview", args: { html } });

‎packages/client-runtime/src/work-log/itemDetail.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ export function toolCallLines(input: {
9797
const args = input.args;
9898
const html =
9999
isHtmlRenderTool(input.toolName) &&
100-
// Bounded inputs can omit the source; reject a blank source only when it is available.
101-
(isRecord(args) && typeof args.html === "string" ? args.html.trim() !== "" : true) &&
100+
// Summary payloads still resolve the full source through the asset route.
101+
(isRecord(args)
102+
? isSummarizedValue(args) || (typeof args.html === "string" && args.html.trim() !== "")
103+
: typeof args === "string" && args.trim() !== "") &&
102104
input.status !== "failed" &&
103105
compactDynamicToolOutput(input.output)?.isError !== true;
104106
if (isRecord(args) && !isSummarizedValue(args)) {

0 commit comments

Comments
 (0)