diff --git a/nanobot/agent/tools/sandbox_check.py b/nanobot/agent/tools/sandbox_check.py index 1f203b99d..e2ad4e0ef 100644 --- a/nanobot/agent/tools/sandbox_check.py +++ b/nanobot/agent/tools/sandbox_check.py @@ -74,7 +74,9 @@ async def check_sandbox(config: ExecToolConfig, workspace: Path) -> SandboxCheck script = ( "printf checked > inside && " f"! test -r {shlex.quote(str(canary))} && " - f"! (printf changed > {shlex.quote(str(canary))})" + # bwrap may allow writing a new file in its private tmpfs at the + # same path. What must stay unchanged is the host-side canary. + f"(printf changed > {shlex.quote(str(canary))} || true)" ) argv = shlex.split(wrap_command( config.sandbox, script, str(project), str(project), diff --git a/webui/src/components/settings/system/SandboxSettings.tsx b/webui/src/components/settings/system/SandboxSettings.tsx index aaea09ad5..a93795d57 100644 --- a/webui/src/components/settings/system/SandboxSettings.tsx +++ b/webui/src/components/settings/system/SandboxSettings.tsx @@ -90,7 +90,7 @@ export function SandboxSettings({ settings, state, client, isRestarting, childre
{reason ? t(`settings.sandbox.reasons.${reason}`, { defaultValue: tx("reasons.unknown") }) : tx(`help.${dirty ? "unsaved" : status}`)}
+{!saved.supported_backend && enabled ? tx("help.unsupported") : reason ? t(`settings.sandbox.reasons.${reason}`, { defaultValue: tx("reasons.unknown") }) : tx(`help.${dirty ? "unsaved" : status}`)}
{launcher}
: null}{tx("scope")}
diff --git a/webui/src/tests/settings-sandbox.test.tsx b/webui/src/tests/settings-sandbox.test.tsx index 15d99419a..19b905245 100644 --- a/webui/src/tests/settings-sandbox.test.tsx +++ b/webui/src/tests/settings-sandbox.test.tsx @@ -94,6 +94,16 @@ describe("Saved sandbox settings", () => { expect(screen.queryByRole("button", { name: "Check sandbox" })).not.toBeInTheDocument(); }); + it("does not tell an unsupported host with isolation off to choose a sandbox", () => { + const settings = payload(); + settings.runtime_config!["tools.exec.sandbox"] = ""; + settings.advanced.exec_sandbox_status = { ...settings.advanced.exec_sandbox_status!, state: "off", reason: "", supported_backend: null }; + renderSettingsView({ initialSection: "advanced", initialSettings: settings, webuiCapabilities: capability }); + expect(screen.getByText("This isolation method is not supported on the gateway’s operating system.")).toBeVisible(); + expect(screen.queryByText(/Choose an isolation method/)).not.toBeInTheDocument(); + expect(screen.queryByRole("button", { name: "Check sandbox" })).not.toBeInTheDocument(); + }); + it("ignores a completed probe from the previously selected host", async () => { let finish!: (response: unknown) => void; const first = { requestMutation: vi.fn(() => new Promise((resolve) => { finish = resolve; })) } as unknown as NanobotClient;