Skip to content

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

fix(assistant-ui): keep activity group open when a parked approval precedes a completed tool

Steven Enamakeldeca0af68bab
diff --git a/app/src/components/assistant-ui/activity-group.tsx b/app/src/components/assistant-ui/activity-group.tsx
index 5cad0c7c94..68035af89e 100644
--- a/app/src/components/assistant-ui/activity-group.tsx
+++ b/app/src/components/assistant-ui/activity-group.tsx
@@ -57,10 +57,15 @@ export const ActivityGroup: FC<PropsWithChildren<{ group: ActivityGroupPart }>>
const isTail = useAuiState(
s => s.message.status?.type === 'running' && indices.at(-1) === s.message.parts.length - 1
);
+ // `GroupedParts` takes its status from the final part. A completed call after
+ // a parked approval would otherwise collapse the approval card out of sight.
+ const requiresAction = useAuiState(
+ s => indices.some(i => s.message.parts[i]?.status?.type === 'requires-action')
+ );
const [userOpen, setUserOpen] = useState<boolean | null>(null);
const running = group.status.type === 'running' || isTail;
- const live = running || group.status.type === 'requires-action';
+ const live = running || group.status.type === 'requires-action' || requiresAction;
return (
<ToolGroupRoot variant="ghost" open={userOpen ?? live} onOpenChange={setUserOpen}>
diff --git a/app/src/components/assistant-ui/thread.activityGroup.test.tsx b/app/src/components/assistant-ui/thread.activityGroup.test.tsx
index ccc80c98fa..a598ada7a8 100644
--- a/app/src/components/assistant-ui/thread.activityGroup.test.tsx
+++ b/app/src/components/assistant-ui/thread.activityGroup.test.tsx
@@ -17,7 +17,7 @@ import { Thread } from './thread';
*/
type Part = Exclude<ThreadMessageLike['content'], string>[number];
-const tool = (id: string, name: string): Part =>
+const tool = (id: string, name: string, over: Record<string, unknown> = {}): Part =>
({
type: 'tool-call',
toolCallId: id,
@@ -25,6 +25,7 @@ const tool = (id: string, name: string): Part =>
args: {},
argsText: '{}',
result: 'ok',
+ ...over,
}) as never;
const interleaved = (status: ThreadMessageLike['status']): ThreadMessageLike[] => [
@@ -95,6 +96,32 @@ describe('activity group', () => {
expect(screen.getByText('live thought')).toBeVisible();
});
+
+ it('is open when a parked approval precedes a completed tool', () => {
+ render(
+ <Harness
+ messages={[
+ { role: 'user', content: [{ type: 'text', text: 'do it' }] },
+ {
+ role: 'assistant',
+ status: { type: 'complete', reason: 'stop' },
+ content: [
+ tool('t1', 'shell', {
+ status: { type: 'requires-action', reason: 'interrupt' },
+ }),
+ tool('t2', 'search_two'),
+ ],
+ },
+ ]}
+ isRunning={false}
+ />
+ );
+
+ expect(screen.getByRole('button', { name: '2 tool calls' })).toHaveAttribute(
+ 'aria-expanded',
+ 'true'
+ );
+ });
});
describe('activityGroupLabel', () => {
diff --git a/app/src/pages/__tests__/Conversations.render.test.tsx b/app/src/pages/__tests__/Conversations.render.test.tsx
index 0507a201bf..30cd193f01 100644
--- a/app/src/pages/__tests__/Conversations.render.test.tsx
+++ b/app/src/pages/__tests__/Conversations.render.test.tsx
@@ -630,7 +630,9 @@ describe('Conversations — smoke render (#1123 welcome-lock removal)', () => {
});
});
- // The past turn's core transcript is projected into assistant-ui exactly once.
+ // The past turn's core transcript is projected into one settled activity
+ // group. Open it before checking the contained tool card.
+ fireEvent.click(await screen.findByRole('button', { name: '1 tool call' }));
expect(await screen.findByTestId('assistant-ui-tool-call')).toHaveTextContent('Read File');
});