Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: windows sandbox install only when required

ogsamrat7b86b598c5c0
diff --git a/apps/server/src/box/box-required-service.test.ts b/apps/server/src/box/box-required-service.test.ts
index 69192d19..960a31a5 100644
--- a/apps/server/src/box/box-required-service.test.ts
+++ b/apps/server/src/box/box-required-service.test.ts
@@ -7,6 +7,7 @@ import { boxKey, setToolsRoot } from "./box.js";
import { planBox, rememberServerDefault, REQUIRED_REDETECT_MS, resolveMode, serverRequired, type BoxRun } from "./launch.js";
import type { RunCommand } from "./run.js";
import { DESKTOP_PROJECTS_FILE } from "./plugin-lib.js";
+import { setupState } from "./setup.js";
import { BoxRequiredError, BoxService, type BoxWorkspace } from "./service.js";
const dirs: string[] = [];
@@ -215,6 +216,18 @@ describe("required sandbox: the desktop's projects", () => {
expect(await boxes.prefetch()).toBe(false);
});
+ test("the admin setup steps run only when the sandbox is required", async () => {
+ const stateDir = await temp("state");
+ const root = await temp("project");
+ const home = await temp("boxhome");
+ const workspace: BoxWorkspace = { id: "ws_setup", path: root, workspaceType: "local" };
+ rememberServerDefault(stateDir, { local_box: { default: "on" } });
+ const boxes = service({ stateDir, workspaces: [workspace], env: { OMNIRUSH_BOX_HOME: home, ...NO_RUNTIME }, platform: "win32" });
+ await boxes.setup(workspace, "decline");
+ await boxes.setup(workspace, "win_install");
+ expect(setupState(home).win).toBeUndefined();
+ });
+
test("a server that says `on` with prefetch: no prefetch for a device it does not require", async () => {
const stateDir = await temp("state");
rememberServerDefault(stateDir, { local_box: { default: "on", required: false, setup: { prefetch: true } } });
diff --git a/apps/server/src/box/service.ts b/apps/server/src/box/service.ts
index ee4a9897..426cb1e6 100644
--- a/apps/server/src/box/service.ts
+++ b/apps/server/src/box/service.ts
@@ -727,6 +727,8 @@ export class BoxService {
async setup(workspace: BoxWorkspace, action: BoxSetupAction): Promise<BoxStatus> {
const home = this.home;
const which = this.platform === "win32" ? "win" : this.platform === "linux" ? "linux" : null;
+ // The admin steps (pkexec, UAC, a restart) run only where the server requires the sandbox.
+ if (!this.required().required && action !== "check") return this.status(workspace, { fresh: true });
if (action === "linux_allow" && this.platform === "linux") await linuxAllow({ home, env: this.env });
else if (action === "win_install" && this.platform === "win32") await windowsInstall({ home, env: this.env });
else if (action === "win_update" && this.platform === "win32") await windowsUpdate({ env: this.env });