A desktop coding agent with free access to frontier models.
TypeScript
feat: sandbox setup panel in the chat
ogsamrat6b029c909821
diff --git a/apps/app/src/app/lib/omnirush-server.ts b/apps/app/src/app/lib/omnirush-server.tsindex a490ccf9..937d7400 100644--- a/apps/app/src/app/lib/omnirush-server.ts+++ b/apps/app/src/app/lib/omnirush-server.ts@@ -479,6 +479,15 @@ export type OmniRushBestPracticesChange = OmniRushBestPractices & {engine: { status: "applied" | "deferred" | "failed" | "unconfigured" };};+/** The box status query: a fresh backend check, and the chat it is asked for. */+function boxQuery(options?: { fresh?: boolean; sessionId?: string | null }): string {+ const query = new URLSearchParams();+ if (options?.fresh) query.set("fresh", "1");+ if (options?.sessionId) query.set("session", options.sessionId);+ const text = query.toString();+ return text ? `?${text}` : "";+}+/*** GET /workspace/:id/box: the workspace's Linux sandbox (commands run in a* per-project container on this computer). `mode` null: the server's default.@@ -487,8 +496,11 @@ export type OmniRushWorkspaceBox = {mode: "on" | "off" | null;serverDefault: "off" | "offer" | "on";on: boolean;- /** "host-builds": the server's default would put it in the sandbox, but the folder has this computer's builds. */- source: "env" | "project" | "server" | "default" | "host-builds" | "buildathon";+ /**+ * "host-builds": the server's default would put it in the sandbox, but the folder has this computer's builds.+ * "required": the account requires the sandbox for new chats; "host-only": required, but the project only builds on this OS.+ */+ source: "env" | "project" | "server" | "default" | "host-builds" | "buildathon" | "required" | "host-only";offer: boolean;state: "off" | "unavailable" | "downloading" | "starting" | "ready" | "failed";runtime: { ok: boolean; name: string | null; flavor: string | null; version: string | null; reason: string | null } | null;@@ -519,7 +531,27 @@ export type OmniRushWorkspaceBox = {hostBuilds?: { native: boolean; things: string; notice: string } | null;/** macOS / Windows, while chats run in the sandbox: one line that says so. Older servers: absent. */boxNotice?: string | null;-};+ /** The account requires the sandbox for new chats: the switch and "Off (this computer)" are disabled. Older servers: absent. */+ required?: boolean;+ requiredText?: { line: string; optOut: string; keptOldChat: string } | null;+ /** Required, but the project only builds on this OS (an Xcode project, a WPF app): its chats run on this computer. */+ hostOnly?: { things: string[]; notice: string } | null;+ /** Required and not ready: what the sandbox needs on this computer (the setup screen). */+ setup?: OmniRushWorkspaceBoxSetup | null;+ /** Asked for one chat: it started on this computer before the sandbox was required and stays here. */+ chatKept?: boolean;+};+export type OmniRushWorkspaceBoxSetup = {+ need: "none" | "linux_allow" | "win_install" | "win_restart" | "win_update" | "mac_vm" | "runtime" | "cannot_run";+ why: "firmware_off" | "nested_vm" | "s_mode" | "old_windows" | "old_macos" | "policy" | "declined" | null;+ whyText: string | null;+ declined: boolean;+ result: { ok: boolean; message: string; at: number } | null;+ fallback: "native" | "native_uncounted";+ /** cannot_run: the one line ("The sandbox can't run on this computer: …."). */+ line?: string | null;+};+export type OmniRushWorkspaceBoxSetupAction = "linux_allow" | "win_install" | "win_restart" | "win_update" | "decline" | "check";export type OmniRushWorkspaceBoxProgress = {bytesDone: number | null;bytesTotal: number | null;@@ -2144,8 +2176,8 @@ export function createOmniRushServerClient(options: { baseUrl: string; token?: srequestJson<OmniRushPendingUploads>(baseUrl, "/omnirush/capture/pending", { token, hostToken, timeoutMs: timeouts.config }),flushPendingUploads: () =>requestJson<{ before: number; after: number }>(baseUrl, "/omnirush/capture/flush", { token, hostToken, method: "POST", body: {}, timeoutMs: SIGN_OUT_FLUSH_TIMEOUT_MS }),- getWorkspaceBox: (workspaceId: string, options?: { fresh?: boolean }) =>- requestJson<OmniRushWorkspaceBox>(baseUrl, `/workspace/${encodeURIComponent(workspaceId)}/box${options?.fresh ? "?fresh=1" : ""}`, {+ getWorkspaceBox: (workspaceId: string, options?: { fresh?: boolean; sessionId?: string | null }) =>+ requestJson<OmniRushWorkspaceBox>(baseUrl, `/workspace/${encodeURIComponent(workspaceId)}/box${boxQuery(options)}`, {token, hostToken, timeoutMs: timeouts.config,}),setWorkspaceBox: (workspaceId: string, mode: "on" | "off" | null) =>@@ -2161,6 +2193,11 @@ export function createOmniRushServerClient(options: { baseUrl: string; token?: srequestJson<OmniRushWorkspaceBox>(baseUrl, `/workspace/${encodeURIComponent(workspaceId)}/box/retry`, {token, hostToken, method: "POST", body: {}, timeoutMs: 30_000,}),+ /** One sandbox setup step (the setup screen): the elevated ones wait for the admin prompt, so the limit is long. */+ setupWorkspaceBox: (workspaceId: string, action: OmniRushWorkspaceBoxSetupAction) =>+ requestJson<OmniRushWorkspaceBox>(baseUrl, `/workspace/${encodeURIComponent(workspaceId)}/box/setup`, {+ token, hostToken, method: "POST", body: { action }, timeoutMs: 35 * 60_000,+ }),resetWorkspaceBox: (workspaceId: string) =>requestJson<{ removed: boolean }>(baseUrl, `/workspace/${encodeURIComponent(workspaceId)}/box/reset`, {token, hostToken, method: "POST", body: {}, timeoutMs: 90_000,diff --git a/apps/app/src/react-app/domains/session/chat/new-task-composer.tsx b/apps/app/src/react-app/domains/session/chat/new-task-composer.tsxindex 3e73dc7f..2b276416 100644--- a/apps/app/src/react-app/domains/session/chat/new-task-composer.tsx+++ b/apps/app/src/react-app/domains/session/chat/new-task-composer.tsx@@ -14,6 +14,7 @@ import { ReactSessionComposer } from "@/react-app/domains/session/surface/composimport { WorkspaceRunModeMenu } from "@/react-app/domains/session/surface/composer/workspace-run-mode-menu";import { FullPermissionsToggle } from "@/react-app/domains/session/surface/composer/full-permissions-toggle";import { SandboxStatusChip } from "@/react-app/domains/session/surface/composer/sandbox-status-chip";+import { SandboxSetupPanel } from "@/react-app/domains/session/surface/sandbox-setup-panel";import { SubagentModelMenu } from "@/react-app/domains/session/surface/composer/subagent-model-menu";import {snapshotComposerSessionState,@@ -431,6 +432,7 @@ export function NewTaskComposer(props: NewTaskComposerProps) {setFailedSubmission(null);}}>Clear the current draft to restore the unsent message</button> : null}{context?.projectPicker ? <ProjectPicker {...context.projectPicker} /> : null}+ <SandboxSetupPanel client={workspaceClient} workspaceId={workspaceId} chatRunning={Boolean(props.busy)} onOpenSettings={() => context?.onOpenSettingsSection?.("sandbox")} /><ReactSessionComposerrunModeControl={<WorkspaceRunModeMenu client={workspaceClient} workspaceId={workspaceId} busy={props.busy} />}fullPermissionsControl={<FullPermissionsToggle client={workspaceClient} workspaceId={workspaceId} />}diff --git a/apps/app/src/react-app/domains/session/surface/composer/sandbox-status-chip.tsx b/apps/app/src/react-app/domains/session/surface/composer/sandbox-status-chip.tsxindex 14df533f..2ebcc6a1 100644--- a/apps/app/src/react-app/domains/session/surface/composer/sandbox-status-chip.tsx+++ b/apps/app/src/react-app/domains/session/surface/composer/sandbox-status-chip.tsx@@ -39,8 +39,10 @@ function SandboxChip(props: { client: LinuxSandboxClient; workspaceId: string; oconst chip = "flex h-9 max-h-9 shrink-0 items-center gap-1.5 rounded-md px-2.5 text-sm text-gray-10 transition-colors hover:bg-gray-3 hover:text-gray-12";if (!box.on && sandbox.pending !== "on") {- // The server's default left this project on this computer (its folder has this computer's builds): say why.- if (box.hostBuilds?.native) {+ // The server's default left this project on this computer (its folder has this computer's builds), or the+ // sandbox is required but the project only builds on this OS: say why.+ const offWhy = box.hostBuilds?.native ? box.hostBuilds.notice : box.source === "host-only" ? box.hostOnly?.notice ?? null : null;+ if (offWhy) {return (<Tooltip><TooltipTrigger@@ -55,7 +57,7 @@ function SandboxChip(props: { client: LinuxSandboxClient; workspaceId: string; o<TooltipContent><div className="flex max-w-64 flex-col"><span className="font-medium">Linux sandbox: off for this project</span>- <span>{box.hostBuilds.notice}</span>+ <span>{offWhy}</span></div></TooltipContent></Tooltip>@@ -108,6 +110,7 @@ function SandboxChip(props: { client: LinuxSandboxClient; workspaceId: string; o<div className="flex max-w-64 flex-col"><span className="font-medium">Linux sandbox: {view.title}</span>{view.progress ? <span>{view.progress.label}</span> : view.detail ? <span>{view.detail}</span> : null}+ {box.required && box.requiredText ? <span className="mt-1 text-gray-9">{box.requiredText.line}</span> : null}</div></TooltipContent></Tooltip>diff --git a/apps/app/src/react-app/domains/session/surface/sandbox-setup-panel.tsx b/apps/app/src/react-app/domains/session/surface/sandbox-setup-panel.tsxnew file mode 100644index 00000000..315cf909--- /dev/null+++ b/apps/app/src/react-app/domains/session/surface/sandbox-setup-panel.tsx@@ -0,0 +1,176 @@+/** @jsxImportSource react */+import { useEffect, useRef, useState } from "react";+import { AlertTriangle, Box, Check, CheckCircle2, Circle, ExternalLink, LoaderCircle, Monitor, XCircle } from "lucide-react";+import { Progress as ProgressPrimitive } from "@base-ui/react/progress";++import { openDesktopUrl } from "@/app/lib/desktop";+import type { OmniRushWorkspaceBox } from "@/app/lib/omnirush-server";+import { Button } from "@/components/ui/button";+import { ProgressIndicator, ProgressTrack } from "@/components/ui/progress";+import { useLinuxSandbox, type LinuxSandboxClient } from "@/react-app/domains/settings/linux-sandbox";+import { sandboxSetupView, type SandboxSetupButton, type SandboxSetupStep, type SandboxSetupView } from "@/react-app/domains/settings/sandbox-setup";++type Props = {+ client: LinuxSandboxClient | null;+ workspaceId: string | null;+ /** The chat shown (null on the new-chat screen): a chat kept on this computer says so instead. */+ sessionId?: string | null;+ /** A chat runs now: "Restart now" waits. */+ chatRunning?: boolean;+ onOpenSettings?: () => void;+};++/**+ * "Setting up the sandbox", across the chat above the composer: shown while+ * the account requires the sandbox and the project's box is not ready (the+ * download and start with progress; Windows' WSL setup with its restart;+ * Ubuntu's one-time Allow; why it cannot run on this computer), then+ * "ready" for a moment. Nothing for a project the sandbox is not required+ * for.+ */+export function SandboxSetupPanel(props: Props) {+ if (!props.client || !props.workspaceId) return null;+ return <Panel key={props.workspaceId} client={props.client} workspaceId={props.workspaceId} sessionId={props.sessionId ?? null} chatRunning={props.chatRunning ?? false} onOpenSettings={props.onOpenSettings} />;+}++const TONE: Record<SandboxSetupView["tone"], string> = {+ busy: "text-dls-secondary",+ attention: "text-warning",+ error: "text-red-11",+ ready: "text-green-11",+ off: "text-dls-secondary",+};++function ToneIcon({ tone }: { tone: SandboxSetupView["tone"] }) {+ const className = `size-5 shrink-0 ${TONE[tone]}`;+ if (tone === "busy") return <LoaderCircle aria-hidden className={`${className} motion-safe:animate-spin`} />;+ if (tone === "ready") return <CheckCircle2 aria-hidden className={className} />;+ if (tone === "attention") return <AlertTriangle aria-hidden className={className} />;+ if (tone === "error") return <XCircle aria-hidden className={className} />;+ return <Box aria-hidden className={className} />;+}++function Step({ step }: { step: SandboxSetupStep }) {+ return (+ <li className="flex min-w-0 items-start gap-2.5" data-testid="sandbox-setup-step" data-step={step.id} data-state={step.state}>+ <span className="mt-0.5 flex size-4 shrink-0 items-center justify-center">+ {step.state === "done" ? <Check aria-hidden className="size-4 text-green-11" />+ : step.state === "active" ? <LoaderCircle aria-hidden className="size-4 text-dls-text motion-safe:animate-spin" />+ : <Circle aria-hidden className="size-3 text-gray-8" />}+ </span>+ <div className="min-w-0 flex-1">+ <div className={`text-[13px] ${step.state === "todo" ? "text-dls-secondary" : "text-dls-text"}`}>{step.label}</div>+ {step.progress ? (+ <ProgressPrimitive.Root value={step.progress.value} aria-label={step.label} getAriaValueText={() => step.progress?.label ?? ""} className="mt-1 flex h-[18px] items-center gap-2" data-testid="sandbox-setup-progress">+ <ProgressTrack className="h-1.5 flex-1 bg-dls-hover">+ <ProgressIndicator className={`rounded-full bg-dls-text/70 motion-safe:duration-500 motion-reduce:transition-none ${step.progress.value === null ? "w-1/4 motion-safe:animate-pulse" : ""}`} />+ </ProgressTrack>+ <span className="shrink-0 text-[11px] tabular-nums text-dls-secondary">{step.progress.label}</span>+ </ProgressPrimitive.Root>+ ) : null}+ </div>+ </li>+ );+}++function ActionButton({ button, onPress }: { button: SandboxSetupButton; onPress: (button: SandboxSetupButton) => void }) {+ return (+ <Button size="sm" variant={button.primary ? "default" : "outline"} disabled={button.disabled} onClick={() => onPress(button)} data-testid={`sandbox-setup-${button.action}`} title={button.hint}>+ {button.label}+ </Button>+ );+}++function Panel(props: { client: LinuxSandboxClient; workspaceId: string; sessionId: string | null; chatRunning: boolean; onOpenSettings?: () => void }) {+ const sandbox = useLinuxSandbox(props.client, props.workspaceId, { fresh: false, sessionId: props.sessionId });+ const [consenting, setConsenting] = useState(false);+ const [later, setLater] = useState(false);+ const [justReady, setJustReady] = useState(false);+ const shown = useRef(false);+ const box: OmniRushWorkspaceBox | null = sandbox.box;+ // Shown while not ready, then "ready" for a few seconds.+ useEffect(() => {+ if (!box?.required || !box.on) return;+ if (box.state !== "ready") {+ shown.current = true;+ return;+ }+ if (!shown.current) return;+ shown.current = false;+ setJustReady(true);+ const timer = setTimeout(() => setJustReady(false), 5_000);+ return () => clearTimeout(timer);+ }, [box?.required, box?.on, box?.state]);++ if (!box) return null;+ if (box.required && box.chatKept && props.sessionId) {+ return (+ <div className="mx-3 mb-2 flex items-center gap-2 rounded-xl border border-dls-border bg-dls-surface px-3 py-2 text-xs text-dls-secondary" data-testid="sandbox-kept-chat">+ <Monitor aria-hidden className="size-4 shrink-0" />+ <span className="min-w-0 flex-1">{box.requiredText?.keptOldChat}</span>+ </div>+ );+ }+ const view = sandboxSetupView(box, { pending: sandbox.pending, chatRunning: props.chatRunning, consenting, justReady });+ if (!view || (later && box.setup?.need === "win_restart")) return null;++ const press = (button: SandboxSetupButton) => {+ if (button.action === "consent") return setConsenting(true);+ if (button.action === "cancel") return setConsenting(false);+ if (button.action === "later") return setLater(true);+ if (button.action === "settings") return props.onOpenSettings?.();+ if (button.action === "retry") return void sandbox.retry();+ setConsenting(false);+ void sandbox.setup(button.action);+ };++ if (view.kind === "line" || view.kind === "ready") {+ return (+ <div className="mx-3 mb-2 flex flex-wrap items-center gap-x-3 gap-y-1.5 rounded-xl border border-dls-border bg-dls-surface px-3 py-2" data-testid="sandbox-setup-panel" data-kind={view.kind}>+ <ToneIcon tone={view.tone} />+ <div className="min-w-0 flex-1 text-xs">+ <span className="font-medium text-dls-text" role="status">{view.title}</span>+ {view.detail ? <span className="ml-1.5 text-dls-secondary">{view.detail}</span> : null}+ </div>+ {view.buttons.map((button) => <ActionButton key={button.action} button={button} onPress={press} />)}+ </div>+ );+ }++ return (+ <section className="mx-3 mb-2 rounded-2xl border border-dls-border bg-dls-surface" aria-labelledby="sandbox-setup-title" data-testid="sandbox-setup-panel" data-kind={view.kind} data-need={box.setup?.need ?? box.state}>+ <div className="flex items-start gap-3 px-4 pt-3.5 pb-3">+ <ToneIcon tone={view.tone} />+ <div className="min-w-0 flex-1">+ <h2 id="sandbox-setup-title" className="text-[14px] font-semibold text-dls-text" role="status" aria-live="polite">{view.title}</h2>+ {view.detail ? <p className="mt-0.5 text-[12px] leading-[18px] text-dls-secondary">{view.detail}</p> : null}+ {view.consent ? <p className="mt-1.5 rounded-lg border border-dls-border bg-dls-hover px-3 py-2 text-[12px] leading-[18px] text-dls-text" data-testid="sandbox-setup-consent">{view.consent}</p> : null}+ {view.steps.length ? <ol className="mt-3 space-y-2" aria-label="Setup steps">{view.steps.map((step) => <Step key={step.id} step={step} />)}</ol> : null}+ {view.howTo.length ? (+ <ol className="mt-2.5 list-decimal space-y-1 pl-5 text-[12px] leading-[18px] text-dls-text" data-testid="sandbox-setup-howto">+ {view.howTo.map((line) => <li key={line}>{line}</li>)}+ </ol>+ ) : null}+ {view.next?.command ? (+ <code className="mt-2 block truncate rounded-lg border border-dls-border bg-dls-hover px-3 py-1.5 font-mono text-[11px] text-dls-text" title={view.next.command}>{view.next.command}</code>+ ) : null}+ {view.result ? <p className={`mt-2 text-[12px] ${view.result.ok ? "text-green-11" : "text-red-11"}`} data-testid="sandbox-setup-result">{view.result.message}</p> : null}+ {sandbox.problem ? <p className="mt-2 text-[12px] text-red-11" role="alert">{sandbox.problem.message}</p> : null}+ {view.buttons.length || view.link ? (+ <div className="mt-3 flex flex-wrap items-center gap-2">+ {view.buttons.map((button) => <ActionButton key={button.action} button={button} onPress={press} />)}+ {view.link ? (+ <Button size="sm" variant="link" className="px-1" onClick={() => void openDesktopUrl(view.link?.href ?? "").catch(() => undefined)} data-testid="sandbox-setup-link">+ {view.link.label}+ <ExternalLink aria-hidden className="size-3.5" />+ </Button>+ ) : null}+ {view.buttons.find((button) => button.hint && button.disabled) ? <span className="text-[11px] text-dls-secondary">{view.buttons.find((button) => button.hint && button.disabled)?.hint}</span> : null}+ </div>+ ) : null}+ </div>+ </div>+ {view.fallbackLine ? <div className="border-t border-dls-border px-4 py-2 pl-12 text-[11px] text-dls-secondary" data-testid="sandbox-setup-fallback">{view.fallbackLine}</div> : null}+ </section>+ );+}diff --git a/apps/app/src/react-app/domains/session/surface/session-surface.tsx b/apps/app/src/react-app/domains/session/surface/session-surface.tsxindex 53c57606..9200d8d1 100644--- a/apps/app/src/react-app/domains/session/surface/session-surface.tsx+++ b/apps/app/src/react-app/domains/session/surface/session-surface.tsx@@ -54,6 +54,7 @@ import { ReactSessionComposer } from "./composer/composer";import { WorkspaceRunModeMenu } from "./composer/workspace-run-mode-menu";import { FullPermissionsToggle } from "./composer/full-permissions-toggle";import { SandboxStatusChip } from "./composer/sandbox-status-chip";+import { SandboxSetupPanel } from "./sandbox-setup-panel";import { useSessionCommandsStore } from "@/react-app/domains/session/commands/session-commands-store";import { SubagentModelMenu } from "./composer/subagent-model-menu";import { useSessionModelSelection } from "./session-model-store";@@ -3614,6 +3615,13 @@ export function SessionSurface(props: SessionSurfaceProps) {{attachment.name}{sending ? " · Uploading…" : ""}</div>)))}+ <SandboxSetupPanel+ client={props.client}+ workspaceId={props.workspaceId}+ sessionId={props.sessionId}+ chatRunning={chatStreaming || (effectiveActivityStatus !== "idle" && effectiveActivityStatus !== "error")}+ onOpenSettings={() => props.onOpenSettingsSection?.("sandbox")}+ /><SessionRunStatusactivityStatus={effectiveActivityStatus}busy={chatStreaming}diff --git a/apps/app/src/react-app/domains/settings/linux-sandbox-card.tsx b/apps/app/src/react-app/domains/settings/linux-sandbox-card.tsxindex da2d6ff8..744a5e3d 100644--- a/apps/app/src/react-app/domains/settings/linux-sandbox-card.tsx+++ b/apps/app/src/react-app/domains/settings/linux-sandbox-card.tsx@@ -152,6 +152,8 @@ function Advanced(props: { box: OmniRushWorkspaceBox; busy: boolean; defaultOpenconst choices = linuxSandboxBackendChoices(box);const others = (box.backend?.alternatives ?? []).filter((alt) => alt.id !== box.backend?.id);const lockedByEnv = box.backendSetting.source === "env";+ // Required on this account: "Off (this computer)" is not a choice.+ const required = box.required === true;const canReset = Boolean(box.container?.exists);return (<Collapsible open={open} onOpenChange={setOpen} className="border-t border-dls-border">@@ -183,7 +185,7 @@ function Advanced(props: { box: OmniRushWorkspaceBox; busy: boolean; defaultOpen<SelectContent><SelectGroup>{choices.map((item) => (- <SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>+ <SelectItem key={item.value} value={item.value} disabled={required && item.value === "native"}>{item.label}</SelectItem>))}</SelectGroup></SelectContent>@@ -191,6 +193,7 @@ function Advanced(props: { box: OmniRushWorkspaceBox; busy: boolean; defaultOpen</div>) : null}</div>+ {required ? <div className="-mt-2 text-[11px] text-dls-secondary" data-testid="linux-sandbox-backend-required">“Off (this computer)”: {box.requiredText?.optOut}</div> : null}{others.length ? (<div><div className="text-[11px] font-medium text-dls-secondary">Other backends on this computer</div>@@ -272,6 +275,9 @@ export function LinuxSandboxCard(props: LinuxSandboxCardProps) {<span className="rounded-full border border-dls-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-dls-secondary">Beta</span></div><div id="linux-sandbox-help" className="text-[11px] text-dls-secondary">{LINUX_SANDBOX_HELP}</div>+ {box?.required ? (+ <div className="mt-1 text-[11px] font-medium text-dls-text" data-testid="linux-sandbox-required">{box.requiredText?.optOut}</div>+ ) : null}{/* TODO(Sam): data-collection wording for sandboxed chats goes here (what uploads record about thesandbox: Linux as the OS, the container image, per-turn changes outside the project). No copy yet. */}</div>@@ -281,7 +287,7 @@ export function LinuxSandboxCard(props: LinuxSandboxCardProps) {aria-describedby="linux-sandbox-help"aria-busy={busy || undefined}checked={checked}- disabled={busy || !box || box.source === "env"}+ disabled={busy || !box || box.source === "env" || box.required === true}onCheckedChange={props.onToggle}/></div>diff --git a/apps/app/src/react-app/domains/settings/linux-sandbox.ts b/apps/app/src/react-app/domains/settings/linux-sandbox.tsindex 84064f04..0345ecfb 100644--- a/apps/app/src/react-app/domains/settings/linux-sandbox.ts+++ b/apps/app/src/react-app/domains/settings/linux-sandbox.ts@@ -1,9 +1,9 @@import { useCallback, useEffect, useRef, useState } from "react";import { captureAnalyticsEvent, type AnalyticsProperties } from "@/app/lib/analytics";-import type { OmniRushServerClient, OmniRushWorkspaceBox, OmniRushWorkspaceBoxProgress } from "@/app/lib/omnirush-server";+import type { OmniRushServerClient, OmniRushWorkspaceBox, OmniRushWorkspaceBoxProgress, OmniRushWorkspaceBoxSetupAction } from "@/app/lib/omnirush-server";-export type LinuxSandboxClient = Pick<OmniRushServerClient, "getWorkspaceBox" | "setWorkspaceBox" | "setWorkspaceBoxBackend" | "resetWorkspaceBox" | "retryWorkspaceBox">;+export type LinuxSandboxClient = Pick<OmniRushServerClient, "getWorkspaceBox" | "setWorkspaceBox" | "setWorkspaceBoxBackend" | "resetWorkspaceBox" | "retryWorkspaceBox"> & Partial<Pick<OmniRushServerClient, "setupWorkspaceBox">>;export const LINUX_SANDBOX_HELP = "Commands run in a Linux container for this project. Your files stay in this folder; installs are kept per project.";@@ -25,7 +25,7 @@ export type LinuxSandboxView = {};/** A change the user made that the server has not answered yet (the switch already shows it). */-export type LinuxSandboxPending = "on" | "off" | "backend" | "reset" | "retry" | null;+export type LinuxSandboxPending = "on" | "off" | "backend" | "reset" | "retry" | "setup" | null;const RUNS_HERE = "Commands run on this computer for now.";const LOAD_FAILED = "The sandbox status could not be loaded.";@@ -103,8 +103,11 @@ export function linuxSandboxView(box: OmniRushWorkspaceBox, pending: LinuxSandboif (pending === "off") return { ...base, tone: "busy", title: "Turning off…", detail: null };if (pending === "reset") return { ...base, tone: "busy", title: "Resetting the sandbox…", detail: "Removing its container and installs." };if (pending === "retry") return { ...base, tone: "busy", title: "Trying again…", detail: null };+ if (pending === "setup") return { ...base, tone: "busy", title: "Setting up the sandbox…", detail: null };if (!box.on) {if (box.source === "env") return { ...base, tone: "off", title: "Off for this app", detail: "Set by OMNIRUSH_BOX where the app is launched." };+ // Required, but the project only builds on this OS: its chats run here.+ if (box.source === "host-only" && box.hostOnly) return { ...base, tone: "attention", title: "Runs on this computer", detail: box.hostOnly.notice };if (box.hostBuilds?.native) return { ...base, tone: "attention", title: "Off for this project", detail: box.hostBuilds.notice };// A buildathon project: turned off here (less reproducible), or the event offers the sandbox.if (box.notice) return { ...base, tone: "attention", title: box.source === "project" ? "Off for this project" : "Off", detail: box.notice };@@ -203,7 +206,7 @@ export type LinuxSandboxProblem = { message: string; retry: (() => void) | null* while it moves, and when the window comes back), the switch (shown at* once, before the server answers), the backend, Retry and Reset.*/-export function useLinuxSandbox(client: LinuxSandboxClient | null, workspaceId: string | null, { fresh: freshOnOpen = true }: { fresh?: boolean } = {}) {+export function useLinuxSandbox(client: LinuxSandboxClient | null, workspaceId: string | null, { fresh: freshOnOpen = true, sessionId = null }: { fresh?: boolean; sessionId?: string | null } = {}) {const [box, setBox] = useState<OmniRushWorkspaceBox | null>(null);const [pending, setPending] = useState<LinuxSandboxPending>(null);const [problem, setProblem] = useState<LinuxSandboxProblem | null>(null);@@ -216,7 +219,7 @@ export function useLinuxSandbox(client: LinuxSandboxClient | null, workspaceId:const load = useCallback(async (fresh = false) => {if (!client || !workspaceId) return;const startedAt = sequence.current;- const value = await client.getWorkspaceBox(workspaceId, { fresh }).catch(() => null);+ const value = await client.getWorkspaceBox(workspaceId, sessionId ? { fresh, sessionId } : { fresh }).catch(() => null);if (sequence.current !== startedAt) return;if (value) {boxFor.current = workspaceId;@@ -225,7 +228,7 @@ export function useLinuxSandbox(client: LinuxSandboxClient | null, workspaceId:} else {setProblem({ message: LOAD_FAILED, retry: () => void load(true) });}- }, [client, workspaceId]);+ }, [client, workspaceId, sessionId]);// Another project: start from nothing. The same project with a new client (the engine// reloaded after the switch): keep what is shown and ask again, so nothing flickers.@@ -322,7 +325,14 @@ export function useLinuxSandbox(client: LinuxSandboxClient | null, workspaceId:const refresh = useCallback(() => load(true), [load]);- return { box, pending, problem, notice, setEnabled, setBackend, retry, reset, refresh };+ /** One setup step of the setup screen (Allow, Set up, Restart now, Not now, Check again). */+ const setup = useCallback((action: OmniRushWorkspaceBoxSetupAction) => {+ if (!client?.setupWorkspaceBox || !workspaceId) return Promise.resolve();+ const run = client.setupWorkspaceBox;+ return change("setup", () => run(workspaceId, action), action === "win_restart" ? "Windows could not be restarted from here. Restart it from the Start menu." : "The setup step did not finish.", () => void setup(action));+ }, [change, client, workspaceId]);++ return { box, pending, problem, notice, setEnabled, setBackend, retry, reset, refresh, setup };}export type LinuxSandboxState = ReturnType<typeof useLinuxSandbox>;diff --git a/apps/app/src/react-app/domains/settings/sandbox-setup.ts b/apps/app/src/react-app/domains/settings/sandbox-setup.tsnew file mode 100644index 00000000..2cfdc6d6--- /dev/null+++ b/apps/app/src/react-app/domains/settings/sandbox-setup.ts@@ -0,0 +1,164 @@+import type { OmniRushWorkspaceBox, OmniRushWorkspaceBoxSetupAction } from "@/app/lib/omnirush-server";++import { linuxSandboxNextStep, linuxSandboxProgress, type LinuxSandboxNextStep, type LinuxSandboxPending } from "./linux-sandbox";++/** Microsoft's page for turning virtualization on and other WSL problems. */+export const WSL_TROUBLESHOOTING_URL = "https://learn.microsoft.com/windows/wsl/troubleshooting";++/** One step of the setup's progress list. */+export type SandboxSetupStep = {+ id: "download" | "import" | "vm" | "start";+ label: string;+ state: "done" | "active" | "todo";+ /** The download bar (bytes, parts), on the active download step. */+ progress?: { value: number | null; label: string } | null;+};++export type SandboxSetupButton = { action: OmniRushWorkspaceBoxSetupAction | "retry" | "consent" | "cancel" | "later" | "settings"; label: string; primary?: boolean; disabled?: boolean; hint?: string };++/**+ * What the chat's setup panel shows: `kind` picks its layout. "progress" (the+ * steps), "action" (one thing to do, with its buttons), "blocked" (the box+ * cannot run on this computer; numbered steps when there is something to+ * try), "line" (one calm line: chats run here meanwhile), "ready" (a short+ * confirmation).+ */+export type SandboxSetupView = {+ kind: "progress" | "action" | "blocked" | "line" | "ready";+ tone: "busy" | "attention" | "error" | "ready" | "off";+ title: string;+ detail: string | null;+ steps: SandboxSetupStep[];+ /** Numbered things to do (turning virtualization on in the firmware). */+ howTo: string[];+ link: { label: string; href: string } | null;+ /** Explicit consent before the app changes Windows features. */+ consent: string | null;+ buttons: SandboxSetupButton[];+ /** A command to copy (the usual next step when no backend works). */+ next: LinuxSandboxNextStep | null;+ /** The last setup step's answer (the password prompt, the install), one line. */+ result: { ok: boolean; message: string } | null;+ /** While it cannot run: where chats run meanwhile. */+ fallbackLine: string | null;+};++const RUNS_HERE = "Chats on this computer run here meanwhile.";++const FIRMWARE_STEPS = [+ "Restart the computer and open its BIOS/UEFI settings (often F2, F10, Del or Esc right at start; on Windows also Settings › System › Recovery › Advanced startup › UEFI Firmware Settings).",+ "Find Intel Virtualization Technology (VT-x) or AMD SVM Mode, usually under CPU, Advanced or Security.",+ "Turn it on, save and restart. Then choose Check again here.",+];++function base(): Omit<SandboxSetupView, "kind" | "tone" | "title"> {+ return { detail: null, steps: [], howTo: [], link: null, consent: null, buttons: [], next: null, result: null, fallbackLine: null };+}++/** The progress list: download, the WSL distro (Windows) or the VM (macOS), start. */+function progressSteps(box: OmniRushWorkspaceBox, vm: boolean): SandboxSetupStep[] {+ const downloading = box.state === "downloading";+ const wsl = box.backend?.id === "wsl" || box.runtime?.name === "wsl";+ // WSL: the distro is added first (no byte count yet), then the image comes down inside it.+ const importing = wsl && downloading && !box.progress?.bytesDone;+ const steps: SandboxSetupStep[] = [];+ if (vm) steps.push({ id: "vm", label: "Start the OmniRush VM", state: box.state === "unavailable" ? "active" : "done" });+ if (wsl) steps.push({ id: "import", label: "Add the OmniRush Linux distro to WSL", state: importing ? "active" : "done" });+ steps.push({ id: "download", label: "Download the sandbox (once)", state: importing || (vm && box.state === "unavailable") ? "todo" : downloading ? "active" : "done", progress: downloading && !importing ? linuxSandboxProgress(box.progress) : null });+ steps.push({ id: "start", label: "Start the sandbox", state: box.state === "starting" ? "active" : box.state === "ready" ? "done" : "todo" });+ return steps;+}++/**+ * The chat's "Setting up the sandbox" panel for the selected project, or+ * null when there is nothing to show (not required, off, or ready).+ * `chatRunning`: a chat runs now ("Restart now" waits for it). `consenting`:+ * the user chose "Set up (one restart)" and sees what it changes.+ */+export function sandboxSetupView(box: OmniRushWorkspaceBox | null, { pending = null, chatRunning = false, consenting = false, justReady = false }: { pending?: LinuxSandboxPending; chatRunning?: boolean; consenting?: boolean; justReady?: boolean } = {}): SandboxSetupView | null {+ if (!box?.required || !box.on) return null;+ if (box.state === "ready") return justReady ? { ...base(), kind: "ready", tone: "ready", title: "The sandbox is ready", detail: box.requiredText?.line ?? null } : null;+ const setup = box.setup ?? null;+ const result = setup?.result ? { ok: setup.result.ok, message: setup.result.message } : null;+ const busy = pending !== null;+ if (box.state === "downloading" || box.state === "starting") {+ return { ...base(), kind: "progress", tone: "busy", title: "Setting up the sandbox", detail: "New chats in this project start as soon as it is ready. This happens once.", steps: progressSteps(box, false) };+ }+ if (box.state === "failed") {+ return { ...base(), kind: "action", tone: "error", title: "The sandbox could not start", detail: box.error ?? box.notice, buttons: [{ action: "retry", label: "Try again", primary: true, disabled: busy }], fallbackLine: RUNS_HERE };+ }+ if (!setup || setup.need === "none") {+ return { ...base(), kind: "progress", tone: "busy", title: "Setting up the sandbox", detail: "Checking this computer…", steps: progressSteps(box, false) };+ }+ if (setup.declined && setup.need !== "cannot_run") {+ return { ...base(), kind: "line", tone: "off", title: "Sandbox setup postponed", detail: "Chats run on this computer until it is set up.", buttons: [{ action: "check", label: "Set up now", disabled: busy }] };+ }+ switch (setup.need) {+ case "linux_allow":+ return {+ ...base(), kind: "action", tone: "attention", title: "Allow the sandbox on this computer",+ detail: "Ubuntu blocks the sandbox until an administrator allows it once. This installs OmniRush's own sandbox helper for this computer and allows only that helper; nothing else changes. Your password is asked once.",+ buttons: [{ action: "linux_allow", label: "Allow the sandbox", primary: true, disabled: busy }, { action: "decline", label: "Not now", disabled: busy }],+ result, fallbackLine: RUNS_HERE,+ };+ case "win_install":+ if (consenting) {+ return {+ ...base(), kind: "action", tone: "attention", title: "Turn on WSL 2?",+ detail: null,+ consent: "This turns on two Windows features, Windows Subsystem for Linux and Virtual Machine Platform, with one Windows administrator prompt, and downloads WSL from Microsoft. Windows then needs one restart; OmniRush opens again afterwards and finishes the setup. Your files and other apps are not changed.",+ buttons: [{ action: "win_install", label: "Turn on and continue", primary: true, disabled: busy }, { action: "cancel", label: "Cancel", disabled: busy }],+ };+ }+ return {+ ...base(), kind: "action", tone: "attention", title: "Set up the sandbox",+ detail: "The sandbox runs in WSL 2, which is not turned on on this PC yet. OmniRush can set it up for you: one administrator prompt, then one restart.",+ buttons: [{ action: "consent", label: "Set up (one restart)", primary: true, disabled: busy }, { action: "decline", label: "Not now", disabled: busy }],+ result, fallbackLine: RUNS_HERE,+ };+ case "win_restart":+ return {+ ...base(), kind: "action", tone: "attention", title: "Restart needed",+ detail: "WSL 2 is installed. Restart Windows to finish; OmniRush opens again afterwards and completes the setup.",+ buttons: [+ { action: "win_restart", label: "Restart now", primary: true, disabled: busy || chatRunning, ...(chatRunning ? { hint: "Waits until the running chat has finished." } : {}) },+ { action: "later", label: "Later", disabled: busy },+ ],+ fallbackLine: RUNS_HERE,+ };+ case "win_update":+ return { ...base(), kind: "action", tone: "attention", title: "Update WSL", detail: "WSL needs an update before the sandbox can start. Windows may ask for permission.", buttons: [{ action: "win_update", label: "Update WSL", primary: true, disabled: busy }, { action: "check", label: "Check again", disabled: busy }], fallbackLine: RUNS_HERE };+ case "mac_vm":+ return { ...base(), kind: "progress", tone: "busy", title: "Setting up the sandbox", detail: "OmniRush starts its own small Linux VM on this Mac (once, no admin password).", steps: progressSteps(box, true) };+ case "cannot_run":+ return cannotRun(box, busy);+ case "runtime": {+ const next = linuxSandboxNextStep(box);+ return { ...base(), kind: "action", tone: "attention", title: next.title, detail: next.detail, next, buttons: [{ action: "check", label: "Check again", disabled: busy }, { action: "settings", label: "Sandbox settings" }], fallbackLine: RUNS_HERE };+ }+ }+}++/** The box cannot run on this computer: why, what to try when there is something, and that chats run here. */+function cannotRun(box: OmniRushWorkspaceBox, busy: boolean): SandboxSetupView {+ const setup = box.setup;+ const why = setup?.why ?? null;+ const check: SandboxSetupButton = { action: "check", label: "Check again", disabled: busy };+ const line = setup?.whyText ?? box.runtime?.reason ?? null;+ switch (why) {+ case "firmware_off":+ return { ...base(), kind: "blocked", tone: "error", title: "Turn on virtualization", detail: "The sandbox needs virtualization, which is turned off in this computer's BIOS/UEFI settings (Intel VT-x or AMD SVM).", howTo: FIRMWARE_STEPS, link: { label: "Microsoft's guide", href: WSL_TROUBLESHOOTING_URL }, buttons: [check], fallbackLine: RUNS_HERE };+ case "nested_vm":+ return { ...base(), kind: "blocked", tone: "error", title: "This Windows runs in a virtual machine", detail: "The sandbox needs nested virtualization, which this virtual machine's host does not offer. Whoever runs the host (Hyper-V, VMware, VirtualBox, a cloud PC) has to turn on nested virtualization for this machine.", link: { label: "Microsoft's guide", href: WSL_TROUBLESHOOTING_URL }, buttons: [check], fallbackLine: RUNS_HERE };+ case "s_mode":+ return { ...base(), kind: "blocked", tone: "error", title: "Windows in S mode", detail: "Windows in S mode can't run WSL, which the sandbox needs. Switching out of S mode (free, in the Microsoft Store) lets it run.", buttons: [check], fallbackLine: RUNS_HERE };+ case "old_windows":+ return { ...base(), kind: "blocked", tone: "error", title: "Windows update needed", detail: "The sandbox needs Windows 10 version 2004 (build 19041) or later. Update Windows, then check again.", buttons: [check], fallbackLine: RUNS_HERE };+ case "policy":+ return { ...base(), kind: "blocked", tone: "error", title: "Blocked by your organisation", detail: "Your organisation's settings block WSL, which the sandbox needs. Ask your IT team to allow Windows Subsystem for Linux and Virtual Machine Platform.", buttons: [check], fallbackLine: RUNS_HERE };+ case "old_macos":+ return { ...base(), kind: "blocked", tone: "error", title: "macOS update needed", detail: "The sandbox needs macOS 13 or later.", buttons: [check], fallbackLine: RUNS_HERE };+ default:+ return { ...base(), kind: "line", tone: "off", title: setup?.line ?? (line ? `The sandbox can't run on this computer: ${line.replace(/\.$/, "")}.` : "The sandbox can't run on this computer."), detail: RUNS_HERE, buttons: [check] };+ }+}diff --git a/apps/app/tests/sandbox-setup.test.tsx b/apps/app/tests/sandbox-setup.test.tsxnew file mode 100644index 00000000..ef92aa3e--- /dev/null+++ b/apps/app/tests/sandbox-setup.test.tsx@@ -0,0 +1,126 @@+import { describe, expect, test } from "bun:test";+import { renderToStaticMarkup } from "react-dom/server";++import type { OmniRushWorkspaceBox, OmniRushWorkspaceBoxSetup } from "../src/app/lib/omnirush-server";+import { LinuxSandboxCard } from "../src/react-app/domains/settings/linux-sandbox-card";+import { linuxSandboxView } from "../src/react-app/domains/settings/linux-sandbox";+import { sandboxSetupView, WSL_TROUBLESHOOTING_URL } from "../src/react-app/domains/settings/sandbox-setup";++const TEXT = {+ line: "New chats run in the OmniRush sandbox, set up for you.",+ optOut: "Required for new chats on this account. Chats started before keep running where they started.",+ keptOldChat: "Started on this computer before the sandbox was required: it stays here.",+};++function box(overrides: Partial<OmniRushWorkspaceBox> = {}): OmniRushWorkspaceBox {+ return {+ mode: null,+ serverDefault: "on",+ on: true,+ source: "required",+ offer: false,+ state: "unavailable",+ runtime: { ok: false, name: null, flavor: null, version: null, reason: "no backend" },+ backend: { id: null, label: null, version: null, flavor: null, why: null, alternatives: [], allowed: null },+ backendSetting: { value: "auto", source: "auto", choices: [{ id: "auto", label: "Automatic" }, { id: "bwrap", label: "bubblewrap" }, { id: "native", label: "Off (this computer)" }] },+ image: { ref: "ghcr.io/omnirush-ai/box-base:2026.10.2", stack: "base", present: false, downloading: false },+ progress: null,+ container: null,+ platform: "linux",+ notice: null,+ error: null,+ required: true,+ requiredText: TEXT,+ hostOnly: null,+ setup: null,+ ...overrides,+ };+}++function setup(overrides: Partial<OmniRushWorkspaceBoxSetup>): OmniRushWorkspaceBoxSetup {+ return { need: "none", why: null, whyText: null, declined: false, result: null, fallback: "native", ...overrides };+}++describe("sandbox setup panel: what it shows", () => {+ test("nothing unless the sandbox is required, on and not ready (ready: a moment after it was shown)", () => {+ expect(sandboxSetupView(box({ required: false }))).toBeNull();+ expect(sandboxSetupView(box({ on: false, source: "env" }))).toBeNull();+ expect(sandboxSetupView(box({ state: "ready" }))).toBeNull();+ expect(sandboxSetupView(box({ state: "ready" }), { justReady: true })).toMatchObject({ kind: "ready", tone: "ready", title: "The sandbox is ready", detail: TEXT.line });+ });++ test("downloading and starting: the steps with bytes; WSL adds its distro step", () => {+ const view = sandboxSetupView(box({ state: "downloading", runtime: { ok: true, name: "bwrap", flavor: "overlayfs", version: "0.11", reason: null }, progress: { bytesDone: 120_000_000, bytesTotal: 300_000_000, layersDone: 2, layersTotal: 5, startedAt: 1 } }));+ expect(view).toMatchObject({ kind: "progress", title: "Setting up the sandbox" });+ expect(view?.steps.map((step) => `${step.id}:${step.state}`)).toEqual(["download:active", "start:todo"]);+ expect(view?.steps[0]?.progress).toEqual({ value: 40, label: "120 of 300 MB · 40%" });+ const wsl = sandboxSetupView(box({ state: "downloading", platform: "win32", runtime: { ok: true, name: "wsl", flavor: "omnirush-distro", version: "2.4", reason: null }, backend: { id: "wsl", label: "WSL", version: null, flavor: null, why: null, alternatives: [], allowed: null } }));+ expect(wsl?.steps.map((step) => `${step.id}:${step.state}`)).toEqual(["import:active", "download:todo", "start:todo"]);+ const starting = sandboxSetupView(box({ state: "starting", runtime: { ok: true, name: "bwrap", flavor: "", version: "", reason: null } }));+ expect(starting?.steps.map((step) => `${step.id}:${step.state}`)).toEqual(["download:done", "start:active"]);+ });++ test("Linux, AppArmor: Allow the sandbox and Not now, with the password prompt's answer", () => {+ const view = sandboxSetupView(box({ setup: setup({ need: "linux_allow", result: { ok: false, message: "The password prompt was dismissed; nothing changed.", at: 1 } }) }));+ expect(view).toMatchObject({ kind: "action", title: "Allow the sandbox on this computer", result: { ok: false } });+ expect(view?.buttons.map((b) => b.action)).toEqual(["linux_allow", "decline"]);+ expect(view?.fallbackLine).toBe("Chats on this computer run here meanwhile.");+ });++ test("Windows: Set up (one restart), then the explicit consent; Restart needed waits for a running chat", () => {+ const install = box({ platform: "win32", setup: setup({ need: "win_install" }) });+ expect(sandboxSetupView(install)?.buttons.map((b) => b.label)).toEqual(["Set up (one restart)", "Not now"]);+ const consent = sandboxSetupView(install, { consenting: true });+ expect(consent?.consent).toContain("Windows Subsystem for Linux and Virtual Machine Platform");+ expect(consent?.consent).toContain("one restart");+ expect(consent?.buttons.map((b) => b.action)).toEqual(["win_install", "cancel"]);+ const restart = box({ platform: "win32", setup: setup({ need: "win_restart" }) });+ expect(sandboxSetupView(restart)?.buttons).toEqual([{ action: "win_restart", label: "Restart now", primary: true, disabled: false }, { action: "later", label: "Later", disabled: false }]);+ expect(sandboxSetupView(restart, { chatRunning: true })?.buttons[0]).toMatchObject({ disabled: true, hint: "Waits until the running chat has finished." });+ });++ test("no virtualization: firmware steps with Microsoft's page, nested VM, S mode, old Windows, policy; each with Check again", () => {+ const firmware = sandboxSetupView(box({ platform: "win32", setup: setup({ need: "cannot_run", why: "firmware_off" }) }));+ expect(firmware).toMatchObject({ kind: "blocked", title: "Turn on virtualization", link: { href: WSL_TROUBLESHOOTING_URL } });+ expect(firmware?.howTo.join(" ")).toContain("Intel Virtualization Technology (VT-x) or AMD SVM Mode");+ for (const [why, title] of [["nested_vm", "This Windows runs in a virtual machine"], ["s_mode", "Windows in S mode"], ["old_windows", "Windows update needed"], ["policy", "Blocked by your organisation"]] as const) {+ const view = sandboxSetupView(box({ platform: "win32", setup: setup({ need: "cannot_run", why }) }));+ expect(view?.title).toBe(title);+ expect(view?.buttons.map((b) => b.action)).toEqual(["check"]);+ expect(view?.fallbackLine).toBe("Chats on this computer run here meanwhile.");+ }+ expect(WSL_TROUBLESHOOTING_URL).toBe("https://learn.microsoft.com/windows/wsl/troubleshooting");+ });++ test("cannot run, no known why: one calm line (the shared text); declined: postponed with Set up now", () => {+ const line = sandboxSetupView(box({ setup: setup({ need: "cannot_run", line: "The sandbox can't run on this computer: unprivileged user namespaces are off." }) }));+ expect(line).toMatchObject({ kind: "line", title: "The sandbox can't run on this computer: unprivileged user namespaces are off.", detail: "Chats on this computer run here meanwhile." });+ const declined = sandboxSetupView(box({ setup: setup({ need: "linux_allow", declined: true }) }));+ expect(declined).toMatchObject({ kind: "line", title: "Sandbox setup postponed" });+ expect(declined?.buttons.map((b) => b.label)).toEqual(["Set up now"]);+ });++ test("macOS VM progress (the VM backend's hook) and the usual next step when no backend works", () => {+ const mac = sandboxSetupView(box({ platform: "darwin", setup: setup({ need: "mac_vm" }) }));+ expect(mac?.steps.map((step) => `${step.id}:${step.state}`)).toEqual(["vm:active", "download:todo", "start:todo"]);+ const runtime = sandboxSetupView(box({ platform: "linux", setup: setup({ need: "runtime" }) }));+ expect(runtime).toMatchObject({ kind: "action", title: "Install Podman or Docker" });+ expect(runtime?.next?.command).toBe("sudo apt install podman");+ });+});++describe("required: the settings card and the status row", () => {+ test("the switch is disabled with the shared line; Off (this computer) cannot be picked", () => {+ const markup = renderToStaticMarkup(<LinuxSandboxCard box={box({ state: "ready", runtime: { ok: true, name: "bwrap", flavor: "", version: "0.11", reason: null } })} pending={null} problem={null} notice="" onToggle={() => {}} onRetry={() => {}} onReset={() => {}} onBackend={() => {}} defaultAdvancedOpen />);+ const toggle = /<[a-z]+[^>]*role="switch"[^>]*>/.exec(markup)?.[0] ?? "";+ expect(toggle).toContain('aria-checked="true"');+ expect(toggle).toContain('aria-disabled="true"');+ expect(markup).toContain(TEXT.optOut);+ expect(markup).toContain('data-testid="linux-sandbox-backend-required"');+ });++ test("a host-only project says why its chats run here", () => {+ const view = linuxSandboxView(box({ on: false, source: "host-only", state: "off", hostOnly: { things: ["App.xcodeproj"], notice: "This project only builds on Mac (App.xcodeproj), so its chats run on this Mac." } }));+ expect(view).toMatchObject({ tone: "attention", title: "Runs on this computer", detail: "This project only builds on Mac (App.xcodeproj), so its chats run on this Mac." });+ });+});