import * as React from 'react' import { Box, Text } from '@anthropic/ink' import { formatNumber } from '../utils/format.js' import type { Theme } from '../utils/theme.js' type Props = { agentType: string description?: string name?: string descriptionColor?: keyof Theme taskDescription?: string toolUseCount: number tokens: number | null color?: keyof Theme isLast: boolean isResolved: boolean isError: boolean isAsync?: boolean shouldAnimate: boolean lastToolInfo?: string | null hideType?: boolean } export function AgentProgressLine({ agentType, description, name, descriptionColor, taskDescription, toolUseCount, tokens, color, isLast, isResolved, isError: _isError, isAsync = false, shouldAnimate: _shouldAnimate, lastToolInfo, hideType = false, }: Props): React.ReactNode { const treeChar = isLast ? '└─' : '├─' const isBackgrounded = isAsync && isResolved // Determine the status text const getStatusText = (): string => { if (!isResolved) { return lastToolInfo || 'Initializing…' } if (isBackgrounded) { return taskDescription ?? 'Running in the background' } return 'Done' } return ( {treeChar} {hideType ? ( <> {name ?? description ?? agentType} {name && description && : {description}} ) : ( <> {agentType} {description && ( <> {' ('} {description} {')'} )} )} {!isBackgrounded && ( <> {' · '} {toolUseCount} tool {toolUseCount === 1 ? 'use' : 'uses'} {tokens !== null && <> · {formatNumber(tokens)} tokens} )} {!isBackgrounded && ( {isLast ? ' ⎿ ' : '│ ⎿ '} {getStatusText()} )} ) }