import type { JSX } from "react"; import { AlertCircle, ChevronDown, ChevronRight } from "lucide-react"; import { FilePenLineIcon } from "../../../app/renderer/components/icons/FilePenLineIcon"; import { FileTextIcon } from "../../../app/renderer/components/icons/FileTextIcon"; import { HammerIcon } from "../../../app/renderer/components/icons/HammerIcon"; import { ToolsLinedIcon } from "../../../app/renderer/components/icons/ToolsLinedIcon"; import { WriteLinedIcon } from "../../../app/renderer/components/icons/WriteLinedIcon"; import { ToolNameIcon } from "../../toolActivityKindIcons"; import { isImageGenerationToolCall } from "../../imageGenerationTool"; import type { AgentToolCallVM } from "../contracts/agentToolCallVM"; import { getFileChangeRenderData, isFailedToolCall } from "./tool-renderers/render-data/agentToolRenderData"; const TOOL_ROW_ICON_SIZE = 16; interface AgentToolCallHeaderProps { call: AgentToolCallVM; expanded: boolean; hasDetail: boolean; } export function AgentToolCallHeader({ call, expanded, hasDetail }: AgentToolCallHeaderProps): JSX.Element { "use memo"; const diffStats = diffStatsForCall(call); const isActive = call.statusKind === "working" || call.statusKind === "waiting"; const isFailed = isFailedToolCall(call); return (
{isFailed ? (
{formatInlineTitleLabel(call.name)} {call.status ? ( {formatInlineStatusLabel(call.status)} ) : null} {isActive ? : null} {diffStats ? ( {diffStats.added > 0 ? ( +{diffStats.added} ) : null} {diffStats.removed > 0 ? ( -{diffStats.removed} ) : null} ) : null}
{hasDetail ? ( expanded ? (
); } function formatInlineStatusLabel(label: string): string { return /^[A-Z][a-z]+$/.test(label) ? label.toLowerCase() : label; } function formatInlineTitleLabel(label: string): string { const trimmed = label.trim(); if (!/[a-z]/.test(trimmed) || !/[A-Z]/.test(trimmed.slice(1))) { return label; } const words = trimmed.split(/(\s+)/); let changed = false; const normalized = words .map((word, index) => { if (index === 0 || !/^[A-Z][a-z]+$/.test(word)) { return word; } changed = true; return word.toLowerCase(); }) .join(""); return changed ? normalized : label; } function LoadingEllipsis(): JSX.Element { "use memo"; return (