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
fix(hydration): kill 3 of 4 React #418 sources; mobile contrast + back labels
Rahmane879ee4139c1
diff --git a/app/layout.tsx b/app/layout.tsxindex 5dd3dac9..5ba9dc1e 100644--- a/app/layout.tsx+++ b/app/layout.tsx@@ -59,8 +59,18 @@ export default async function RootLayout({paints (dark users otherwise get a light flash). A raw nonced <script>at body-top runs synchronously during parse; the nonce (proxy.ts →x-nonce header) satisfies the strict CSP script-src. */}+ {/* suppressHydrationWarning is REQUIRED here, not cosmetic. Browsers blank the+ `nonce` content attribute once CSP has consumed it — a deliberate+ anti-exfiltration measure — so the DOM reports nonce="" while the server+ HTML carried the real value. React compares the attribute and reports a+ mismatch on EVERY page load. Confirmed against a non-minified dev build:+ + nonce="NjA3NDAxNWIt…" (server)+ - nonce="" (client)+ The nonce itself must stay: proxy.ts mints it per request and the strict+ CSP script-src will not execute this script without it. */}<scriptnonce={nonce}+ suppressHydrationWarningdangerouslySetInnerHTML={{__html:'try{var t=JSON.parse(localStorage.getItem("mso:tweaks"));if(t&&t.theme)document.documentElement.dataset.theme=t.theme;}catch(e){}',diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 7677ea94..593f53dc 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -8,6 +8,61 @@ Running log of what shipped each phase. Newest at top.> Read those phases as history. **This file is the source of truth for what exists** —> `ARCHITECTURE.md` is no longer maintained and carries a stale-warning banner.+## 2026-08-04 (hydration + mobile polish) — three of four hydration mismatches killed (DONE)++Chasing React #418, which had been firing on every page load and every app. A hydration+mismatch is not cosmetic: React discards the hydrated tree and re-renders the whole shell+on the client. Localised with a **non-minified dev build in a throwaway `git archive`+tree on :4007** — the minified production message names nothing. Four distinct causes,+three fixed.++1. **The `nonce` attribute on the theme-restore inline script.** Browsers blank the+ `nonce` content attribute once CSP has consumed it (anti-exfiltration), so the DOM+ reports `nonce=""` while the server HTML carried the real value. Dev build showed it+ verbatim: `+ nonce="NjA3NDAxNWIt…"` / `- nonce=""`. Fixed with+ `suppressHydrationWarning` on that one script. The nonce itself must stay — proxy.ts+ mints it per request and the strict CSP will not run the script without it.+2. **`useWidgetState`'s `getServerSnapshot` returned the live `state`.** React uses+ `getServerSnapshot` for the *first client render while hydrating*, and by then the+ module-level `state` had already been read from `localStorage`. So the server rendered+ the desktop widget layer off and hydration rendered it on, throwing the whole tree+ away. Now returns a frozen SSR default matching `load()`'s no-localStorage branch.+3. **`Clock` could not match, for two independent reasons**: it captures `new Date()` at+ SSR time and again at hydration time, and `toLocaleTimeString`/`toLocaleDateString`+ resolve against the *server's* locale during SSR and the *browser's* on the client.+ Both are named on React's own hydration-mismatch page. `suppressHydrationWarning` on+ each branch — which is precisely the attribute's purpose — keeps the server text (no+ layout shift) and lets the client correct it on the next tick.++**Result: the home route is hydration-clean on desktop and mobile in the production+build.** Verified against :4005, not just dev.++**STILL OPEN, and architectural rather than a bug.** Deep-linking into an app at phone+width still mismatches. The dev trace points at a Radix `DropdownMenuTrigger`'s+`useId`-generated `id`, which is a *symptom*: `responsive-provider.ts`'s `initial()`+deliberately returns **desktop** for SSR, so the server renders the macOS shell (menu bar+full of dropdowns) while the client computes mobile and renders iOS. Different trees →+different `useId` sequence. Closing it means changing what the server renders for the+shell (a neutral skeleton, or no shell until mount), which trades away SSR'd content and+risks a flash. Left for a deliberate decision rather than changed in passing.++**Mobile polish shipped alongside**, all from actually looking at the rendered pixels:+- Android home labels and clock were `foreground` (dark) directly on a dark wallpaper.+ Now white + text-shadow, matching the treatment iOS home/app-library already used.+ The colour is set on the **home grid container**, not inside `AppCell` — that same+ cell is reused by the App Drawer, a light sheet where white would be invisible.+ Caught before shipping by checking the cell's other call site.+- `Clock mode="date"` hard-codes `text-muted-foreground`, correct on a card and invisible+ on a wallpaper. Overridden locally with a `[&_div]:` descendant selector — (0,1,1)+ beats the class deterministically, with no `!important` and no API change to a+ component four shells share.+- Files' history back said `aria-label="Back"`, identical to the two shell-level+ exit-app controls, so a screen reader announced "Back" three times with three+ different meanings. It is now "Previous folder"; "Back" is reserved for leaving an app.++**Feature sweep: 17/17 apps render in both mobile shells**, each with a reachable exit+(iOS "Done", Android NavBar + header). No blank screens, no fatals.+## 2026-08-04 — every `border-<color>` utility in the app was dead, and that is why Android had no visible Back (DONE)Started from a user report — "stuck in the Android shell, there is no back button, anddiff --git a/frontend/slices/appshell/components/clock.tsx b/frontend/slices/appshell/components/clock.tsxindex d88cced0..aa6afbf8 100644--- a/frontend/slices/appshell/components/clock.tsx+++ b/frontend/slices/appshell/components/clock.tsx@@ -10,8 +10,17 @@ export function Clock({ mode }: { mode: "time" | "big" | "date" | "datetime" })const t = setInterval(() => setNow(new Date()), 30000);return () => clearInterval(t);}, []);- if (mode === "big") return <div className="text-5xl font-medium tracking-tight">{now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}</div>;- if (mode === "date") return <div className="text-sm text-muted-foreground">{now.toLocaleDateString([], { weekday: "long", day: "numeric", month: "long" })}</div>;- if (mode === "datetime") return <span>{now.toLocaleDateString([], { weekday: "short", day: "numeric", month: "short" })} · {now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}</span>;- return <span>{now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}</span>;+ // suppressHydrationWarning on every branch, and it is load-bearing. This text+ // cannot match between server and client for TWO independent reasons: the server+ // renders at one instant and hydration happens at another, and toLocaleTime/DateString+ // resolves against the SERVER's locale during SSR and the BROWSER's on the client.+ // React's own hydration-mismatch page lists both. Left unsuppressed it threw+ // "Hydration failed … this tree will be regenerated on the client" on every deep+ // link into an app, discarding the whole shell tree. Suppressing keeps the server+ // text in place (no layout shift) and lets the client correct it on the next tick —+ // which is exactly what this attribute exists for.+ if (mode === "big") return <div suppressHydrationWarning className="text-5xl font-medium tracking-tight">{now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}</div>;+ if (mode === "date") return <div suppressHydrationWarning className="text-sm text-muted-foreground">{now.toLocaleDateString([], { weekday: "long", day: "numeric", month: "long" })}</div>;+ if (mode === "datetime") return <span suppressHydrationWarning>{now.toLocaleDateString([], { weekday: "short", day: "numeric", month: "short" })} · {now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}</span>;+ return <span suppressHydrationWarning>{now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}</span>;}diff --git a/frontend/slices/appshell/components/shells/android/android-parts.tsx b/frontend/slices/appshell/components/shells/android/android-parts.tsxindex beeb1802..7ebef6cc 100644--- a/frontend/slices/appshell/components/shells/android/android-parts.tsx+++ b/frontend/slices/appshell/components/shells/android/android-parts.tsx@@ -119,6 +119,10 @@ export function AppCell({ app, onClick }: { app: AppDescriptor; onClick: () => vreturn (<Button type="button" variant="ghost" onClick={onClick} className="h-auto p-0 font-normal hover:bg-transparent flex flex-col items-center gap-1.5"><span className="size-14"><AppIcon app={app} /></span>+ {/* Colour is INHERITED, deliberately: this cell renders both on the home grid+ (over the wallpaper, where the parent sets white + a shadow) and inside the+ App Drawer (a light bg-background/95 sheet, where white would be invisible).+ Hard-coding either one breaks the other surface. */}<span className="w-full truncate text-center text-[11px]">{app.title}</span></Button>);diff --git a/frontend/slices/appshell/components/shells/android/android-shell.tsx b/frontend/slices/appshell/components/shells/android/android-shell.tsxindex 9f5a33b3..beba08e4 100644--- a/frontend/slices/appshell/components/shells/android/android-shell.tsx+++ b/frontend/slices/appshell/components/shells/android/android-shell.tsx@@ -122,7 +122,13 @@ function AndroidShell() {grid + NavBar drop out of tab/AT order under the z-20 app layer).Pull down → Control Center; clock+date live on the wallpaper. */}<div className="flex min-h-0 flex-1 flex-col overflow-y-auto px-5 pb-1" inert={showApp} aria-hidden={showApp} onPointerDown={pullDown} onContextMenu={onHomeContext} style={{ paddingTop: "var(--sai-top, 0px)" }}>- <div className="mt-6 shrink-0">+ {/* Same reason as the app labels: the clock sits on the wallpaper, so it+ needs its own light-on-dark treatment rather than the theme foreground. */}+ {/* `[&_div]:text-white/80` targets Clock mode="date", which hard-codes+ text-muted-foreground — correct on a card, invisible on a wallpaper. The+ descendant selector is (0,1,1) so it beats that class deterministically,+ without !important and without changing Clock's shared API for one caller. */}+ <div className="mt-6 shrink-0 text-white [text-shadow:0_1px_3px_rgba(0,0,0,0.5)] [&_div]:text-white/80"><Clock mode="big" /><Clock mode="date" /></div>@@ -142,7 +148,11 @@ function AndroidShell() {an agent workspace (20-24 Hermes/OpenClaw features). The grid is already`min-h-0 overflow-y-auto`, so it just scrolls a longer list; usePullDownstill arms only at scrollTop 0, so the shade gesture is unchanged. */}- <div ref={gridRef} className="mt-5 grid min-h-0 grid-cols-4 content-start gap-x-3 gap-y-5 overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">+ {/* White + shadow HERE rather than inside AppCell: the same cell is reused by+ the App Drawer, which is a light sheet where white text would vanish. This+ grid is the only surface that sits directly on the wallpaper. Matches the+ treatment the iOS home and app library already use. */}+ <div ref={gridRef} className="mt-5 grid min-h-0 grid-cols-4 content-start gap-x-3 gap-y-5 overflow-y-auto text-white [scrollbar-width:none] [text-shadow:0_1px_3px_rgba(0,0,0,0.5)] [&::-webkit-scrollbar]:hidden">{dockable.map((a) => (<AppCell key={a.id} app={a} onClick={() => launch(a)} />))}diff --git a/frontend/slices/appshell/features/widgets/widget-registry.ts b/frontend/slices/appshell/features/widgets/widget-registry.tsindex 9301efa3..c8e264a3 100644--- a/frontend/slices/appshell/features/widgets/widget-registry.ts+++ b/frontend/slices/appshell/features/widgets/widget-registry.ts@@ -101,6 +101,21 @@ function commit(next: WidgetState) {subs.forEach((f) => f());}+// getServerSnapshot must return what the SERVER rendered, which is load()'s+// no-localStorage branch — NOT `state`. React uses getServerSnapshot for the first+// client render while hydrating, and by then the module-level `state` has already+// been populated from localStorage. Returning it there meant the server rendered+// the widget layer as off while hydration rendered it on, and React threw the whole+// shell tree away with "Hydration failed because the server rendered HTML didn't+// match the client" on every single page load. Frozen + module-level so the+// reference is stable; an inline object would loop useSyncExternalStore.+const SSR_STATE: WidgetState = Object.freeze({+ on: false,+ enabled: DEFAULT_ENABLED,+ sizes: {},+ positions: {},+}) as WidgetState;+export function useWidgetState(): WidgetState {return useSyncExternalStore((cb) => {@@ -110,7 +125,7 @@ export function useWidgetState(): WidgetState {};},() => state,- () => state,+ () => SSR_STATE,);}diff --git a/frontend/slices/files-manager/components/files-toolbar.tsx b/frontend/slices/files-manager/components/files-toolbar.tsxindex 9ececfed..b7333002 100644--- a/frontend/slices/files-manager/components/files-toolbar.tsx+++ b/frontend/slices/files-manager/components/files-toolbar.tsx@@ -53,7 +53,7 @@ export function FilesToolbar(props: {<Button variant="ghost" size="icon" onClick={props.onOpenSidebar} aria-label="Browse" className="size-9 shrink-0 text-primary [@media(pointer:coarse)]:size-[44px]"><PanelLeft className="size-5" /></Button>- <Button variant="ghost" size="icon" disabled={!props.canBack} onClick={props.onBack} aria-label="Back" className="size-9 shrink-0 text-primary disabled:text-muted-foreground [@media(pointer:coarse)]:size-[44px]">+ <Button variant="ghost" size="icon" disabled={!props.canBack} onClick={props.onBack} aria-label="Previous folder" className="size-9 shrink-0 text-primary disabled:text-muted-foreground [@media(pointer:coarse)]:size-[44px]"><ChevronRight className="size-5 rotate-180" /></Button><FileCrumbs@@ -114,7 +114,7 @@ export function FilesToolbar(props: {<PanelLeft className="size-4" /></Button><div className="flex items-center gap-0.5">- <Button variant="ghost" size="icon" disabled={!props.canBack} onClick={props.onBack} aria-label="Back" className="size-7 [@media(pointer:coarse)]:size-9">+ <Button variant="ghost" size="icon" disabled={!props.canBack} onClick={props.onBack} aria-label="Previous folder" className="size-7 [@media(pointer:coarse)]:size-9"><ChevronRight className="size-4 rotate-180" /></Button><Button variant="ghost" size="icon" disabled={!props.canForward} onClick={props.onForward} aria-label="Forward" className="size-7 [@media(pointer:coarse)]:size-9">