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
"use client";
import { useCallback, useState } from "react";
import { addUsage, type ProviderUsage } from "./turn-usage";
// Per-turn and per-thread token accounting for the Alfa chat. Extracted from
// ChatPanel (which was tripping max-lines) so the panel stays about the run loop
// and this state has one home: `record` folds each turn's usage into the thread
// total, `reset` clears both when the conversation switches.
export function useTurnUsage() {
const [turnUsage, setTurnUsage] = useState<ProviderUsage | null>(null);
const [threadUsage, setThreadUsage] = useState<ProviderUsage | null>(null);
const record = useCallback((usage?: ProviderUsage | null) => {
if (!usage) return;
setTurnUsage(usage);
setThreadUsage((prev) => addUsage(prev, usage));
}, []);
const reset = useCallback(() => {
setTurnUsage(null);
setThreadUsage(null);
}, []);
return { turnUsage, threadUsage, record, reset };
}