🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(web): one Tools header with the Called / Not called switch, no muted rows (#19089)
Trang Nguyen02d03015148b
diff --git a/web/src/components/ui/IOSection.stories.tsx b/web/src/components/ui/IOSection.stories.tsxindex 273effb44d..6cd9725dbc 100644--- a/web/src/components/ui/IOSection.stories.tsx+++ b/web/src/components/ui/IOSection.stories.tsx@@ -1,3 +1,4 @@+import { useState } from "react";import preview from "../../../.storybook/preview";import { expect, fn, userEvent, within } from "storybook/test";import Image from "next/image";@@ -64,6 +65,29 @@ const jsonToggle = {onCheckedChange: fn(),};+/** A section whose header carries a view switch (always visible while open). */+function TabsControlExample() {+ const [tab, setTab] = useState("called");+ return (+ <IOSection+ title="Tools"+ variant="table"+ tabs={{+ value: tab,+ onValueChange: setTab,+ items: [+ { value: "called", label: "Called", count: 3 },+ { value: "not-called", label: "Not called", count: 36 },+ ],+ }}+ >+ <p className="px-1 py-1.5 text-sm">+ {tab === "called" ? "3 called tools" : "36 tools not called"}+ </p>+ </IOSection>+ );+}+export const Default = meta.story({args: {title: "user",@@ -189,6 +213,10 @@ export const VariantMatrix = meta.story({</IOSection></Example>+ <Example caption="Tabs control: Called / Not called switch in the header, hidden while collapsed">+ <TabsControlExample />+ </Example>+<Example caption="Title icon"><IOSection onCopy={args.onCopy} title="Tools" titleIcon={Wrench}><p className="text-sm">diff --git a/web/src/components/ui/IOSection.tsx b/web/src/components/ui/IOSection.tsxindex a5d6e766dc..f188f2713b 100644--- a/web/src/components/ui/IOSection.tsx+++ b/web/src/components/ui/IOSection.tsx@@ -13,6 +13,7 @@ import { Badge } from "@/src/components/design-system/Badge/Badge";import { HoverCard } from "@/src/components/design-system/HoverCard/HoverCard";import { Spinner } from "@/src/components/design-system/Spinner/Spinner";import { Switch } from "@/src/components/design-system/Switch/Switch";+import { Tabs } from "@/src/components/design-system/Tabs/Tabs";import { cn } from "@/src/utils/tailwind";/** An icon button in the section header. */@@ -40,6 +41,13 @@ export type IOSectionToggle = {disabled?: boolean;};+/** A segmented switch in the header, always visible while the section is open. */+type IOSectionTabs = {+ value: string;+ onValueChange: (value: string) => void;+ items: { value: string; label: string; count?: number }[];+};+/** An info hover card after the title. */export type IOSectionInfo = {/** Accessible name of the info trigger. */@@ -62,6 +70,8 @@ export type IOSectionProps = {actions?: IOSectionAction[];status?: IOSectionStatus;toggle?: IOSectionToggle;+ /** Primary view switch for the body; hidden while collapsed. */+ tabs?: IOSectionTabs;/** Initial state of an uncontrolled section. */defaultCollapsed?: boolean;/** Controlled state; the header calls `onCollapsedChange`. */@@ -144,6 +154,7 @@ export function IOSection({actions,status,toggle,+ tabs,defaultCollapsed = false,collapsed,onCollapsedChange,@@ -200,6 +211,22 @@ export function IOSection({tabIndex={-1}onClick={toggleCollapsed}/>+ {tabs && !isCollapsed ? (+ <div className="flex shrink-0 items-center pr-1 font-normal normal-case">+ <Tabs value={tabs.value} onValueChange={tabs.onValueChange}>+ <Tabs.List variant="inset" size="sm">+ {tabs.items.map((item) => (+ <Tabs.Trigger+ key={item.value}+ value={item.value}+ label={item.label}+ count={item.count}+ />+ ))}+ </Tabs.List>+ </Tabs>+ </div>+ ) : null}<divclassName={cn("mr-1 flex shrink-0 flex-row items-center gap-1",diff --git a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.stories.tsx b/web/src/features/traces/components/IOPreview/components/SectionToolDefinitions.stories.tsxsimilarity index 75%rename from web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.stories.tsxrename to web/src/features/traces/components/IOPreview/components/SectionToolDefinitions.stories.tsxindex 4ae94ab36f..eb793affe7 100644--- a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.stories.tsx+++ b/web/src/features/traces/components/IOPreview/components/SectionToolDefinitions.stories.tsx@@ -1,10 +1,8 @@import { expect, userEvent, within } from "storybook/test";import preview from "../../../../../../.storybook/preview";-import {- ToolCallDefinitionCard,- type ToolDefinition,-} from "./ToolCallDefinitionCard";+import type { ToolDefinition } from "./ToolCallDefinitionCard";+import { SectionToolDefinitions } from "./SectionToolDefinitions";import type { ToolCallInvocation } from "../../../hooks/useChatMLParser";const baseTools: ToolDefinition[] = [@@ -43,7 +41,7 @@ const baseToolCalls = new Map<string, ToolCallInvocation[]>([]);const meta = preview.meta({- component: ToolCallDefinitionCard,+ component: SectionToolDefinitions,});export const Default = meta.story({@@ -191,74 +189,107 @@ const manyToolNames = [];const calledNames = new Set(manyToolNames.slice(12));-const TOOLS_COLLAPSED_KEY = "toolsSectionCollapsed";--/** Opens the section so stories with many tools show their rows. */-const startExpanded = () => {- sessionStorage.setItem(TOOLS_COLLAPSED_KEY, "false");- return () => sessionStorage.removeItem(TOOLS_COLLAPSED_KEY);-};-/** Both sides have tools, so the header shows the Called / Not called switch. */export const ManyTools = meta.story({- beforeEach: startExpanded,args: {tools: manyToolNames.map((name) => ({ name })),toolCallCounts: new Map(manyToolNames.map((name) => [name, calledNames.has(name) ? 1 : 0]),),toolCallsByName: new Map(),+ defaultCollapsed: false,},});-/** Nothing called: no switch, one muted list. */+/** Nothing called: no switch, one list. */export const NoneCalled = meta.story({- beforeEach: startExpanded,args: {tools: manyToolNames.map((name) => ({ name })),toolCallCounts: new Map(manyToolNames.map((name) => [name, 0])),toolCallsByName: new Map(),+ defaultCollapsed: false,},});/** Everything called: no switch, one list. */export const AllCalled = meta.story({- beforeEach: startExpanded,args: {tools: manyToolNames.map((name) => ({ name })),toolCallCounts: new Map(manyToolNames.map((name) => [name, 1])),toolCallsByName: new Map(),+ defaultCollapsed: false,},});+const TOOLS_COLLAPSED_KEY = "toolsSectionCollapsed";+/** Stories start without a remembered collapse choice. */+const forgetCollapse = () => {+ sessionStorage.removeItem(TOOLS_COLLAPSED_KEY);+};+export const NotCalledTab = meta.story({name: "(Test) Not Called Tab",- beforeEach: startExpanded,+ beforeEach: forgetCollapse,args: ManyTools.input.args,play: async ({ canvasElement }) => {const canvas = within(canvasElement);await expect(canvas.getByRole("tab", { name: /^Called\s*6$/ }),).toHaveAttribute("aria-selected", "true");+ await expect(+ canvas.getByRole("button", {+ name: /^1\.\s*langfuse_searchLangfuseDocs$/,+ }),+ ).toBeVisible();await userEvent.click(canvas.getByRole("tab", { name: /^Not called\s*12$/ }),);- const firstRow = canvas.getByRole("button", {- name: /langfuse_getPrompt$/,- });- await expect(within(firstRow).getByText("1.")).toBeVisible();+ await expect(+ canvas.getByRole("button", { name: /^1\.\s*langfuse_getPrompt$/ }),+ ).toBeVisible();await expect(canvas.queryByText("langfuse_getSession")).toBeNull();},});-/** More than five tools: the section starts collapsed to its header. */+/** One side empty: no switch, the whole list shows. */+export const NoSwitchWhenOneSideEmpty = meta.story({+ name: "(Test) No Switch When One Side Empty",+ beforeEach: forgetCollapse,+ args: NoneCalled.input.args,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await expect(canvas.queryByRole("tab")).toBeNull();+ await expect(+ canvas.getByRole("button", { name: /^18\.\s*langfuse_getSession$/ }),+ ).toBeVisible();+ },+});++export const RowTogglesDetails = meta.story({+ name: "(Test) Row Toggles Details",+ beforeEach: forgetCollapse,+ args: Called.input.args,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const row = canvas.getByRole("button", { name: /^1\.\s*search_docs$/ });+ await expect(row).toHaveAttribute("aria-expanded", "false");+ await expect(canvas.queryByText("Description")).toBeNull();+ await userEvent.click(row);+ await expect(row).toHaveAttribute("aria-expanded", "true");+ await expect(canvas.getByText("Description")).toBeVisible();+ await userEvent.click(row);+ await expect(row).toHaveAttribute("aria-expanded", "false");+ },+});++/** More than five tools: collapsed to the header, switch hidden; opening it is remembered for the session. */export const CollapsedByDefault = meta.story({name: "(Test) Collapsed By Default",- beforeEach: () => sessionStorage.removeItem(TOOLS_COLLAPSED_KEY),- args: ManyTools.input.args,+ beforeEach: forgetCollapse,+ args: { ...ManyTools.input.args, defaultCollapsed: undefined },play: async ({ canvasElement }) => {const canvas = within(canvasElement);- const header = canvas.getByRole("button", { name: "Tools" });+ const header = canvas.getByRole("button", { name: "Expand Tools" });await expect(header).toHaveAttribute("aria-expanded", "false");await expect(canvas.queryByRole("tab")).toBeNull();@@ -267,6 +298,7 @@ export const CollapsedByDefault = meta.story({await expect(canvas.getByRole("tab", { name: /^Called\s*6$/ }),).toBeVisible();+ await expect(sessionStorage.getItem(TOOLS_COLLAPSED_KEY)).toBe("false");sessionStorage.removeItem(TOOLS_COLLAPSED_KEY);},});diff --git a/web/src/features/traces/components/IOPreview/components/SectionToolDefinitions.tsx b/web/src/features/traces/components/IOPreview/components/SectionToolDefinitions.tsxindex dfa9080b77..30b65b51d1 100644--- a/web/src/features/traces/components/IOPreview/components/SectionToolDefinitions.tsx+++ b/web/src/features/traces/components/IOPreview/components/SectionToolDefinitions.tsx@@ -1,4 +1,6 @@+import { useMemo, useState } from "react";import { IOSection } from "@/src/components/ui/IOSection";+import useSessionStorage from "@/src/components/useSessionStorage";import {ToolCallDefinitionCard,type ToolDefinition,@@ -10,21 +12,86 @@ export interface SectionToolDefinitionsProps {tools: ToolDefinition[];toolCallCounts: Map<string, number>;toolCallsByName: Map<string, ToolCallInvocation[]>;+ /** Initial state before the user toggles; by default long lists (more than five tools) start collapsed. */+ defaultCollapsed?: boolean;}+type ToolTab = "called" | "not-called";++/** Above this many tools the section starts collapsed. */+const TOOLS_COLLAPSE_THRESHOLD = 5;+/** The user's collapse choice lasts the session, across observations. */+const TOOLS_COLLAPSED_KEY = "toolsSectionCollapsed";+/**- * SectionToolDefinitions renders the tool definitions section at the top of IOPreview.+ * SectionToolDefinitions renders the Tools section at the top of IOPreview:+ * an IOSection whose header carries a Called / Not called switch (only when+ * both sides have tools) over the active tab's tools, numbered from 1.*/export function SectionToolDefinitions({tools,toolCallCounts,toolCallsByName,+ defaultCollapsed,}: SectionToolDefinitionsProps) {+ const [activeTab, setActiveTab] = useState<ToolTab>("called");+ const [storedCollapsed, setStoredCollapsed] = useSessionStorage<+ boolean | null+ >(TOOLS_COLLAPSED_KEY, null);++ const { calledTools, notCalledTools } = useMemo(+ () =>+ tools.reduce(+ (groups, tool) => {+ if ((toolCallCounts.get(tool.name) ?? 0) > 0) {+ groups.calledTools.push(tool);+ } else {+ groups.notCalledTools.push(tool);+ }+ return groups;+ },+ {+ calledTools: [] as ToolDefinition[],+ notCalledTools: [] as ToolDefinition[],+ },+ ),+ [tools, toolCallCounts],+ );++ const hasSwitch = calledTools.length > 0 && notCalledTools.length > 0;+ const tabTools = activeTab === "called" ? calledTools : notCalledTools;+ const visibleTools = hasSwitch ? tabTools : tools;+return (- <IOSection title="Tools">+ <IOSection+ title="Tools"+ variant="table"+ collapsed={+ storedCollapsed ??+ defaultCollapsed ??+ tools.length > TOOLS_COLLAPSE_THRESHOLD+ }+ onCollapsedChange={setStoredCollapsed}+ tabs={+ hasSwitch+ ? {+ value: activeTab,+ onValueChange: (value) => setActiveTab(value as ToolTab),+ items: [+ { value: "called", label: "Called", count: calledTools.length },+ {+ value: "not-called",+ label: "Not called",+ count: notCalledTools.length,+ },+ ],+ }+ : undefined+ }+ ><ToolCallDefinitionCard- tools={tools}- toolCallCounts={toolCallCounts}+ key={activeTab}+ tools={visibleTools}toolCallsByName={toolCallsByName}/></IOSection>diff --git a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.clienttest.tsx b/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.clienttest.tsxdeleted file mode 100644index 2aec2f02f3..0000000000--- a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.clienttest.tsx+++ /dev/null@@ -1,187 +0,0 @@-/* eslint-disable @repo/prefer-stories-over-client-tests */-import { fireEvent, render, screen, within } from "@testing-library/react";-import { vi } from "vitest";--import {- ToolCallDefinitionCard,- type ToolDefinition,-} from "./ToolCallDefinitionCard";-import type { ToolCallInvocation } from "../../../hooks/useChatMLParser";--function createMemoryStorage(): Storage {- const store = new Map<string, string>();-- return {- get length() {- return store.size;- },- clear: () => store.clear(),- getItem: (key) => store.get(key) ?? null,- key: (index) => Array.from(store.keys())[index] ?? null,- removeItem: (key) => {- store.delete(key);- },- setItem: (key, value) => {- store.set(key, value);- },- };-}--const makeTool = (name: string): ToolDefinition => ({- name,- description: `${name} description`,- parameters: { type: "object" },-});--function renderTools({- calledToolCount,- notCalledToolCount,-}: {- calledToolCount: number;- notCalledToolCount: number;-}) {- const calledTools = Array.from({ length: calledToolCount }, (_, index) =>- makeTool(`called_tool_${index + 1}`),- );- const notCalledTools = Array.from(- { length: notCalledToolCount },- (_, index) => makeTool(`not_called_tool_${index + 1}`),- );- const tools = [...calledTools, ...notCalledTools];- const toolCallCounts = new Map<string, number>();- const toolCallsByName = new Map<string, ToolCallInvocation[]>();-- calledTools.forEach((tool, index) => {- toolCallCounts.set(tool.name, 1);- toolCallsByName.set(tool.name, [- {- id: `call-${index + 1}`,- name: tool.name,- arguments: "{}",- invocationNumber: index + 1,- },- ]);- });-- return render(- <ToolCallDefinitionCard- tools={tools}- toolCallCounts={toolCallCounts}- toolCallsByName={toolCallsByName}- />,- );-}--// Row buttons are named "N.<tool name>"; strip the number and match the name exactly.-const rowFor = (toolName: string) =>- screen.queryByRole("button", {- name: (accessibleName) =>- accessibleName.replace(/^\d+\.\s*/, "") === toolName,- });-const rowNumberOf = (toolName: string) =>- within(rowFor(toolName)!).getByText(/^\d+\.$/).textContent;--describe("ToolCallDefinitionCard", () => {- beforeEach(() => {- vi.stubGlobal("localStorage", createMemoryStorage());- vi.stubGlobal("sessionStorage", createMemoryStorage());- });-- it("starts long lists collapsed and keeps the user's choice for the session", () => {- const first = renderTools({ calledToolCount: 2, notCalledToolCount: 4 });- const header = screen.getByRole("button", { name: "Tools" });-- expect(header).toHaveAttribute("aria-expanded", "false");- expect(rowFor("called_tool_1")).not.toBeInTheDocument();- expect(screen.queryByRole("tab")).not.toBeInTheDocument();-- fireEvent.click(header);- expect(header).toHaveAttribute("aria-expanded", "true");- expect(rowFor("called_tool_1")).toBeInTheDocument();- first.unmount();-- renderTools({ calledToolCount: 2, notCalledToolCount: 4 });- expect(screen.getByRole("button", { name: "Tools" })).toHaveAttribute(- "aria-expanded",- "true",- );- expect(rowFor("called_tool_1")).toBeInTheDocument();- });-- it("starts short lists expanded", () => {- renderTools({ calledToolCount: 2, notCalledToolCount: 3 });-- expect(screen.getByRole("button", { name: "Tools" })).toHaveAttribute(- "aria-expanded",- "true",- );- });-- it("shows the Called / Not called switch only when both sides have tools", () => {- const both = renderTools({ calledToolCount: 2, notCalledToolCount: 3 });- expect(- screen.getByRole("tab", { name: /^Called\s*2$/ }),- ).toBeInTheDocument();- expect(- screen.getByRole("tab", { name: /^Not called\s*3$/ }),- ).toBeInTheDocument();- both.unmount();-- const noneCalled = renderTools({- calledToolCount: 0,- notCalledToolCount: 3,- });- expect(screen.queryByRole("tab")).not.toBeInTheDocument();- expect(rowFor("not_called_tool_3")).toBeInTheDocument();- noneCalled.unmount();-- renderTools({ calledToolCount: 2, notCalledToolCount: 0 });- expect(screen.queryByRole("tab")).not.toBeInTheDocument();- expect(rowFor("called_tool_2")).toBeInTheDocument();- });-- it("defaults to the Called tab", () => {- renderTools({ calledToolCount: 2, notCalledToolCount: 3 });-- expect(screen.getByRole("tab", { name: /^Called\s*2$/ })).toHaveAttribute(- "aria-selected",- "true",- );- expect(rowFor("called_tool_1")).toBeInTheDocument();- expect(rowFor("not_called_tool_1")).not.toBeInTheDocument();- });-- it("numbers each tab from 1", () => {- renderTools({ calledToolCount: 2, notCalledToolCount: 3 });-- expect(rowNumberOf("called_tool_1")).toBe("1.");-- fireEvent.mouseDown(screen.getByRole("tab", { name: /^Not called\s*3$/ }), {- button: 0,- });-- expect(rowFor("called_tool_1")).not.toBeInTheDocument();- expect(rowNumberOf("not_called_tool_1")).toBe("1.");- expect(rowNumberOf("not_called_tool_3")).toBe("3.");- });-- it("toggles a row's details on click", () => {- renderTools({ calledToolCount: 1, notCalledToolCount: 0 });-- const row = rowFor("called_tool_1")!;- expect(row).toHaveAttribute("aria-expanded", "false");- expect(- screen.queryByText("called_tool_1 description"),- ).not.toBeInTheDocument();-- fireEvent.click(row);- expect(row).toHaveAttribute("aria-expanded", "true");- expect(screen.getByText("called_tool_1 description")).toBeInTheDocument();-- fireEvent.click(row);- expect(row).toHaveAttribute("aria-expanded", "false");- expect(- screen.queryByText("called_tool_1 description"),- ).not.toBeInTheDocument();- });-});diff --git a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx b/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsxindex 64cce2c6e1..6cee2ff0e9 100644--- a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx+++ b/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx@@ -4,8 +4,7 @@ import { cn } from "@/src/utils/tailwind";import { PrettyJsonView } from "@/src/components/ui/PrettyJsonView";import { Tabs } from "@/src/components/design-system/Tabs/Tabs";import useLocalStorage from "@/src/components/useLocalStorage";-import useSessionStorage from "@/src/components/useSessionStorage";-import { useMemo, useState } from "react";+import { useState } from "react";import type { ToolCallInvocation } from "../../../hooks/useChatMLParser";// Tool definition extracted from messages@@ -17,17 +16,12 @@ export interface ToolDefinition {// ToolCallDefinitionCard propsexport interface ToolCallDefinitionCardProps {+ /** Rendered in order and numbered from 1. */tools: ToolDefinition[];- toolCallCounts: Map<string, number>;toolCallsByName?: Map<string, ToolCallInvocation[]>;className?: string;}-type ToolTab = "called" | "not-called";--/** Above this many tools the section starts collapsed. */-const TOOLS_COLLAPSE_THRESHOLD = 5;-function parseToolCallArguments(argumentsValue: unknown): unknown {if (typeof argumentsValue !== "string") {return argumentsValue;@@ -100,7 +94,6 @@ function ToolDefinitionRow({tool,isExpanded,onToggle,- isCalled,toolCalls,rowNumber,currentView,@@ -109,7 +102,6 @@ function ToolDefinitionRow({tool: ToolDefinition;isExpanded: boolean;onToggle: () => void;- isCalled: boolean;toolCalls: ToolCallInvocation[];rowNumber: number;currentView: "formatted" | "json";@@ -132,10 +124,7 @@ function ToolDefinitionRow({<Caret size="base" color="default" aria-hidden /><Wrench size="base" color="muted" /><span- className={cn(- "ph-no-capture block truncate text-sm",- isCalled ? "text-foreground" : "text-muted-foreground",- )}+ className="ph-no-capture text-foreground block truncate text-sm"title={tool.name}><span className="mr-1">{rowNumber}.</span>@@ -209,112 +198,43 @@ function ToolDefinitionRow({}/**- * ToolCallDefinitionCard renders the Tools section: a header with a- * collapse caret and a Called / Not called switch (only when both sides- * have tools), and the active tab's tools as expandable rows numbered- * from 1. Long lists start collapsed; the user's choice lasts the session.+ * ToolCallDefinitionCard renders tools as expandable rows numbered from 1.+ * The section header, its collapse and the Called / Not called switch+ * belong to the hosting IOSection (see SectionToolDefinitions).*/export function ToolCallDefinitionCard({tools,- toolCallCounts,toolCallsByName,className,}: ToolCallDefinitionCardProps) {const [expandedToolKey, setExpandedToolKey] = useState<string | null>(null);- const [activeTab, setActiveTab] = useState<ToolTab>("called");- const [collapsedPreference, setCollapsedPreference] = useSessionStorage<- boolean | null- >("toolsSectionCollapsed", null);const [currentView, setCurrentView] = useLocalStorage<"formatted" | "json">("toolCallPillViewPreference","formatted",);- const { calledTools, notCalledTools } = useMemo(- () =>- tools.reduce(- (groups, tool) => {- if ((toolCallCounts.get(tool.name) ?? 0) > 0) {- groups.calledTools.push(tool);- } else {- groups.notCalledTools.push(tool);- }- return groups;- },- {- calledTools: [] as ToolDefinition[],- notCalledTools: [] as ToolDefinition[],- },- ),- [tools, toolCallCounts],- );-- const hasSwitch = calledTools.length > 0 && notCalledTools.length > 0;- const tabTools = activeTab === "called" ? calledTools : notCalledTools;- const visibleTools = hasSwitch ? tabTools : tools;- const isCollapsed =- collapsedPreference ?? tools.length > TOOLS_COLLAPSE_THRESHOLD;- const Caret = isCollapsed ? ChevronRight : ChevronDown;-- const handleCollapseToggle = () => setCollapsedPreference(!isCollapsed);-return (- <div className={cn("flex flex-col", className)}>- <div className="io-message-header flex items-center justify-between gap-2 px-1 py-1">- <button- type="button"- onClick={handleCollapseToggle}- aria-expanded={!isCollapsed}- className="focus-visible:ring-ring flex items-center gap-1.5 rounded-sm text-base font-bold focus-visible:ring-2 focus-visible:outline-hidden"- >- <Caret aria-hidden="true" size="base" color="default" />- Tools- </button>- {hasSwitch && !isCollapsed && (- <Tabs- value={activeTab}- onValueChange={(value) => setActiveTab(value as ToolTab)}- >- <Tabs.List variant="inset" size="sm">- <Tabs.Trigger- value="called"- label="Called"- count={calledTools.length}- />- <Tabs.Trigger- value="not-called"- label="Not called"- count={notCalledTools.length}- />- </Tabs.List>- </Tabs>- )}- </div>- {!isCollapsed && (- <div className="divide-border flex flex-col divide-y">- {visibleTools.map((tool, index) => {- const toolKey = `${activeTab}-${tool.name}-${index}`;+ <div className={cn("divide-border flex flex-col divide-y", className)}>+ {tools.map((tool, index) => {+ const toolKey = `${tool.name}-${index}`;- return (- <ToolDefinitionRow- key={toolKey}- tool={tool}- isExpanded={expandedToolKey === toolKey}- onToggle={() =>- setExpandedToolKey((current) =>- current === toolKey ? null : toolKey,- )- }- isCalled={(toolCallCounts.get(tool.name) ?? 0) > 0}- toolCalls={toolCallsByName?.get(tool.name) ?? []}- rowNumber={index + 1}- currentView={currentView}- setCurrentView={setCurrentView}- />- );- })}- </div>- )}+ return (+ <ToolDefinitionRow+ key={toolKey}+ tool={tool}+ isExpanded={expandedToolKey === toolKey}+ onToggle={() =>+ setExpandedToolKey((current) =>+ current === toolKey ? null : toolKey,+ )+ }+ toolCalls={toolCallsByName?.get(tool.name) ?? []}+ rowNumber={index + 1}+ currentView={currentView}+ setCurrentView={setCurrentView}+ />+ );+ })}</div>);}