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
feat: complete terminal and mobile app surfaces
Rahman57b246798530
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 4d81a441..945e0994 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -6,6 +6,10 @@ this is the *what*, and it is what Settings → About shows as “What's new”.## 2026-08-23+**Added**++- complete terminal and mobile app surfaces+**Fixed**- `android` clear notch in app drawerdiff --git a/frontend/slices/appshell/features/widgets/components/mobile-widget-layout.test.ts b/frontend/slices/appshell/features/widgets/components/mobile-widget-layout.test.tsindex 3c8381c7..f7d653d8 100644--- a/frontend/slices/appshell/features/widgets/components/mobile-widget-layout.test.ts+++ b/frontend/slices/appshell/features/widgets/components/mobile-widget-layout.test.ts@@ -14,6 +14,7 @@ describe("mobile widget layout policy", () => {const mobile = readFileSync(new URL("./mobile-widgets.tsx", import.meta.url), "utf8");expect(defs).toContain('data-slot="quicklinks-widget-grid"');expect(defs).toContain("overflow-x-clip");+ expect(defs).toContain('surface="clear"');expect(mobile).toContain("overflow-x-clip");expect(mobile).toContain('data-slot="quick-open-grid"');expect(mobile).toContain("grid-cols-4");diff --git a/frontend/slices/appshell/features/widgets/components/widget-cards.tsx b/frontend/slices/appshell/features/widgets/components/widget-cards.tsxindex 1cfb1f5b..2df46854 100644--- a/frontend/slices/appshell/features/widgets/components/widget-cards.tsx+++ b/frontend/slices/appshell/features/widgets/components/widget-cards.tsx@@ -12,7 +12,15 @@ export function gb(bytes: number): string {// className lets an interactive widget opt back into pointer events — the desktop// stack wrapper is pointer-events-none, so Notes/Quicklinks pass "pointer-events-auto".-export function Card({ children, className }: { children: React.ReactNode; className?: string }) {+export function Card({+ children,+ className,+ surface = "card",+}: {+ children: React.ReactNode;+ className?: string;+ surface?: "card" | "clear";+}) {return (<div// Radius comes from --widget-radius with the mobile default (1rem) as the@@ -26,7 +34,11 @@ export function Card({ children, className }: { children: React.ReactNode; classclassName,)}data-slot="widget-card"- style={{ background: "var(--widget-bg, var(--glass-menu))" }}+ style={{+ background: surface === "clear" ? "transparent" : "var(--widget-bg, var(--glass-menu))",+ borderColor: surface === "clear" ? "transparent" : undefined,+ backdropFilter: surface === "clear" ? "none" : undefined,+ }}>{children}</div>diff --git a/frontend/slices/appshell/features/widgets/components/widgets-defs.tsx b/frontend/slices/appshell/features/widgets/components/widgets-defs.tsxindex 02d51754..dc65d5f9 100644--- a/frontend/slices/appshell/features/widgets/components/widgets-defs.tsx+++ b/frontend/slices/appshell/features/widgets/components/widgets-defs.tsx@@ -77,7 +77,7 @@ function NotesWidget() {typeof localStorage !== "undefined" ? localStorage.getItem(NOTES_KEY) ?? "" : "",);return (- <Card className="pointer-events-auto">+ <Card surface="clear" className="pointer-events-auto px-1 py-2"><div className="mb-2 flex items-center gap-2"><StickyNote className="size-4 text-muted-foreground" /><span className="text-[12.5px] font-semibold">Notes</span>diff --git a/frontend/slices/camoufox-browser/app.tsx b/frontend/slices/camoufox-browser/app.tsxindex 9e7c14ec..f681d355 100644--- a/frontend/slices/camoufox-browser/app.tsx+++ b/frontend/slices/camoufox-browser/app.tsx@@ -156,7 +156,7 @@ export default function CamoufoxBrowser() {}return (- <div className="flex h-full w-full flex-col bg-black">+ <div className="flex h-full min-h-0 w-full flex-col overflow-hidden bg-black"><header className="flex shrink-0 items-center gap-2 border-b border-border bg-background px-2 py-1"><span className="size-1.5 shrink-0 rounded-full bg-emerald-500" aria-hidden /><span className="truncate text-[11px] text-muted-foreground">Running on the server</span>@@ -164,7 +164,7 @@ export default function CamoufoxBrowser() {type="button"disabled={busy}onClick={() => void power(false)}- className="ml-auto inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] hover:bg-muted disabled:opacity-50"+ className="ml-auto inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] hover:bg-muted disabled:opacity-50 [@media(pointer:coarse)]:min-h-[44px]">{busy ? <Loader2 className="size-3.5 animate-spin" /> : <Power className="size-3.5" />}{busy ? "Working…" : "Turn off"}@@ -172,9 +172,15 @@ export default function CamoufoxBrowser() {</header>{error && <p className="shrink-0 bg-destructive/10 px-3 py-1.5 text-[11px] text-destructive">{error}</p>}{src ? (- <iframe src={src} title="Camoufox browser" className="h-full w-full border-0 bg-black" allow="clipboard-read; clipboard-write" />+ <iframe+ src={src}+ title="Camoufox browser"+ className="min-h-0 w-full flex-1 border-0 bg-black"+ allow="clipboard-read; clipboard-write"+ allowFullScreen+ />) : (- <div className="flex h-full w-full items-center justify-center gap-2 bg-black text-xs text-white/60">+ <div className="flex min-h-0 w-full flex-1 items-center justify-center gap-2 bg-black text-xs text-white/60"><Loader2 className="size-4 animate-spin" /> Connecting to the browser session…</div>)}diff --git a/frontend/slices/camoufox-browser/mobile-layout.test.ts b/frontend/slices/camoufox-browser/mobile-layout.test.tsnew file mode 100644index 00000000..b045474a--- /dev/null+++ b/frontend/slices/camoufox-browser/mobile-layout.test.ts@@ -0,0 +1,11 @@+import { readFileSync } from "node:fs";+import { describe, expect, it } from "vitest";++describe("Camoufox mobile layout", () => {+ it("lets the viewer consume remaining flex height instead of overflowing under chrome", () => {+ const src = readFileSync(new URL("./app.tsx", import.meta.url), "utf8");+ expect(src).toContain("min-h-0 w-full flex-1 border-0 bg-black");+ expect(src).toContain("overflow-hidden bg-black");+ expect(src).toContain("allowFullScreen");+ });+});diff --git a/frontend/slices/camoufox-browser/power-panel.tsx b/frontend/slices/camoufox-browser/power-panel.tsxindex 99446fcc..cf2a7985 100644--- a/frontend/slices/camoufox-browser/power-panel.tsx+++ b/frontend/slices/camoufox-browser/power-panel.tsx@@ -40,7 +40,7 @@ export function PowerPanel({the whole web — including the sites that refuse to be put in an iframe. It is switched offright now and using none of the server's memory or CPU.</p>- <Button className="mt-1" disabled={busy} onClick={onStart}>+ <Button className="mt-1 [@media(pointer:coarse)]:min-h-[44px]" disabled={busy} onClick={onStart}>{busy ? <Loader2 className="size-4 animate-spin" /> : <Power className="size-4" />}{busy ? "Starting the browser…" : "Turn the browser on"}</Button>@@ -55,7 +55,7 @@ export function PowerPanel({function Shell({ icon, title, children }: { icon: React.ReactNode; title: string; children: React.ReactNode }) {return (- <div className="flex h-full min-h-0 flex-col items-center justify-center gap-3 overflow-auto bg-background px-6 py-8 text-center">+ <div className="flex h-full min-h-0 flex-col items-center justify-center gap-3 overflow-auto bg-background px-4 py-6 text-center sm:px-6 sm:py-8">{icon}<p className="max-w-md text-sm font-medium">{title}</p><div className="flex max-w-md flex-col items-center gap-3 text-[11px] leading-relaxed text-muted-foreground">diff --git a/frontend/slices/code-editor/app.tsx b/frontend/slices/code-editor/app.tsxindex f859c5e1..65f61302 100644--- a/frontend/slices/code-editor/app.tsx+++ b/frontend/slices/code-editor/app.tsx@@ -15,10 +15,12 @@ import { TabStrip } from "./components/tab-strip";import { StatusBar } from "./components/status-bar";import { NewFileModal } from "./components/new-file-modal";import { CloseGuardDialog } from "./components/close-guard-dialog";+import { IntegratedTerminal } from "./components/integrated-terminal";import { useEditor } from "./lib/use-editor";import { useCloseGuard } from "./lib/use-close-guard";import { isPreviewable } from "./lib/build-preview";import { baseName, langOf } from "./lib/util";+import { parentPath } from "@/lib/path";const TAB_SIZE = 2;@@ -38,6 +40,7 @@ export default function CodeEditor({ payload, winId }: AppProps) {const [newOpen, setNewOpen] = useState(false);const [pos, setPos] = useState({ ln: 1, col: 1 });const [preview, setPreview] = useState(false);+ const [terminalOpen, setTerminalOpen] = useState(false);// Save-on-shortcut + dirty-window close guard. `saveRef` always points at the// current save (no stale closures in the global listener / Inspector action).@@ -82,7 +85,7 @@ export default function CodeEditor({ payload, winId }: AppProps) {);return (- <div className="relative flex h-full bg-[#1e1e22]">+ <div className="relative flex h-full min-h-0 w-full overflow-hidden bg-[#1e1e22]">{/* Explorer: inline rail on wide windows, left Sheet on narrow/mobile. */}<AppSidebaropen={explorerOpen}@@ -115,8 +118,10 @@ export default function CodeEditor({ payload, winId }: AppProps) {canSave={ed.active != null}canPreview={canPreview}previewing={showPreview}+ terminalOpen={terminalOpen}onOpenExplorer={() => setExplorerOpen(true)}onTogglePreview={() => setPreview((p) => !p)}+ onToggleTerminal={() => setTerminalOpen((open) => !open)}onSave={save}/>@@ -163,6 +168,8 @@ export default function CodeEditor({ payload, winId }: AppProps) {)}</div>+ {terminalOpen && <IntegratedTerminal cwd={path ? parentPath(path) : "~"} />}+<StatusBarpath={ed.active}ln={pos.ln}diff --git a/frontend/slices/code-editor/components/editor-toolbar.tsx b/frontend/slices/code-editor/components/editor-toolbar.tsxindex c9a26f35..a0a3ffa3 100644--- a/frontend/slices/code-editor/components/editor-toolbar.tsx+++ b/frontend/slices/code-editor/components/editor-toolbar.tsx@@ -1,7 +1,7 @@"use client";// audit-allow-hex: VS-Code-dark editor chrome palette is the slice's design, not themable tokens.-import { Eye, PanelLeft, Save } from "lucide-react";+import { Eye, PanelLeft, Save, SquareTerminal } from "lucide-react";import { Button } from "@/components/ui/button";import { Badge } from "@/components/ui/badge";import { cn } from "@/lib/utils";@@ -13,8 +13,10 @@ export function EditorToolbar({canSave,canPreview,previewing,+ terminalOpen,onOpenExplorer,onTogglePreview,+ onToggleTerminal,onSave,}: {lang: Lang;@@ -22,12 +24,14 @@ export function EditorToolbar({canSave: boolean;canPreview: boolean;previewing: boolean;+ terminalOpen: boolean;onOpenExplorer: () => void;onTogglePreview: () => void;+ onToggleTerminal: () => void;onSave: () => void;}) {return (- <header className="flex items-center gap-2 border-b border-[#2a2a30] bg-[#16161a] px-2 py-1.5">+ <header className="flex min-w-0 items-center gap-2 border-b border-[#2a2a30] bg-[#16161a] px-2 py-1.5">{/* Explorer opens as a left Sheet when the rail is hidden (narrow). */}<Buttontype="button"@@ -44,7 +48,7 @@ export function EditorToolbar({<PanelLeft className="size-4" /></Button><div className="ml-auto flex items-center gap-2">- <Badge variant="secondary" className="font-mono text-[10px] uppercase">+ <Badge variant="secondary" className="font-mono text-[10px] uppercase @max-[420px]:hidden">{lang}</Badge>{canPreview && (@@ -58,12 +62,24 @@ export function EditorToolbar({className="[@media(pointer:coarse)]:h-[44px]"><Eye />- Preview+ <span className="@max-[480px]:hidden">Preview</span></Button>)}+ <Button+ type="button"+ variant={terminalOpen ? "default" : "secondary"}+ size="sm"+ onClick={onToggleTerminal}+ title="Toggle integrated terminal"+ aria-pressed={terminalOpen}+ className="[@media(pointer:coarse)]:h-[44px]"+ >+ <SquareTerminal />+ <span className="@max-[480px]:hidden">Terminal</span>+ </Button><Button size="sm" onClick={onSave} disabled={!canSave || !dirty} className="[@media(pointer:coarse)]:h-[44px]"><Save />- Save+ <span className="@max-[480px]:hidden">Save</span></Button></div></header>diff --git a/frontend/slices/code-editor/components/integrated-terminal.tsx b/frontend/slices/code-editor/components/integrated-terminal.tsxnew file mode 100644index 00000000..014061af--- /dev/null+++ b/frontend/slices/code-editor/components/integrated-terminal.tsx@@ -0,0 +1,20 @@+"use client";++import { Suspense } from "react";+import { Terminal } from "@/features/os-terminal";++export function IntegratedTerminal({ cwd }: { cwd: string }) {+ return (+ <div className="h-[42%] min-h-[150px] shrink-0 border-t border-[#2a2a30] @[700px]:h-[34%] @[700px]:min-h-[170px]">+ <Suspense+ fallback={+ <div className="grid h-full place-items-center bg-[#0d0e12] font-mono text-xs text-[#9298a4]">+ Loading terminal…+ </div>+ }+ >+ <Terminal initialCwd={cwd} />+ </Suspense>+ </div>+ );+}diff --git a/frontend/slices/code-editor/integrated-terminal.test.ts b/frontend/slices/code-editor/integrated-terminal.test.tsnew file mode 100644index 00000000..5eebd93b--- /dev/null+++ b/frontend/slices/code-editor/integrated-terminal.test.ts@@ -0,0 +1,12 @@+import { readFileSync } from "node:fs";+import { describe, expect, it } from "vitest";++describe("Code integrated terminal", () => {+ it("exposes a terminal toggle and mounts the shared terminal panel", () => {+ const app = readFileSync(new URL("./app.tsx", import.meta.url), "utf8");+ const toolbar = readFileSync(new URL("./components/editor-toolbar.tsx", import.meta.url), "utf8");+ expect(app).toContain("<IntegratedTerminal");+ expect(app).toContain("terminalOpen");+ expect(toolbar).toContain("Toggle integrated terminal");+ });+});diff --git a/frontend/slices/os-settings/components/quicklinks-section.tsx b/frontend/slices/os-settings/components/quicklinks-section.tsxindex 28fc87f0..561c3dda 100644--- a/frontend/slices/os-settings/components/quicklinks-section.tsx+++ b/frontend/slices/os-settings/components/quicklinks-section.tsx@@ -43,7 +43,7 @@ export function QuicklinksSection() {{items.map((ql, i) => {const src = faviconUrl(ql.url);return (- <SettingsBlock key={ql.id} className="flex items-center gap-2">+ <SettingsBlock key={ql.id} className="flex flex-wrap items-center gap-2 @md:flex-nowrap"><span className="grid size-8 shrink-0 place-items-center overflow-hidden rounded-md bg-white text-zinc-500">{src ? (// eslint-disable-next-line @next/next/no-img-element@@ -56,14 +56,14 @@ export function QuicklinksSection() {value={ql.title}onChange={(e) => update(ql.id, { title: e.target.value })}aria-label="Label"- className="h-8 min-w-0 flex-1"+ className="h-8 min-w-[100px] flex-1"/><Inputvalue={ql.url}onChange={(e) => update(ql.id, { url: e.target.value })}onBlur={(e) => update(ql.id, { url: normalizeUrl(e.target.value) })}aria-label="URL"- className="h-8 min-w-0 flex-[2] font-mono text-[11px]"+ className="order-last h-8 min-w-0 basis-full font-mono text-[11px] @md:order-none @md:basis-0 @md:flex-[2]"/><Button type="button" variant="ghost" size="icon" aria-label="Move up" onClick={() => move(ql.id, -1)} disabled={i === 0} className="[@media(pointer:coarse)]:size-[44px]"><ArrowUp className="size-4" />@@ -85,7 +85,7 @@ export function QuicklinksSection() {);})}{/* Add row — flush-free, iOS "+ new item at the list bottom" */}- <SettingsBlock className="flex flex-col gap-2 sm:flex-row">+ <SettingsBlock className="flex flex-col gap-2 @md:flex-row"><Inputplaceholder="github.com"value={url}@@ -99,7 +99,7 @@ export function QuicklinksSection() {onChange={(e) => setTitle(e.target.value)}onKeyDown={(e) => e.key === "Enter" && submit()}aria-label="Label"- className="sm:max-w-[38%]"+ className="@md:max-w-[38%]"/><Button type="button" onClick={submit} className="shrink-0"><Plus className="size-4" /> Adddiff --git a/frontend/slices/os-terminal/app.tsx b/frontend/slices/os-terminal/app.tsxindex d0976d96..814c5c47 100644--- a/frontend/slices/os-terminal/app.tsx+++ b/frontend/slices/os-terminal/app.tsx@@ -1,58 +1,20 @@"use client";-// audit-allow-hex: terminal glass chrome palette is the slice's design, not themable tokens.-import { useState } from "react";-import { useOsApi } from "./lib/host";-import ExecTerminal from "./components/exec-terminal";-import PtyTerminal from "./components/pty-terminal";+import { TerminalSession, type TerminalSessionProps } from "./components/terminal-session";+import { TerminalTabs } from "./components/terminal-tabs";-// Terminal entry: LIVE mode gets the real interactive PTY (xterm.js over-// /api/v1/term/* — vim/top/ssh/tab-completion all work); mock/demo keeps the-// simulated shell untouched. If the PTY can't open (route error, session cap,-// old server build), we show why and fall back to the legacy one-shot exec-// terminal so live never regresses below the old behaviour.-// `initialCommand` (optional) is written to the live PTY once it connects — used-// by the Claude Code app to auto-run `claude` on open. Normal Terminal passes none.-export function Terminal({ initialCommand }: { initialCommand?: string } = {}) {- const api = useOsApi();- const [ptyError, setPtyError] = useState<string | null>(null);- // A mode flip (Settings → Server) re-arms the PTY attempt (render-time- // state adjustment — the React-endorsed "derive from prop change" pattern).- const [prevMode, setPrevMode] = useState(api.mode);- if (prevMode !== api.mode) {- setPrevMode(api.mode);- setPtyError(null);- }+export type TerminalProps = TerminalSessionProps & {+ /** Set false for single-purpose shells such as Claude Code. */+ tabbed?: boolean;+};- if (api.mode === "live" && ptyError === null)- return <PtyTerminal onFallback={setPtyError} initialCommand={initialCommand} />;-- return (- <div className="flex h-full w-full flex-col">- {api.mode === "live" && ptyError !== null && (- <div- className="flex select-none items-center gap-2 px-2 py-1 text-[11px] font-semibold"- style={{ color: "#fff", background: "#a14545" }}- >- <span className="min-w-0 flex-1 truncate">- PTY unavailable: {ptyError} — basic exec mode- </span>- <button- onClick={() => setPtyError(null)}- className="rounded bg-white/15 px-2 py-0.5 hover:bg-white/25 [@media(pointer:coarse)]:min-h-[44px]"- >- Retry PTY- </button>- </div>- )}- <div className="min-h-0 flex-1">- <ExecTerminal />- </div>- </div>- );+// Public terminal surface. Normal Terminal and embedded Code terminals get a+// persistent tab workspace; focused tool shells can opt out with tabbed=false.+export function Terminal({ initialCommand, initialCwd, tabbed = true }: TerminalProps = {}) {+ if (!tabbed) return <TerminalSession initialCommand={initialCommand} initialCwd={initialCwd} />;+ return <TerminalTabs initialCommand={initialCommand} initialCwd={initialCwd} />;}-// Default export = the plain Terminal (the app-manifest loader expects a default).export default function TerminalApp() {return <Terminal />;}diff --git a/frontend/slices/os-terminal/claude-code.tsx b/frontend/slices/os-terminal/claude-code.tsxindex 56872e95..b407738c 100644--- a/frontend/slices/os-terminal/claude-code.tsx+++ b/frontend/slices/os-terminal/claude-code.tsx@@ -30,5 +30,5 @@ export default function ClaudeCodeApp({ payload }: AppProps) {? (payload as { cwd?: unknown }).cwd: undefined;const initialCommand = typeof cwd === "string" && cwd ? cdPrefix(cwd) + BASE : BASE;- return <Terminal initialCommand={initialCommand} />;+ return <Terminal initialCommand={initialCommand} tabbed={false} />;}diff --git a/frontend/slices/os-terminal/components/exec-terminal.tsx b/frontend/slices/os-terminal/components/exec-terminal.tsxindex 8c7d7e93..ff3dff0e 100644--- a/frontend/slices/os-terminal/components/exec-terminal.tsx+++ b/frontend/slices/os-terminal/components/exec-terminal.tsx@@ -9,7 +9,7 @@ import { run, seedFs, NEOFETCH, type Line } from "../lib/commands";// + in-memory FS; `ls`/`cat` read live OsApi data and fall back to the model.// Glass aesthetic: monospace, colored `root@mso:/path$` prompt, red errors,// arrow-key history. Command logic lives in ./lib/commands to keep this < 200 LOC.-export default function ExecTerminal() {+export default function ExecTerminal({ initialCwd }: { initialCwd?: string } = {}) {const api = useOsApi();const apiRef = useRef(api);const fs = useMemo(() => seedFs(), []);@@ -20,7 +20,7 @@ export default function ExecTerminal() {// Live starts at home (~); mock keeps its "/" sandbox root. A live shell at// "/" lists outside the host read roots and every `ls` fails — that read as// "terminal not working" when the mode was actually fine.- const [cwd, setCwd] = useState(api.mode === "live" ? "~" : "/");+ const [cwd, setCwd] = useState(api.mode === "live" ? (initialCwd ?? "~") : "/");const cwdRef = useRef(cwd);const modeRef = useRef(api.mode);// Latest-ref mirrors for event handlers (post-render, per react-hooks/refs).@@ -33,7 +33,7 @@ export default function ExecTerminal() {useEffect(() => {if (modeRef.current === api.mode) return;modeRef.current = api.mode;- setCwd(api.mode === "live" ? "~" : "/");+ setCwd(api.mode === "live" ? (initialCwd ?? "~") : "/");setLines((l) => [...l,{@@ -41,7 +41,7 @@ export default function ExecTerminal() {v: api.mode === "live" ? "● switched to LIVE — real shell on this host" : "○ switched to MOCK — demo data",},]);- }, [api.mode]);+ }, [api.mode, initialCwd]);const [input, setInput] = useState("");const [hist, setHist] = useState<string[]>([]);const [hp, setHp] = useState(-1);diff --git a/frontend/slices/os-terminal/components/pty-terminal.tsx b/frontend/slices/os-terminal/components/pty-terminal.tsxindex 293e0f48..e30b4fa5 100644--- a/frontend/slices/os-terminal/components/pty-terminal.tsx+++ b/frontend/slices/os-terminal/components/pty-terminal.tsx@@ -11,7 +11,15 @@ import KeyBar, { type KeyInterceptor } from "./key-bar";// xterm is dynamic-imported inside the effect — it touches the DOM at// construction and must never run during SSR. `gen` bumps re-run the whole// effect for a fresh session (Restart).-export default function PtyTerminal({ onFallback, initialCommand }: { onFallback: (msg: string) => void; initialCommand?: string }) {+export default function PtyTerminal({+ onFallback,+ initialCommand,+ initialCwd,+}: {+ onFallback: (msg: string) => void;+ initialCommand?: string;+ initialCwd?: string;+}) {const hostRef = useRef<HTMLDivElement>(null);const [status, setStatus] = useState<PtyStatus>({ kind: "connecting" });const [gen, setGen] = useState(0);@@ -65,6 +73,7 @@ export default function PtyTerminal({ onFallback, initialCommand }: { onFallbackhandle = await startPty({cols: term.cols,rows: term.rows,+ cwd: initialCwd,onData: (bytes) => term?.write(bytes),onStatus: (s) => {if (!disposed) setStatus(s);@@ -106,7 +115,7 @@ export default function PtyTerminal({ onFallback, initialCommand }: { onFallbackhandle?.dispose(); // kills the server-side shell tooterm?.dispose();};- }, [gen, initialCommand]);+ }, [gen, initialCommand, initialCwd]);// `@container` so the key bar's @max-md variant tracks the WINDOW width// (compact pane), not the viewport. Root padding already absorbsdiff --git a/frontend/slices/os-terminal/components/terminal-session.tsx b/frontend/slices/os-terminal/components/terminal-session.tsxnew file mode 100644index 00000000..490006d5--- /dev/null+++ b/frontend/slices/os-terminal/components/terminal-session.tsx@@ -0,0 +1,59 @@+"use client";++import { useState } from "react";+import { useOsApi } from "../lib/host";+import ExecTerminal from "./exec-terminal";+import PtyTerminal from "./pty-terminal";++export type TerminalSessionProps = {+ initialCommand?: string;+ initialCwd?: string;+};++// One terminal process/view. The tab workspace keeps these mounted so switching+// tabs never destroys an interactive PTY. Demo mode and PTY failures retain the+// existing one-shot terminal fallback.+export function TerminalSession({ initialCommand, initialCwd }: TerminalSessionProps) {+ const api = useOsApi();+ const [ptyError, setPtyError] = useState<string | null>(null);+ const [prevMode, setPrevMode] = useState(api.mode);++ if (prevMode !== api.mode) {+ setPrevMode(api.mode);+ setPtyError(null);+ }++ if (api.mode === "live" && ptyError === null) {+ return (+ <PtyTerminal+ onFallback={setPtyError}+ initialCommand={initialCommand}+ initialCwd={initialCwd}+ />+ );+ }++ return (+ <div className="flex h-full min-h-0 w-full flex-col">+ {api.mode === "live" && ptyError !== null && (+ <div+ className="flex shrink-0 select-none items-center gap-2 px-2 py-1 text-[11px] font-semibold"+ style={{ color: "#fff", background: "#a14545" }}+ >+ <span className="min-w-0 flex-1 truncate">+ PTY unavailable: {ptyError} — basic exec mode+ </span>+ <button+ onClick={() => setPtyError(null)}+ className="shrink-0 rounded bg-white/15 px-2 py-0.5 hover:bg-white/25 [@media(pointer:coarse)]:min-h-[44px]"+ >+ Retry PTY+ </button>+ </div>+ )}+ <div className="min-h-0 flex-1">+ <ExecTerminal initialCwd={initialCwd} />+ </div>+ </div>+ );+}diff --git a/frontend/slices/os-terminal/components/terminal-tabs.tsx b/frontend/slices/os-terminal/components/terminal-tabs.tsxnew file mode 100644index 00000000..c58fdf9b--- /dev/null+++ b/frontend/slices/os-terminal/components/terminal-tabs.tsx@@ -0,0 +1,105 @@+"use client";++import { useRef, useState } from "react";+import { Plus, SquareTerminal, X } from "lucide-react";+import { cn } from "@/lib/utils";+import { TerminalSession, type TerminalSessionProps } from "./terminal-session";++type Tab = TerminalSessionProps & { id: number; title: string };+const MAX_TABS = 8;++export function TerminalTabs({ initialCommand, initialCwd }: TerminalSessionProps) {+ const nextId = useRef(2);+ const [tabs, setTabs] = useState<Tab[]>(() => [+ { id: 1, title: "Terminal 1", initialCommand, initialCwd },+ ]);+ const [active, setActive] = useState(1);++ const addTab = () => {+ if (tabs.length >= MAX_TABS) return;+ const id = nextId.current++;+ setTabs((current) => [...current, { id, title: `Terminal ${id}`, initialCwd }]);+ setActive(id);+ };++ const closeTab = (id: number) => {+ const index = tabs.findIndex((tab) => tab.id === id);+ const next = tabs.filter((tab) => tab.id !== id);+ if (next.length === 0) {+ const freshId = nextId.current++;+ setTabs([{ id: freshId, title: `Terminal ${freshId}`, initialCwd }]);+ setActive(freshId);+ return;+ }+ setTabs(next);+ if (active === id) setActive(next[Math.min(Math.max(index, 0), next.length - 1)].id);+ };++ return (+ <div className="flex h-full min-h-0 w-full flex-col overflow-hidden bg-[#0d0e12]">+ <div+ role="tablist"+ aria-label="Terminal sessions"+ className="flex min-h-9 shrink-0 items-stretch overflow-x-auto border-b border-white/10 bg-[#15161b] [scrollbar-width:none] [@media(pointer:coarse)]:min-h-[44px]"+ >+ {tabs.map((tab) => {+ const selected = tab.id === active;+ return (+ <div+ key={tab.id}+ className={cn(+ "flex min-w-[112px] max-w-[180px] shrink-0 items-center border-r border-white/10",+ selected ? "bg-[#0d0e12] text-white" : "text-[#9298a4] hover:bg-white/5",+ )}+ >+ <button+ type="button"+ role="tab"+ aria-selected={selected}+ onClick={() => setActive(tab.id)}+ className="flex min-w-0 flex-1 items-center gap-1.5 px-2.5 text-left text-[11px] font-medium [@media(pointer:coarse)]:min-h-[44px]"+ >+ <SquareTerminal className="size-3.5 shrink-0" />+ <span className="truncate">{tab.title}</span>+ </button>+ <button+ type="button"+ aria-label={`Close ${tab.title}`}+ onClick={() => closeTab(tab.id)}+ className="grid size-7 shrink-0 place-items-center rounded hover:bg-white/10 [@media(pointer:coarse)]:size-[44px]"+ >+ <X className="size-3.5" />+ </button>+ </div>+ );+ })}+ <button+ type="button"+ aria-label="New terminal"+ title={tabs.length >= MAX_TABS ? `Maximum ${MAX_TABS} terminals` : "New terminal"}+ onClick={addTab}+ disabled={tabs.length >= MAX_TABS}+ className="grid w-9 shrink-0 place-items-center text-[#9298a4] hover:bg-white/5 hover:text-white disabled:opacity-35 [@media(pointer:coarse)]:w-[44px]"+ >+ <Plus className="size-4" />+ </button>+ </div>++ <div className="relative min-h-0 flex-1">+ {tabs.map((tab) => (+ <div+ key={tab.id}+ role="tabpanel"+ aria-hidden={tab.id !== active}+ className={cn(+ "absolute inset-0 min-h-0",+ tab.id === active ? "visible" : "invisible pointer-events-none",+ )}+ >+ <TerminalSession initialCommand={tab.initialCommand} initialCwd={tab.initialCwd} />+ </div>+ ))}+ </div>+ </div>+ );+}diff --git a/frontend/slices/os-terminal/lib/use-pty.ts b/frontend/slices/os-terminal/lib/use-pty.tsindex 0f59f09a..71158b31 100644--- a/frontend/slices/os-terminal/lib/use-pty.ts+++ b/frontend/slices/os-terminal/lib/use-pty.ts@@ -41,6 +41,7 @@ function b64Bytes(b64: string): Uint8Array {export async function startPty(opts: {cols: number;rows: number;+ cwd?: string;onData: (bytes: Uint8Array) => void;onStatus: (s: PtyStatus) => void;}): Promise<PtyHandle> {@@ -49,7 +50,7 @@ export async function startPty(opts: {let res: Response;try {- res = await post("open", { cols: opts.cols, rows: opts.rows });+ res = await post("open", { cols: opts.cols, rows: opts.rows, cwd: opts.cwd });} catch {throw new Error("network error opening the terminal");}@@ -88,6 +89,28 @@ export async function startPty(opts: {else onStatus({ kind: "connecting" });};+ // React cleanup reliably runs when an MSO window is closed, but it is NOT a+ // browser-lifecycle guarantee: closing/reloading the whole tab can terminate the+ // document before component unmount. Without this, those shells sit detached until+ // the 30-minute idle reaper and can consume all eight PTY slots. pagehide is the+ // browser-supported unload signal; keepalive lets the close request survive teardown.+ //+ // BFCache is not exempt: a cached whole document can otherwise pin a shell while it+ // is invisible. If that document is restored with Back, reload it so React mounts a+ // fresh terminal instead of reviving UI whose server-side shell was intentionally+ // closed during pagehide. Client-side MSO navigation does not trigger pagehide.+ const onPageHide = () => {+ if (disposed) return;+ disposed = true;+ es.close();+ void post("close", { id }, true);+ };+ const onPageShow = (event: PageTransitionEvent) => {+ if (event.persisted && disposed) window.location.reload();+ };+ window.addEventListener("pagehide", onPageHide);+ window.addEventListener("pageshow", onPageShow);+// Keystroke batching: coalesce whatever arrives while a POST is in flight,// and never overlap requests (overlap could reorder keystrokes).let queue = "";@@ -117,6 +140,8 @@ export async function startPty(opts: {dispose() {if (disposed) return;disposed = true;+ window.removeEventListener("pagehide", onPageHide);+ window.removeEventListener("pageshow", onPageShow);es.close();void post("close", { id }, true); // keepalive: survives unmount/nav},diff --git a/frontend/slices/os-terminal/terminal-workspace.test.ts b/frontend/slices/os-terminal/terminal-workspace.test.tsnew file mode 100644index 00000000..6b619468--- /dev/null+++ b/frontend/slices/os-terminal/terminal-workspace.test.ts@@ -0,0 +1,25 @@+import { readFileSync } from "node:fs";+import { describe, expect, it } from "vitest";++describe("terminal workspace policy", () => {+ it("keeps a tabbed workspace while allowing focused single-session tools", () => {+ const app = readFileSync(new URL("./app.tsx", import.meta.url), "utf8");+ const tabs = readFileSync(new URL("./components/terminal-tabs.tsx", import.meta.url), "utf8");+ expect(app).toContain("tabbed = true");+ expect(app).toContain("<TerminalTabs");+ expect(tabs).toContain('role="tablist"');+ expect(tabs).toContain("TerminalSession");+ expect(tabs).toContain("invisible pointer-events-none");+ });++ it("threads an initial cwd into the PTY open request and closes on document teardown", () => {+ const pty = readFileSync(new URL("./lib/use-pty.ts", import.meta.url), "utf8");+ expect(pty).toContain("cwd?: string");+ expect(pty).toContain("cwd: opts.cwd");+ expect(pty).toContain('window.addEventListener("pagehide", onPageHide)');+ expect(pty).toContain('window.addEventListener("pageshow", onPageShow)');+ expect(pty).toContain("event.persisted && disposed");+ expect(pty).toContain("window.location.reload()");+ expect(pty).toContain('post("close", { id }, true)');+ });+});diff --git a/frontend/slices/quicklinks/app.tsx b/frontend/slices/quicklinks/app.tsxindex 8a4ca802..fca07f79 100644--- a/frontend/slices/quicklinks/app.tsx+++ b/frontend/slices/quicklinks/app.tsx@@ -25,7 +25,7 @@ export default function QuicklinksApp() {return (<AppFrame>- <div className="grid grid-cols-3 gap-4 p-5 sm:grid-cols-4 md:grid-cols-5">+ <div className="grid grid-cols-3 gap-3 p-4 @sm:grid-cols-4 @md:grid-cols-5 @md:gap-4 @md:p-5">{items.map((ql) => {const src = faviconUrl(ql.url);return (diff --git a/frontend/slices/quicklinks/responsive-layout.test.ts b/frontend/slices/quicklinks/responsive-layout.test.tsnew file mode 100644index 00000000..0efdfae1--- /dev/null+++ b/frontend/slices/quicklinks/responsive-layout.test.ts@@ -0,0 +1,14 @@+import { readFileSync } from "node:fs";+import { describe, expect, it } from "vitest";++describe("Quicklinks responsive layout", () => {+ it("uses pane/container breakpoints rather than viewport breakpoints", () => {+ const app = readFileSync(new URL("./app.tsx", import.meta.url), "utf8");+ const settings = readFileSync(new URL("../os-settings/components/quicklinks-section.tsx", import.meta.url), "utf8");+ expect(app).toContain("@sm:grid-cols-4");+ expect(app).toContain("@md:grid-cols-5");+ expect(settings).toContain("flex-wrap");+ expect(settings).toContain("basis-full");+ expect(settings).toContain("@md:flex-row");+ });+});diff --git a/lib/camoufox/service-script.test.ts b/lib/camoufox/service-script.test.tsnew file mode 100644index 00000000..1f0ed721--- /dev/null+++ b/lib/camoufox/service-script.test.ts@@ -0,0 +1,13 @@+import { readFileSync } from "node:fs";+import { describe, expect, it } from "vitest";++describe("Camoufox noVNC webroot", () => {+ it("serves distro assets through a runtime overlay with the metadata noVNC fetches", () => {+ const script = readFileSync(new URL("../../scripts/camoufox-vnc-service", import.meta.url), "utf8");+ expect(script).toContain('NOVNC_SOURCE="${CAMOUFOX_NOVNC_SOURCE:-/usr/share/novnc}"');+ expect(script).toContain("mso-camoufox-novnc");+ expect(script).toContain('NOVNC_WEBROOT/package.json');+ expect(script).toContain('websockify --web="$NOVNC_WEBROOT"');+ expect(script).not.toContain("websockify --web=/usr/share/novnc");+ });+});diff --git a/lib/host/pty-limits.test.ts b/lib/host/pty-limits.test.tsindex a9c7d88f..2e92e990 100644--- a/lib/host/pty-limits.test.ts+++ b/lib/host/pty-limits.test.ts@@ -118,6 +118,44 @@ describe("PTY session cap", () => {expect(id9).toBeTruthy();});+ it("reclaims the oldest detached shell under capacity pressure after the reconnect grace", async () => {+ vi.useFakeTimers();+ vi.setSystemTime(new Date("2026-01-01T00:00:00Z"));+ try {+ const { openPty, attachPty } = await importPty();+ const ids: string[] = [];+ for (let i = 0; i < 8; i++) ids.push((await openPty({ cols: 80, rows: 24 })).id);++ // Seven active streams are protected. Leave only the eighth detached.+ for (const id of ids.slice(0, 7)) attachPty(id, 0, { onData: () => {}, onExit: () => {} });+ await vi.advanceTimersByTimeAsync(11_000);++ const { id: replacement } = await openPty({ cols: 80, rows: 24 });+ expect(replacement).toBeTruthy();+ expect(fakePtys[7]!.killed).toBe(true);+ expect(fakePtys.slice(0, 7).every((pty) => !pty.killed)).toBe(true);+ } finally {+ vi.useRealTimers();+ }+ });++ it("never reclaims an attached shell even when every slot is old", async () => {+ vi.useFakeTimers();+ vi.setSystemTime(new Date("2026-01-01T00:00:00Z"));+ try {+ const { openPty, attachPty } = await importPty();+ const ids: string[] = [];+ for (let i = 0; i < 8; i++) ids.push((await openPty({ cols: 80, rows: 24 })).id);+ for (const id of ids) attachPty(id, 0, { onData: () => {}, onExit: () => {} });+ await vi.advanceTimersByTimeAsync(60_000);++ await expect(openPty({ cols: 80, rows: 24 })).rejects.toThrow(/Too many terminal sessions/);+ expect(fakePtys.every((pty) => !pty.killed)).toBe(true);+ } finally {+ vi.useRealTimers();+ }+ });+it("closePty is idempotent + returns false on a dead session", async () => {const { openPty, closePty } = await importPty();const { id } = await openPty({ cols: 80, rows: 24 });diff --git a/lib/host/pty.ts b/lib/host/pty.tsindex 9db78df4..d5fa30d7 100644--- a/lib/host/pty.ts+++ b/lib/host/pty.ts@@ -19,6 +19,11 @@ import { childEnv } from "./child-env";const MAX_SESSIONS = 8; // concurrent live shellsconst BUFFER_CAP = 256 * 1024; // chars of replay buffer per sessionconst IDLE_REAP_MS = 30 * 60_000; // no attached client for 30 min → kill+// Hard browser/process exits cannot reliably send /term/close. If all eight slots are+// occupied, a shell that has had NO stream listener for this long is safe to reclaim+// under capacity pressure. The grace is deliberately longer than EventSource's normal+// reconnect window, and attached shells are never candidates.+const CAPACITY_RECLAIM_GRACE_MS = 10_000;const DEAD_LINGER_MS = 60_000; // exited sessions linger so streams deliver `exit`const REAP_TICK_MS = 60_000;@@ -75,6 +80,24 @@ function clampDim(n: number): number {return Math.max(2, Math.min(500, Math.round(n)));}+function reclaimDetachedSlot(now = Date.now()): boolean {+ let candidate: Session | null = null;+ for (const session of sessions.values()) {+ if (session.dead || session.listeners.size > 0) continue;+ if (now - session.idleSince < CAPACITY_RECLAIM_GRACE_MS) continue;+ if (!candidate || session.idleSince < candidate.idleSince) candidate = session;+ }+ if (!candidate) return false;++ // Delete first so the slot is immediately available even though node-pty emits its+ // exit callback asynchronously. A late reconnect to the reclaimed id correctly gets+ // “Unknown terminal session” and the client can Restart instead of reviving a shell+ // we deliberately evicted under capacity pressure.+ sessions.delete(candidate.id);+ candidate.pty.kill();+ return true;+}+export async function openPty(opts: {cols: number;rows: number;@@ -82,7 +105,7 @@ export async function openPty(opts: {}): Promise<{ id: string; cwd: string }> {let live = 0;for (const s of sessions.values()) if (!s.dead) live++;- if (live >= MAX_SESSIONS)+ if (live >= MAX_SESSIONS && !reclaimDetachedSlot())throw new HostError(`Too many terminal sessions (max ${MAX_SESSIONS}) — close one first`);const cwd = await resolveCwd(opts.cwd); // write-root bounded, falls back homediff --git a/scripts/camoufox-vnc-service b/scripts/camoufox-vnc-serviceindex bf23363b..c4167509 100755--- a/scripts/camoufox-vnc-service+++ b/scripts/camoufox-vnc-service@@ -99,4 +99,27 @@ fi# dropping both v6 listeners costs nothing.x11vnc -display "$DISPLAY" -localhost -noipv6 -rfbportv6 -1 -forever -shared -rfbauth "$VNC_PASSWD" -rfbport "$VNC_PORT" -quiet &-exec websockify --web=/usr/share/novnc "127.0.0.1:${NOVNC_PORT}" "127.0.0.1:${VNC_PORT}"+# Debian's noVNC package intentionally installs the web app without its upstream+# package.json, but app/ui.js fetches ./package.json on every full-client launch to+# show the version. Serving /usr/share/novnc directly therefore produces a noisy 404+# in every MSO Browser session even though VNC itself works. Build a tiny RUNTIME+# overlay instead of modifying /usr/share (root-owned): symlink every distro asset+# and add only the missing metadata file. The overlay lives under XDG_RUNTIME_DIR,+# is recreated on every start, and contains no browser profile/session data.+NOVNC_SOURCE="${CAMOUFOX_NOVNC_SOURCE:-/usr/share/novnc}"+NOVNC_WEBROOT="${CAMOUFOX_NOVNC_WEBROOT:-${XDG_RUNTIME_DIR:-/tmp}/mso-camoufox-novnc}"+if [ ! -f "$NOVNC_SOURCE/vnc.html" ]; then+ echo "camoufox-vnc: noVNC web assets missing at $NOVNC_SOURCE" >&2+ exit 1+fi+rm -rf "$NOVNC_WEBROOT"+mkdir -p "$NOVNC_WEBROOT"+chmod 700 "$NOVNC_WEBROOT"+for asset in "$NOVNC_SOURCE"/*; do+ ln -s "$asset" "$NOVNC_WEBROOT/$(basename "$asset")"+done+NOVNC_VERSION="$(dpkg-query -W -f='${Version}' novnc 2>/dev/null || printf 'system')"+printf '{"version":"%s"}\n' "$NOVNC_VERSION" >"$NOVNC_WEBROOT/package.json"+chmod 600 "$NOVNC_WEBROOT/package.json"++exec websockify --web="$NOVNC_WEBROOT" "127.0.0.1:${NOVNC_PORT}" "127.0.0.1:${VNC_PORT}"