Skip to content

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

fix(conversations): correct tool part rendering for edge cases

Steven Enamakel9d4f5fa782ce
diff --git a/app/src/features/conversations/components/ChatToolParts.test.tsx b/app/src/features/conversations/components/ChatToolParts.test.tsx
index 1aa5c2dd93..582343ea5b 100644
--- a/app/src/features/conversations/components/ChatToolParts.test.tsx
+++ b/app/src/features/conversations/components/ChatToolParts.test.tsx
@@ -168,7 +168,7 @@ describe('ChatToolParts', () => {
expect(screen.getByTestId('assistant-ui-tool-call')).toHaveTextContent('Searched the web');
await userEvent.click(screen.getByRole('button', { name: /Searched the web/ }));
- expect(screen.getByText(/Lean open conjectures/)).toBeInTheDocument();
+ expect(screen.getAllByText(/Lean open conjectures/).length).toBeGreaterThan(0);
expect(screen.queryByText('Query', { exact: true })).not.toBeInTheDocument();
expect(screen.getByText('Found 12 candidate problems')).toBeInTheDocument();
});
@@ -189,12 +189,16 @@ describe('ChatToolParts', () => {
/>
);
- await userEvent.click(screen.getByRole('button', { name: /Fetched from the web/ }));
+ await userEvent.click(screen.getByRole('button', { name: /Read webpage/ }));
expect(screen.getByRole('strong')).toHaveTextContent('Example Domain');
expect(screen.queryByText('Content', { exact: true })).not.toBeInTheDocument();
});
- it('infers web search labels when a persisted tool name degraded to tool', () => {
+ // The old card called any call with a `query` argument "Searched the web",
+ // which mislabelled memory, tool and email searches. A call whose name
+ // degraded to `tool` is now labelled as what is known about it: an
+ // unnamed tool, with its query as the chip.
+ it('does not guess a web search from a query argument alone', () => {
render(
<ChatToolFallback
type="tool-call"
@@ -210,7 +214,9 @@ 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');
});
});
diff --git a/app/src/features/conversations/components/ChatToolParts.tsx b/app/src/features/conversations/components/ChatToolParts.tsx
index 7e089ba888..3ff9ab9fcf 100644
--- a/app/src/features/conversations/components/ChatToolParts.tsx
+++ b/app/src/features/conversations/components/ChatToolParts.tsx
@@ -213,7 +213,10 @@ export const ChatToolFallback: ToolCallMessagePartComponent = props => {
return <GatedToolCall {...props} />;
};
-const selectMessageParts = (state: AssistantState) => state.message.parts;
+const NO_PARTS: readonly never[] = [];
+// `optional`: a group rendered outside a message (tests, previews) has no
+// message scope, and reading `state.message` there throws.
+const selectMessageParts = (state: AssistantState) => state.optional.message?.parts ?? NO_PARTS;
/**
* The chat's tool timeline: a run of adjacent tool calls under assistant-ui's
diff --git a/app/src/features/conversations/derived/mapDisplayItems.test.ts b/app/src/features/conversations/derived/mapDisplayItems.test.ts
index 2f7d68affb..949e5e6bb9 100644
--- a/app/src/features/conversations/derived/mapDisplayItems.test.ts
+++ b/app/src/features/conversations/derived/mapDisplayItems.test.ts
@@ -1,3 +1,4 @@
+import { formatTimelineEntry } from '../../../utils/toolTimelineFormatting';
import { describe, expect, it } from 'vitest';
import type { DerivedDisplayItem } from '../../../types/derivedTranscript';
@@ -188,7 +189,7 @@ describe('mapDisplayItems', () => {
expect(timelines['req-1'][0].failure?.causePlain).toBe('raw error text');
});
- it('derives displayName/detail for a tool row (parity with turn_state rows)', () => {
+ it('derives the detail for a tool row but leaves displayName to the server', () => {
const chronological: DerivedDisplayItem[] = [
{ kind: 'turnBoundary', requestId: 'req-1' },
{
@@ -204,8 +205,11 @@ describe('mapDisplayItems', () => {
const { timelines } = mapDisplayItems(newestFirst(chronological));
const row = timelines['req-1'][0];
- expect(typeof row.displayName).toBe('string');
- expect(row.displayName?.length ?? 0).toBeGreaterThan(0);
+ // A baked client title froze its tense ("Running command" on a finished
+ // row); surfaces resolve the title at render time instead.
+ expect(row.displayName).toBeUndefined();
+ expect(row.detail).toBe('ls -la');
+ expect(formatTimelineEntry(row).title).toBe('Ran command');
});
it('anchors a subagent to its own requestId, not the current turn cursor', () => {
diff --git a/app/src/features/human/SubMascotLayer.test.tsx b/app/src/features/human/SubMascotLayer.test.tsx
index c2a0285cd0..2e31e87112 100644
--- a/app/src/features/human/SubMascotLayer.test.tsx
+++ b/app/src/features/human/SubMascotLayer.test.tsx
@@ -76,7 +76,7 @@ describe('subMascotModelsFromTimeline', () => {
}),
]);
- expect(running?.activity).toBe('Using Read File');
+ expect(running?.activity).toBe('Using read file');
expect(running?.face).toBe('thinking');
// success and error are filtered out — only 1 model returned.
expect(
@@ -133,7 +133,9 @@ describe('subMascotModelsFromTimeline', () => {
}),
]);
- expect(models[0].activity).toBe('Using Fetching');
+ // The label is already an activity; the old "Using " prefix made this
+ // "Using Fetching".
+ expect(models[0].activity).toBe('Reading webpage');
});
});