From 316c11868032d7c4cdf1bd5d302bb285dc5b75bc Mon Sep 17 00:00:00 2001 From: hzliangzhi Date: Mon, 17 Aug 2026 11:46:50 +0800 Subject: [PATCH] fix(collab-web): render the user-added note in ask tool cards The ask tool stores the user-attached note in result details (note on the single-question shape, per-item note inside results[]), but the shared tool renderer dropped it: AskAnswer carried no note field and the card never rendered one. Extract and render it as a muted row so HTML exports and the collab guest view keep the user's context. --- packages/collab-web/CHANGELOG.md | 4 ++ .../collab-web/src/tool-render/tools/ask.tsx | 8 +++ packages/collab-web/test/tool-view.test.tsx | 62 +++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/packages/collab-web/CHANGELOG.md b/packages/collab-web/CHANGELOG.md index 0c46e80f5..5c03479c8 100644 --- a/packages/collab-web/CHANGELOG.md +++ b/packages/collab-web/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- The ask tool card now renders the note the user attached to their answer; previously it was dropped from HTML exports and the collab guest view. + ## [17.2.10] - 2026-08-06 ### Changed diff --git a/packages/collab-web/src/tool-render/tools/ask.tsx b/packages/collab-web/src/tool-render/tools/ask.tsx index 27dc91856..d507dd031 100644 --- a/packages/collab-web/src/tool-render/tools/ask.tsx +++ b/packages/collab-web/src/tool-render/tools/ask.tsx @@ -22,6 +22,8 @@ interface AskAnswer { id?: string; selectedOptions: string[]; customInput?: string; + /** Free-form note the user attached to the answer via the rich ask dialog. */ + note?: string; timedOut?: boolean; } @@ -106,6 +108,7 @@ function answerOf(rec: Record): AskAnswer { id: str(rec.id) ?? undefined, selectedOptions, customInput: str(rec.customInput) ?? undefined, + note: str(rec.note) ?? undefined, timedOut: rec.timedOut === true, }; } @@ -187,6 +190,11 @@ function QuestionBlock({ q, answer }: { q: AskQuestion; answer: AskAnswer | unde {answer.customInput} )} + {answer?.note !== undefined && ( + + {answer.note} + + )} {answer && answer.selectedOptions.length === 0 && answer.customInput === undefined && ( no selection diff --git a/packages/collab-web/test/tool-view.test.tsx b/packages/collab-web/test/tool-view.test.tsx index ac718b585..6c54ccef2 100644 --- a/packages/collab-web/test/tool-view.test.tsx +++ b/packages/collab-web/test/tool-view.test.tsx @@ -152,3 +152,65 @@ describe("ToolView xd:// dispatches", () => { expect(html).not.toContain("tv-out-title"); }); }); + +describe("ToolView ask renderer", () => { + const questions = [ + { + id: "auth", + question: "Which auth method?", + options: [{ label: "JWT" }, { label: "OAuth2" }], + }, + ]; + + it("renders the user-added note from a single-question answer", () => { + const html = renderToStaticMarkup( + , + ); + + expect(html).toContain('OAuth2'); + expect(html).toContain("keep the redirect short-lived"); + }); + + it("renders per-question notes from results[] answers", () => { + const html = renderToStaticMarkup( + , + ); + + expect(html).toContain('Postgres'); + expect(html).toContain("managed instance"); + // The cache question answered without a note must not leak the db note. + expect(html.match(/managed instance/g)?.length).toBe(1); + }); +});