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(tui): a suspended panel really leaves the alternate screen, so an approval is readable (#205)
Abdurrahman Fakhrul46e1cccb3b38
diff --git a/app/login/page.tsx b/app/login/page.tsxindex 56de67e9..0edc6b1a 100644--- a/app/login/page.tsx+++ b/app/login/page.tsx@@ -1,5 +1,5 @@import { redirect } from "next/navigation";-import { ServerLoginPage } from "@/features/auth";+import { ServerLoginPage } from "@/features/auth/panels";import { getSessionContext } from "@/lib/auth/require-session";import { safeReturnPath } from "@/lib/auth/return-path";import { IS_DEMO } from "@/lib/demo";diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex f467e187..5a0b8ef8 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -8,7 +8,7 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh**Added**-- `tui` mid-turn writes go into the panel, and prompts suspend it instead of fighting it+- `tui` mid-turn writes go into the panel, and prompts suspend it instead of fighting it (#204)- `tui` the composer reports its height, so the panel stops guessing how much to reserve (#203)- `tui` one print sink, so command output lands in the panel instead of on top of it (#202)- `tui` a right-hand side pane for todos, the last diff and changed files (#198)@@ -20,10 +20,16 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh**Fixed**+- `gates` enforce the byte budget against a build of this tree- `tui` the two bugs a real pty found, and the test that found them (#201)- `ci` apply the same parser workaround to the last two mock call sites (#196)- `ci` stop the semgrep scan failing on a generic argument in a test mock (#195)+**Faster**++- `shell` take 26.7 KiB gzip off the eager graph+- `shell` pick one artwork variant instead of letting CSS hide two+**Changed**- `tui` paint the composer through a frame writer instead of appending (#189)diff --git a/frontend/slices/appshell/alfa.ts b/frontend/slices/appshell/alfa.tsnew file mode 100644index 00000000..be58ced6--- /dev/null+++ b/frontend/slices/appshell/alfa.ts@@ -0,0 +1,14 @@+export { AlfaThread } from "./components/alfa-thread";+export { ChatComposer } from "./components/chat-composer";+export * from "./lib/mentions";+export * from "./lib/alfa";+export * from "./lib/alfa-run-state";+export * from "./lib/alfa-approval-policy";+export { AlfaApprovalGrants } from "./components/alfa-approval-grants";+export { AlfaRunProgress } from "./components/alfa-run-progress";+export * from "./lib/alfa-sources";+export * from "./lib/alfa-approvals";+export * from "./lib/alfa-work-context";+export { MessageBubble } from "./components/message-bubble";+export type { ChatMessage, ToolCard } from "./components/message-bubble";+export { ApprovalCard } from "./components/approval-card";diff --git a/frontend/slices/appshell/defer-eager-boundaries.test.ts b/frontend/slices/appshell/defer-eager-boundaries.test.tsnew file mode 100644index 00000000..bb78165b--- /dev/null+++ b/frontend/slices/appshell/defer-eager-boundaries.test.ts@@ -0,0 +1,59 @@+import { describe, expect, it } from "vitest";+import { readFileSync } from "node:fs";++describe("Eager bundle boundaries", () => {+ it("keeps heavy auth panels out of the main auth barrel", () => {+ const authBarrel = readFileSync("frontend/slices/auth/index.ts", "utf8");+ const authPanels = readFileSync("frontend/slices/auth/panels.ts", "utf8");++ // Main barrel keeps only session + gate+ expect(authBarrel).toContain("AuthGate");+ expect(authBarrel).toContain("SessionProvider");+ expect(authBarrel).not.toContain("LoginScreen");+ expect(authBarrel).not.toContain("LoginCard");+ expect(authBarrel).not.toContain("DevicesPanel");+ expect(authBarrel).not.toContain("ServerLoginPage");++ // Panels subpath exports them+ expect(authPanels).toContain("LoginScreen");+ expect(authPanels).toContain("LoginCard");+ expect(authPanels).toContain("DevicesPanel");+ expect(authPanels).toContain("ServerLoginPage");+ });++ it("keeps Alfa/chat out of the main appshell barrel and isolates in alfa subpath", () => {+ const appshellBarrel = readFileSync("frontend/slices/appshell/index.ts", "utf8");+ const alfaBarrel = readFileSync("frontend/slices/appshell/alfa.ts", "utf8");++ // Main barrel keeps CopyButton and tiny alfa-loader, but NO Alfa components/stores+ expect(appshellBarrel).toContain("CopyButton");+ expect(appshellBarrel).toContain("registerAlfaLoader");+ expect(appshellBarrel).not.toContain("AlfaThread");+ expect(appshellBarrel).not.toContain("ChatComposer");+ expect(appshellBarrel).not.toContain("alfa-run-state");+ expect(appshellBarrel).not.toContain("alfa-approval-policy");+ expect(appshellBarrel).not.toContain("alfa-work-context");++ // Alfa subpath exports them+ expect(alfaBarrel).toContain("AlfaThread");+ expect(alfaBarrel).toContain("ChatComposer");+ expect(alfaBarrel).toContain("alfa-run-state");+ });++ it("defers widgets and shortcut-help while keeping lock-screen eager for security boundary", () => {+ const widgetsIndex = readFileSync("frontend/slices/appshell/features/widgets/index.ts", "utf8");+ const shortcutIndex = readFileSync("frontend/slices/appshell/features/shortcut-help/index.ts", "utf8");+ const lockIndex = readFileSync("frontend/slices/appshell/features/lock-screen/index.ts", "utf8");+ const lockScreenSource = readFileSync("frontend/slices/appshell/features/lock-screen/components/lock-screen.tsx", "utf8");++ expect(widgetsIndex).toContain("DeferredDesktopWidgets");+ expect(widgetsIndex).toContain("DeferredMobileWidgets");+ expect(shortcutIndex).toContain("DeferredShortcutHelp");++ // Security invariant: lock-screen remains eagerly mounted to preserve idle auto-lock+ // as enforced by frontend/slices/organization/bundle-boundary.test.ts+ expect(lockIndex).toContain('from "./components/lock-screen"');+ expect(lockScreenSource).toContain("autoLockMinutes");+ expect(lockScreenSource).toContain("setTimeout(lock");+ });+});diff --git a/frontend/slices/appshell/features/shortcut-help/deferred.tsx b/frontend/slices/appshell/features/shortcut-help/deferred.tsxnew file mode 100644index 00000000..26562542--- /dev/null+++ b/frontend/slices/appshell/features/shortcut-help/deferred.tsx@@ -0,0 +1,24 @@+"use client";++import { useEffect } from "react";+import { setShortcutHelpOpen, useShortcutHelpOpen } from "../../lib/shortcuts";+import { DeferredSurface } from "../../primitives/deferred-surface";++const load = () => import("./components/shortcut-help-overlay").then((module) => ({ default: module.ShortcutHelpOverlay }));++export function DeferredShortcutHelp() {+ const open = useShortcutHelpOpen();++ useEffect(() => {+ const onKey = (e: KeyboardEvent) => {+ if ((e.metaKey || e.ctrlKey) && e.key === "/") {+ e.preventDefault();+ setShortcutHelpOpen(!open);+ }+ };+ window.addEventListener("keydown", onKey);+ return () => window.removeEventListener("keydown", onKey);+ }, [open]);++ return <DeferredSurface active={open} load={load} label="Keyboard shortcuts" />;+}diff --git a/frontend/slices/appshell/features/shortcut-help/index.ts b/frontend/slices/appshell/features/shortcut-help/index.tsindex b0557c94..0eadae14 100644--- a/frontend/slices/appshell/features/shortcut-help/index.ts+++ b/frontend/slices/appshell/features/shortcut-help/index.ts@@ -1,8 +1,8 @@import { defineFeature } from "../../registry/types";-import { ShortcutHelpOverlay } from "./components/shortcut-help-overlay";+import { DeferredShortcutHelp } from "./deferred";// Keyboard-shortcut cheat sheet — ⌘/ overlay over lib/shortcuts.export const shortcutHelpFeature = defineFeature({id: "shortcut-help",- slots: { overlay: ShortcutHelpOverlay },+ slots: { overlay: DeferredShortcutHelp },});diff --git a/frontend/slices/appshell/features/widgets/components/desktop-widgets.tsx b/frontend/slices/appshell/features/widgets/components/desktop-widgets.tsxindex a41dfa98..0c80cfe4 100644--- a/frontend/slices/appshell/features/widgets/components/desktop-widgets.tsx+++ b/frontend/slices/appshell/features/widgets/components/desktop-widgets.tsx@@ -3,16 +3,12 @@import { createElement, useEffect, useRef, useState, type CSSProperties } from "react";import { Check, LayoutGrid, Trash2 } from "lucide-react";import { ContextMenu, useContextMenu } from "../../../components/shells/context-menu";-import { registerCommands } from "../../../lib/commands";-import { registerContextMenu, type MenuItem } from "../../../lib/context-menu";-import { toast } from "../../../lib/toast";+import type { MenuItem } from "../../../lib/context-menu";import { cn } from "@/lib/utils";import {- getWidgetState,setPickerOpen,setWidgetPos,setWidgetSize,- setWidgetsOn,toggleWidget,useWidgetState,type WidgetPos,@@ -26,31 +22,6 @@ import { WidgetPicker } from "./widget-picker";// removes it. Layout + membership live in the widget-registry store; the// WidgetPicker (live-preview gallery) edits membership.-registerCommands("desktop-widgets", [- {- id: "widgets:desktop",- label: "Toggle desktop widgets",- hint: "Widgets",- keywords: "glance dashboard wallpaper stats",- run: () => {- const next = !getWidgetState().on;- setWidgetsOn(next);- toast(next ? "Desktop widgets on" : "Desktop widgets off");- },- },- {- id: "widgets:configure",- label: "Configure desktop widgets",- hint: "Widgets",- keywords: "desktop widget picker add remove reorder",- run: () => setPickerOpen(true),- },-]);--registerContextMenu("macos", () => [- { label: "Desktop widgets…", icon: LayoutGrid, onClick: () => setPickerOpen(true) },-]);-const SIZE_W: Record<WidgetSize, string> = { s: "w-44", m: "w-60", l: "w-72" };const SIZE_PX: Record<WidgetSize, number> = { s: 176, m: 240, l: 288 };diff --git a/frontend/slices/appshell/features/widgets/deferred.tsx b/frontend/slices/appshell/features/widgets/deferred.tsxnew file mode 100644index 00000000..697fdc7c--- /dev/null+++ b/frontend/slices/appshell/features/widgets/deferred.tsx@@ -0,0 +1,52 @@+"use client";++import { LayoutGrid } from "lucide-react";+import { registerCommands } from "../../lib/commands";+import { registerContextMenu } from "../../lib/context-menu";+import { toast } from "../../lib/toast";+import {+ getWidgetState,+ setPickerOpen,+ setWidgetsOn,+ usePickerOpen,+ useWidgetState,+} from "./widget-registry";+import { DeferredSurface } from "../../primitives/deferred-surface";++registerCommands("desktop-widgets", [+ {+ id: "widgets:desktop",+ label: "Toggle desktop widgets",+ hint: "Widgets",+ keywords: "glance dashboard wallpaper stats",+ run: () => {+ const next = !getWidgetState().on;+ setWidgetsOn(next);+ toast(next ? "Desktop widgets on" : "Desktop widgets off");+ },+ },+ {+ id: "widgets:configure",+ label: "Configure desktop widgets",+ hint: "Widgets",+ keywords: "desktop widget picker add remove reorder",+ run: () => setPickerOpen(true),+ },+]);++registerContextMenu("macos", () => [+ { label: "Desktop widgets…", icon: LayoutGrid, onClick: () => setPickerOpen(true) },+]);++const loadDesktop = () => import("./components/desktop-widgets").then((m) => ({ default: m.DesktopWidgets }));+const loadMobile = () => import("./components/mobile-widgets").then((m) => ({ default: m.MobileWidgets }));++export function DeferredDesktopWidgets() {+ const { on } = useWidgetState();+ const pickerOpen = usePickerOpen();+ return <DeferredSurface active={on || pickerOpen} load={loadDesktop} label="Desktop Widgets" keepMounted />;+}++export function DeferredMobileWidgets() {+ return <DeferredSurface active={true} load={loadMobile} label="Widgets" keepMounted />;+}diff --git a/frontend/slices/appshell/features/widgets/index.ts b/frontend/slices/appshell/features/widgets/index.tsindex f18dfeec..b3eec44d 100644--- a/frontend/slices/appshell/features/widgets/index.ts+++ b/frontend/slices/appshell/features/widgets/index.ts@@ -1,10 +1,9 @@import { defineFeature } from "../../registry/types";-import { MobileWidgets } from "./components/mobile-widgets";-import { DesktopWidgets } from "./components/desktop-widgets";+import { DeferredDesktopWidgets, DeferredMobileWidgets } from "./deferred";// Widgets — the iOS "Today" page (mobile home pager) + the desktop// wallpaper-layer widget stack (opt-in, behind every window).export const widgetsFeature = defineFeature({id: "widgets",- slots: { today: MobileWidgets, desktopWidgets: DesktopWidgets },+ slots: { today: DeferredMobileWidgets, desktopWidgets: DeferredDesktopWidgets },});diff --git a/frontend/slices/appshell/index.ts b/frontend/slices/appshell/index.tsindex 49f98204..66f29c0c 100644--- a/frontend/slices/appshell/index.ts+++ b/frontend/slices/appshell/index.ts@@ -119,20 +119,7 @@ export type {export type { Toast, ToastOptions, ToastTone } from "./lib/toast";export type { AppDescriptor, AppIconComponent, AppMenu, AppMenuItem, WindowState, WinId, AppProps } from "./lib/types";export { CopyButton } from "./components/copy-button";-export { AlfaThread } from "./components/alfa-thread";-export { ChatComposer } from "./components/chat-composer";-export * from "./lib/mentions";-export * from "./lib/alfa";-export * from "./lib/alfa-run-state";-export * from "./lib/alfa-approval-policy";-export { AlfaApprovalGrants } from "./components/alfa-approval-grants";-export { AlfaRunProgress } from "./components/alfa-run-progress";-export * from "./lib/alfa-sources";-export * from "./lib/alfa-approvals";-export * from "./lib/alfa-work-context";-export { MessageBubble } from "./components/message-bubble";-export type { ChatMessage, ToolCard } from "./components/message-bubble";-export { ApprovalCard } from "./components/approval-card";+export { registerAlfaLoader } from "./lib/alfa-loader";export {registerShell,diff --git a/frontend/slices/appshell/lib/alfa-loader.ts b/frontend/slices/appshell/lib/alfa-loader.tsnew file mode 100644index 00000000..707e8ccc--- /dev/null+++ b/frontend/slices/appshell/lib/alfa-loader.ts@@ -0,0 +1,18 @@+"use client";++// Loader registration for lazy-loaded Alfa sources (skills, agent catalog).+let loader: (() => void | Promise<void>) | null = null;+let loaderStarted = false;++export function registerAlfaLoader(fn: () => void | Promise<void>): void {+ loader = fn;+}++export function triggerAlfaLoader(): void {+ if (loader && !loaderStarted) {+ loaderStarted = true;+ void Promise.resolve(loader()).catch(() => {+ loaderStarted = false;+ });+ }+}diff --git a/frontend/slices/appshell/lib/alfa-sources.ts b/frontend/slices/appshell/lib/alfa-sources.tsindex 537e3dab..1777dce2 100644--- a/frontend/slices/appshell/lib/alfa-sources.ts+++ b/frontend/slices/appshell/lib/alfa-sources.ts@@ -1,6 +1,9 @@"use client";import type { MentionItem } from "./mentions";+import { triggerAlfaLoader } from "./alfa-loader";++export { registerAlfaLoader } from "./alfa-loader";// Completion sources for the composer's @ and / menus. Same seam as the runner and// for the same reason: agents live in the assistant slice's localStorage store and@@ -25,17 +28,6 @@ let sources: AlfaSources = NO_SOURCES;const subs = new Set<() => void>();let version = 0;-// The consumer's source module is worth ~88 KB of chunk (tool catalog, its run()-// closures, agent presets) and NOTHING renders it until an AI composer exists. So-// the consumer registers a LOADER instead of importing eagerly, and the first-// composer render is what pulls it in.-let loader: (() => void | Promise<void>) | null = null;-let loaderStarted = false;--export function registerAlfaLoader(fn: () => void | Promise<void>): void {- loader = fn;-}-export function registerAlfaSources(next: AlfaSources): void {sources = next;notifyAlfaSources();@@ -61,12 +53,6 @@ export function alfaSourcesVersion(): number {}export function alfaSources(): AlfaSources {- if (loader && !loaderStarted) {- loaderStarted = true;- // Fire and forget: the loader calls registerAlfaSources, which notifies.- void Promise.resolve(loader()).catch(() => {- loaderStarted = false; // a failed chunk may succeed on the next open- });- }+ triggerAlfaLoader();return sources;}diff --git a/frontend/slices/assistant/components/alfa-cockpit-bar.tsx b/frontend/slices/assistant/components/alfa-cockpit-bar.tsxindex 2dae36c0..4f8f73f9 100644--- a/frontend/slices/assistant/components/alfa-cockpit-bar.tsx+++ b/frontend/slices/assistant/components/alfa-cockpit-bar.tsx@@ -3,7 +3,7 @@import { useState } from "react";import { Activity, FolderGit2, Gauge, ShieldCheck } from "lucide-react";import { Button } from "@/components/ui/button";-import { useAlfaApprovalCount, useAlfaBusy } from "@/features/appshell";+import { useAlfaApprovalCount, useAlfaBusy } from "@/features/appshell/alfa";import { useAlfaCockpit } from "./use-alfa-cockpit";import { AlfaCockpitDialog } from "./alfa-cockpit-dialog";diff --git a/frontend/slices/assistant/components/alfa-cockpit-dialog.tsx b/frontend/slices/assistant/components/alfa-cockpit-dialog.tsxindex 1d326741..2d1534e3 100644--- a/frontend/slices/assistant/components/alfa-cockpit-dialog.tsx+++ b/frontend/slices/assistant/components/alfa-cockpit-dialog.tsx@@ -3,7 +3,8 @@import { Activity, Brain, Bot, Cpu, FolderGit2, RefreshCw, Settings2 } from "lucide-react";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";-import { ResponsiveDialog, openWindow, sendToAlfa } from "@/features/appshell";+import { ResponsiveDialog, openWindow } from "@/features/appshell";+import { sendToAlfa } from "@/features/appshell/alfa";import type { AlfaCockpitData, HostSkillRow } from "../lib/cockpit-types";import { HostSkillsSection } from "./host-skills-section";import { ModelQuickControl } from "./model-quick-control";diff --git a/frontend/slices/assistant/components/chat-panel.tsx b/frontend/slices/assistant/components/chat-panel.tsxindex 6539e22d..644e0ec9 100644--- a/frontend/slices/assistant/components/chat-panel.tsx+++ b/frontend/slices/assistant/components/chat-panel.tsx@@ -11,26 +11,19 @@ import {import { ScrollArea } from "@/components/ui/scroll-area";import { cn } from "@/lib/utils";import { errText } from "./error-text";+import { useActiveShell } from "@/features/appshell";import {- updateAlfa,- useActiveShell,- useAlfaMessages,- awaitAlfaApproval,- resolveAlfaApproval,- clearAlfaApprovals,- useAlfaBusy,- sendToAlfa,- ChatComposer,- type AlfaMessage-} from "@/features/appshell";-import { AlfaRunProgress, AlfaApprovalGrants, alfaRunState, setAlfaOperation, pulseAlfaRun, recordAlfaRunActivity, endAlfaRunState, stopAlfaRunState } from "@/features/appshell";+ updateAlfa, useAlfaMessages, awaitAlfaApproval, resolveAlfaApproval, clearAlfaApprovals,+ useAlfaBusy, sendToAlfa, ChatComposer, type AlfaMessage, AlfaRunProgress, AlfaApprovalGrants,+ alfaRunState, setAlfaOperation, pulseAlfaRun, recordAlfaRunActivity, endAlfaRunState,+ stopAlfaRunState, type ChatMessage, type ToolCard, alfaProjectContext,+} from "@/features/appshell/alfa";import { runToolAgent, useOsApi, type AgentMsg } from "../lib/host";import type { Agent, Automation } from "../lib/types";import { activeAgent } from "../lib/store";import { composeSystem } from "../lib/agent-request";import { composeAutomationRequest } from "../lib/automation-request";import { useHostCommands, type HostToolUi } from "../host-tools/use-host-commands";-import { type ChatMessage, type ToolCard } from "@/features/appshell";import { ChatTranscript } from "./chat-transcript";import { TurnUsage } from "./turn-usage";import { useTurnUsage } from "./use-turn-usage";@@ -39,7 +32,6 @@ import { EmptyState } from "./empty-state";import { useThreadPersistence } from "./use-thread-persistence";import { useAlfaRunner } from "./use-alfa-runner";import { beginAlfaRun, finishAlfaRun } from "../lib/alfa-activity";-import { alfaProjectContext } from "@/features/appshell";const SUGGESTED = ["Show system stats", "List ~/projects", "Create notes.txt in ~/projects with a TODO"];diff --git a/frontend/slices/assistant/components/chat-transcript.tsx b/frontend/slices/assistant/components/chat-transcript.tsxindex 5f8703d3..f28a62b4 100644--- a/frontend/slices/assistant/components/chat-transcript.tsx+++ b/frontend/slices/assistant/components/chat-transcript.tsx@@ -1,6 +1,6 @@"use client";-import { ApprovalCard, MessageBubble, type ChatMessage } from "@/features/appshell";+import { ApprovalCard, MessageBubble, type ChatMessage } from "@/features/appshell/alfa";function legacyMessageTime(id: string): number | undefined {const match = /^m(\d+)-/.exec(id);diff --git a/frontend/slices/assistant/components/use-alfa-cockpit.ts b/frontend/slices/assistant/components/use-alfa-cockpit.tsindex db7348a5..4ae2e5ff 100644--- a/frontend/slices/assistant/components/use-alfa-cockpit.ts+++ b/frontend/slices/assistant/components/use-alfa-cockpit.ts@@ -5,7 +5,7 @@ import {setAlfaProjectContext,setAlfaSelectedProject,useAlfaSelectedProject,-} from "@/features/appshell";+} from "@/features/appshell/alfa";import type { AlfaCockpitData } from "../lib/cockpit-types";function publishProjectContext(data: AlfaCockpitData | null) {diff --git a/frontend/slices/assistant/components/use-alfa-runner.ts b/frontend/slices/assistant/components/use-alfa-runner.tsindex b732c04e..049ccd3f 100644--- a/frontend/slices/assistant/components/use-alfa-runner.ts+++ b/frontend/slices/assistant/components/use-alfa-runner.ts@@ -1,7 +1,7 @@"use client";import { useEffect, useRef } from "react";-import { registerAlfaRunner, registerAlfaStop, unregisterAlfaRunner } from "@/features/appshell";+import { registerAlfaRunner, registerAlfaStop, unregisterAlfaRunner } from "@/features/appshell/alfa";/*** Publish this panel as THE Alfa engine while it is mounted, so the per-app Alfadiff --git a/frontend/slices/assistant/components/use-thread-persistence.ts b/frontend/slices/assistant/components/use-thread-persistence.tsindex 5cf30137..3c84b822 100644--- a/frontend/slices/assistant/components/use-thread-persistence.ts+++ b/frontend/slices/assistant/components/use-thread-persistence.ts@@ -2,8 +2,8 @@import { useCallback, useRef, type Dispatch, type SetStateAction } from "react";import type { AgentMsg } from "../lib/host";-import type { ChatMessage } from "@/features/appshell";-import { clearAlfaRunState, newAlfaApprovalSession } from "@/features/appshell";+import type { ChatMessage } from "@/features/appshell/alfa";+import { clearAlfaRunState, newAlfaApprovalSession } from "@/features/appshell/alfa";type LoadArg = { id: string; title?: string; createdAt: number; messages: unknown[]; history: unknown[] };diff --git a/frontend/slices/assistant/host-tools/use-host-commands.ts b/frontend/slices/assistant/host-tools/use-host-commands.tsindex 0ab02764..09f9320e 100644--- a/frontend/slices/assistant/host-tools/use-host-commands.ts+++ b/frontend/slices/assistant/host-tools/use-host-commands.ts@@ -3,8 +3,16 @@import { useMemo, useRef } from "react";import { matchDestructive, useOsApi } from "../lib/host";import type { AiTool, ToolInvocation, ToolOutcome } from "../lib/host";-import { useApps, type ToolCard } from "@/features/appshell";-import { alfaRunState, alfaProjectContext, alfaApprovalScope, alfaApprovalKey, hasAlfaApproval, rememberAlfaApproval } from "@/features/appshell";+import { useApps } from "@/features/appshell";+import {+ type ToolCard,+ alfaRunState,+ alfaProjectContext,+ alfaApprovalScope,+ alfaApprovalKey,+ hasAlfaApproval,+ rememberAlfaApproval,+} from "@/features/appshell/alfa";import { findHostTool, HOST_AI_TOOLS } from "./registry";import { recordAlfaTool } from "../lib/alfa-activity";diff --git a/frontend/slices/assistant/lib/alfa-sources.ts b/frontend/slices/assistant/lib/alfa-sources.tsindex 12a2b900..a031d16e 100644--- a/frontend/slices/assistant/lib/alfa-sources.ts+++ b/frontend/slices/assistant/lib/alfa-sources.ts@@ -1,6 +1,6 @@"use client";-import { notifyAlfaSources, registerAlfaSources, type MentionItem } from "@/features/appshell";+import { notifyAlfaSources, registerAlfaSources, type MentionItem } from "@/features/appshell/alfa";import { HOST_TOOLS } from "../host-tools/catalog";import { activeAgent, agentList, setActiveAgentId } from "./store";diff --git a/frontend/slices/auth/index.ts b/frontend/slices/auth/index.tsindex 77a0745e..1042655f 100644--- a/frontend/slices/auth/index.ts+++ b/frontend/slices/auth/index.ts@@ -1,8 +1,5 @@// Barrel — the app layer imports the gate + session from here.-export { AuthGate } from "./components/auth-gate";-export { openOnboarding } from "./components/auth-gate";-export { LoginScreen, LoginCard } from "./components/login-screen";-export { DevicesPanel } from "./components/devices-panel";+export { AuthGate, openOnboarding } from "./components/auth-gate";export { SessionProvider, useSession, type SessionStatus } from "./lib/use-session";export type { DeviceRole } from "@/lib/auth/roles";-export { ServerLoginPage } from "./components/login-page";+diff --git a/frontend/slices/auth/panels.ts b/frontend/slices/auth/panels.tsnew file mode 100644index 00000000..9e856442--- /dev/null+++ b/frontend/slices/auth/panels.ts@@ -0,0 +1,3 @@+export { LoginScreen, LoginCard } from "./components/login-screen";+export { DevicesPanel } from "./components/devices-panel";+export { ServerLoginPage } from "./components/login-page";diff --git a/frontend/slices/os-settings/components/devices-sign-in-dialog.tsx b/frontend/slices/os-settings/components/devices-sign-in-dialog.tsxindex b9cefde2..ed9bd1d4 100644--- a/frontend/slices/os-settings/components/devices-sign-in-dialog.tsx+++ b/frontend/slices/os-settings/components/devices-sign-in-dialog.tsx@@ -1,7 +1,7 @@"use client";import { ResponsiveDialog } from "@/features/appshell";-import { LoginCard } from "@/features/auth";+import { LoginCard } from "@/features/auth/panels";/** Sign-in prompt used by the Devices host card when a live/SSH target is selected* while signed out. Split out of devices-host-card.tsx for the 220-line cap. */diff --git a/frontend/slices/os-settings/components/sections.tsx b/frontend/slices/os-settings/components/sections.tsxindex 53f0678e..3ae04c77 100644--- a/frontend/slices/os-settings/components/sections.tsx+++ b/frontend/slices/os-settings/components/sections.tsx@@ -5,7 +5,8 @@ import dynamic from "next/dynamic";import { Button } from "@/components/ui/button";import { ScrollArea } from "@/components/ui/scroll-area";import { useActiveShell } from "@/features/appshell";-import { DevicesPanel, useSession } from "@/features/auth";+import { useSession } from "@/features/auth";+import { DevicesPanel } from "@/features/auth/panels";import { SettingsSection } from "@/features/shell-settings";import { cn } from "@/lib/utils";import { Lock, ShieldCheck } from "lucide-react";diff --git a/frontend/slices/os-shell/brand-marks.test.tsx b/frontend/slices/os-shell/brand-marks.test.tsxindex d1aa43b6..93bfd97a 100644--- a/frontend/slices/os-shell/brand-marks.test.tsx+++ b/frontend/slices/os-shell/brand-marks.test.tsx@@ -1,10 +1,18 @@import { renderToStaticMarkup } from "react-dom/server";import { describe, expect, it } from "vitest";+import { ActiveShellProvider, type ShellId } from "@/features/appshell";import { APP_MARKS } from "./brand-marks";-function markup(id: string) {+function markup(id: string, shell?: { id: ShellId; surface?: "desktop" | "mobile" }) {const Icon = APP_MARKS[id];if (!Icon) throw new Error(`missing app mark ${id}`);+ if (shell) {+ return renderToStaticMarkup(+ <ActiveShellProvider id={shell.id} surface={shell.surface ?? "desktop"}>+ <Icon className="size-full" />+ </ActiveShellProvider>,+ );+ }return renderToStaticMarkup(<Icon className="size-full" />);}@@ -19,13 +27,69 @@ describe("third-party official app marks", () => {expect(html).toContain(`src="${src}"`);expect(html).not.toContain("shell-artwork-macos");expect(html).not.toContain("shell-artwork-windows");+ expect((html.match(/<img\b/g) ?? []).length).toBe(1);});+});- it("keeps first-party app artwork platform-aware", () => {+describe("first-party platform app artwork", () => {+ it("defaults to macOS artwork outside a provider (isolated tests)", () => {const html = markup("files-manager");+ expect((html.match(/<img\b/g) ?? []).length).toBe(1);+ expect(html).toContain("/app-icons/macos/files.webp");+ expect(html).toContain("shell-artwork-macos");+ expect(html).not.toContain("/app-icons/windows/files.webp");+ expect(html).not.toContain("/app-icons/files.webp");+ });++ it("renders macOS artwork for macOS shell", () => {+ const html = markup("files-manager", { id: "macos" });+ expect((html.match(/<img\b/g) ?? []).length).toBe(1);expect(html).toContain("/app-icons/macos/files.webp");- expect(html).toContain("/app-icons/windows/files.webp");expect(html).toContain("shell-artwork-macos");+ expect(html).not.toContain("/app-icons/windows/files.webp");+ });++ it("reuses macOS artwork family for iOS shell", () => {+ const html = markup("files-manager", { id: "ios", surface: "mobile" });+ expect((html.match(/<img\b/g) ?? []).length).toBe(1);+ expect(html).toContain("/app-icons/macos/files.webp");+ expect(html).toContain("shell-artwork-macos");+ expect(html).not.toContain("/app-icons/windows/files.webp");+ expect(html).not.toContain("/app-icons/files.webp");+ });++ it("renders Windows artwork for Windows shell", () => {+ const html = markup("files-manager", { id: "windows" });+ expect((html.match(/<img\b/g) ?? []).length).toBe(1);+ expect(html).toContain("/app-icons/windows/files.webp");+ expect(html).toContain("shell-artwork-windows");+ expect(html).not.toContain("/app-icons/macos/files.webp");+ });++ it("reuses Windows artwork family for Android shell", () => {+ const html = markup("files-manager", { id: "android", surface: "mobile" });+ expect((html.match(/<img\b/g) ?? []).length).toBe(1);+ expect(html).toContain("/app-icons/windows/files.webp");expect(html).toContain("shell-artwork-windows");+ expect(html).not.toContain("/app-icons/macos/files.webp");+ expect(html).not.toContain("/app-icons/files.webp");+ });++ it("falls back to default artwork for dashboard shell", () => {+ const html = markup("files-manager", { id: "dashboard" });+ expect((html.match(/<img\b/g) ?? []).length).toBe(1);+ expect(html).toContain("/app-icons/files.webp");+ expect(html).toContain("shell-artwork-default");+ expect(html).not.toContain("/app-icons/macos/files.webp");+ expect(html).not.toContain("/app-icons/windows/files.webp");+ });++ it("falls back to default artwork for unknown shell", () => {+ const html = markup("files-manager", { id: "unknown" as ShellId });+ expect((html.match(/<img\b/g) ?? []).length).toBe(1);+ expect(html).toContain("/app-icons/files.webp");+ expect(html).toContain("shell-artwork-default");+ expect(html).not.toContain("/app-icons/macos/files.webp");+ expect(html).not.toContain("/app-icons/windows/files.webp");});});diff --git a/frontend/slices/os-shell/brand-marks.tsx b/frontend/slices/os-shell/brand-marks.tsxindex 8a64f7a4..9ad495d2 100644--- a/frontend/slices/os-shell/brand-marks.tsx+++ b/frontend/slices/os-shell/brand-marks.tsx@@ -1,11 +1,13 @@+"use client";+// MSO app artwork.//// Raster app artwork is intentionally WebP. Toolbar/menu/control glyphs stay// vector (Lucide), while app icons are allowed to carry richer platform-specific// illustration. macOS and Windows do NOT share the same art direction: the shell-// chooses the correct image through data-shell CSS. Mobile intentionally reuses+// chooses the correct image via useActiveShell(). Mobile intentionally reuses// those families: iOS = macOS artwork, Android = Windows artwork.-import type { AppIconComponent } from "@/features/appshell";+import { useActiveShell, type AppIconComponent } from "@/features/appshell";/** An official third-party brand mark is shell-invariant by definition. */function officialMark(src: string): AppIconComponent {@@ -22,20 +24,28 @@ function officialMark(src: string): AppIconComponent {function platformMark(fallback: string, macos: string, windows: string): AppIconComponent {const Mark: AppIconComponent = ({ className: cls }) => {const size = cls ?? "size-full";- // All three variants are in the markup because the shell family is only known- // after hydration (SSR would guess, and a guess here is a hydration mismatch).- // What the markup CAN say without guessing: these are decorative. So the hidden- // variants are low priority and never blocking, and the visible one is decoded- // asynchronously. The download itself is left to the browser: `loading="lazy"`- // here would demote the very image mobile measures LCP on.+ const { id: shellId } = useActiveShell();++ let src = fallback;+ let variant = "default";+ if (shellId === "macos" || shellId === "ios") {+ src = macos;+ variant = "macos";+ } else if (shellId === "windows" || shellId === "android") {+ src = windows;+ variant = "windows";+ }+return (<span className={`shell-platform-mark relative block ${size}`} aria-hidden>{/* eslint-disable-next-line @next/next/no-img-element */}- <img src={fallback} alt="" className="shell-artwork shell-artwork-default" draggable={false} decoding="async" fetchPriority="low" />- {/* eslint-disable-next-line @next/next/no-img-element */}- <img src={macos} alt="" className="shell-artwork shell-artwork-macos" draggable={false} decoding="async" fetchPriority="low" />- {/* eslint-disable-next-line @next/next/no-img-element */}- <img src={windows} alt="" className="shell-artwork shell-artwork-windows" draggable={false} decoding="async" fetchPriority="low" />+ <img+ src={src}+ alt=""+ className={`shell-artwork shell-artwork-${variant}`}+ draggable={false}+ decoding="async"+ /></span>);};diff --git a/lib/config/env-example.test.ts b/lib/config/env-example.test.tsindex 9d7db6d8..ca6f73c7 100644--- a/lib/config/env-example.test.ts+++ b/lib/config/env-example.test.ts@@ -23,6 +23,9 @@ const NOT_A_KNOB: Record<string, string> = {NODE_ENV: "standard Node/Next process mode; artifact maintenance starts only in production",NEXT_PUBLIC_BUILD_ID: "injected by next.config.mjs at build time",MSO_RUNTIME_INSTANCE_ID: "injected by the installer-managed service to prove restart readiness",+ // Set by scripts/verify-build.sh in the out-of-tree archive it just built, so the+ // bundle budget knows those bytes describe that source rather than a stale .next.+ MSO_BUNDLE_BUILD_IS_CURRENT: "set by scripts/verify-build.sh for its own out-of-tree build; never user configuration",// Private launcher-to-agent handoff. scripts/mso-cli-agent.sh owns these; users// should configure the public CLI knobs instead of persisting these in .env.local.MSO_AGENT_BASE: "internal mso-cli-agent launcher handoff for the selected loopback API base",diff --git a/scripts/bundle-budget.json b/scripts/bundle-budget.jsonindex be14dd7b..47315677 100644--- a/scripts/bundle-budget.json+++ b/scripts/bundle-budget.json@@ -1,8 +1,8 @@{- "note": "Derived arithmetically from measured production build on 2026-10-29. Framework floor is 132,670 B gzip (react-dom 73,603 + Next client 44,229 + next/navigation 8,167 + turbopack 4,390 + next-isr 2,281). App code entry is 155,048 B gzip; +2.0% headroom (3,101 B) sets entry ceiling to 158,149 B. Initial ceiling is framework floor + entry ceiling = 290,819 B gzip (+3,101 B / 1.08% headroom over 287,718 B actual). Preloaded font is 69,652 B raw; +2.0% headroom (1,393 B) sets preloadedFontBytes to 71,045 B. CSS is 30,705 B gzip; +2.0% headroom (614 B) sets CSS ceiling to 31,319 B.",+ "note": "Derived arithmetically from measured production build. Framework floor is 132,679 B gzip (react-dom, Next client, next/navigation, turbopack, next-isr) and is untouched by app code. Entry is the eager app graph: 158,149 B in the 2026-10-29 build, 119,540 B after the 2026-10-31 eager-graph trim (widgets/shortcut-help deferred, Alfa/chat and auth panels moved to subpath barrels), with +2.0% headroom. Initial ceiling is framework floor + entry ceiling. Preloaded font is 69,652 B raw; +2.0% headroom sets preloadedFontBytes to 71,045 B. CSS is 30,721 B gzip; +2.0% headroom sets CSS ceiling to 31,319 B.","gzipBytes": {- "initial": 290819,- "entry": 158149,+ "initial": 252219,+ "entry": 119540,"css": 31319},"preloadedFontBytes": 71045diff --git a/scripts/check-bundle-stale.test.ts b/scripts/check-bundle-stale.test.tsnew file mode 100644index 00000000..65d46dae--- /dev/null+++ b/scripts/check-bundle-stale.test.ts@@ -0,0 +1,78 @@+import { spawnSync } from "node:child_process";+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import os from "node:os";+import path from "node:path";+import { afterEach, describe, expect, it } from "vitest";++// The stale-build guard exists because `.next` is never built in place here (an in-place+// build takes the live :4005 service down), so the gate reads whatever was built last —+// usually a different commit. A tightened budget then fails against bytes that describe+// history, and the failure reads like a regression. Two things must hold: a stale build+// says so explicitly, and an authoritative build is not second-guessed.++const roots: string[] = [];+afterEach(() => {+ for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true });+});++/** A repo-shaped dir holding a copy of check-bundle.mjs plus a fake `.next`. */+function fixture() {+ const root = mkdtempSync(path.join(os.tmpdir(), "mso-stale-bundle-"));+ roots.push(root);+ mkdirSync(path.join(root, "scripts"), { recursive: true });+ mkdirSync(path.join(root, ".next"), { recursive: true });+ writeFileSync(path.join(root, ".next/BUILD_ID"), "fixture");+ // Budget 0 forces a violation whatever the measured bytes are; the point under test is+ // which MESSAGE comes out, not the numbers.+ writeFileSync(+ path.join(root, "scripts/bundle-budget.json"),+ JSON.stringify({ gzipBytes: { initial: 0, entry: 0, css: 0 }, preloadedFontBytes: 0 }, null, 2),+ );+ writeFileSync(+ path.join(root, "scripts/lib-bundle-report-stub.mjs"),+ `export function readBundleReport() {+ return { initial: { gzip: 10 }, entry: { gzip: 10 }, css: { gzip: 10, bytes: 0, files: 0 },+ fonts: { bytes: 0, files: 0 }, initialHeavyModules: [] };+}+export function bundleViolations() { return ['entry: 10 gzip bytes > 0']; }`,+ );+ writeFileSync(path.join(root, "package.json"), JSON.stringify({ type: "module" }));+ return root;+}++const SCRIPT = new URL("./check-bundle.mjs", import.meta.url).pathname;++function run(root: string, env: Record<string, string> = {}) {+ // Point the script's imports at the stub by running a rewritten copy.+ const source = readFileSync(SCRIPT, "utf8").replace("./lib/bundle-report.mjs", "./lib-bundle-report-stub.mjs");+ writeFileSync(path.join(root, "scripts/check-bundle-copy.mjs"), source);+ return spawnSync(process.execPath, ["scripts/check-bundle-copy.mjs"], {+ cwd: root,+ encoding: "utf8",+ env: { ...process.env, ...env },+ });+}++describe("check-bundle stale-build guard", () => {+ it("names a stale build instead of reporting a bare regression", () => {+ const root = fixture();+ const git = (...args: string[]) => spawnSync("git", args, { cwd: root, encoding: "utf8" });+ git("init", "-q");+ git("-c", "user.name=T", "-c", "[email protected]", "add", "scripts");+ git("-c", "user.name=T", "-c", "[email protected]", "commit", "-qm", "x");++ const result = run(root);+ expect(result.status).toBe(1);+ expect(result.stderr).toContain("entry: 10 gzip bytes > 0");+ // The message must explain itself; a bare violation is the failure mode this guards.+ expect(result.stderr).toMatch(/stale|newer than the build|uncommitted/);+ });++ it("does not second-guess a build that is authoritative by declaration", () => {+ const root = fixture();+ const result = run(root, { MSO_BUNDLE_BUILD_IS_CURRENT: "1" });+ expect(result.status).toBe(1);+ expect(result.stderr).toContain("entry: 10 gzip bytes > 0");+ expect(result.stderr).not.toMatch(/stale|newer than the build|uncommitted/);+ });+});diff --git a/scripts/check-bundle.mjs b/scripts/check-bundle.mjsindex 9f5c9d81..83b9800e 100644--- a/scripts/check-bundle.mjs+++ b/scripts/check-bundle.mjs@@ -1,15 +1,48 @@#!/usr/bin/env nodeimport fs from 'node:fs';+import { execFileSync } from 'node:child_process';import { readBundleReport, bundleViolations } from './lib/bundle-report.mjs';+// A budget only means something against a build of THIS tree. `.next` is whatever was+// built last — often a different commit, since nobody builds in place here (it takes the+// live service down). Enforcing a tightened budget against a stale tree produces a+// failure that reads like a regression but describes history, so say which it is.+//+// `verify-build.sh` builds an archive of HEAD out of tree and sets+// MSO_BUNDLE_BUILD_IS_CURRENT=1, because there the build really does describe the source.+function staleBuild() {+ if (process.env.MSO_BUNDLE_BUILD_IS_CURRENT === '1') return null;+ let built;+ try {+ built = fs.statSync('.next/BUILD_ID').mtimeMs;+ } catch {+ return null;+ }+ try {+ const changed = execFileSync('git', ['status', '--porcelain', '--', '.', ':!docs/CHANGELOG.md'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();+ if (changed) return `working tree has uncommitted changes`;+ } catch {+ // Not a git checkout (or git is unavailable): the mtime check below still applies.+ }+ try {+ const newest = execFileSync('git', ['log', '-1', '--format=%ct'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();+ if (newest && Number(newest) * 1000 > built) return `HEAD is newer than the build`;+ } catch {}+ return null;+}+try {const report = readBundleReport();+ const stale = staleBuild();if (process.argv.includes('--json')) console.log(JSON.stringify(report, null, 2));else for (const key of ['initial', 'entry', 'css', 'fonts']) {console.log(`bundle ${key}: ${(report[key].bytes / 1024).toFixed(1)} KiB raw / ${(report[key].gzip / 1024).toFixed(1)} KiB gzip (${report[key].files} files)`);}if (!process.argv.includes('--report-only')) {const failures = bundleViolations(report, JSON.parse(fs.readFileSync('scripts/bundle-budget.json', 'utf8')));+ if (failures.length && stale) {+ throw new Error(`${failures.join('\n')}\n.build/ is stale (${stale}); these bytes describe an older tree, not this one. Rebuild with scripts/verify-build.sh before reading this as a regression.`);+ }if (failures.length) throw new Error(failures.join('\n'));console.log('bundle: eager shell budget passed; optional engines remain deferred.');}diff --git a/scripts/gates-12.sh b/scripts/gates-12.shindex e707cbda..5f2b7f62 100755--- a/scripts/gates-12.sh+++ b/scripts/gates-12.sh@@ -39,7 +39,19 @@ run "architecture" node scripts/check-architecture.mjsrun "docs" node scripts/check-docs.mjsrun "changelog" node scripts/gen-changelog.mjs --checkrun "contrast" node scripts/check-contrast.mjs-run "bundle budget" node scripts/check-bundle.mjs+# Fast mode has no build of its own: `.next` belongs to whatever was built last, so it+# can only REPORT bytes (`--report-only`) here. Enforcement happens against a build of+# this tree — `verify-build.sh` in full mode, and `bundle:check` in CI right after the+# production build step.+# Byte budgets only mean something against a build of THIS tree. Fast mode has no build+# of its own — `.next` belongs to whatever was built last — so it can only REPORT bytes+# here. Full mode enforces them inside `verify-build.sh`, against the out-of-tree build+# it just made; CI does the same with `bundle:check` right after `bun run build`.+if [ "$MODE" = "fast" ]; then+ run "bundle bytes (report)" node scripts/check-bundle.mjs --report-only+else+ skip "bundle budget" "enforced against the out-of-tree build by verify-build.sh"+firun "instance guard" node scripts/check-instance-literals.mjsrun "audit strict" node scripts/audit.mjs --strictrun "ci contract" node --test scripts/ci/contract.node.mjsdiff --git a/scripts/verify-build.sh b/scripts/verify-build.shindex d054b691..bcd41b3b 100755--- a/scripts/verify-build.sh+++ b/scripts/verify-build.sh@@ -50,7 +50,8 @@ if grep -Ei "(^|[[:space:]])warnings?[: ]|⚠" "$MSO_VERIFY_BUILD_LOG"; thenfiecho "== verify: eager shell bundle budget"-node scripts/check-bundle.mjs+# The build described this exact archive, so the stale-build guard must not fire here.+MSO_BUNDLE_BUILD_IS_CURRENT=1 node scripts/check-bundle.mjsecho "== verify 2/3: Playwright Chromium runtime"if ! node scripts/ensure-playwright-browser.mjs; then