Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

Merge remote-tracking branch 'upstream/main' into tool-call-presentation

Steven Enamakele609e9d1edc0
diff --cc app/src/components/assistant-ui/elements/surfaces.tsx
index a71252143c,9a8f8319e9..ed80c5538e
--- a/app/src/components/assistant-ui/elements/surfaces.tsx
+++ b/app/src/components/assistant-ui/elements/surfaces.tsx
@@@ -1,19 -1,13 +1,15 @@@
'use client';
/**
- * Shared design tokens for the assistant-ui elements in this folder.
- *
- * Vendored from assistant-ui `packages/ui/src/components/react/assistant-ui/elements/surfaces.tsx`
- * (commit 1abca347). Changes from upstream, kept minimal so a re-sync stays a
- * small diff:
- * - `cn` import path.
- * - `collapsePanel` drives the Radix collapsible this app uses (upstream
- * targets Base UI's `--collapsible-panel-height`).
- * - `openRotate` added: the Radix trigger reports `data-state=open`, not Base
- * UI's `data-open` / `data-panel-open`.
+ * Shared surface primitives for the assistant-ui elements, vendored verbatim
+ * from the `elements-surfaces` registry item
- * (https://r.assistant-ui.com/elements-surfaces.json). The one local change is
- * `collapsePanel`, adapted from Base UI to Radix (see below).
++ * (https://r.assistant-ui.com/elements-surfaces.json). Local changes, all for
++ * this app's Radix collapsible and jsdom: `collapsePanel` adapted from Base UI
++ * to Radix, an added `openRotate` chevron selector, and a `ResizeObserver`
++ * guard in `SwapLabel`.
*/
import { cn } from '@/components/assistant-ui/lib/utils';
- import { type ComponentProps, type ReactNode, useLayoutEffect, useRef, useState } from 'react';
+ import { type ComponentProps, useLayoutEffect, useRef, useState } from 'react';
export const paper = 'bg-background border border-border/60 dark:bg-popover';
@@@ -37,12 -41,12 +43,17 @@@ export const labelSwapIn = 'opacity-10
export const labelSwapOut = 'pointer-events-none select-none opacity-0 blur-[2px]';
+ // Local adaptation: upstream animates Base UI's `--collapsible-panel-height`;
+ // this app's `ui/collapsible` is Radix, whose content exposes
+ // `--radix-collapsible-content-height` to tw-animate-css's collapsible keyframes.
export const collapsePanel =
- 'overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down motion-reduce:animate-none';
+ 'overflow-hidden ease-[cubic-bezier(0.32,0.72,0,1)] data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down motion-reduce:animate-none';
++// Local addition: the Radix trigger reports `data-state=open`, not Base UI's
++// `data-open` / `data-panel-open`, so the chevron rotation needs this selector.
+export const openRotate =
+ 'transition-transform duration-200 ease-[cubic-bezier(0.32,0.72,0,1)] group-data-[state=open]/trigger:rotate-90 motion-reduce:transition-none';
+
export const live = 'text-blue-500 dark:text-blue-400';
export const mono = 'font-mono text-[11px] tracking-tight';
@@@ -90,7 -92,6 +99,8 @@@ export function SwapLabel(
if (!target) return undefined;
const measure = () => setWidth(Math.ceil(target.getBoundingClientRect().width));
measure();
++ // Local guard: jsdom (unit tests) has no ResizeObserver.
+ if (typeof ResizeObserver === 'undefined') return undefined;
const observer = new ResizeObserver(measure);
observer.observe(target);
return () => observer.disconnect();
diff --cc app/src/features/conversations/components/ChatToolParts.test.tsx
index 582343ea5b,f42528c6a7..e5f463fbf6
--- a/app/src/features/conversations/components/ChatToolParts.test.tsx
+++ b/app/src/features/conversations/components/ChatToolParts.test.tsx
@@@ -214,9 -210,62 +214,65 @@@ describe('ChatToolParts', () =>
/>
);
- expect(screen.getByTestId('assistant-ui-tool-call')).toHaveTextContent('Searched the web');
- expect(screen.getByTestId('assistant-ui-tool-call')).not.toHaveTextContent(/^Tool done$/);
+ const card = screen.getByTestId('assistant-ui-tool-call');
+ expect(card).not.toHaveTextContent('Searched the web');
+ expect(card).toHaveTextContent('Used tool');
+ expect(card).toHaveTextContent('latest world news');
});
+
+ it('names the tool-discovery bridge for what it is, not a web search', () => {
+ // `tool_search` ranks the DEFERRED TOOL CATALOGUE — Composio actions, MCP
+ // tools — and never touches the network. It matched `looksLikeSearch`
+ // twice (its name contains "search" AND its argument is `query`), so a
+ // turn that fetched the user's own Google Calendar through Composio opened
+ // with "Searched the web".
+ render(
+ <ChatToolFallback
+ type="tool-call"
+ toolName="tool_search"
+ toolCallId="bridge-search"
+ args={{ query: 'list calendar events google calendar' } as never}
+ argsText={'{"query":"list calendar events google calendar"}'}
+ result="1 match(es). Invoke one with tool_call"
+ status={{ type: 'complete' }}
+ addResult={() => {}}
+ resume={() => {}}
+ respondToApproval={() => {}}
+ />
+ );
+
- expect(screen.getByTestId('assistant-ui-tool-call')).toHaveTextContent('Found the right tool');
++ expect(screen.getByTestId('assistant-ui-tool-call')).toHaveTextContent('Found tools');
+ // The regression this pins: BOTH heuristic legs still match this row, so
+ // dropping the explicit branch renders the web label again.
+ expect(screen.getByTestId('assistant-ui-tool-call')).not.toHaveTextContent('Searched the web');
+ });
+
+ it('labels the tool_call wrapper by the tool it actually invoked', () => {
+ // `tool_call_schema()` declares `{name, arguments}`, both required, so the
+ // wrapped tool is always in `name`. The row used to show only the wrapper,
+ // so the one call that fetched the user's calendar rendered "Tool Call".
+ render(
+ <ChatToolFallback
+ type="tool-call"
+ toolName="tool_call"
+ toolCallId="bridge-call"
+ args={{ name: 'GOOGLECALENDAR_EVENTS_LIST', arguments: { calendarId: 'primary' } } as never}
+ argsText={'{"name":"GOOGLECALENDAR_EVENTS_LIST"}'}
+ result="Items: Product Team Standup"
+ status={{ type: 'complete' }}
+ addResult={() => {}}
+ resume={() => {}}
+ respondToApproval={() => {}}
+ />
+ );
+
+ // Composio slugs carry no separator inside the toolkit name, so this also
- // pins the `googlecalendar` spelling in `KNOWN_TOOLKIT_RE`: without it the
- // row degrades to the raw "GOOGLECALENDAR EVENTS LIST".
- expect(screen.getByTestId('assistant-ui-tool-call')).toHaveTextContent(
- 'Google Calendar: Events list'
- );
++ // pins the `googlecalendar` catalog lookup: without it the row degrades to
++ // the raw "GOOGLECALENDAR EVENTS LIST".
++ const card = screen.getByTestId('assistant-ui-tool-call');
++ expect(card).toHaveTextContent('Used Google Calendar');
++ expect(card).toHaveTextContent('Events list');
++ expect(card).not.toHaveTextContent('GOOGLECALENDAR');
+ expect(screen.getByTestId('assistant-ui-tool-call')).not.toHaveTextContent('Tool Call');
+ });
});