Skip to content

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

fix(aui): correct subagent activity card test import path

Steven Enamakelc5d757a54f49
diff --git a/app/src/features/conversations/aui/SubagentActivityCard.test.tsx b/app/src/features/conversations/aui/SubagentActivityCard.test.tsx
new file mode 100644
index 0000000000..855a5b41c0
--- /dev/null
+++ b/app/src/features/conversations/aui/SubagentActivityCard.test.tsx
@@ -0,0 +1,103 @@
+import { fireEvent, render, screen, within } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+
+import type { SubagentActivity } from '../../../store/chatRuntimeSlice';
+import { SubagentActivityCard } from './SubagentActivityCard';
+
+function openDisclosure() {
+ fireEvent.click(within(screen.getByTestId('assistant-ui-subagent-call')).getByRole('button'));
+}
+
+describe('SubagentActivityCard', () => {
+ it('derives a working state from a running activity with no explicit status text needed', () => {
+ render(
+ <SubagentActivityCard
+ activity={{ taskId: 't', agentId: 'researcher', status: 'running', toolCalls: [] }}
+ />
+ );
+ expect(screen.getByTestId('assistant-ui-subagent-call')).toHaveAttribute('data-status', 'working');
+ });
+
+ it('marks a failed delegation as failed rather than complete', () => {
+ render(
+ <SubagentActivityCard
+ activity={{ taskId: 't', agentId: 'researcher', status: 'failed', toolCalls: [] }}
+ />
+ );
+ expect(screen.getByTestId('assistant-ui-subagent-call')).toHaveAttribute('data-status', 'failed');
+ });
+
+ it('marks a cancelled delegation as cancelled', () => {
+ render(
+ <SubagentActivityCard
+ activity={{ taskId: 't', agentId: 'researcher', status: 'cancelled', toolCalls: [] }}
+ />
+ );
+ expect(screen.getByTestId('assistant-ui-subagent-call')).toHaveAttribute(
+ 'data-status',
+ 'cancelled'
+ );
+ });
+
+ it('shows the awaiting-user question as plain text with no reply box', () => {
+ // This surface (the inline rail, the Agent Process Source panel) renders
+ // outside an AssistantRuntimeProvider, so unlike `SubagentTaskCard` there
+ // is nowhere to send a reply through — the question is read-only here.
+ render(
+ <SubagentActivityCard
+ activity={{
+ taskId: 't',
+ agentId: 'researcher',
+ status: 'awaiting_user',
+ awaitingQuestion: 'Which repo should I use?',
+ toolCalls: [],
+ }}
+ />
+ );
+ expect(screen.getByTestId('assistant-ui-subagent-call')).toHaveAttribute(
+ 'data-status',
+ 'awaiting_user'
+ );
+ expect(screen.getByTestId('subagent-awaiting-question')).toHaveTextContent(
+ 'Which repo should I use?'
+ );
+ expect(screen.queryByTestId('subagent-answer-input')).toBeNull();
+ });
+
+ it('renders the delegation label with the agent display name', () => {
+ render(
+ <SubagentActivityCard
+ activity={{
+ taskId: 't',
+ agentId: 'researcher',
+ displayName: 'Researcher',
+ status: 'success',
+ toolCalls: [],
+ }}
+ />
+ );
+ expect(screen.getByText('Delegated to Researcher')).toBeInTheDocument();
+ });
+
+ it('renders child tool calls (from `toolCalls`) inside the nested transcript once opened', () => {
+ render(
+ <SubagentActivityCard
+ activity={{
+ taskId: 't',
+ agentId: 'researcher',
+ status: 'success',
+ toolCalls: [{ callId: 'c1', toolName: 'web_search', status: 'success' }],
+ }}
+ />
+ );
+ openDisclosure();
+ expect(screen.getByTestId('subagent-activity')).toBeInTheDocument();
+ });
+
+ it('renders no nested-transcript disclosure chevron when there is nothing to show', () => {
+ render(<SubagentActivityCard activity={{ taskId: 't', agentId: 'researcher', toolCalls: [] }} />);
+ expect(
+ screen.getByRole('button', { name: /Delegated to researcher/i })
+ ).toHaveAttribute('disabled');
+ });
+});
diff --git a/app/src/features/conversations/components/AssistantUiChat.tsx b/app/src/features/conversations/components/AssistantUiChat.tsx
index b8a9ed1dd7..b899c64732 100644
--- a/app/src/features/conversations/components/AssistantUiChat.tsx
+++ b/app/src/features/conversations/components/AssistantUiChat.tsx
@@ -8,18 +8,16 @@ import { Button } from '../../../components/ui';
import type { Attachment } from '../../../lib/attachments';
import { useT } from '../../../lib/i18n/I18nContext';
import { AssistantUiRuntimeProvider } from '../../../providers/AssistantUiRuntimeProvider';
-import { emptySessionTokenUsage } from '../../../store/chatRuntimeSlice';
import { useAppSelector } from '../../../store/hooks';
import { DEFAULT_MASCOT_COLOR } from '../../../store/mascotSlice';
import { MascotChipAvatar } from '../../human/Mascot/MascotChipAvatar';
import { AgentRunningStatus } from '../aui/AgentRunningStatus';
import { ChatConversationMap } from '../aui/ChatConversationMap';
import { ComposerTriggers } from '../aui/ComposerTriggers';
+import { ContextUsage } from '../aui/ContextUsage';
import { ChatSources } from './aui/ChatSources';
import { ChatToolFallback } from './ChatToolParts';
-import { contextUsageFromTokenUsage, ContextWindowPill } from './composer/ContextWindowPill';
-const EMPTY_TOKEN_USAGE = emptySessionTokenUsage();
const selectComposerText = (state: AssistantState) => state.composer.text;
function ComposerTextBridge({
@@ -120,15 +118,6 @@ export function AssistantUiChat({
const mascotCustomPrimary = useAppSelector(state => state.mascot?.customPrimaryColor ?? null);
const selectedThreadId = useAppSelector(state => state.thread.selectedThreadId);
const loadError = useAppSelector(state => state.thread.messagesError);
- const tokenUsage = useAppSelector(state =>
- selectedThreadId
- ? (state.chatRuntime.usageByThread[selectedThreadId] ?? EMPTY_TOKEN_USAGE)
- : EMPTY_TOKEN_USAGE
- );
- const contextUsage = useMemo(
- () => contextUsageFromTokenUsage(tokenUsage, modelContextWindow),
- [modelContextWindow, tokenUsage]
- );
// Every prop the composer slots below read, refreshed on each host render.
//
@@ -141,24 +130,26 @@ export function AssistantUiChat({
const slotPropsRef = useRef({
attachments,
attachmentInteractionBlocked,
- contextUsage,
maxAttachments,
mascotColor,
mascotCustomPrimary,
+ modelContextWindow,
onAttachFiles,
onOpenHumanMode,
onRemoveAttachment,
+ selectedThreadId,
});
slotPropsRef.current = {
attachments,
attachmentInteractionBlocked,
- contextUsage,
maxAttachments,
mascotColor,
mascotCustomPrimary,
+ modelContextWindow,
onAttachFiles,
onOpenHumanMode,
onRemoveAttachment,
+ selectedThreadId,
};
// Read through a ref for the same reason `ComposerHeader` does below: the
// slot is rendered by type, so closing over the node would remount the whole
@@ -166,10 +157,10 @@ export function AssistantUiChat({
const composerFooterExtrasRef = useRef(composerFooterExtras);
composerFooterExtrasRef.current = composerFooterExtras;
const ComposerExtras = useCallback(() => {
- const { contextUsage: usage } = slotPropsRef.current;
+ const { modelContextWindow, selectedThreadId } = slotPropsRef.current;
return (
<>
- <ContextWindowPill usage={usage} />
+ <ContextUsage threadId={selectedThreadId} modelContextWindow={modelContextWindow} />
{composerFooterExtrasRef.current}
</>
);