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 (
{agent.notes.trim().slice(0, 80)}{agent.notes.length > 80 ? '…' : ''}
)} {expanded && ({agent.notes}
}