web: React+Vite SPA — sessions, streaming chat, task panel, spawn flow (build clean)

This commit is contained in:
Raphael Westphal
2026-08-18 13:37:14 +02:00
parent 345025b070
commit 7d5f866527
22 changed files with 4253 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
export interface Settings {
serverUrl: string;
token: string;
}
const STORAGE_KEY: string = "lvmh.settings";
export function getSettings(): Settings | null {
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (raw === null) return null;
const parsed: unknown = JSON.parse(raw);
if (
parsed !== null &&
typeof parsed === "object" &&
typeof (parsed as { serverUrl?: unknown }).serverUrl === "string" &&
typeof (parsed as { token?: unknown }).token === "string"
) {
return parsed as Settings;
}
return null;
} catch {
return null;
}
}
export function saveSettings(settings: Settings): void {
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
}
export function clearSettings(): void {
localStorage.removeItem(STORAGE_KEY);
}
export function buildWsUrl(settings: Settings): string {
const base = settings.serverUrl.replace(/\/+$/, "").replace(/^http/, "ws");
return `${base}/ws?token=${encodeURIComponent(settings.token)}`;
}