import { useEffect, useState } from 'react'; import { useModalAmbientDuck } from '../../context/AmbientMusicContext'; import { FLEET_GROUP_COLORS, normalizeGroupColor } from '../../help/fleetGroups'; import './CreateGroupModal.css'; interface Props { open: boolean; agentCount: number; onClose: () => void; onCreate: (name: string, color: string) => void; } export default function CreateGroupModal({ open, agentCount, onClose, onCreate }: Props) { useModalAmbientDuck(open); const [name, setName] = useState(''); const [color, setColor] = useState(FLEET_GROUP_COLORS[0]); useEffect(() => { if (open) { setName(''); setColor(FLEET_GROUP_COLORS[groupsColorIndex(agentCount) % FLEET_GROUP_COLORS.length]); } }, [open, agentCount]); if (!open || agentCount < 1) return null; const submit = (e: React.FormEvent) => { e.preventDefault(); const trimmed = name.trim(); if (!trimmed) return; onCreate(trimmed, normalizeGroupColor(color)); onClose(); }; return (
e.stopPropagation()} >

Create group

Saves {agentCount} selected machine{agentCount === 1 ? '' : 's'} — usable in Crucible for bulk commands.

setName(e.target.value)} placeholder="e.g. Living room PCs" autoFocus maxLength={64} />

Group color

{FLEET_GROUP_COLORS.map((c) => (
setColor(e.target.value)} aria-label="Custom color" /> {normalizeGroupColor(color)}
); } function groupsColorIndex(n: number): number { return Math.abs(n) % FLEET_GROUP_COLORS.length; }