Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

feat: sandbox backend choice in settings

ogsamrata63cc64d5920
diff --git a/apps/app/src/app/lib/omnirush-server.ts b/apps/app/src/app/lib/omnirush-server.ts
index 480f1e18..92d8733b 100644
--- a/apps/app/src/app/lib/omnirush-server.ts
+++ b/apps/app/src/app/lib/omnirush-server.ts
@@ -439,6 +439,18 @@ export type OmniRushWorkspaceBox = {
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;
+ /** What runs the sandbox on this computer: the chosen backend, why, and the others (each with why not). */
+ backend: {
+ id: string | null;
+ label: string | null;
+ version: string | null;
+ flavor: string | null;
+ why: string | null;
+ alternatives: Array<{ id: string; label: string; ok: boolean; reason: string | null }>;
+ allowed: string[] | null;
+ } | null;
+ /** The computer's backend setting: "auto", one backend id, or "native"; and the values it takes here. */
+ backendSetting: { value: string; source: "env" | "setting" | "auto"; choices: Array<{ id: string; label: string }> };
image: { ref: string; stack: string; present: boolean | null; downloading: boolean } | null;
container: { name: string; exists: boolean; running: boolean } | null;
notice: string | null;
@@ -1957,6 +1969,10 @@ export function createOmniRushServerClient(options: { baseUrl: string; token?: s
requestJson<OmniRushWorkspaceBoxChange>(baseUrl, `/workspace/${encodeURIComponent(workspaceId)}/box`, {
token, hostToken, method: "PUT", body: { mode }, timeoutMs: ENGINE_RELOAD_TIMEOUT_MS,
}),
+ setWorkspaceBoxBackend: (workspaceId: string, backend: string) =>
+ requestJson<OmniRushWorkspaceBoxChange>(baseUrl, `/workspace/${encodeURIComponent(workspaceId)}/box`, {
+ token, hostToken, method: "PUT", body: { backend }, timeoutMs: ENGINE_RELOAD_TIMEOUT_MS,
+ }),
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/settings/linux-sandbox.ts b/apps/app/src/react-app/domains/settings/linux-sandbox.ts
index 0da933a9..48aa6687 100644
--- a/apps/app/src/react-app/domains/settings/linux-sandbox.ts
+++ b/apps/app/src/react-app/domains/settings/linux-sandbox.ts
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
import type { OmniRushServerClient, OmniRushWorkspaceBox } from "@/app/lib/omnirush-server";
-export type LinuxSandboxClient = Pick<OmniRushServerClient, "getWorkspaceBox" | "setWorkspaceBox" | "resetWorkspaceBox">;
+export type LinuxSandboxClient = Pick<OmniRushServerClient, "getWorkspaceBox" | "setWorkspaceBox" | "setWorkspaceBoxBackend" | "resetWorkspaceBox">;
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.";
@@ -30,6 +30,21 @@ export function linuxSandboxStatusLine(box: OmniRushWorkspaceBox): string {
}
}
+/** "Backend: <label> <version>": what runs the sandbox on this computer. */
+export function linuxSandboxBackendLine(box: OmniRushWorkspaceBox): string {
+ if (box.backendSetting.value === "native") return "Backend: off (commands run on this computer)";
+ const backend = box.backend;
+ if (!backend?.id) return "Backend: none available";
+ return `Backend: ${[backend.label ?? backend.id, backend.version].filter(Boolean).join(" ")}`;
+}
+
+/** The other backends here, one short entry each: available, or why not. */
+export function linuxSandboxOthersLine(box: OmniRushWorkspaceBox): string | null {
+ const others = (box.backend?.alternatives ?? []).filter((alt) => alt.id !== box.backend?.id);
+ if (!others.length) return null;
+ return `Others: ${others.map((alt) => `${alt.label} (${alt.ok ? "available" : alt.reason ?? "not available"})`).join("; ")}`;
+}
+
/** States that change on their own: the card asks again while it shows one. */
const MOVING = new Set<OmniRushWorkspaceBox["state"]>(["downloading", "starting"]);
const POLL_MS = 5_000;
@@ -102,5 +117,24 @@ export function useLinuxSandbox(client: LinuxSandboxClient | null, workspaceId:
await load(true);
}, [busy, client, load, workspaceId]);
- return { box, busy, status, setEnabled, reset };
+ const setBackend = useCallback(async (backend: string) => {
+ if (!client || !workspaceId || busy) return;
+ sequence.current += 1;
+ const startedAt = sequence.current;
+ setBusy(true);
+ setStatus("Saving the backend…");
+ try {
+ const result = await client.setWorkspaceBoxBackend(workspaceId, backend);
+ if (sequence.current !== startedAt) return;
+ setBox(result);
+ setStatus("");
+ } catch {
+ if (sequence.current !== startedAt) return;
+ setStatus("The backend could not be saved. Try again.");
+ } finally {
+ if (sequence.current === startedAt) setBusy(false);
+ }
+ }, [busy, client, workspaceId]);
+
+ return { box, busy, status, setEnabled, setBackend, reset };
}
diff --git a/apps/app/src/react-app/domains/settings/pages/general-view.tsx b/apps/app/src/react-app/domains/settings/pages/general-view.tsx
index 0263de82..8b4858bc 100644
--- a/apps/app/src/react-app/domains/settings/pages/general-view.tsx
+++ b/apps/app/src/react-app/domains/settings/pages/general-view.tsx
@@ -18,6 +18,7 @@ import {
import type { OmniRushAccountSignOutReason } from "@omnirush/types/desktop-ipc";
import { Button } from "@/components/ui/button";
+import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import { t } from "../../../../i18n";
import type { SettingsTab } from "../../../../app/types";
@@ -37,7 +38,7 @@ import {
} from "../approval-mode";
import { DiagnosticsSection } from "./diagnostics-section";
import { BEST_PRACTICES_HELP, useBestPractices, type BestPracticesClient } from "../best-practices";
-import { LINUX_SANDBOX_HELP, linuxSandboxStatusLine, useLinuxSandbox, type LinuxSandboxClient } from "../linux-sandbox";
+import { LINUX_SANDBOX_HELP, linuxSandboxBackendLine, linuxSandboxOthersLine, linuxSandboxStatusLine, useLinuxSandbox, type LinuxSandboxClient } from "../linux-sandbox";
export type GeneralSettingsViewProps = {
onNavigateTab: (tab: SettingsTab) => void;
@@ -227,8 +228,11 @@ export function LinuxSandboxCard(props: {
status: string;
onToggle: (enabled: boolean) => void;
onReset: () => void;
+ onBackend?: (backend: string) => void;
}) {
const box = props.box;
+ const backendItems = box?.backendSetting.choices.map((choice) => ({ value: choice.id, label: choice.label })) ?? [];
+ const others = box ? linuxSandboxOthersLine(box) : null;
return (
<div className="space-y-3">
<div className="text-[11px] font-semibold uppercase tracking-[0.15em] text-dls-secondary">Linux sandbox</div>
@@ -244,10 +248,40 @@ export function LinuxSandboxCard(props: {
{box ? (
<div className="mt-0.5 text-[11px] text-dls-secondary" role="status" data-testid="linux-sandbox-state">{linuxSandboxStatusLine(box)}</div>
) : null}
+ {box ? (
+ <div className="mt-0.5 text-[11px] text-dls-secondary" data-testid="linux-sandbox-backend">
+ {linuxSandboxBackendLine(box)}
+ {box.backend?.why ? <span className="block">{box.backend.why}</span> : null}
+ {others ? <span className="block">{others}</span> : null}
+ </div>
+ ) : null}
{props.status ? (
<div className="mt-0.5 text-[11px] text-dls-secondary" data-testid="linux-sandbox-status">{props.status}</div>
) : null}
</div>
+ {box && props.onBackend ? (
+ <div className="w-44 shrink-0">
+ <Select
+ value={box.backendSetting.value}
+ items={backendItems}
+ onValueChange={(value) => {
+ if (typeof value === "string") props.onBackend?.(value);
+ }}
+ disabled={props.busy || box.backendSetting.source === "env"}
+ >
+ <SelectTrigger className="w-full" aria-label="Sandbox backend">
+ <SelectValue placeholder="Automatic" />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectGroup>
+ {backendItems.map((item) => (
+ <SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>
+ ))}
+ </SelectGroup>
+ </SelectContent>
+ </Select>
+ </div>
+ ) : null}
{box?.on && box.container?.exists ? (
<Button variant="outline" size="xs" disabled={props.busy} onClick={props.onReset}>Reset sandbox</Button>
) : null}
@@ -436,6 +470,7 @@ export function GeneralSettingsView(props: GeneralSettingsViewProps) {
status={linuxSandbox.status}
onToggle={(enabled) => void linuxSandbox.setEnabled(enabled)}
onReset={() => void linuxSandbox.reset()}
+ onBackend={(backend) => void linuxSandbox.setBackend(backend)}
/>
) : null}
diff --git a/apps/app/tests/linux-sandbox-card.test.tsx b/apps/app/tests/linux-sandbox-card.test.tsx
index ac9f931c..3879c6aa 100644
--- a/apps/app/tests/linux-sandbox-card.test.tsx
+++ b/apps/app/tests/linux-sandbox-card.test.tsx
@@ -3,7 +3,7 @@ import { renderToStaticMarkup } from "react-dom/server";
import type { OmniRushWorkspaceBox } from "../src/app/lib/omnirush-server";
import { LinuxSandboxCard } from "../src/react-app/domains/settings/pages/general-view";
-import { LINUX_SANDBOX_HELP, linuxSandboxStatusLine } from "../src/react-app/domains/settings/linux-sandbox";
+import { LINUX_SANDBOX_HELP, linuxSandboxBackendLine, linuxSandboxOthersLine, linuxSandboxStatusLine } from "../src/react-app/domains/settings/linux-sandbox";
function box(overrides: Partial<OmniRushWorkspaceBox> = {}): OmniRushWorkspaceBox {
return {
@@ -14,6 +14,16 @@ function box(overrides: Partial<OmniRushWorkspaceBox> = {}): OmniRushWorkspaceBo
offer: false,
state: "off",
runtime: { ok: true, name: "docker", flavor: "desktop", version: "27.1", reason: null },
+ backend: {
+ id: "docker-desktop", label: "Docker Desktop", version: "27.1", flavor: "desktop", why: "the first that works here, in order: apple > orbstack > colima > docker-desktop",
+ alternatives: [
+ { id: "apple", label: "Apple container", ok: false, reason: "Apple container needs macOS 26 or later (this is macOS 25)" },
+ { id: "docker-desktop", label: "Docker Desktop", ok: true, reason: null },
+ { id: "colima", label: "colima", ok: true, reason: null },
+ ],
+ allowed: null,
+ },
+ backendSetting: { value: "auto", source: "auto", choices: [{ id: "auto", label: "Automatic" }, { id: "apple", label: "Apple container" }, { id: "docker-desktop", label: "Docker Desktop" }, { id: "native", label: "Off (this computer)" }] },
image: { ref: "ghcr.io/omnirush-ai/box-base:2026.10.1", stack: "base", present: true, downloading: false },
container: null,
notice: null,
@@ -54,4 +64,16 @@ describe("Linux sandbox card", () => {
expect(linuxSandboxStatusLine(box({ on: true, state: "failed", error: "could not start the sandbox: x" }))).toBe("The sandbox could not start: could not start the sandbox: x. Commands run on this computer.");
expect(linuxSandboxStatusLine(box({ source: "env" }))).toContain("OMNIRUSH_BOX");
});
+
+ test("backend: the chosen one with its version and why, the others with why not, and the override", () => {
+ const value = box({ mode: "on", on: true, source: "project", state: "ready" });
+ expect(linuxSandboxBackendLine(value)).toBe("Backend: Docker Desktop 27.1");
+ expect(linuxSandboxOthersLine(value)).toBe("Others: Apple container (Apple container needs macOS 26 or later (this is macOS 25)); colima (available)");
+ const markup = renderToStaticMarkup(<LinuxSandboxCard box={value} busy={false} status="" onToggle={() => {}} onReset={() => {}} onBackend={() => {}} />);
+ expect(markup).toContain("Backend: Docker Desktop 27.1");
+ expect(markup).toContain("in order: apple &gt; orbstack");
+ expect(markup).toContain('aria-label="Sandbox backend"');
+ expect(linuxSandboxBackendLine(box({ backend: { id: null, label: null, version: null, flavor: null, why: "no sandbox backend works here", alternatives: [], allowed: null } }))).toBe("Backend: none available");
+ expect(linuxSandboxBackendLine(box({ backendSetting: { value: "native", source: "setting", choices: [] } }))).toBe("Backend: off (commands run on this computer)");
+ });
});