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
test(e2e): a committed browser check for Preview and the update panel
Rahmanc465a033102b
diff --git a/CLAUDE.md b/CLAUDE.mdindex fcea8122..5b9d696f 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -237,6 +237,12 @@ to `resources/` (rr) and drive any project from one manifest:(3 generations, 0700). Restore after an accidental wipe: stop the unit,`cp -p ~/.local/state/camoufox/session-backup/1/* <profile>/`, start. Roll back to `2`or `3` if generation `1` already captured the logged-out state.+- **Two committed browser checks**: `bun run e2e` (shell) and `bun run e2e:preview+ [width]` (Preview app + Settings → About update panel). Both install the session+ cookie rather than drive the login form, and both take a viewport — run them at+ 1280 AND 390. `e2e:preview` provisions its own fixtures under+ `~/.cache/mso-e2e-preview` and asserts bytes ARRIVED (`naturalWidth`, `readyState`,+ text inside the sandboxed frame), not that elements exist.- Verify shell behaviour with **Playwright directly** — `os-browser/node_modules/playwright`(CommonJS) is the repo's only install — at 1280 for desktop and 390 for mobile. The`os-browser` SERVICE is gone (its source was deleted 2026-08-10; only the vendoreddiff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 56bd1298..e18fb429 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -23,6 +23,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Tests**+- `e2e` a committed browser check for Preview and the update panel- `preview` one anchor the e2e can read on both surfaces**Docs**diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 96553c18..6ef52277 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -70,6 +70,30 @@ viewer and Files, so the two can no longer disagree about what a `.heic` is:- Files gained **Preview** in the context menu and **Space** as its shortcut (themacOS Quick Look binding), because a `.md` or `.csv` double-click correctly goes tothe editor, and reading it is a different verb from editing it.+- **Long-press opens that menu on a phone.** Touch has no contextmenu event worth+ relying on (Chrome Android fires one, iOS Safari mostly does not), so on mobile the+ ENTIRE context menu — Preview, Rename, Download, Move to Trash — had never been+ reachable. 500 ms, 10 px drift cancels, and the click the finger-lift produces is+ swallowed so it neither opens the file underneath nor dismisses the menu it just+ opened. Its rows are 44 px on coarse pointers now, for the same reason.++**Found while verifying, and fixed:** the panel first reported the CHECKOUT's HEAD as+"running", which is only true until someone pulls without rebuilding. `next.config`+now bakes the commit into the bundle (`NEXT_PUBLIC_COMMIT_SHA`, which About already+had a row for and always showed as "not set"), the status carries `buildSha` ++`pendingBuild`, and "already up to date" is no longer returned when the running build+is older than the checkout — it offers the rebuild instead.++**Verified live, not asserted.** `scripts/e2e/preview.mjs` (`bun run e2e:preview+[width]`) drives the real :4005 at 1280 and 390: every format above, paging by button+and by arrow key, and the update panel. It checks that the bytes ARRIVED —+`naturalWidth > 0`, `readyState >= 1`, the text inside the sandboxed frame — because+an element that exists proves nothing. It also asserts the fixture's `<script>` does+NOT run inside that frame. It provisions its own fixtures under+`~/.cache/mso-e2e-preview` and skips what it cannot make (no ffmpeg → no video). The+full self-update path was exercised end to end the same way: the checkout was moved a+commit back, the button pulled, verified out-of-tree, built, restarted, and the CSS+chunk check passed — 6 minutes, `UPDATE OK`.## 2026-08-11 — shells to their 2026 specs, and a backup for the state that had none (DONE)diff --git a/package.json b/package.jsonindex 5ac49d40..fa0995c5 100644--- a/package.json+++ b/package.json@@ -17,6 +17,7 @@"audit": "node scripts/audit.mjs","verify": "bun run typecheck && bun run lint && bun run coverage && bun run check && bun run audit","e2e": "node scripts/e2e/shell.mjs",+ "e2e:preview": "node scripts/e2e/preview.mjs","changelog": "node scripts/gen-changelog.mjs","ship": "bash scripts/ship.sh","smoke": "E2E_BASE_URL=http://localhost:4005 vitest run scripts/e2e/smoke.test.ts"diff --git a/scripts/e2e/preview.mjs b/scripts/e2e/preview.mjsnew file mode 100644index 00000000..87bd0ffd--- /dev/null+++ b/scripts/e2e/preview.mjs@@ -0,0 +1,227 @@+#!/usr/bin/env node+// Browser e2e for the Preview app and the Settings update panel.+//+// node scripts/e2e/preview.mjs # desktop, 1280+// node scripts/e2e/preview.mjs 390 # the mobile shell+// E2E_BASE_URL=… E2E_PASSWORD=… node scripts/e2e/preview.mjs+//+// Preview is the app most likely to LOOK fine and be wrong: an <img> that never+// decoded, a PDF frame that 404s, an HTML file rendered with its scripts live. Every+// check here asserts the bytes actually arrived (naturalWidth, readyState, frame+// text), not that an element exists.+//+// It provisions its own fixtures under ~/.cache/mso-e2e-preview and skips the ones+// it cannot make (no ffmpeg → no video/audio; no system PDF → no PDF), so a fresh+// machine runs a smaller suite rather than a red one.+//+// Same session trick as shell.mjs: install the cookie rather than drive the form,+// because Chromium refuses to STORE a Secure cookie arriving over plain http, and+// the shell renders for signed-out visitors too (backed by mocks) — a run that+// quietly tested fakes would report green forever.+import { createRequire } from "node:module";+import { execFileSync } from "node:child_process";+import { existsSync, mkdirSync, writeFileSync, copyFileSync } from "node:fs";+import { readFileSync } from "node:fs";+import os from "node:os";+import path from "node:path";++const require = createRequire(import.meta.url);+const { chromium } = require(path.join(process.cwd(), "os-browser/node_modules/playwright"));++const BASE = process.env.E2E_BASE_URL ?? "http://127.0.0.1:4005";+const WIDTH = Number(process.argv[2] ?? 1280);+const MOBILE = WIDTH < 768;+const DIR = process.env.E2E_PREVIEW_DIR ?? path.join(os.homedir(), ".cache", "mso-e2e-preview");++const env = (key) =>+ new RegExp(`^${key}=(.*)$`, "m").exec(readFileSync(path.join(process.cwd(), ".env.local"), "utf8"))?.[1]?.trim().replace(/^["']|["']$/g, "");+const approvedDevice = () => {+ const file = process.env.OS_DEVICE_STORE ?? path.join(os.homedir(), ".mso", "auth-devices.json");+ const ids = Object.keys(JSON.parse(readFileSync(file, "utf8")).approved ?? {});+ if (!ids.length) throw new Error(`no approved device in ${file} — run: mso device approve <id> "e2e"`);+ return ids[0];+};+const PASSWORD = process.env.E2E_PASSWORD ?? env("OS_LOGIN_PASSWORD");+const DEVICE = process.env.E2E_DEVICE ?? approvedDevice();++const failures = [];+const pass = (m) => console.log(` ✓ ${m}`);+const fail = (m) => { failures.push(m); console.log(` ✗ ${m}`); };+const check = (cond, m) => (cond ? pass(m) : fail(m));+const skip = (m) => console.log(` – ${m}`);++// 1×1 transparent PNG — enough for naturalWidth to prove the bytes decoded.+const PNG_B64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==";++function fixtures() {+ mkdirSync(DIR, { recursive: true });+ writeFileSync(path.join(DIR, "sample.png"), Buffer.from(PNG_B64, "base64"));+ writeFileSync(path.join(DIR, "logo.svg"), '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><rect width="64" height="64" fill="#10ac84"/></svg>');+ writeFileSync(path.join(DIR, "notes.md"), "# Preview test\n\nThis file checks the **Markdown** renderer.\n\n- one\n- two\n");+ writeFileSync(path.join(DIR, "rows.csv"), 'name,role\nRahman,owner\nClaude,"assistant, occasionally wrong"\n');+ // The script tag is the point: it must NOT run inside the sandboxed frame.+ writeFileSync(path.join(DIR, "page.html"), "<!doctype html><html><body><h1>HTML renders sandboxed</h1><script>document.body.innerHTML+='SCRIPT RAN'</script></body></html>");+ writeFileSync(path.join(DIR, "server.log"), "boot ok\nlistening on 4005\n");+ writeFileSync(path.join(DIR, "report.docx"), "not really a document"); // kind: none+ const pdf = ["/usr/share/doc/shared-mime-info/shared-mime-info-spec.pdf", "/usr/share/cups/data/default-testpage.pdf"].find(existsSync);+ if (pdf) copyFileSync(pdf, path.join(DIR, "spec.pdf"));+ for (const [file, args] of [+ ["sample.mp4", ["-f", "lavfi", "-i", "testsrc=size=160x120:rate=10", "-t", "1", "-pix_fmt", "yuv420p"]],+ ["sample.mp3", ["-f", "lavfi", "-i", "sine=frequency=440:duration=1", "-q:a", "9"]],+ ]) {+ if (existsSync(path.join(DIR, file))) continue;+ try {+ execFileSync("ffmpeg", [...args, path.join(DIR, file), "-y"], { stdio: "ignore" });+ } catch {+ /* no ffmpeg — those two checks skip */+ }+ }+ return {+ pdf: existsSync(path.join(DIR, "spec.pdf")),+ video: existsSync(path.join(DIR, "sample.mp4")),+ audio: existsSync(path.join(DIR, "sample.mp3")),+ };+}++async function mintSession() {+ const r = await fetch(`${BASE}/api/auth/login`, {+ method: "POST",+ headers: { "content-type": "application/json", origin: BASE },+ body: JSON.stringify({ password: PASSWORD, deviceId: DEVICE, deviceLabel: "e2e-preview" }),+ });+ if (!r.ok) throw new Error(`login failed (${r.status}) — is the device approved? ${DEVICE}`);+ const value = /(?:^|,\s*)session=([^;]+)/.exec(r.headers.get("set-cookie") ?? "")?.[1];+ if (!value) throw new Error("login 200 but no session cookie");+ return value;+}++// The desktop puts each app in a [data-window]; the mobile shell shows ONE app+// full-screen with no window chrome. Same assertions, two surfaces.+const scope = (page, name) =>+ MOBILE ? page.locator("#main-content") : page.locator("[data-window]").filter({ hasText: name }).last();++const run = async () => {+ const have = fixtures();+ const browser = await chromium.launch({ headless: process.env.E2E_HEADED !== "1" });+ const ctx = await browser.newContext({+ viewport: { width: WIDTH, height: MOBILE ? 800 : 900 },+ hasTouch: MOBILE,+ isMobile: MOBILE,+ });+ const errors = [];+ ctx.on("console", (m) => {+ const t = m.text();+ // The sandbox refusing to run the fixture's script IS the passing behaviour.+ if (m.type() === "error" && !/favicon|DevTools|Blocked script execution/i.test(t)) errors.push(t);+ });+ const http = [];+ ctx.on("response", (r) => r.status() >= 400 && http.push(`${r.status()} ${new URL(r.url()).pathname}`));++ await ctx.addCookies([{ name: "session", value: await mintSession(), url: BASE, sameSite: "Strict" }]);+ const page = await ctx.newPage();+ await page.addInitScript(+ ([id]) => {+ localStorage.setItem("mso.device.id", id);+ localStorage.setItem("mso:onboarding:v1", "done");+ },+ [DEVICE],+ );++ console.log(`\n▶ Preview @ ${WIDTH}px (${DIR})`);+ await page.goto(`${BASE}/files${DIR}`, { waitUntil: "domcontentloaded" });+ await page.waitForSelector("#main-content[data-shell]", { timeout: 25_000 });+ const me = await page.evaluate(async () => (await fetch("/api/auth/me", { cache: "no-store" })).json());+ check(me?.authenticated === true, `really signed in (authenticated=${me?.authenticated})`);+ await page.waitForSelector('[data-name="sample.png"]', { timeout: 20_000 }).catch(() => {});++ // Open by deep link — the same route the window store takes, and the only one+ // that works identically on both shells (mobile has no Space and no right-click).+ const open = async (name) => {+ await page.goto(`${BASE}/viewer${DIR}/${name}`, { waitUntil: "domcontentloaded" });+ await page.waitForSelector(`[data-preview-file="${name}"]`, { timeout: 20_000 }).catch(() => {});+ await page.waitForTimeout(900);+ };+ const shown = async () => (await page.locator("[data-preview-file]").last().getAttribute("data-preview-file")) ?? "";++ await open("sample.png");+ let win = scope(page, "sample.png");+ check((await win.locator("img").count()) > 0, "PNG renders as <img>");+ check(await win.locator("img").first().evaluate((el) => el.naturalWidth > 0).catch(() => false), "PNG actually decoded");+ check((await page.locator("[aria-label='Next file']").count()) > 0, "← → paging present");+ const before = await shown();+ await page.locator("[aria-label='Next file']").first().click();+ await page.waitForTimeout(1200);+ const after = await shown();+ check(before !== after, `Next paged ${before} → ${after}`);+ await page.keyboard.press("ArrowLeft");+ await page.waitForTimeout(1200);+ check((await shown()) === before, `ArrowLeft came back to ${before}`);++ if (have.pdf) {+ await open("spec.pdf");+ check((await scope(page, "spec.pdf").locator("iframe").count()) > 0, "PDF renders in a frame");+ } else skip("PDF (no system pdf to copy)");++ if (have.video) {+ await open("sample.mp4");+ const vid = scope(page, "sample.mp4").locator("video");+ check((await vid.count()) > 0, "MP4 renders as <video>");+ const ready = await vid.first().evaluate((el) => new Promise((res) => {+ if (el.readyState >= 1) return res(true);+ el.addEventListener("loadedmetadata", () => res(true), { once: true });+ setTimeout(() => res(false), 5000);+ })).catch(() => false);+ check(ready, "MP4 metadata loaded (the bytes really stream)");+ } else skip("MP4 (no ffmpeg)");++ if (have.audio) {+ await open("sample.mp3");+ check((await scope(page, "sample.mp3").locator("audio").count()) > 0, "MP3 renders as <audio>");+ } else skip("MP3 (no ffmpeg)");++ await open("notes.md");+ check(/Preview test/.test(await scope(page, "notes.md").innerText()), "Markdown rendered");++ await open("rows.csv");+ win = scope(page, "rows.csv");+ check((await win.locator("table tr").count()) >= 3, "CSV rendered as a table");+ check(/assistant, occasionally wrong/.test(await win.innerText()), "CSV quoted field kept its comma");++ await open("page.html");+ const frame = scope(page, "page.html").locator("iframe");+ check((await frame.count()) > 0, "HTML rendered in a frame");+ check((await frame.first().getAttribute("sandbox")) === "", "HTML frame is fully sandboxed");+ const inner = await frame.first().contentFrame();+ const innerText = inner ? await inner.locator("body").innerText().catch(() => "") : "";+ check(/HTML renders sandboxed/.test(innerText), "HTML body actually rendered");+ check(!/SCRIPT RAN/.test(innerText), "script inside the HTML did NOT run");++ await open("server.log");+ check(/listening on 4005/.test(await scope(page, "server.log").innerText()), "Plain text rendered");++ await open("report.docx");+ check(/No browser can render this format/i.test(await scope(page, "report.docx").innerText()), "DOCX says why, and offers the download");++ // Settings → About: the update panel is the other thing that can only be wrong live.+ await page.goto(`${BASE}/settings`, { waitUntil: "domcontentloaded" });+ await page.waitForTimeout(2500);+ const about = page.getByText("About", { exact: true }).first();+ if (await about.count()) await about.click().catch(() => {});+ await page.waitForTimeout(3500);+ const settings = await (MOBILE ? page.locator("#main-content") : page.locator("[data-window]").last()).innerText();+ check(/Software update/i.test(settings), "Settings → About shows the update panel");+ check(/Up to date|available|build is pending/i.test(settings), "Update panel reported a state");+ check(/Release notes and docs/i.test(settings), "Release notes + docs row present");++ console.log(`\n console errors: ${errors.length ? [...new Set(errors)].slice(0, 5).join(" | ") : "none"}`);+ console.log(` http >=400: ${http.length ? [...new Set(http)].join(" | ") : "none"}`);+ if (errors.length) fail(`${errors.length} console error(s)`);+ await browser.close();+ console.log(failures.length ? `\n${failures.length} FAILED` : "\nall good");+ process.exit(failures.length ? 1 : 0);+};++run().catch((e) => {+ console.error(e);+ process.exit(1);+});