Skip to content

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

fix(assistant-ui): handle missing task data in task card component

Steven Enamakel52b18aafbf79
diff --git a/app/src/components/assistant-ui/elements/task-card.aui.tsx b/app/src/components/assistant-ui/elements/task-card.aui.tsx
index 81943ab49b..6f4b5a40fe 100644
--- a/app/src/components/assistant-ui/elements/task-card.aui.tsx
+++ b/app/src/components/assistant-ui/elements/task-card.aui.tsx
@@ -172,94 +172,3 @@ const TaskCard: FC<{ part: TaskPart; className?: string }> = ({ part, className
);
};
-const TaskLane: FC<{ index: number }> = ({ index }) => {
- const aui = useAui();
- const part = useAuiState(s => s.message.parts[index]);
- if (part?.type !== 'tool-call') return null;
- const client = aui.message.part({ toolCallId: part.toolCallId });
- return (
- <TaskCard
- part={{
- ...part,
- addResult: client.addToolResult,
- resume: client.resumeToolCall,
- respondToApproval: client.respondToToolApproval,
- }}
- />
- );
-};
-
-/** English defaults for `TaskGroup`'s summary line; override via its `strings` prop. */
-export interface TaskGroupStrings {
- tasks: (count: number) => string;
- running: (count: number) => string;
- waiting: (count: number) => string;
- failed: (count: number) => string;
- showMore: (count: number) => string;
-}
-
-const DEFAULT_TASK_GROUP_STRINGS: TaskGroupStrings = {
- tasks: count => `${count} tasks`,
- running: count => `${count} running`,
- waiting: count => `${count} waiting`,
- failed: count => `${count} failed`,
- showMore: count => `Show ${count} more`,
-};
-
-export const TaskGroup: FC<{
- group: MessagePrimitive.GroupedParts.GroupPart;
- className?: string;
- strings?: TaskGroupStrings;
-}> = ({ group, className, strings = DEFAULT_TASK_GROUP_STRINGS }) => {
- const [visible, setVisible] = useState(TASK_PAGE_SIZE);
- const { indices, counts } = group;
- // A selector has to return a stable value, so the lane keys travel as one string and are split afterwards.
- const laneKeys = useAuiState(s =>
- indices
- .map(index => {
- const part = s.message.parts[index];
- return part?.type === 'tool-call' ? part.toolCallId : String(index);
- })
- .join(KEY_SEPARATOR)
- ).split(KEY_SEPARATOR);
- const failed = useAuiState(s =>
- indices.reduce((count, index) => {
- const part = s.message.parts[index];
- return part?.type === 'tool-call' && taskStateOf(part.status, part.isError) === 'failed'
- ? count + 1
- : count;
- }, 0)
- );
- if (indices.length === 1) return <TaskLane index={indices[0]!} />;
-
- const shown = indices.slice(0, visible);
- const hidden = indices.length - shown.length;
- const summary = [
- strings.tasks(indices.length),
- counts.running > 0 && strings.running(counts.running),
- counts.requiresAction > 0 && strings.waiting(counts.requiresAction),
- failed > 0 && strings.failed(failed),
- ].filter((entry): entry is string => typeof entry === 'string');
-
- return (
- <div
- data-slot="aui_task-group"
- className={cn('flex w-full max-w-sm flex-col gap-2', className)}>
- <div data-slot="aui_task-group-summary" className="text-muted-foreground px-1 text-xs">
- {summary.join(' · ')}
- </div>
- {shown.map((index, position) => (
- <TaskLane key={laneKeys[position] ?? index} index={index} />
- ))}
- {hidden > 0 && (
- <button
- type="button"
- data-slot="aui_task-group-more"
- onClick={() => setVisible(count => count + TASK_PAGE_SIZE)}
- className="text-muted-foreground hover:text-foreground w-fit px-1 text-xs transition-colors">
- {strings.showMore(Math.min(hidden, TASK_PAGE_SIZE))}
- </button>
- )}
- </div>
- );
-};