Skip to content

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

fix(activity-group): keep group open during inter-step gaps

Steven Enamakel941dea58fb81
diff --git a/app/src/components/assistant-ui/activity-group.tsx b/app/src/components/assistant-ui/activity-group.tsx
index 5aa622032c..5cad0c7c94 100644
--- a/app/src/components/assistant-ui/activity-group.tsx
+++ b/app/src/components/assistant-ui/activity-group.tsx
@@ -34,9 +34,9 @@ export function activityGroupLabel(reasoningCount: number, toolCount: number): s
* and the answer drowned among them. As one group the message reads input →
* work → answer however the work interleaved.
*
- * Open while the work is live (`running`, or `requires-action` for a tool
- * parked on an approval, whose decision card lives inside), closed once it
- * settles so the answer leads. The first manual toggle wins from then on.
+ * Open while the work is live (`running`, the running turn's tail, or
+ * `requires-action` for a tool parked on an approval, whose decision card lives
+ * inside), closed once it settles so the answer leads. The first manual toggle wins from then on.
*/
export const ActivityGroup: FC<PropsWithChildren<{ group: ActivityGroupPart }>> = ({
group,
@@ -50,16 +50,20 @@ export const ActivityGroup: FC<PropsWithChildren<{ group: ActivityGroupPart }>>
const reasoningCount = useAuiState(
s => indices.filter(i => s.message.parts[i]?.type === 'reasoning').length
);
+ // Between steps — a tool has returned, the next inference has not started —
+ // every part in the group is complete while the turn is not. Without this the
+ // group would close and reopen on every round trip. It stays open until the
+ // turn moves past it (the answer starts streaming) or ends.
+ const isTail = useAuiState(
+ s => s.message.status?.type === 'running' && indices.at(-1) === s.message.parts.length - 1
+ );
const [userOpen, setUserOpen] = useState<boolean | null>(null);
- const running = group.status.type === 'running';
+ const running = group.status.type === 'running' || isTail;
const live = running || group.status.type === 'requires-action';
return (
- <ToolGroupRoot
- variant="ghost"
- open={userOpen ?? live}
- onOpenChange={setUserOpen}>
+ <ToolGroupRoot variant="ghost" open={userOpen ?? live} onOpenChange={setUserOpen}>
<ToolGroupTrigger
count={toolCount}
label={activityGroupLabel(reasoningCount, toolCount)}
diff --git a/app/src/components/assistant-ui/thread.activityGroup.test.tsx b/app/src/components/assistant-ui/thread.activityGroup.test.tsx
index f6a1e66e2f..88daab2f4a 100644
--- a/app/src/components/assistant-ui/thread.activityGroup.test.tsx
+++ b/app/src/components/assistant-ui/thread.activityGroup.test.tsx
@@ -56,7 +56,9 @@ function Harness({ messages, isRunning }: { messages: ThreadMessageLike[]; isRun
describe('activity group', () => {
it('puts interleaved reasoning and tool calls under one trigger, answer outside', () => {
- render(<Harness messages={interleaved({ type: 'complete', reason: 'stop' })} isRunning={false} />);
+ render(
+ <Harness messages={interleaved({ type: 'complete', reason: 'stop' })} isRunning={false} />
+ );
const triggers = screen.getAllByRole('button', { name: /Reasoning · 2 tool calls/ });
expect(triggers).toHaveLength(1);
@@ -78,7 +80,10 @@ describe('activity group', () => {
<Harness
messages={interleaved({ type: 'running' }).map((m, i) =>
i === 1
- ? { ...m, content: [{ type: 'reasoning', text: 'live thought' }, tool('t1', 'search_one')] }
+ ? {
+ ...m,
+ content: [{ type: 'reasoning', text: 'live thought' }, tool('t1', 'search_one')],
+ }
: m
)}
isRunning
diff --git a/app/src/features/conversations/components/ChatToolParts.tsx b/app/src/features/conversations/components/ChatToolParts.tsx
index 572c881659..478b2ad40d 100644
--- a/app/src/features/conversations/components/ChatToolParts.tsx
+++ b/app/src/features/conversations/components/ChatToolParts.tsx
@@ -3,7 +3,7 @@ import {
type ToolCallMessagePartComponent,
useAui,
} from '@assistant-ui/react';
-import { type FC, useCallback } from 'react';
+import { useCallback } from 'react';
import ApprovalRequestCard from '../../../components/chat/ApprovalRequestCard';
import IntegrationConnectCard from '../../../components/chat/IntegrationConnectCard';