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.
mso Full Audit — 2026-06-11
Archived point-in-time audit. This file preserves findings against HEAD
84e857con 2026-06-11, including the commands/paths/counts used then. Many findings were fixed or structurally superseded. Do not use it as today's architecture/runbook; start withREADME.md,ARCHITECTURE.mdandTROUBLESHOOTING.md. Source comments may still cite finding numbers here, which is why the original body is intentionally retained.
Method: six parallel audit passes over HEAD
84e857c(security, shell core, app slices, shell fidelity inventory, Next/React best-practice with Context7 docs, DX/code-quality), every load-bearing claim verified against the actual code (the two single-source P1s re-verified by hand). Gates at HEAD:pnpm typecheckPASS ·pnpm lintPASS (0 warnings) · vitest 136/136 PASS.Companion doc:
SHELL-FIDELITY-PLAN.md(how to make the five shells feel like their real OSes). This file is the issue/bug/improvement inventory.
TL;DR scorecard
| Dimension | State | Headline |
|---|---|---|
| Security | Strong | No P0/P1. Auth gate on every route, realpath jail holds, timing-safe compares. Findings are hardening + doc drift. |
| Shell core (WM) | Good, 5 real P1s | Resize +30px drift, Spotlight infinite query loop, deep-link reload duplicates windows, no offscreen re-clamp, z-order ignores focus recency. |
| App slices | Weakest area | 5 P0s (image-editor export wrong + load-clobber, Settings SSH target uneditable, ⌘S broken in code-editor, Files "Download" no-op) + a long P1 tail. Data-loss class concentrated in image-editor. |
| UX coherence | Inconsistent | 7 different error-surface regimes, destructive ops mostly unconfirmed, advertised-but-unbound shortcuts everywhere, 6 stray Indonesian strings. |
| Performance | OK with leaks | Pollers never pause when hidden; screencast/playback re-render whole trees; object-URL leaks; no virtualization (only Files needs it). |
| DX / code quality | Excellent baseline | 0 any, 0 ts-ignore, 136 fast tests + e2e harness, rules ~98% honored. Debt: ~1,870 dead lines in media-studio, 8 Convex-era slice.json, 5 barrel violations. |
| A11y | Patchy | KeyBar/transport buttons exemplary; menus/tabs/toolbars elsewhere keyboard-dead; pinch-zoom disabled (WCAG 1.4.4). |
1. P0 — broken now, user-visible
- image-editor: Export/Save renders the viewport, not the document —
frontend/slices/image-editor/lib/export.ts:18callsstage.toDataURL({...})with no x/y/width/height: output includes pasteboard padding, zoom-dependent resolution, Transformer handles and the drop-shadow baked into the file, black surround on JPEG. Affects Export panel, ⌘Save, mobile top-bar, AIexport.image, and the close-guard save. Fix: pass the doc rect +pixelRatio: scale / zoom, hide the overlay layer during render. - image-editor: failed project load auto-clobbers the saved file —
image-editor.tsx:117-127—fetch(src)…catch(() => {}).finally(onDone)flipsready=trueeven on failure; 800 ms later the autosaver writes the blank starter doc over the user's file. One network blip = file destroyed. Fix: onlyonDone()on success; error toast otherwise. - Settings: "Laptop" SSH target is uneditable —
lib/appearance/server-targets.ts:37—uniqueTargets([...legacyVps, ...existing])puts pristineCORE_TARGETSfirst in a first-wins dedupe andensureServerTargetsruns on everysetServer, so each keystroke in host/user/port is instantly reverted. Fix: invert precedence (saved first), append only missing core ids. - code-editor: ⌘S while typing opens the browser Save dialog —
components/editor-surface.tsx:98— the textarea'sonKeyDowndoese.stopPropagation()on every key, so the window-level save listener (app.tsx:47-56, bubble phase) never sees ⌘S in the only state where you'd press it. Fix: handle ⌘S in the textarea handler (or use capture phase). - files-manager: context-menu "Download" is a stub —
app.tsx:183onDownload={() => fs.setError(null)}. Fix: anchor torawUrl(joinPath(fs.path, name))with thedownloadattr (media-viewer has the pattern), or remove the item.
2. P1 — break under realistic conditions
Shell / window manager (verified 3× independently where noted)
- Resize commits viewport coords into section-relative state —
appshell/hooks/use-window-drag.ts:96-99usesgetBoundingClientRect()where the drag path 40 lines above documents whyoffsetLeft/offsetTopis required. On macOS shell (top-[30px]section) every resize drops the window +30px, accumulating. Two-line fix. (Found by 3 independent passes.) - Spotlight self-sustains an infinite search loop —
os-shell/capabilities.ts:42-52returns a fresh async closure per render;shell-search/components/spotlight.tsxkeys its effect on that identity →/api/v1/fs/searchfires every ~150 ms while the palette is open with text. The capability contract (registry/capabilities.tsx:79-83) explicitly forbids this. Fix:useCallbackonapi. (Re-verified by hand.) - Deep-link reload duplicates a Files window every refresh —
appshell/lib/store-persist.ts:59-64—hydrateBootdrops a persisted window only for single-instance apps; formultiAppsthe UrlSync-spawned live window and the persisted copy of the same window both survive, +1 per reload, unbounded. Fix: also drop a persisted multi-app window whose payload deep-equals a live one. (Re-verified by hand.) - No re-clamp of restored/free windows —
store-persist.ts:31-70restores raw rects; nothing listens to viewportresize;retileSnapped()only runs from the Windows-shell chrome insets. Shrink the browser → title bars land offscreen, unreachable. Fix: clamp inhydrate*+ debounced resize handler. - Visible stacking ignores
win.z—components/window.tsx:57gives all unfocused windowsz-10; DOM order = creation order. Focus an old window, click another → it sinks to creation depth, ⌘Tab "MRU" is actually creation-order,closeWindowfocuses by insertion. Fix: render sorted byz(or move-to-end oforderon focus).
Data integrity (apps)
- files-manager rename-to-existing silently destroys the target
(
hooks/use-file-commands.ts:94— POSIX rename clobbers; thetakenset is already available). Also: cut+paste into the same folder renames files in place (use-file-ops.ts:107-108), and failed listing renders as an empty folder with a "Drop files to upload" invite (use-files.ts:51-53). - image-editor paint-pixel loss cluster (
lib/doc-ops.ts:22-72): delete layer kills its canvas before the history push (undo restores blank); duplicate never copies pixels; crop re-bakes destructively; doc resize never resizes paint canvases. Plusblob:URLs serialized into autosave (menu-bar.tsx:52→ dead after reload, layers silently vanish) and window-global hotkeys (Backspace deletes a layer while another window is focused,hooks/use-keyboard.ts:38-46). - media-studio doc save is fire-and-forget and bypasses the os-api seam —
app.tsx:95-100void fetch("/api/v1/fs/write"): no.ok, no catch, hits live routes even in mock/demo. Close-prompt "Save" force-closes (discarding work) when export returns null (app.tsx:69). - code-editor stale-buffer cluster (
lib/use-editor.ts:36,57,102): reopened tab shows stale content then Save overwrites a newer host file; payload-open clobbers in-flight edits; optimisticsetDiskmakes a failed save unretryable; no close guard for dirty tabs; the Inspector "Save" action runs a stale closure (app.tsx:74-80). - prefs read-modify-write race —
lib/prefs/store.ts:38: two debounced section POSTs within ~1.5 s interleave; one section silently lost.
Streams / resources
- assistant: no abort seam end-to-end —
chat-panel.tsx:73,lib/ai/stream.ts:63-68,app/api/assistant/route.ts:82-105: closing the window keeps billing Anthropic tokens to completion; mid-stream error replaces the partial reply; switching in-app tabs unmounts and destroys the conversation. Fix: wirereq.signal+AbortController, append errors, lift messages out of component state. - browser: window close leaks remote Chromium pages —
lib/use-remote-browser.ts:139-144never callsapi.closeon unmount and the service reaper defaults off (os-browser/server.mjs:25,IDLE_MS=0). Also: service-down = eternal "Loading remote browser…" (lib/host.ts:49-55swallows errors, polls a dead endpoint forever); RemoteView is functionally desktop-only (no touch scroll/keyboard/zoom). - reel-editor: render outlives window close (
lib/use-export.ts— records black frames against a disposed MediaCache, then announces success); same-source audio clips share one GainNode (lib/media-audio.ts:43,98— one copy's envelope mutes the other); imported object URLs never revoked. - system-monitor: stats failure = infinite spinner +1 unhandled rejection
per 1.5 s (
lib/use-stats-history.ts:33-35); polling never pauses hidden.
Error reporting / misc
lib/os-apidiscards the server's JSON error body —http-adapter.ts:27throws\${status} ${statusText}`and statusText is empty on HTTP/2 → every live-mode error in the OS reads"403 "while the route's descriptive{error}is thrown away. **One fix improves every error message in the product.** Also:statsStreamandauth.*` adapter methods target routes that don't exist (mock masks it).- quicklinks hydrate trusts parsed shape —
lib/quicklinks/store.tsx:74(noArray.isArray): one bad localStorage row crashes dock + Launchpad + widget + Settings at once (theapplyServerpath has the guard). - login: errors invisible in the pending-device state
(
auth/components/login-screen.tsx:118— error<p>only renders in the!pendingbranch); unknown statuses all masquerade as "Password salah." - app-store: touch users uninstall by tapping "Installed" —
hover-revealed destructive swap, no hover on coarse pointers, no confirm
(
store-app-card.tsx:65-74,system-card.tsx:64-73). - create-app: empty name persisted while the preview shows a fallback
(
app.tsx:96); custom slug can collide with built-in app ids. - image-picker: link "verification" is theater —
LinkTab.tsx:20-25img.onerror = () => resolve()then selects unconditionally. - Phone-frame escape: Control Center uses a Radix Sheet portal to
document.body(fixed) so in framed mobile preview it covers the whole monitor (control-center.tsx:33-36); toasts likewise. - mobile-switcher mounts live
WindowContentper card —mobile-switcher.tsx:129-133: a second live instance of every open app (double PTY/screencast sessions) while the switcher is open, and nowinId→ close guards dead on mobile. Fix: static snapshot cards (desktopWindowOverviewalready does this).
3. Security (no P0/P1 — hardening list)
Verified solid: every /api/* route gates with verifyAuth/requireSession
first (coverage table checked route-by-route); realpath-before-bounds jail
with no working traversal/symlink escape (tmp+rename writes never write
through a symlink); timing-safe compares with fail-closed weak-secret
rejection; SameSite=Strict + Sec-Fetch-Site CSRF depth-2; ~/.mso
0700/0600 atomic writes; BYOK key masked; SVG served with CSP: sandbox;
demo mode can't be flipped into an open host shell.
- P2 —
OS_AGENT_TOKENis documented as browser-only but unlocks the entire host API (lib/agent/server.ts:81-84—verifyAuthaccepts it for exec / fs / term too; no expiry, no rotation, bypasses device approval). Either scope it to/api/v1/browser/*or rewrite.env.exampleto say "full host control". Also attribute its audit lines (currentlyactor: null). - P2 — sensitive-file denylist incomplete vs. its marketing
(
lib/host/paths.ts:62): blocks.ssh/.bash_historybut not.aws,.kube,.docker,.config/gcloud,.netrc,.git-credentials,.zsh_history. Extend or soften the README claim. - P2 — browser fill/type audit lines persist typed text —
lib/agent/server.ts:52-54: passwords typed into third-party sites via the Browser app land in plaintext in~/.mso/audit.log. Redact value/text. - P2 — child processes inherit the full secret env (
lib/host/exec.ts:89,pty.ts:90): oneprintenvrevealsOS_SESSION_SECRETetc. — defeats the denylist's stated purpose (persistence after revocation). ScrubOS_*+ANTHROPIC_API_KEYfrom child env. - P3 — login length-leak via the
a.length === b.lengthshort-circuit (hash both sides to fixed width first, as agent-token already does); no HSTS at app layer (set at the TLS proxy and document); device factor is a static JS-readable bearer id, not a challenge (acceptable single-owner, document it);/api/assistanthas no rate limit (owner's own spend). - Doc fix in your favor: README claims revoking a device doesn't kill live
sessions — it does (
getSessionre-checksisApprovedper request).
4. UX — cross-cutting patterns (the systemic stuff)
- Seven error-surface regimes. Terminal = inline red lines; Files = inline bar for mutations but swallowed for listings + toasts for uploads; browser = swallowed or success-styled; monitor = spinner-only; code-editor = status-bar text; assistant = injected into the reply bubble; Settings = toast for a passive read, silence for actionable failures. The shell toast bus exists and almost no app uses it. Pick one doctrine (inline for in-flow validation, toast bus for async/background, full-state for listings) and sweep.
- Destructive ops mostly unconfirmed. Trash-first exists only in Files
(no Restore). Zero confirm for: layer delete (one keystroke), agent/skill
delete, app uninstall (hover-mislabeled on touch), quicklink remove, device
revoke, "New project" wipe, dirty-tab close. media-studio's close guard
(
setCloseGuardveto + Save/Don't Save/Cancel) is the model — adopt it in code-editor and reel-editor first, where work loss hurts most.ResponsiveDialogwas built for this and has zero adopters; three apps still callwindow.confirm. - Shortcut chaos in both directions. Advertised-but-unbound: browser ⌘T/
⌘R (do the host browser action), image-editor ⌘S/⇧⌘S/⌘W/Enter-to-crop,
reel ⌘E/⌘D/⌘±. Inverse: window-global listeners firing when the app isn't
focused (code-editor ⌘S, image-editor Backspace, Space swallowed OS-wide).
The shell needs a focused-window-scoped hotkey capability; every app is
reinventing it wrong. Also:
Ctrl+Shift+V(clipboard overlay) and⌘I(inspector) fire inside inputs/terminal — both need theinEditable()guard that quick-look already uses. - i18n: exactly six Indonesian strings in an otherwise English product
(4 login errors,
"Gagal membuat app","App slug sudah dipakai"). Pick a locale per surface. - A11y: hand-rolled menus/tabs without roles or keyboard support
(files context menu, image-picker tabs, browser tabs, assistant tabs);
icon buttons unlabeled in media-viewer toolbar;
maximumScale: 1inapp/layout.tsx:20-21(WCAG 1.4.4); Files list-view keyboard-dead. - Stale slice.json metadata misleads — 8 slices still declare Convex deps
that don't exist (
auth/slice.jsondescribes a JWT/JWKS auth that isn't the real HMAC-cookie one); 3 contracts sayauth: "convex".
5. Performance
- Pollers without visibility gating: system-monitor 1.5 s ×2 requests,
capabilities CPU 4 s + sys/disk 3 s (one interval per mounted consumer —
menu-bar chip + Today widget poll concurrently), browser MJPEG screencast
never pauses (only the JPEG fallback checks
document.hidden). Gate all onvisibilitychange; share one poller per capability. - Re-render hotspots: every screencast frame re-renders the whole browser
chrome (
shotis top-level state); reel playbacksetFramere-renders the entire slice per frame (zeroReact.memo); code-editor re-tokenizes the full document per keystroke; assistant per-token full-array map + forcedscrollIntoView. - Store-subscription tearing class:
dock.tsx:37andmenu-bar-menus.tsx:126readshellStore.getWindow()during render while subscribed only toorder/focused→ stale dock hover lists / Window-menu marks onpatch()-only updates. Use per-windowuseWindow(id)(the taskbar already does it right). Related:registry.tsx:16,23unmemoized Map + fresh array defeats everyuseMemo(..., [apps])downstream;clipboard.ts:105/recents.ts:64return mutated module state asgetServerSnapshot(copyshells.tsx:131's constant pattern). - Memory: image-editor history holds up to 120 full-canvas data URLs; object-URL leaks in image-editor/reel/image-picker; reel MediaCache never evicts removed clips; Files streams full-resolution bytes as thumbnails, no virtualization (the one list that needs it).
- Deps:
tailwind-merge2.6 against Tailwind 4 (v2 targets v3 class tables —cn()conflict resolution can silently be wrong; bump to ^3); dual Radix import surface (5 files monolith vs 7 scoped) misaligned withoptimizePackageImports.
6. Developer experience / code quality
In good shape: 0 any / 0 ts-ignore across ~43k lines, clean
typecheck+lint+tests (136 in 1.1 s) + real-browser e2e harness, react-hooks
compiler rules at error, fs/exec correctly funneled through lib/host
(one exception), barrel architecture genuinely respected, .env.example
exemplary.
- ~1,870 dead lines: media-studio's pre-wrapper standalone editor
(
canvas-stage,tool-rail,studio-chrome,lib/use-studio,panel/*— zero importers since the image-editor wrap). Delete; it also removes ~10 raw<button>findings and a duplicate panel kit for free. - Rule violations: 2 files >200 lines (
lib/os-api/mock-adapter.ts294,lib/host/fs.ts206; two more riding exactly 200); ~22 hardcoded-hex classNames (code-editor's VSCode palette ×18, terminal ×4 — tokenize as--editor-*); 5 barrel violations (3× create-app →app-store/lib/glyphunexported, media-studio →image-editor/ui/slider,os-root.tsx→ os-shellintegrations/a11y-commandsunexported); 1 route bypasses lib/host (browser/agent-logre-implements audit-log path resolution — exportreadAuditTail()instead). - No
error.tsx/global-error.tsx/instrumentation.ts— a render error anywhere white-screens the whole cockpit with no retry (the SW self-heal only covers ChunkLoadError). Addapp/global-error.tsxwith a reload button. - Test gaps (the suite is good but misses):
lib/host/fs.ts(the actual clobbering surface),lib/auth/device-store.ts, storemulti/focusAppcontract, UrlSync dedup. - Docs/env drift:
.env.examplemissingOS_FS_ALLOW_SENSITIVE+OS_PREFS_PATH;ARCHITECTURE.md:14still shows the pre-catch-all layout; 8 Convex-era slice.json files. - Unused deps:
next-themes,@radix-ui/react-{label,popover,select}(umbrellaradix-uiused instead). Schedulelucide-react1.0 (renames). - Tooling gaps vs. the rr sibling: no formatter, no pre-commit hook (only pre-push), no dependency-audit step.
7. Recommended fix waves
| Wave | Theme | Items | Effort |
|---|---|---|---|
| 1 | Data safety | P0 #1–#5; files rename/cut-paste clobbers; image-editor doc-ops + blob-URL autosave; media-studio save through os-api; code-editor stale buffers + close guard | ~2 days |
| 2 | Shell correctness | resize offset commit; useSearch memo; hydrateBoot dedup; re-clamp on resize/boot; z-order by focus; mobile-switcher snapshots; phone-frame portals | ~1.5 days |
| 3 | Error doctrine | http-adapter error body (1 fix, OS-wide); listing/spinner failure states (Files, monitor, browser-offline); login pending-state errors; toast-bus sweep; abort seams (assistant + browser close) | ~1.5 days |
| 4 | Hygiene | delete media-studio dead cluster; tokenize editor hexes; barrel fixes; tailwind-merge ^3; global-error.tsx; env-example/docs drift; Convex-era slice.json; visibility-gated pollers | ~1 day |
| 5 | UX polish | focused-window hotkey capability + shortcut sweep; confirm/undo pass (ResponsiveDialog adoption); i18n single-locale; a11y roles on hand-rolled menus/tabs | ongoing |
Verification rule per CLAUDE.md: reproduce on demo :4006 first (e.g. the
+30 px resize jump, the Spotlight loop in the network tab), fix, then
pnpm build → restart, never the reverse.
8. What's genuinely good (keep doing this)
- The auth/jail core is among the cleanest implementations of this stack: per-request device revocation, fail-closed weak-secret rejection, SSE term stream with Last-Event-ID resume + heartbeat + abort cleanup.
- External-store discipline: 15+ pub/sub buses, all with stable snapshots, SSR guards, and leak-free unsubscribes.
- files-manager's stale-listing fix by derivation (
listing.key === loadKey) and the PTY lifecycle (serialized batches, keepalive close, 8-session cap + reaper) are the reference patterns for the rest. - Dock magnification math (constant-width gaussian pool, rAF outside React) and the capability/slot seam (defaults merged, accessors unconditional) are framework-grade.
- UnsplashTab's debounce + AbortController search is the best async snippet in the repo — copy it wherever fetch-on-type exists.