import AgentRemoteActions from './AgentRemoteActions'; import { formatHashrate, formatUptime } from '../../help/fleetFilters'; import { lotlTierLabel } from '../../help/warRoomTelemetry'; import type { Agent } from '../../types'; import type { SeqCommandResult } from '../../context/WebSocketContext'; import type { FleetGroup } from '../../help/fleetGroups'; import LatencyBadge from './LatencyBadge'; function formatRelTime(iso: string): string { const diff = Date.now() - new Date(iso).getTime(); const mins = Math.floor(diff / 60000); if (mins < 2) return 'just now'; if (mins < 60) return `${mins}m ago`; const hrs = Math.floor(mins / 60); if (hrs < 24) return `${hrs}h ago`; return `${Math.floor(hrs / 24)}d ago`; } interface Props { agent: Agent; selected: boolean; expanded: boolean; selectable?: boolean; checked?: boolean; onToggleExpand: () => void; onSelect: () => void; onCheck?: (checked: boolean) => void; commandResults?: SeqCommandResult[]; memberGroups?: FleetGroup[]; } export default function AgentListItem({ agent, selected, expanded, selectable, checked, onToggleExpand, onSelect, onCheck, commandResults, memberGroups = [], }: Props) { const online = agent.status === 'online'; const primaryGroup = memberGroups[0]; const handleRowClick = (e: React.MouseEvent) => { const target = e.target as HTMLElement; if (target.closest('input[type="checkbox"]') || target.closest('button') || target.closest('.agent-remote')) { return; } onSelect(); onToggleExpand(); }; return (
{selectable && ( { e.stopPropagation(); onCheck?.(e.target.checked); }} onClick={(e) => e.stopPropagation()} /> )} {agent.name} {agent.platform && ( {agent.platform}{agent.arch ? `/${agent.arch}` : ''} )} {agent.campaign && ( c:{agent.campaign} )} {lotlTierLabel(agent.lotl_tier) && ( {lotlTierLabel(agent.lotl_tier)} )}
{agent.status}
{(memberGroups.length > 0 || (agent.tags?.length ?? 0) > 0) && (
{memberGroups.map((g) => ( {g.name} ))} {agent.tags?.map((t) => ( {t} ))}
)}
{formatHashrate(agent.hashrate_15m)} {agent.ip || '—'} {agent.status !== 'online' && agent.last_seen && ( last seen {formatRelTime(agent.last_seen)} )} {!expanded && agent.status === 'online' && click for details}
{!expanded && agent.notes?.trim() && (

{agent.notes.trim().slice(0, 80)}{agent.notes.length > 80 ? '…' : ''}

)} {expanded && (
e.stopPropagation()}>
Shares: {agent.shares_good}/{agent.shares_total} {agent.cpu_cores} cores · {agent.memory_gb} GB Uptime: {formatUptime(agent.uptime_seconds)} v{agent.version || '?'} {agent.build_id && build:{agent.build_id.slice(0, 8)}} {agent.campaign && c:{agent.campaign}}
{agent.notes?.trim() &&

{agent.notes}

}
)}
); }