diff --git a/ui/src/pages/chat/components/chat-message.test.ts b/ui/src/pages/chat/components/chat-message.test.ts index 74403154b322..c4b97111ca85 100644 --- a/ui/src/pages/chat/components/chat-message.test.ts +++ b/ui/src/pages/chat/components/chat-message.test.ts @@ -1532,6 +1532,9 @@ describe("grouped chat rendering", () => { }); expect(container.querySelector(".chat-tool-msg-summary__label")?.textContent?.trim()).toBe( + "presentation_create", + ); + expect(container.querySelector(".chat-tool-msg-summary__names")?.textContent?.trim()).toBe( "Example Deck", ); expect(container.querySelector(".chat-tool-msg-summary")?.textContent).not.toContain( @@ -1542,6 +1545,9 @@ describe("grouped chat rendering", () => { isToolMessageExpanded: () => true, }); + expect(container.querySelector(".chat-tool-msg-body")?.textContent).not.toContain( + "presentation_create", + ); expect(container.querySelector(".chat-tool-card__block code")?.textContent).toBe( "with Example Deck", ); diff --git a/ui/src/pages/chat/components/chat-message.ts b/ui/src/pages/chat/components/chat-message.ts index 345658938aaf..24ec60bcaba0 100644 --- a/ui/src/pages/chat/components/chat-message.ts +++ b/ui/src/pages/chat/components/chat-message.ts @@ -1977,20 +1977,20 @@ function renderGroupedMessage( ? toolNames.join(", ") : `${toolNames.slice(0, 2).join(", ")} +${toolNames.length - 2} more` : singleToolDisplayDetail - ? singleToolCard?.outputText?.trim() - ? "output" - : undefined + ? !markdown && !hasImages + ? singleToolDisplayDetail + : singleToolCard?.outputText?.trim() + ? "output" + : undefined : toolNames.length <= 3 ? toolNames.join(", ") : `${toolNames.slice(0, 2).join(", ")} +${toolNames.length - 2} more`; const toolPreview = markdown ? (formatCollapsedToolPreviewText(markdown) ?? "") : ""; const toolMessageLabelRaw = toolMessageHasError ? "Tool error" - : singleToolDisplayDetail && !markdown && !hasImages - ? singleToolDisplayDetail - : singleToolDisplay && !markdown && !hasImages - ? singleToolDisplay.label - : "Tool output"; + : singleToolDisplay && !markdown && !hasImages + ? singleToolDisplay.label + : "Tool output"; const toolMessageLabel = formatCollapsedToolSummaryText(toolMessageLabelRaw) ?? toolMessageLabelRaw; const toolSummaryLabel = formatDistinctCollapsedToolSummaryText( diff --git a/ui/src/pages/chat/components/chat-tool-cards.test.ts b/ui/src/pages/chat/components/chat-tool-cards.test.ts index f067b57b5efd..b9d12ce762e1 100644 --- a/ui/src/pages/chat/components/chat-tool-cards.test.ts +++ b/ui/src/pages/chat/components/chat-tool-cards.test.ts @@ -121,6 +121,36 @@ describe("tool-cards", () => { ]); }); + it("does not repeat the tool identity in expanded details", () => { + const container = document.createElement("div"); + render( + renderToolCard( + { + id: "msg:4a:call-4a", + name: "skill_workshop", + args: { action: "create" }, + inputText: '{\n "action": "create"\n}', + outputText: "Proposal created", + }, + { + expanded: true, + onOpenSidebar: vi.fn(), + onToggleExpanded: vi.fn(), + }, + ), + container, + ); + + expect(container.textContent?.match(/Skill Workshop/g)).toHaveLength(1); + expect(container.querySelector(".chat-tool-msg-body")?.textContent).not.toContain( + "Skill Workshop", + ); + expect(container.querySelector(".chat-tool-card__detail")?.textContent).toContain("create"); + expect(container.querySelector(".chat-tool-card__action-btn")).toBeInstanceOf( + HTMLButtonElement, + ); + }); + it("renders expanded tool calls without an inline output block when no output is present", () => { const container = document.createElement("div"); render( diff --git a/ui/src/pages/chat/components/chat-tool-cards.ts b/ui/src/pages/chat/components/chat-tool-cards.ts index 130ce8ed439c..1d47c1c1ded0 100644 --- a/ui/src/pages/chat/components/chat-tool-cards.ts +++ b/ui/src/pages/chat/components/chat-tool-cards.ts @@ -423,29 +423,29 @@ export function renderExpandedToolCardContent( return html`