Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: apple container only when picked

Samrat Talukdarf7b9fa7e8ebb
diff --git a/apps/server/src/box/backends/apple.ts b/apps/server/src/box/backends/apple.ts
index f9971ad2..bccdf360 100644
--- a/apps/server/src/box/backends/apple.ts
+++ b/apps/server/src/box/backends/apple.ts
@@ -100,7 +100,7 @@ export async function probeApple({ env = process.env, platform = process.platfor
const status = await run(bin, ["system", "status"], { env, timeoutMs });
const said = `${status.stdout}\n${status.stderr}`;
if (status.code !== 0 || /not running|not registered|unavailable/i.test(said) || versions.server === null) {
- return { ...base, ok: false, bin, version, reason: "Apple container is installed but not started (run `container system start` once)" };
+ return { ...base, ok: false, bin, version, reason: "Apple container is installed but not running (OmniRush never starts it; `container system start` is known to hang on macOS 27)" };
}
return { ...base, ok: true, bin, version, os: "linux", arch: "arm64", flavor: "apple-container", rootless: true, vm: true };
}
diff --git a/apps/server/src/box/backends/index.ts b/apps/server/src/box/backends/index.ts
index 774cc71f..a0d3fae9 100644
--- a/apps/server/src/box/backends/index.ts
+++ b/apps/server/src/box/backends/index.ts
@@ -10,7 +10,8 @@
// `__sandbox__` format, so the converter and the rebuild do not change.
//
// Linux: bwrap (no daemon, no root) > rootless Podman > Docker
-// macOS: Apple container (macOS 26+) > OrbStack > colima > Docker Desktop > Rancher > Podman machine
+// macOS: OrbStack > colima > Docker Desktop > Rancher > Podman machine
+// (Apple container is opt-in only: never picked on its own, never started unasked)
// Windows: WSL containers (wslc, WSL 3.0.1+) > OmniRush's WSL distro > Docker Desktop > Podman machine
// > Docker in the default WSL distro
//
@@ -34,10 +35,19 @@ type Env = NodeJS.ProcessEnv;
export const ORDER: Record<"linux" | "darwin" | "win32", string[]> = {
linux: ["bwrap", "podman", "docker"],
- darwin: ["apple", "orbstack", "colima", "docker-desktop", "rancher", "podman", "docker"],
+ darwin: ["orbstack", "colima", "docker-desktop", "rancher", "podman", "docker"],
win32: ["wslc", "wsl", "docker-desktop", "podman", "docker", "wsl-engine"],
};
+/**
+ * Backends used only when chosen by name (the sandbox backend setting,
+ * OMNIRUSH_BOX_BACKEND), never in the automatic order. Apple container: on
+ * macOS 27 `container system start` can hang and leave the Mac's network
+ * sharing stuck until a reboot (apple/container#2275), and it turns the
+ * packet filter on for all host traffic (#2335).
+ */
+export const OPT_IN: Partial<Record<NodeJS.Platform, string[]>> = { darwin: ["apple"] };
+
/** What the backend setting takes (and what uploads record as sandbox.backend). */
export const BACKENDS = ["bwrap", "apple", "wslc", "wsl", "orbstack", "colima", "docker-desktop", "rancher", "docker", "podman", "wsl-engine"] as const;
export type BackendId = (typeof BACKENDS)[number];
@@ -183,7 +193,7 @@ function writeCache(boxHome: string, key: string, result: RuntimeResult, now: nu
/** One line when nothing works, with the free option to install. */
export function noneReason(platform: NodeJS.Platform): string {
if (platform === "linux") return "no sandbox backend works here (install bubblewrap, Podman or Docker)";
- if (platform === "darwin") return "no container runtime found (free: `brew install colima docker && colima start`; also Apple container on macOS 26, OrbStack, Docker Desktop, Podman)";
+ if (platform === "darwin") return "no container runtime found (free: `brew install colima docker && colima start`; also OrbStack, Docker Desktop, Podman; Apple container only when chosen in Settings)";
return "no sandbox backend found (turn on WSL 2: `wsl --install --no-distribution` as administrator, then `wsl --update` for WSL containers; or Docker Desktop, Podman)";
}
@@ -263,6 +273,8 @@ export async function detectBackend({ boxHome, env = process.env, platform = pro
if (chosen && !all) break;
}
if (all && containers === null) await containerList();
+ // Opt-in backends are listed for the status, never probed or started unless chosen.
+ if (all && wanted === "auto") for (const id of OPT_IN[platform] ?? []) if (!results.some((r) => r.backend === id)) results.push({ backend: id, name: id, ok: false, reason: "opt-in only: choose it in Settings (sandbox backend)" });
const probedContainers: Probed[] = containers ?? [];
if (all) for (const r of probedContainers) if (!results.some((x) => "bin" in x && x.bin === r.bin && ("context" in x ? x.context : undefined) === r.context && x.name === r.name)) results.push(r);
const failed = [...skipped, ...results.filter((r) => !r.ok)];
diff --git a/apps/server/src/box/box-backends.test.ts b/apps/server/src/box/box-backends.test.ts
index 877b4a9d..847bedb4 100644
--- a/apps/server/src/box/box-backends.test.ts
+++ b/apps/server/src/box/box-backends.test.ts
@@ -12,7 +12,7 @@ import os from "node:os";
import path from "node:path";
import { PassThrough } from "node:stream";
-import { BACKENDS, backendsFor, detectBackend, driverFor, normalizeBackend, ORDER } from "./backends/index.js";
+import { OPT_IN, BACKENDS, backendsFor, detectBackend, driverFor, normalizeBackend, ORDER } from "./backends/index.js";
import { apparmorProfile, boxdEnv, boxrunPath, explainProbe, parseOut, probeBwrap, upArgs } from "./backends/bwrap.js";
import { createAppleArgs, findDigest, macosMajor, parseVersions, probeApple, snapshotInfo, SUPPORTED as APPLE } from "./backends/apple.js";
import { versionAtLeast } from "./backends/shared.js";
@@ -54,11 +54,14 @@ function helperBin(): string {
describe("box backends: ranking and overrides", () => {
test("the ranked order per OS", () => {
expect(ORDER.linux).toEqual(["bwrap", "podman", "docker"]);
- expect(ORDER.darwin).toEqual(["apple", "orbstack", "colima", "docker-desktop", "rancher", "podman", "docker"]);
+ expect(ORDER.darwin).toEqual(["orbstack", "colima", "docker-desktop", "rancher", "podman", "docker"]);
+ expect(OPT_IN.darwin).toEqual(["apple"]);
expect(ORDER.win32).toEqual(["wslc", "wsl", "docker-desktop", "podman", "docker", "wsl-engine"]);
for (const list of Object.values(ORDER)) for (const id of list) expect(BACKENDS.some((b) => b === id)).toBe(true);
expect(backendsFor("linux")).toEqual(ORDER.linux);
expect(backendChoices("win32").map((c) => c.id)).toEqual(["auto", ...ORDER.win32, "native"]);
+ expect(backendChoices("darwin").map((c) => c.id)).toEqual(["auto", ...ORDER.darwin, "apple", "native"]);
+ expect(backendChoices("darwin").find((c) => c.id === "apple")?.label).toBe("Apple container (opt-in)");
});
test("setting values: ids, aliases, auto, native; anything else is refused", () => {
@@ -221,7 +224,7 @@ describe("box backends: macOS", () => {
expect(findDigest({ variants: [{ config: { digest: `sha256:${"d".repeat(64)}` } }] })).toBe(`sha256:${"d".repeat(64)}`);
});
- test("ranking: Apple container first, then OrbStack, colima, Docker Desktop through docker contexts", async () => {
+ test("ranking: OrbStack, colima, Docker Desktop through docker contexts; Apple container never probed unasked", async () => {
const docker = "/usr/local/bin/docker";
const infos: Record<string, unknown> = { orbstack: { OperatingSystem: "OrbStack", Name: "orbstack", ServerVersion: "27.0", OSType: "linux", Architecture: "aarch64" }, colima: { OperatingSystem: "Ubuntu 24.04", Name: "colima", ServerVersion: "27.1", OSType: "linux" }, "desktop-linux": { OperatingSystem: "Docker Desktop", ServerVersion: "28.0", OSType: "linux" } };
const contexts = ["desktop-linux", "colima", "default"].map((Name) => JSON.stringify({ Name, DockerEndpoint: `unix:///x/${Name}.sock` })).join("\n");
@@ -234,11 +237,29 @@ describe("box backends: macOS", () => {
const home = tmp();
const found = await detectBackend({ boxHome: home, platform: "darwin", arch: "arm64", release: "24.0.0", home: "/Users/sam", env: { PATH: "/usr/local/bin" }, exists: set(docker), run, fresh: true, all: true });
expect(found).toMatchObject({ ok: true, backend: "colima", prefix: ["--context", "colima"] });
- expect(found.alternatives?.find((a) => a.backend === "apple")?.reason).toMatch(/macOS 26/);
+ expect(found.alternatives?.find((a) => a.backend === "apple")?.reason).toMatch(/opt-in only/);
expect(found.alternatives?.some((a) => a.backend === "docker-desktop" && a.ok)).toBe(true);
const none = await detectBackend({ boxHome: home, platform: "darwin", home: "/Users/sam", env: { PATH: "/usr/bin" }, exists: () => false, run, fresh: true });
expect(none).toMatchObject({ ok: false, hint: "colima" });
});
+
+ test("Apple container: opt-in only, used when chosen, never started", async () => {
+ const calls: string[][] = [];
+ const run: RunCommand = async (bin, args) => {
+ calls.push([bin, ...args]);
+ if (bin === APPLE_BIN) return args[1] === "version" ? ok(appleVersions) : ok("apiserver is running");
+ return fail("Cannot connect to the Docker daemon");
+ };
+ const base = { boxHome: tmp(), platform: "darwin" as const, arch: "arm64", release: "26.0.0", home: "/Users/sam", env: { PATH: "/usr/local/bin" }, exists: set(APPLE_BIN), run, fresh: true };
+ const auto = await detectBackend(base);
+ expect(auto.ok).toBe(false);
+ expect(calls.some(([bin]) => bin === APPLE_BIN)).toBe(false);
+ const asked = await detectBackend({ ...base, asked: "apple-container" });
+ expect(asked).toMatchObject({ ok: true, backend: "apple" });
+ expect(calls.some((c) => c.slice(1).join(" ") === "system start")).toBe(false);
+ const stopped = await probeApple({ ...base, run: async (_b, args) => (args[1] === "version" ? ok(appleVersions) : fail("apiserver is not running")) });
+ expect(stopped.ok ? "" : stopped.reason).toMatch(/never starts it/);
+ });
});
// --- Windows: the OmniRush WSL distro --------------------------------------------------------
diff --git a/apps/server/src/box/service.ts b/apps/server/src/box/service.ts
index a868ab33..8e26de8f 100644
--- a/apps/server/src/box/service.ts
+++ b/apps/server/src/box/service.ts
@@ -25,7 +25,7 @@ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { boxHome, boxKey, boxSnapshotsDir, containerName, installShell, listBoxes, readRecord, resetBox, savedTurns, type BoxLabel, type BoxLog } from "./box.js";
-import { LABELS, backendsFor, driverFor } from "./backends/index.js";
+import { LABELS, OPT_IN, backendsFor, driverFor } from "./backends/index.js";
import type { BoxExec } from "./backends/types.js";
import { detectStack, imageFor } from "./images.js";
import { askedBackend, boxRun, planBox, pulling, pullInBackground, resolveMode, saveBackend, serverBackends, serverDefault, shimsDir, type BoxRun, type ProjectBoxMode, type ServerBoxDefault } from "./launch.js";
@@ -88,9 +88,10 @@ export type BoxBackendView = {
allowed: string[] | null;
};
-/** The backend choices of a platform: auto, the ranked ids there, native. */
+/** The backend choices of a platform: auto, the ranked ids there, the opt-in ones, native. */
export function backendChoices(platform: NodeJS.Platform = process.platform): Array<{ id: string; label: string }> {
- return [{ id: "auto", label: "Automatic" }, ...backendsFor(platform).map((id) => ({ id, label: LABELS[id] ?? id })), { id: "native", label: "Off (this computer)" }];
+ const optIn = (OPT_IN[platform] ?? []).map((id) => ({ id, label: `${LABELS[id] ?? id} (opt-in)` }));
+ return [{ id: "auto", label: "Automatic" }, ...backendsFor(platform).map((id) => ({ id, label: LABELS[id] ?? id })), ...optIn, { id: "native", label: "Off (this computer)" }];
}
export type BoxServiceOptions = {