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 { useEffect, useMemo, useState } from "react";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { FormDrawer } from "@/features/appshell";
import { filterAndSortModels, type CatModel, type ModelFilters, type ModelSort } from "./model-catalog-utils";
const fmtCtx = (n?: number) => (!n ? "-" : n >= 1e6 ? `${n / 1e6}M` : n >= 1e3 ? `${Math.round(n / 1e3)}K` : `${n}`);
const fmtCost = (n?: number) => (n == null ? "-" : `$${n}`);
// Searchable browser over the same live model catalog used by CLI onboarding.
// `free` is server-derived only from explicit zero input+output pricing; unknown
// pricing never receives the badge or passes the Free filter.
export function ModelCatalog({ provider, value, onPick }: { provider: string; value: string; onPick: (id: string) => void }) {
const [open, setOpen] = useState(false);
const [q, setQ] = useState("");
const [models, setModels] = useState<CatModel[]>([]);
const [sort, setSort] = useState<ModelSort>("best");
const [filters, setFilters] = useState<ModelFilters>({ free: false, tools: false, reasoning: false, vision: false, minContext: 0 });
useEffect(() => {
if (!open) return;
let alive = true;
fetch(`/api/models?provider=${encodeURIComponent(provider)}`, { cache: "no-store" })
.then((r) => (r.ok ? r.json() : { models: [] }))
.then((d) => alive && setModels((d.models ?? []) as CatModel[]))
.catch(() => alive && setModels([]));
return () => {
alive = false;
};
}, [open, provider]);
const filtered = useMemo(() => filterAndSortModels(models, q, filters, sort), [models, q, filters, sort]);
const toggle = (key: "free" | "tools" | "reasoning" | "vision") => setFilters((f) => ({ ...f, [key]: !f[key] }));
return (
<>
<Button type="button" variant="outline" size="sm" onClick={() => setOpen(true)} className="[@media(pointer:coarse)]:min-h-[44px]">Browse</Button>
<FormDrawer open={open} onOpenChange={setOpen} size="md">
<FormDrawer.Header>
<FormDrawer.Title>Models: {provider}</FormDrawer.Title>
</FormDrawer.Header>
<FormDrawer.Body className="space-y-3">
<Input autoFocus placeholder="Search models…" value={q} onChange={(e) => setQ(e.target.value)} />
<div className="flex flex-wrap items-center gap-2 text-xs">
<select className="h-8 rounded-md border border-border bg-background px-2" value={sort} onChange={(e) => setSort(e.target.value as ModelSort)} aria-label="Sort models">
<option value="best">Sort: most worth</option>
<option value="price">Sort: lowest price</option>
<option value="capability">Sort: capability</option>
<option value="context">Sort: context length</option>
</select>
<select className="h-8 rounded-md border border-border bg-background px-2" value={filters.minContext} onChange={(e) => setFilters((f) => ({ ...f, minContext: Number(e.target.value) }))} aria-label="Minimum context length">
<option value={0}>Any context</option>
<option value={32000}>32K+ context</option>
<option value={128000}>128K+ context</option>
<option value={1000000}>1M+ context</option>
</select>
<Filter checked={filters.free} label="Free" onChange={() => toggle("free")} />
<Filter checked={filters.tools} label="Tools" onChange={() => toggle("tools")} />
<Filter checked={filters.reasoning} label="Reasoning" onChange={() => toggle("reasoning")} />
<Filter checked={filters.vision} label="Vision" onChange={() => toggle("vision")} />
</div>
{models.some((model) => model.free) && (
<p className="text-xs leading-5 text-muted-foreground">
Free = the live catalog reports $0 input and $0 output token cost. Provider account/API key and rate limits may still apply.
</p>
)}
{filtered.length === 0 ? (
<p className="py-8 text-center text-sm text-muted-foreground">No models match these filters.</p>
) : (
<div className="space-y-1 pr-3">
{filtered.map((m) => (
<button
key={m.ref}
type="button"
onClick={() => {
onPick(m.id);
setOpen(false);
}}
className={`flex w-full flex-col items-start gap-1 rounded-lg border p-2.5 text-left hover:bg-[var(--hover-strong)] ${m.id === value ? "border-primary" : "border-border"}`}
>
<div className="flex w-full flex-wrap items-center gap-2">
<span className="font-medium">{m.name || m.id}</span>
{m.free && <Badge emphasis>FREE</Badge>}
{m.tools && <Badge>tools</Badge>}
{m.reasoning && <Badge>reasoning</Badge>}
{m.vision && <Badge>vision</Badge>}
</div>
<div className="flex flex-wrap gap-x-3 text-xs text-muted-foreground">
<span className="font-mono">{m.id}</span>
<span>ctx {fmtCtx(m.context)}</span>
<span>in {fmtCost(m.inputCost)}/M</span>
<span>out {fmtCost(m.outputCost)}/M</span>
</div>
</button>
))}
</div>
)}
</FormDrawer.Body>
</FormDrawer>
</>
);
}
function Badge({ children, emphasis = false }: { children: React.ReactNode; emphasis?: boolean }) {
return <span className={emphasis ? "rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary" : "rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground"}>{children}</span>;
}
function Filter({ checked, label, onChange }: { checked: boolean; label: string; onChange: () => void }) {
return (
<label className="flex h-8 items-center gap-1.5 rounded-md border border-border px-2">
<input type="checkbox" checked={checked} onChange={onChange} />
{label}
</label>
);
}