Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
// Talking to /api/v1/camoufox/service. No React here so the retry/readiness logic
// stays testable without a DOM.
export interface CamoufoxServiceStatus {
running: boolean;
enabled: boolean;
installed: boolean;
viewerReady?: boolean;
}
export async function fetchStatus(signal?: AbortSignal): Promise<CamoufoxServiceStatus> {
const response = await fetch("/api/v1/camoufox/service", { cache: "no-store", signal });
const payload = (await response.json()) as CamoufoxServiceStatus & { error?: string };
// Never fall back to a synthetic "not installed": that reads as a settled fact
// about the host when it is really an unanswered question, and it sends whoever
// sees it looking for a missing install instead of the real fault.
if (!response.ok) throw new Error(payload.error ?? "The browser session is unreachable");
return payload;
}
export async function setPower(on: boolean, signal?: AbortSignal): Promise<CamoufoxServiceStatus> {
const response = await fetch("/api/v1/camoufox/service", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ action: on ? "start" : "stop" }),
signal,
});
const payload = (await response.json()) as CamoufoxServiceStatus & { error?: string };
if (!response.ok) throw new Error(payload.error ?? "Could not change the browser session");
return payload;
}
/** systemd reports `active` before websockify/noVNC is listening. The cockpit cannot
* fetch the dedicated viewer origin directly without widening CORS, so the authenticated
* same-origin status route performs the bounded loopback probe and returns viewerReady. */
export async function waitForViewer(signal: AbortSignal, timeoutMs = 30_000, onStatus?: (status: CamoufoxServiceStatus) => void): Promise<boolean> {
const deadline = Date.now() + timeoutMs;
while (!signal.aborted) {
try {
const status = await fetchStatus(signal);
if (signal.aborted) return false;
onStatus?.(status);
if (!status.running) return false;
if (status.viewerReady) return true;
} catch {
if (signal.aborted) return false;
}
if (Date.now() >= deadline) return false;
await new Promise((resolve) => setTimeout(resolve, 700));
}
return false;
}
/** Check public TLS through the authenticated API, never by widening browser CORS. */
export async function verifyViewerTransport(signal: AbortSignal): Promise<void> {
const response = await fetch("/api/v1/camoufox/service?probe=viewer", { cache: "no-store", signal });
const result = await response.json() as { reachable?: boolean; state?: string; clientOnly?: boolean; message?: string; error?: string };
const clientPrivateRoute = result.state === "client-only" && result.clientOnly === true;
if (!response.ok || (result.reachable !== true && !clientPrivateRoute)) throw new Error(result.message ?? result.error ?? "The secure viewer is unavailable");
}