"use client"; import { useState, useCallback, memo } from "react"; import { IconChevronDown, IconChevronRight } from "@tabler/icons-react"; import { GridSpinner } from "@/components/grid-spinner"; import { cn } from "@/lib/utils"; import type { Message } from "@/lib/types/http"; import type { ToolCallMetadata } from "@/components/task/chat/types"; import { SubagentMetaRow } from "@/components/task/chat/messages/subagent-meta-row"; type ToolSubagentMessageProps = { comment: Message; childMessages: Message[]; worktreePath?: string; onOpenFile?: (path: string) => void; renderChild: (message: Message) => React.ReactNode; }; // Custom comparison function that ignores renderChild (it's always recreated but referentially stable in behavior) function arePropsEqual( prevProps: ToolSubagentMessageProps, nextProps: ToolSubagentMessageProps, ): boolean { return ( prevProps.comment === nextProps.comment && prevProps.childMessages === nextProps.childMessages && prevProps.worktreePath === nextProps.worktreePath && prevProps.onOpenFile === nextProps.onOpenFile ); } type SubagentHeaderProps = { isExpanded: boolean; subagentType: string; description: string; isActive: boolean; childCount: number; onToggle: () => void; }; function SubagentHeader({ isExpanded, subagentType, description, isActive, childCount, onToggle, }: SubagentHeaderProps) { return ( ); } const NESTED_BORDER = "ml-2 pl-4 border-l-2 border-border/30 mt-1"; type SubagentContentProps = { isExpanded: boolean; childMessages: Message[]; isActive: boolean; prompt?: string; renderChild: (message: Message) => React.ReactNode; }; function SubagentContent({ isExpanded, childMessages, isActive, prompt, renderChild, }: SubagentContentProps) { if (!isExpanded) return null; if (childMessages.length > 0) { return (
{prompt}