diff --git a/apps/gui/src/app/actions.ts b/apps/gui/src/app/actions.ts index 966c199..8ace413 100644 --- a/apps/gui/src/app/actions.ts +++ b/apps/gui/src/app/actions.ts @@ -38,6 +38,7 @@ export async function startSimulation(input: { scenario?: string; playEntity?: string; providerInstanceId?: string; + customName?: string; }): Promise { try { const scenarioFile = @@ -52,6 +53,7 @@ export async function startSimulation(input: { resolved, input.playEntity || undefined, input.providerInstanceId, + input.customName, ); if (snapshot.status === "error") { @@ -348,3 +350,21 @@ export async function fetchAvailableModelsForInstance( inst.endpointUrl, ); } + +export async function renameSimulation( + simId: string, + newName: string, +): Promise<{ ok: true; snapshot: SimSnapshot } | { ok: false; error: string }> { + try { + const snapshot = await simulationManager.rename(simId, newName); + if (!snapshot) { + return { ok: false, error: "Simulation session not found" }; + } + return { ok: true, snapshot }; + } catch (err) { + return { + ok: false, + error: err instanceof Error ? err.message : "Failed to rename simulation", + }; + } +} diff --git a/apps/gui/src/components/home/HomeView.tsx b/apps/gui/src/components/home/HomeView.tsx index b01209d..183398a 100644 --- a/apps/gui/src/components/home/HomeView.tsx +++ b/apps/gui/src/components/home/HomeView.tsx @@ -33,6 +33,7 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; +import { Input } from "@/components/ui/input"; export function HomeView() { const router = useRouter(); @@ -59,6 +60,7 @@ export function HomeView() { const [loadingEntities, setLoadingEntities] = useState(false); const [selectedEntityForModal, setSelectedEntityForModal] = useState(""); + const [customName, setCustomName] = useState(""); const loadSavedSessions = useCallback(async () => { try { @@ -144,6 +146,7 @@ export function HomeView() { setScenarioForModal(scenario); setLoadingEntities(true); setSelectedEntityForModal(""); // Reset selection to Spectator + setCustomName(scenario.name); // Set custom simulation name default try { const res = await getScenarioEntities(scenario.path); if (res.ok) { @@ -168,6 +171,7 @@ export function HomeView() { const result = await startSimulation({ scenario: targetScenario.path, playEntity: selectedEntityForModal || undefined, + customName: customName.trim() || undefined, }); if (!result.ok) { @@ -394,6 +398,16 @@ export function HomeView() { ) : (
+
+ + setCustomName(e.target.value)} + placeholder="Enter custom name..." + /> +