Skip to content

armgit / mso

Public Imported from GitHub
0

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.

fix(update): harden release verification and settings UX

Rahmand0e53df88b1f
diff --git a/components/ui/skeleton.tsx b/components/ui/skeleton.tsx
new file mode 100644
index 00000000..34430b1b
--- /dev/null
+++ b/components/ui/skeleton.tsx
@@ -0,0 +1,14 @@
+import * as React from "react";
+import { cn } from "@/lib/utils";
+
+function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
+ return (
+ <div
+ aria-hidden="true"
+ className={cn("animate-pulse rounded-md bg-muted", className)}
+ {...props}
+ />
+ );
+}
+
+export { Skeleton };
diff --git a/frontend/slices/os-settings/components/about-section.tsx b/frontend/slices/os-settings/components/about-section.tsx
index f1f7965b..3657c132 100644
--- a/frontend/slices/os-settings/components/about-section.tsx
+++ b/frontend/slices/os-settings/components/about-section.tsx
@@ -1,31 +1,52 @@
"use client";
-import { useEffect, useState } from "react";
+import { useEffect, useState, type ReactNode } from "react";
import { Info } from "lucide-react";
-import { useOsApi, type SysStats, type FsUsage } from "@/features/appshell";
-import { fmtGiB, fmtUptime } from "@/lib/os-api/format";
-import { useAppearance, effectiveServerTarget } from "@/lib/appearance";
-import { IS_DEMO } from "@/lib/demo";
-import { SettingsSection, SettingsValueRow, SettingsActionRow } from "@/features/shell-settings";
import { MsoMark } from "@/components/shared/mso-mark";
-import { WhatsNew } from "./whats-new";
-import { UpdateSection } from "./update-section";
-import { MaintenanceSection } from "./maintenance-section";
-import pkg from "../../../../package.json";
+import { Skeleton } from "@/components/ui/skeleton";
+import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { openOnboarding } from "@/features/auth";
+import { useOsApi, type FsUsage, type SysStats } from "@/features/appshell";
+import {
+ SettingsActionRow,
+ SettingsSection,
+ SettingsValueRow,
+} from "@/features/shell-settings";
+import { effectiveServerTarget, useAppearance } from "@/lib/appearance";
+import { IS_DEMO } from "@/lib/demo";
+import { fmtGiB, fmtUptime } from "@/lib/os-api/format";
+import pkg from "../../../../package.json";
+import { MaintenanceSection } from "./maintenance-section";
+import { UpdateSection } from "./update-section";
+import { WhatsNew } from "./whats-new";
const APP_NAME = "Manef Shell OS";
const APP_TAGLINE = "Browser-based visual shell";
+type AboutTab = "overview" | "update" | "whats-new" | "maintenance";
+
+const ABOUT_TABS: ReadonlyArray<{ id: AboutTab; label: string }> = [
+ { id: "overview", label: "Overview" },
+ { id: "update", label: "Update" },
+ { id: "whats-new", label: "What's new" },
+ { id: "maintenance", label: "Maintenance" },
+];
+
+function ValueSkeleton({ width = "w-20" }: { width?: string }) {
+ return <Skeleton className={`ml-auto h-3.5 ${width}`} />;
+}
+
export function AboutSection() {
const api = useOsApi();
const { tweaks } = useAppearance();
const [stats, setStats] = useState<SysStats | null>(null);
const [usage, setUsage] = useState<FsUsage | null>(null);
+ const [tab, setTab] = useState<AboutTab>("overview");
// Stats are MOCK when the active target is mock/demo — flag it so About never
// presents invented machine specs as the real host (VPS-essence honesty).
- const isSample = IS_DEMO || effectiveServerTarget(tweaks.server, IS_DEMO)?.kind === "mock";
+ const isSample =
+ IS_DEMO || effectiveServerTarget(tweaks.server, IS_DEMO)?.kind === "mock";
useEffect(() => {
let alive = true;
@@ -36,57 +57,110 @@ export function AboutSection() {
setUsage(u);
})
.catch(() => {
- /* leave placeholders */
+ /* keep loading placeholders instead of flashing invented values */
});
return () => {
alive = false;
};
}, [api]);
- const rows: [string, string][] = [
+ const rows: [string, ReactNode][] = [
["Status", "Public Alpha"],
["App version", pkg.version ?? "0.0.0"],
["Build ID", process.env.NEXT_PUBLIC_BUILD_ID || "dev"],
["Commit", process.env.NEXT_PUBLIC_COMMIT_SHA || "not set"],
["Runtime mode", IS_DEMO ? "Demo — mock data only" : "Live-capable"],
- ["Cores", stats ? String(stats.cpu.cores) : "—"],
- ["Memory", stats ? fmtGiB(stats.mem.total) : "—"],
- ["Disk", stats ? fmtGiB(stats.disk.total) : "—"],
- ["Uptime", stats ? fmtUptime(stats.uptime) : "—"],
- ["Storage used", usage ? `${fmtGiB(usage.used)} of ${fmtGiB(usage.total)}` : "—"],
+ ["Cores", stats ? String(stats.cpu.cores) : <ValueSkeleton width="w-8" />],
+ ["Memory", stats ? fmtGiB(stats.mem.total) : <ValueSkeleton />],
+ ["Disk", stats ? fmtGiB(stats.disk.total) : <ValueSkeleton />],
+ [
+ "Uptime",
+ stats ? fmtUptime(stats.uptime) : <ValueSkeleton width="w-24" />,
+ ],
+ [
+ "Storage used",
+ usage ? (
+ `${fmtGiB(usage.used)} of ${fmtGiB(usage.total)}`
+ ) : (
+ <ValueSkeleton width="w-28" />
+ ),
+ ],
];
return (
<div className="space-y-4 sm:space-y-5">
- {/* About-This-Mac style identity header — above the grouped cards */}
- <div className="flex flex-col items-center gap-2 pt-1 text-center">
- <MsoMark className="size-16 shell-icon-tile" />
- <div>
- <div className="text-lg font-bold tracking-tight text-foreground">{APP_NAME}</div>
+ <div className="flex items-center gap-3 rounded-xl border border-border/60 bg-card/50 p-3 sm:p-4">
+ <MsoMark className="size-12 shrink-0 shell-icon-tile sm:size-14" />
+ <div className="min-w-0">
+ <div className="truncate text-base font-bold tracking-tight text-foreground sm:text-lg">
+ {APP_NAME}
+ </div>
<div className="text-xs text-muted-foreground">{APP_TAGLINE}</div>
+ <div className="mt-1 truncate font-mono text-[10px] text-muted-foreground/80">
+ v{pkg.version ?? "0.0.0"} ·{" "}
+ {process.env.NEXT_PUBLIC_COMMIT_SHA || "development"}
+ </div>
</div>
</div>
- <SettingsSection
- icon={<Info />}
- title="System"
- footnote={isSample ? "Sample data — connect a live host in Server for real specs." : undefined}
- >
- {rows.map(([k, v]) => (
- <SettingsValueRow key={k} label={k} value={v} />
- ))}
- </SettingsSection>
+ <Tabs className="gap-4">
+ <div className="overflow-x-auto pb-1 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden">
+ <TabsList className="min-w-max">
+ {ABOUT_TABS.map((item) => (
+ <TabsTrigger
+ key={item.id}
+ active={tab === item.id}
+ onClick={() => setTab(item.id)}
+ className="min-h-9 [@media(pointer:coarse)]:min-h-[44px]"
+ >
+ {item.label}
+ </TabsTrigger>
+ ))}
+ </TabsList>
+ </div>
+
+ <div
+ role="tabpanel"
+ aria-label={ABOUT_TABS.find((item) => item.id === tab)?.label}
+ >
+ {tab === "overview" && (
+ <SettingsSection
+ icon={<Info />}
+ title="System"
+ footnote={
+ isSample
+ ? "Sample data — connect a live host in Server for real specs."
+ : "Build identity and live host capacity."
+ }
+ >
+ {rows.map(([key, value]) => (
+ <SettingsValueRow key={key} label={key} value={value} />
+ ))}
+ </SettingsSection>
+ )}
- {/* Above "What's new": the update is the thing to ACT on, the changelog is the
- thing to read. Renders nothing in demo, or where the host cannot self-update. */}
- <UpdateSection />
+ {tab === "update" && <UpdateSection />}
- <WhatsNew />
+ {tab === "whats-new" && <WhatsNew />}
- <SettingsSection icon={<Info />} title="Setup">
- <SettingsActionRow label="Open onboarding" icon={<Info />} onClick={openOnboarding} />
- </SettingsSection>
- <MaintenanceSection />
+ {tab === "maintenance" && (
+ <div className="space-y-4 sm:space-y-5">
+ <SettingsSection
+ icon={<Info />}
+ title="Setup"
+ footnote="Reopen the guided setup without resetting existing configuration."
+ >
+ <SettingsActionRow
+ label="Open onboarding"
+ icon={<Info />}
+ onClick={openOnboarding}
+ />
+ </SettingsSection>
+ <MaintenanceSection />
+ </div>
+ )}
+ </div>
+ </Tabs>
</div>
);
}
diff --git a/frontend/slices/os-settings/components/update-section.tsx b/frontend/slices/os-settings/components/update-section.tsx
index 7d8c298d..4b626fd1 100644
--- a/frontend/slices/os-settings/components/update-section.tsx
+++ b/frontend/slices/os-settings/components/update-section.tsx
@@ -1,27 +1,24 @@
"use client";
import { useCallback, useEffect, useRef, useState } from "react";
-import { ArrowDownToLine, BookOpen, CheckCircle2, RefreshCw, Search } from "lucide-react";
+import { ArrowDownToLine, BookOpen, RefreshCw, Search } from "lucide-react";
import { Button } from "@/components/ui/button";
-import { ScrollArea } from "@/components/ui/scroll-area";
import { FormDrawer } from "@/features/appshell";
-import { SettingsSection, SettingsActionRow, SettingsBlock } from "@/features/shell-settings";
+import { SettingsActionRow, SettingsSection } from "@/features/shell-settings";
import { IS_DEMO } from "@/lib/demo";
import type { UpdateStatus } from "@/lib/host/self-update";
import { UpdateNotes } from "./update-notes";
+import { UpdateStatusCard, UpdateStatusSkeleton } from "./update-status-card";
-// Settings → About → Software update. The button the whole deploy hangs off:
-// prod is systemd with no webhook, so a commit on main is invisible in the running
-// app until someone rebuilds — which used to mean someone with ssh.
-//
-// `import type` only: lib/host/self-update is "server-only" and the type is erased
-// at compile time, so the shape stays shared without the module reaching the bundle.
-
+// Settings → About → Update. The public route only starts the user-scoped updater;
+// the updater itself proves the candidate build before the running service is replaced.
const POLL_MS = 3_000;
const OK_MARKER = "UPDATE OK";
async function readStatus(check: boolean): Promise<UpdateStatus | null> {
- const res = await fetch(`/api/v1/sys/update${check ? "" : "?check=0"}`, { cache: "no-store" });
+ const res = await fetch(`/api/v1/sys/update${check ? "" : "?check=0"}`, {
+ cache: "no-store",
+ });
return res.ok ? ((await res.json()) as UpdateStatus) : null;
}
@@ -31,14 +28,10 @@ export function UpdateSection() {
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [notes, setNotes] = useState(false);
- // "An update ran in THIS tab (or was running when we looked)" — the outcome below
- // is derived from it rather than stored, so nothing has to be reset on the next run.
const [sawRunning, setSawRunning] = useState(false);
const postRunRemoteCheck = useRef(false);
const refresh = useCallback(async (check: boolean) => {
- // A poll that lands while the service is restarting simply fails; keeping the
- // last known state is the honest render, and the next tick recovers.
const next = await readStatus(check).catch(() => null);
if (next) {
setInfo(next);
@@ -47,10 +40,6 @@ export function UpdateSection() {
return next;
}, []);
- // The first read asks the remote; every later one is the poll below. Written as a
- // subscription-shaped effect (start an external call, set state in ITS callback)
- // rather than calling `refresh` here — the two are the same work, but only this
- // shape is honestly "synchronise with an external system".
useEffect(() => {
if (IS_DEMO) return;
let alive = true;
@@ -69,8 +58,6 @@ export function UpdateSection() {
};
}, []);
- // Poll only while an update is in flight — including across the restart it ends
- // with, which is the one moment the API is briefly gone.
useEffect(() => {
if (!info?.running) return;
const id = setInterval(() => void refresh(false), POLL_MS);
@@ -78,7 +65,8 @@ export function UpdateSection() {
}, [info?.running, refresh]);
useEffect(() => {
- if (!sawRunning || info?.running !== false || postRunRemoteCheck.current) return;
+ if (!sawRunning || info?.running !== false || postRunRemoteCheck.current)
+ return;
postRunRemoteCheck.current = true;
void refresh(true);
}, [sawRunning, info?.running, refresh]);
@@ -105,113 +93,76 @@ export function UpdateSection() {
};
if (IS_DEMO || (!info && !checking)) return null;
- const ahead = info?.ahead ?? 0;
- const behind = info?.behind ?? 0;
- const diverged = ahead > 0 && behind > 0;
- const localAhead = ahead > 0 && behind === 0;
- const running = info?.running ?? false;
- const pending = (info?.pendingBuild ?? false) && behind === 0;
- // Derived, never stored: an update we watched, that is no longer running, either
- // left its marker in the log or stopped before deploying.
- const finished = sawRunning && !running && info ? (info.log.includes(OK_MARKER) ? "ok" : "failed") : null;
+ if (!info && checking) {
+ return (
+ <SettingsSection
+ icon={<ArrowDownToLine />}
+ title="Software update"
+ footnote="Checking the running build, checkout and update service."
+ >
+ <UpdateStatusSkeleton />
+ </SettingsSection>
+ );
+ }
+
+ if (!info) return null;
+ const ahead = info.ahead ?? 0;
+ const behind = info.behind ?? 0;
+ const running = info.running ?? false;
+ const pending = (info.pendingBuild ?? false) && behind === 0;
+ const finished =
+ sawRunning && !running
+ ? info.log.includes(OK_MARKER)
+ ? "ok"
+ : "failed"
+ : null;
return (
<SettingsSection
icon={<ArrowDownToLine />}
title="Software update"
footnote={
- info?.supported === false
+ info.supported === false
? (info.reason ?? undefined)
- : "Pulls origin/main, proves it compiles out-of-tree, then builds and restarts. The out-of-tree check runs first because an in-place build cannot be undone."
+ : "Pulls origin/main, verifies compile and mandatory browser journeys out-of-tree, then builds and restarts. The running build is not replaced until those checks pass."
}
>
- <SettingsBlock className="space-y-2">
- <div className="flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs">
- <span className="font-medium text-foreground">
- {checking
- ? "Checking for updates…"
- : diverged
- ? "Update blocked — local and remote diverged"
- : localAhead
- ? `${ahead} local commit${ahead > 1 ? "s" : ""} not on origin/main`
- : behind > 0
- ? `${behind} update${behind > 1 ? "s" : ""} available`
- : pending
- ? "A build is pending"
- : "Up to date"}
- </span>
- {/* The RUNNING commit, not the checkout's — they differ whenever someone
- pulled without rebuilding, and that gap is the whole point of the row. */}
- <span className="font-mono text-[11px] text-muted-foreground">
- running {info?.buildSha || info?.current || "—"}
- </span>
- </div>
- {pending && (
- <p className="text-[11px] text-muted-foreground">
- The checkout is at <span className="font-mono">{info?.current}</span>, which this build was not compiled
- from. Rebuild to run it.
- </p>
- )}
- {info?.currentSubject && <p className="line-clamp-2 text-[11px] text-muted-foreground">{info.currentSubject}</p>}
- {diverged && (
- <p className="text-[11px] text-destructive-text">
- Local main is ahead {ahead} and behind {behind}. MSO will not overwrite either side automatically; reconcile or preserve the local commits first.
- </p>
- )}
- {localAhead && (
- <p className="text-[11px] text-amber-500">Local main has {ahead} unpushed commit{ahead > 1 ? "s" : ""}; normal update is blocked until it is pushed or reconciled.</p>
- )}
- {info && info.supported !== false && !info.remoteChecked && !running && (
- <p className="text-[11px] text-amber-500">
- Could not reach the remote — this is what was last fetched, not necessarily what is on main now.
- </p>
- )}
- {error && <p className="text-[11px] text-destructive-text">{error}</p>}
- {finished === "ok" && !running && (
- <p className="flex items-center gap-1.5 text-[11px] text-emerald-500">
- <CheckCircle2 className="size-3.5" /> Updated and restarted — reload to run the new build.
- </p>
- )}
- {finished === "failed" && !running && (
- <p className="text-[11px] text-destructive-text">The update stopped before deploying. The running build was left untouched — see the log.</p>
- )}
- {running && (
- // Same ScrollArea as everything else in Settings, so the updater's
- // transcript scrolls in the panel's own idiom instead of a raw browser
- // scrollbar in the middle of a card.
- <ScrollArea className="max-h-48 rounded-md bg-secondary/60">
- <pre className="p-2 text-[10px] leading-relaxed whitespace-pre-wrap break-words">
- {info?.log?.trim() || "starting…"}
- </pre>
- </ScrollArea>
- )}
- {finished === "ok" && !running && (
- <Button type="button" size="sm" className="w-full [@media(pointer:coarse)]:min-h-[44px]" onClick={() => window.location.reload()}>
- <RefreshCw className="size-4" /> Reload MSO
- </Button>
- )}
- </SettingsBlock>
+ <UpdateStatusCard
+ info={info}
+ checking={checking}
+ sawRunning={sawRunning}
+ error={error}
+ finished={finished}
+ />
- {behind > 0 && ahead === 0 && info?.supported !== false && (
+ {behind > 0 && ahead === 0 && info.supported !== false && (
<SettingsActionRow
- label={running ? "Updating…" : `Update to ${info?.commits[0]?.sha ?? "latest"} and restart`}
+ label={
+ running
+ ? "Updating…"
+ : `Update to ${info.commits[0]?.sha ?? "latest"} and restart`
+ }
icon={<ArrowDownToLine />}
busy={busy || running}
disabled={running}
onClick={() => void start(false)}
/>
)}
- {info?.supported !== false && (
+ {info.supported !== false && (
<SettingsActionRow
label="Release notes and docs"
icon={<BookOpen />}
onClick={() => setNotes(true)}
- trailing={behind > 0 ? <span className="text-[11px] text-muted-foreground">{behind} new</span> : undefined}
+ trailing={
+ behind > 0 ? (
+ <span className="text-[11px] text-muted-foreground">
+ {behind} new
+ </span>
+ ) : undefined
+ }
/>
)}
- {info?.supported !== false && !running && (
- // The check runs once, on open. A release that lands while the panel is
- // sitting there would otherwise need the whole window closed and reopened.
+ {info.supported !== false && !running && (
<SettingsActionRow
label="Check again"
icon={<Search />}
@@ -222,9 +173,13 @@ export function UpdateSection() {
}}
/>
)}
- {info?.supported !== false && behind === 0 && (
+ {info.supported !== false && behind === 0 && (
<SettingsActionRow
- label={pending ? `Build ${info?.current} and restart` : "Rebuild and restart"}
+ label={
+ pending
+ ? `Build ${info.current} and restart`
+ : "Rebuild and restart"
+ }
icon={<RefreshCw />}
busy={busy || running}
disabled={running}
@@ -234,12 +189,15 @@ export function UpdateSection() {
<FormDrawer open={notes} onOpenChange={setNotes} size="lg">
<FormDrawer.Header>
- <FormDrawer.Title>{behind > 0 ? `What's in this update (${behind})` : "Release notes"}</FormDrawer.Title>
+ <FormDrawer.Title>
+ {behind > 0 ? `What's in this update (${behind})` : "Release notes"}
+ </FormDrawer.Title>
<FormDrawer.Description>
- Incoming commits first, then everything already shipped to this deployment.
+ Incoming commits first, then everything already shipped to this
+ deployment.
</FormDrawer.Description>
</FormDrawer.Header>
- <UpdateNotes commits={info?.commits ?? []} />
+ <UpdateNotes commits={info.commits ?? []} />
<FormDrawer.Footer>
<Button type="button" variant="ghost" onClick={() => setNotes(false)}>
Close
diff --git a/frontend/slices/os-settings/components/update-status-card.tsx b/frontend/slices/os-settings/components/update-status-card.tsx
new file mode 100644
index 00000000..bcaef0fb
--- /dev/null
+++ b/frontend/slices/os-settings/components/update-status-card.tsx
@@ -0,0 +1,185 @@
+"use client";
+
+import { useEffect, useRef } from "react";
+import { CheckCircle2, RefreshCw, TerminalSquare } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { ScrollArea } from "@/components/ui/scroll-area";
+import { Skeleton } from "@/components/ui/skeleton";
+import { SettingsBlock } from "@/features/shell-settings";
+import type { UpdateStatus } from "@/lib/host/self-update";
+
+const OK_MARKER = "UPDATE OK";
+
+export function UpdateStatusSkeleton() {
+ return (
+ <SettingsBlock className="space-y-3 p-4">
+ <div className="flex items-center justify-between gap-4">
+ <div className="space-y-2">
+ <Skeleton className="h-3.5 w-36" />
+ <Skeleton className="h-3 w-52 max-w-[60vw]" />
+ </div>
+ <Skeleton className="h-5 w-20 shrink-0 rounded-full" />
+ </div>
+ <Skeleton className="h-3 w-4/5" />
+ </SettingsBlock>
+ );
+}
+
+export function UpdateStatusCard({
+ info,
+ checking,
+ sawRunning,
+ error,
+ finished,
+}: {
+ info: UpdateStatus;
+ checking: boolean;
+ sawRunning: boolean;
+ error: string | null;
+ finished: "ok" | "failed" | null;
+}) {
+ const logRef = useRef<HTMLPreElement>(null);
+ const ahead = info.ahead ?? 0;
+ const behind = info.behind ?? 0;
+ const diverged = ahead > 0 && behind > 0;
+ const localAhead = ahead > 0 && behind === 0;
+ const running = info.running ?? false;
+ const pending = (info.pendingBuild ?? false) && behind === 0;
+ const logText = info.log?.trim() ?? "";
+ const lastAttemptFailed =
+ logText.includes("FAILED:") && !logText.includes(OK_MARKER);
+ const showLog =
+ Boolean(logText) && (running || sawRunning || pending || lastAttemptFailed);
+
+ useEffect(() => {
+ if (!running || !logRef.current) return;
+ const viewport = logRef.current.closest(
+ "[data-radix-scroll-area-viewport]",
+ ) as HTMLElement | null;
+ if (viewport) viewport.scrollTop = viewport.scrollHeight;
+ }, [info.log, running]);
+
+ const headline = checking
+ ? "Checking for updates…"
+ : diverged
+ ? "Update blocked — local and remote diverged"
+ : localAhead
+ ? `${ahead} local commit${ahead > 1 ? "s" : ""} not on origin/main`
+ : behind > 0
+ ? `${behind} update${behind > 1 ? "s" : ""} available`
+ : pending
+ ? "A build is pending"
+ : "Up to date";
+
+ const stateLabel = running
+ ? "Running"
+ : finished === "failed" || lastAttemptFailed
+ ? "Failed safely"
+ : finished === "ok"
+ ? "Complete"
+ : pending
+ ? "Build required"
+ : behind > 0
+ ? "Available"
+ : "Current";
+
+ return (
+ <SettingsBlock className="space-y-3 p-4">
+ <div className="flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between">
+ <div className="min-w-0 space-y-1">
+ <p className="text-sm font-medium text-foreground">{headline}</p>
+ <p className="font-mono text-[11px] text-muted-foreground">
+ running {info.buildSha || info.current || "—"}
+ </p>
+ </div>
+ <span className="w-fit shrink-0 rounded-full border border-border/70 bg-secondary px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground">
+ {stateLabel}
+ </span>
+ </div>
+
+ {pending && (
+ <p className="text-[11px] leading-relaxed text-muted-foreground">
+ The checkout is at <span className="font-mono">{info.current}</span>,
+ which this running build was not compiled from. Rebuild to run it.
+ </p>
+ )}
+ {info.currentSubject && (
+ <p className="line-clamp-2 text-[11px] leading-relaxed text-muted-foreground">
+ {info.currentSubject}
+ </p>
+ )}
+ {diverged && (
+ <p className="text-[11px] leading-relaxed text-destructive-text">
+ Local main is ahead {ahead} and behind {behind}. MSO will not
+ overwrite either side automatically; reconcile or preserve the local
+ commits first.
+ </p>
+ )}
+ {localAhead && (
+ <p className="text-[11px] leading-relaxed text-amber-500">
+ Local main has {ahead} unpushed commit{ahead > 1 ? "s" : ""}; normal
+ update is blocked until it is pushed or reconciled.
+ </p>
+ )}
+ {info.supported !== false && !info.remoteChecked && !running && (
+ <p className="text-[11px] leading-relaxed text-amber-500">
+ Could not reach the remote — this is what was last fetched, not
+ necessarily what is on main now.
+ </p>
+ )}
+ {error && (
+ <p className="text-[11px] leading-relaxed text-destructive-text">
+ {error}
+ </p>
+ )}
+ {finished === "ok" && !running && (
+ <p className="flex items-center gap-1.5 text-[11px] text-emerald-500">
+ <CheckCircle2 className="size-3.5" /> Updated and restarted — reload
+ to run the new build.
+ </p>
+ )}
+ {(finished === "failed" || lastAttemptFailed) && !running && (
+ <p className="text-[11px] leading-relaxed text-destructive-text">
+ The update stopped before deployment. The running build was left
+ untouched; the stage that failed is preserved below.
+ </p>
+ )}
+
+ {showLog && (
+ <div className="space-y-2 border-t border-border/60 pt-3">
+ <div className="flex items-center justify-between gap-3">
+ <p className="flex items-center gap-1.5 text-[11px] font-medium text-foreground">
+ <TerminalSquare className="size-3.5" /> Build log
+ </p>
+ <span className="text-[10px] text-muted-foreground">
+ {running ? "live · follows latest output" : "last attempt"}
+ </span>
+ </div>
+ <ScrollArea
+ className="h-56 rounded-md border border-border/60 bg-background/70 sm:h-64"
+ aria-label="Software update build log"
+ >
+ <pre
+ ref={logRef}
+ tabIndex={0}
+ className="min-w-full p-3 font-mono text-[10px] leading-5 whitespace-pre-wrap break-words text-foreground/85 outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ {logText || "starting…"}
+ </pre>
+ </ScrollArea>
+ </div>
+ )}
+
+ {finished === "ok" && !running && (
+ <Button
+ type="button"
+ size="sm"
+ className="w-full [@media(pointer:coarse)]:min-h-[44px]"
+ onClick={() => window.location.reload()}
+ >
+ <RefreshCw className="size-4" /> Reload MSO
+ </Button>
+ )}
+ </SettingsBlock>
+ );
+}
diff --git a/scripts/ensure-playwright-browser.mjs b/scripts/ensure-playwright-browser.mjs
new file mode 100755
index 00000000..06d0c1a2
--- /dev/null
+++ b/scripts/ensure-playwright-browser.mjs
@@ -0,0 +1,48 @@
+#!/usr/bin/env node
+// Keep the mandatory release E2E runnable after @playwright/test changes the
+// Chromium revision. Playwright packages and browser binaries are versioned
+// separately, so `bun install` can leave a host with a new package that points at a
+// browser revision not present in ~/.cache/ms-playwright. Self-update runs as the
+// MSO owner: install only that package's Chromium binary, never sudo/system deps.
+import { existsSync } from "node:fs";
+import { execFileSync } from "node:child_process";
+import { chromium } from "@playwright/test";
+
+function browserPath() {
+ return chromium.executablePath();
+}
+
+const expected = browserPath();
+if (existsSync(expected)) {
+ console.log(`Playwright Chromium ready: ${expected}`);
+ process.exit(0);
+}
+
+console.log(
+ "Playwright Chromium for this package revision is missing; installing it now…",
+);
+try {
+ execFileSync(
+ process.execPath,
+ ["node_modules/playwright/cli.js", "install", "chromium"],
+ {
+ env: process.env,
+ stdio: "inherit",
+ },
+ );
+} catch {
+ console.error(
+ "Playwright Chromium bootstrap failed; release E2E cannot run safely.",
+ );
+ process.exit(1);
+}
+
+const installed = browserPath();
+if (!existsSync(installed)) {
+ console.error(
+ `Playwright reported success but the expected Chromium executable is still missing: ${installed}`,
+ );
+ process.exit(1);
+}
+
+console.log(`Playwright Chromium installed and ready: ${installed}`);
diff --git a/scripts/self-update.sh b/scripts/self-update.sh
index 133bd7b5..c3e7a9e0 100755
--- a/scripts/self-update.sh
+++ b/scripts/self-update.sh
@@ -93,12 +93,14 @@ if [ "$SHIP_FINALIZE" -eq 1 ]; then
[ "$(git rev-parse HEAD)" = "$EXPECTED_SHA" ] && [ -z "$(git status --porcelain)" ] \
|| die "checkout moved before the in-place build"
else
- step "verifying the build out-of-tree (this does not touch the live .next)"
- bash scripts/verify-build.sh >/dev/null || die "HEAD does not compile — nothing was deployed"
+ step "verifying compile + browser release gates out-of-tree (this does not touch the live .next)"
+ if ! bash scripts/verify-build.sh; then
+ die "out-of-tree verification failed at the stage shown above — nothing was deployed"
+ fi
fi
step "building in place"
-node node_modules/next/dist/bin/next build >/dev/null || die "in-place build failed — check disk space"
+node node_modules/next/dist/bin/next build || die "in-place build failed — check the build output above and disk space"
step "restarting mso.service (same-user signal; no sudo)"
# mso.service runs as the owner and has Restart=always. Signalling its MainPID is
diff --git a/scripts/verify-build.sh b/scripts/verify-build.sh
index 6ab50b22..5f1474d7 100755
--- a/scripts/verify-build.sh
+++ b/scripts/verify-build.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# verify-build.sh — prove HEAD actually compiles, WITHOUT touching the .next that the
-# live :4005 service is serving from.
+# verify-build.sh — prove HEAD actually compiles and passes mandatory release E2E,
+# WITHOUT touching the .next that the live :4005 service is serving from.
#
# Why not simply run `next build` here, and why the pre-push hook keeps `--skip build`:
# the build's FIRST act is to delete everything in distDir except /^(cache|dev|lock)/
@@ -33,19 +33,36 @@ mkdir "$TMP/node_modules"
cp -a "$REPO/node_modules/." "$TMP/node_modules/"
cd "$TMP"
-# nice/ionice: this box also serves prod. A build gate must not starve :4005.
MSO_VERIFY_BUILD_LOG="$TMP/build-output.log"
-nice -n 15 ionice -c2 -n7 node node_modules/.bin/next build 2>&1 | tee "$MSO_VERIFY_BUILD_LOG"
+
+echo "== verify 1/3: isolated Next build"
+# nice/ionice: this box also serves prod. A build gate must not starve :4005.
+if ! nice -n 15 ionice -c2 -n7 node node_modules/.bin/next build 2>&1 | tee "$MSO_VERIFY_BUILD_LOG"; then
+ echo "verification failed during isolated compile/build" >&2
+ exit 40
+fi
if grep -Ei "(^|[[:space:]])warnings?[: ]|⚠" "$MSO_VERIFY_BUILD_LOG"; then
- echo "build: warnings are a release failure; resolve their source before shipping" >&2
- exit 1
+ echo "verification failed: build warnings are a release failure; resolve their source before shipping" >&2
+ exit 41
fi
+echo "== verify 2/3: Playwright Chromium runtime"
+if ! node scripts/ensure-playwright-browser.mjs; then
+ echo "verification failed while preparing the browser required by release E2E" >&2
+ exit 42
+fi
+
+echo "== verify 3/3: mandatory release E2E"
# Reuse this exact built tree for mandatory browser journeys; synthetic stores only.
-node scripts/e2e/release.mjs
+if ! node scripts/e2e/release.mjs; then
+ echo "verification failed during mandatory release E2E" >&2
+ exit 43
+fi
# Optional deeper media/native acceptance, using the same isolated built tree.
if [ "${1:-}" = "--extended" ]; then
+ echo "== verify extended: desktop native acceptance"
node scripts/e2e/desktop-native.mjs
+ echo "== verify extended: preview acceptance"
node scripts/e2e/preview.mjs
fi
diff --git a/scripts/worktree-gates.test.ts b/scripts/worktree-gates.test.ts
index bdbbb529..446d8255 100644
--- a/scripts/worktree-gates.test.ts
+++ b/scripts/worktree-gates.test.ts
@@ -1,32 +1,74 @@
import { spawnSync } from "node:child_process";
-import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
+import {
+ copyFileSync,
+ existsSync,
+ mkdirSync,
+ mkdtempSync,
+ readFileSync,
+ readdirSync,
+ rmSync,
+ statSync,
+ symlinkSync,
+ writeFileSync,
+} from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
const roots: string[] = [];
-afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
+afterEach(() => {
+ for (const root of roots.splice(0))
+ rmSync(root, { recursive: true, force: true });
+});
function fixture(script: string) {
- const root = mkdtempSync(path.join(os.tmpdir(), "mso-worktree-gate-")); roots.push(root);
- const repo = path.join(root, "repo"); mkdirSync(path.join(repo, "scripts"), { recursive: true });
- copyFileSync(path.join(process.cwd(), "scripts", script), path.join(repo, "scripts", script));
+ const root = mkdtempSync(path.join(os.tmpdir(), "mso-worktree-gate-"));
+ roots.push(root);
+ const repo = path.join(root, "repo");
+ mkdirSync(path.join(repo, "scripts"), { recursive: true });
+ copyFileSync(
+ path.join(process.cwd(), "scripts", script),
+ path.join(repo, "scripts", script),
+ );
+ if (script === "verify-build.sh") {
+ copyFileSync(
+ path.join(process.cwd(), "scripts", "ensure-playwright-browser.mjs"),
+ path.join(repo, "scripts", "ensure-playwright-browser.mjs"),
+ );
+ }
const git = (...args: string[]) => {
const result = spawnSync("git", args, { cwd: repo, encoding: "utf8" });
- expect(result.status, result.stderr).toBe(0); return result.stdout.trim();
+ expect(result.status, result.stderr).toBe(0);
+ return result.stdout.trim();
};
mkdirSync(path.join(repo, "scripts/e2e"), { recursive: true });
- writeFileSync(path.join(repo, "scripts/e2e/release.mjs"), "import fs from 'node:fs'; if (!fs.existsSync('.build-verified') || fs.existsSync('.env.local')) throw Error('unsafe E2E fixture'); console.log('isolated E2E fixture passed');");
- git("init", "-q"); git("add", "scripts");
- git("-c", "user.name=Test", "-c", "[email protected]", "commit", "-qm", "fixture");
+ writeFileSync(
+ path.join(repo, "scripts/e2e/release.mjs"),
+ "import fs from 'node:fs'; if (!fs.existsSync('.build-verified') || fs.existsSync('.env.local')) throw Error('unsafe E2E fixture'); console.log('isolated E2E fixture passed');",
+ );
+ git("init", "-q");
+ git("add", "scripts");
+ git(
+ "-c",
+ "user.name=Test",
+ "-c",
+ "commit",
+ "-qm",
+ "fixture",
+ );
return { root, repo, git };
}
describe("isolated worktree release guards", () => {
it("installs the shared hook from a linked worktree whose .git is a file", () => {
- const { root, repo, git } = fixture("gates.sh"); const work = path.join(root, "linked");
+ const { root, repo, git } = fixture("gates.sh");
+ const work = path.join(root, "linked");
git("worktree", "add", "-qb", "linked-test", work);
expect(statSync(path.join(work, ".git")).isFile()).toBe(true);
- const run = spawnSync("bash", ["scripts/gates.sh", "--install"], { cwd: work, encoding: "utf8" });
+ const run = spawnSync("bash", ["scripts/gates.sh", "--install"], {
+ cwd: work,
+ encoding: "utf8",
+ });
expect(run.status, run.stderr).toBe(0);
const hook = path.join(repo, ".git/hooks/pre-push");
expect(readFileSync(hook, "utf8")).toContain("scripts/gates.sh");
@@ -35,24 +77,74 @@ describe("isolated worktree release guards", () => {
it("builds a committed archive with copied dependency contents and no local secrets", () => {
const { root, repo } = fixture("verify-build.sh");
- const modules = path.join(root, "modules"); mkdirSync(path.join(modules, ".bin"), { recursive: true });
- writeFileSync(path.join(modules, ".bin/next"), `const fs=require('node:fs'); if(fs.lstatSync('node_modules').isSymbolicLink()) throw Error('outside-root symlink'); if(fs.existsSync('.env.local')) throw Error('secret copied'); fs.writeFileSync('.build-verified','ok'); console.log('isolated build fixture passed');`);
+ const modules = path.join(root, "modules");
+ mkdirSync(path.join(modules, ".bin"), { recursive: true });
+ writeFileSync(
+ path.join(modules, ".bin/next"),
+ `const fs=require('node:fs'); if(fs.lstatSync('node_modules').isSymbolicLink()) throw Error('outside-root symlink'); if(fs.existsSync('.env.local')) throw Error('secret copied'); fs.writeFileSync('.build-verified','ok'); console.log('isolated build fixture passed');`,
+ );
+ const playwrightTest = path.join(modules, "@playwright/test");
+ mkdirSync(playwrightTest, { recursive: true });
+ writeFileSync(
+ path.join(playwrightTest, "package.json"),
+ JSON.stringify({
+ name: "@playwright/test",
+ type: "module",
+ exports: "./index.mjs",
+ }),
+ );
+ writeFileSync(
+ path.join(playwrightTest, "index.mjs"),
+ `export const chromium = { executablePath: () => "/bin/sh" };`,
+ );
symlinkSync(modules, path.join(repo, "node_modules"), "dir");
- writeFileSync(path.join(repo, ".env.local"), "# synthetic local configuration\n");
- mkdirSync(path.join(repo, ".next")); writeFileSync(path.join(repo, ".next/keep"), "live marker");
- const run = spawnSync("bash", ["scripts/verify-build.sh"], { cwd: repo, encoding: "utf8", timeout: 10_000 });
- expect(run.status, run.stderr).toBe(0); expect(run.stdout).toContain("isolated build fixture passed");
+ writeFileSync(
+ path.join(repo, ".env.local"),
+ "# synthetic local configuration\n",
+ );
+ mkdirSync(path.join(repo, ".next"));
+ writeFileSync(path.join(repo, ".next/keep"), "live marker");
+ const run = spawnSync("bash", ["scripts/verify-build.sh"], {
+ cwd: repo,
+ encoding: "utf8",
+ timeout: 10_000,
+ });
+ expect(run.status, run.stderr).toBe(0);
+ expect(run.stdout).toContain("isolated build fixture passed");
+ expect(run.stdout).toContain("Playwright Chromium ready");
expect(run.stdout).toContain("isolated E2E fixture passed");
- expect(readFileSync(path.join(repo, ".next/keep"), "utf8")).toBe("live marker");
+ expect(readFileSync(path.join(repo, ".next/keep"), "utf8")).toBe(
+ "live marker",
+ );
expect(existsSync(path.join(repo, ".env.local"))).toBe(true);
});
+
+ it("bootstraps only the package-matched Chromium binary without sudo", () => {
+ const source = readFileSync(
+ path.join(process.cwd(), "scripts/ensure-playwright-browser.mjs"),
+ "utf8",
+ );
+ expect(source).toContain(
+ '["node_modules/playwright/cli.js", "install", "chromium"]',
+ );
+ expect(source).toContain("chromium.executablePath()");
+ expect(source).not.toContain('"sudo"');
+ expect(source).not.toContain('"install-deps"');
+ });
});
describe("root test inventory", () => {
it("registers every root-level test in the normal verification gate", () => {
- const config = readFileSync(path.join(process.cwd(), "vitest.config.mts"), "utf8");
- for (const file of readdirSync(process.cwd()).filter((name) => /\.test\.tsx?$/.test(name))) {
- expect(config, `unregistered root test: ${file}`).toContain(JSON.stringify(file));
+ const config = readFileSync(
+ path.join(process.cwd(), "vitest.config.mts"),
+ "utf8",
+ );
+ for (const file of readdirSync(process.cwd()).filter((name) =>
+ /\.test\.tsx?$/.test(name),
+ )) {
+ expect(config, `unregistered root test: ${file}`).toContain(
+ JSON.stringify(file),
+ );
}
});
});