// Display Rover Cell // Purpose: Shows one rover's room-readable driver and battery status. // Scope: Reuses shared rover/battery presentation primitives while avoiding controls, queues, and video. import { useTelemetryFrame } from '../../../context/TelemetryContext.jsx'; import BatteryBar from '../../../components/BatteryBar/index.jsx'; import RoverLabel from '../../../components/RoverLabel/index.jsx'; import AutoFitText from '../../../mini/MiniSummaryApp/components/AutoFitText.jsx'; import { buildRoverStateText, findDriverForRover, formatBatteryText, getDisplayBatteryVisual, } from '../utils.js'; function classNames(...values) { return values.filter(Boolean).join(' '); } export default function DisplayRoverCell({ rover, session }) { const frame = useTelemetryFrame(rover?.id); const visual = getDisplayBatteryVisual({ rover, frame }); const driver = findDriverForRover({ roverId: rover?.id, session }); const stateText = buildRoverStateText(rover, visual); const batteryText = formatBatteryText(visual); const active = Boolean(driver); const urgent = Boolean(visual?.urgentActive); const warn = Boolean(visual?.warnActive); const locked = Boolean(rover?.locked); return (
{locked ? ( // Keep the lock warning adjacent to the rover identity so the cell // remains readable while still making the locked state impossible // to miss at a glance.
LOCKED
{rover?.lockReason ? (
{rover.lockReason}
) : null}
) : null}
{driver?.label || 'Idle'}
{batteryText}
{stateText ? (
{stateText}
) : ( // This empty line keeps cells with and without exceptional states the // same height. The grid should not jump just because one rover becomes // locked or low battery while people are reading the board.
); }