Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: test answers only in source builds

ogsamrat8a8b07b50df7
diff --git a/apps/desktop/electron/computer-use-answers.mjs b/apps/desktop/electron/computer-use-answers.mjs
new file mode 100644
index 00000000..f7e5ec41
--- /dev/null
+++ b/apps/desktop/electron/computer-use-answers.mjs
@@ -0,0 +1,8 @@
+// Whether a rig may answer computer use questions without a physical press (remote-debugging clicks).
+// Only in a build run from source: a packaged app ignores OMNIRUSH_COMPUTER_USE_TEST_ANSWERS, so relaunching
+// it with that environment can never approve on the person's behalf.
+export function testAnswersAllowed(env, isPackaged, warn = () => {}) {
+ if (env?.OMNIRUSH_COMPUTER_USE_TEST_ANSWERS !== "1") return false;
+ if (isPackaged) { warn("OMNIRUSH_COMPUTER_USE_TEST_ANSWERS is ignored in a packaged app."); return false; }
+ return true;
+}
diff --git a/apps/desktop/electron/computer-use-answers.test.mjs b/apps/desktop/electron/computer-use-answers.test.mjs
new file mode 100644
index 00000000..872bf4cd
--- /dev/null
+++ b/apps/desktop/electron/computer-use-answers.test.mjs
@@ -0,0 +1,13 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { testAnswersAllowed } from "./computer-use-answers.mjs";
+
+test("computer use test answers: only a build run from source honours the switch", () => {
+ const warnings = [];
+ assert.equal(testAnswersAllowed({ OMNIRUSH_COMPUTER_USE_TEST_ANSWERS: "1" }, true, (m) => warnings.push(m)), false);
+ assert.equal(warnings.length, 1);
+ assert.equal(testAnswersAllowed({ OMNIRUSH_COMPUTER_USE_TEST_ANSWERS: "1" }, false), true);
+ assert.equal(testAnswersAllowed({}, false), false);
+ assert.equal(testAnswersAllowed({ OMNIRUSH_COMPUTER_USE_TEST_ANSWERS: "true" }, false), false);
+});
diff --git a/apps/desktop/electron/computer-use.mjs b/apps/desktop/electron/computer-use.mjs
index 34e13fb0..31ec1902 100644
--- a/apps/desktop/electron/computer-use.mjs
+++ b/apps/desktop/electron/computer-use.mjs
@@ -19,6 +19,7 @@ import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
import { app } from "electron";
+import { testAnswersAllowed } from "./computer-use-answers.mjs";
import { createComputerUseHost } from "./computer-use-host.mjs";
import { createComputerPreview } from "./computer-use-preview.mjs";
@@ -33,9 +34,10 @@ const secretHeaders = { "x-omnirush-computer-use-secret": HOST_SECRET };
// The profile folder the local server expects the host in (computer-use/desktop.ts expectedHostCommand).
const profileDir = () => process.env.OMNIRUSH_DESKTOP_USER_DATA_DIR?.trim() || app.getPath("userData");
const SYNTHETIC_MESSAGE = "Use your own mouse or keyboard to approve.";
-// Answers need a physical press in this app's window. OMNIRUSH_COMPUTER_USE_TEST_ANSWERS=1 (rigs only: the
-// app's own environment, which the agent cannot set for a running app) accepts remote-debugging clicks.
-const testAnswers = process.env.OMNIRUSH_COMPUTER_USE_TEST_ANSWERS === "1";
+// Answers need a physical press in this app's window. OMNIRUSH_COMPUTER_USE_TEST_ANSWERS=1 accepts
+// remote-debugging clicks, in builds run from source only (the e2e rig).
+// Packaged apps ignore it (computer-use-answers.mjs).
+const testAnswers = testAnswersAllowed(process.env, app.isPackaged, (message) => console.warn(`[computer-use] ${message}`));
async function personAnswered() {
if (!host) return false;
if (await host.syntheticInput()) return false;
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 03fa8ec2..4c48082a 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -27,7 +27,7 @@
"prepare:sidecar": "node ./scripts/prepare-sidecar.mjs",
"pretest": "pnpm --filter @omnirush/headless-threads build",
"test:omnirush-account": "node --test electron/omnirush-account.test.mjs",
- "test": "node --test scripts/prepare-server-constants.test.mjs scripts/verify-update-manifest.test.mjs electron/after-pack-paths.test.mjs electron/agent-context-diagnostics-fetch.test.mjs electron/automation-runner.test.mjs electron/binary-transfer.test.mjs electron/blank-slate-profile.test.mjs electron/blank-slate-profile-isolation.test.mjs electron/brand-app-name.test.mjs electron/brand-icon-darwin.test.mjs electron/brand-icon-windows.test.mjs electron/browser-login-sync.test.mjs electron/browser-panel.test.mjs electron/connect-link.test.mjs electron/desktop-distribution.test.mjs electron/dev-profile.test.mjs electron/electron-builder-config.test.mjs electron/linux-desktop-integration.test.mjs electron/linux-password-store.test.mjs electron/logs-folder.test.mjs electron/media-permissions.test.mjs electron/no-bare-external-fetch.test.mjs electron/nuke.test.mjs electron/omnirush-account.test.mjs electron/omnirush-ui-mcp.test.mjs electron/open-external.test.mjs electron/open-local-path.test.mjs electron/process-resilience.test.mjs electron/runtime.test.mjs electron/runtime-ca.test.mjs electron/system-ca-trust.test.mjs electron/external-fetch.test.mjs electron/runtime-chain-repair.test.mjs electron/sentry.test.mjs electron/server-dependency-mirror.test.mjs electron/skill-folder.test.mjs electron/secure-vault-key.test.mjs electron/stdio-errors.test.mjs electron/terminal-sessions.test.mjs electron/ui-control-server.test.mjs electron/updater.test.mjs electron/update-gate.test.mjs electron/quality.test.mjs electron/buildathon.test.mjs electron/placements-desktop.test.mjs electron/feedback-desktop.test.mjs electron/turn-guard.test.mjs electron/keep-awake.test.mjs electron/remote-workspace.test.mjs electron/workspace-archive.test.mjs electron/workspace-store.test.mjs electron/start-report.test.mjs electron/start-reset.test.mjs electron/start-store-check.test.mjs",
+ "test": "node --test scripts/prepare-server-constants.test.mjs scripts/verify-update-manifest.test.mjs electron/after-pack-paths.test.mjs electron/agent-context-diagnostics-fetch.test.mjs electron/automation-runner.test.mjs electron/binary-transfer.test.mjs electron/blank-slate-profile.test.mjs electron/blank-slate-profile-isolation.test.mjs electron/brand-app-name.test.mjs electron/brand-icon-darwin.test.mjs electron/brand-icon-windows.test.mjs electron/browser-login-sync.test.mjs electron/browser-panel.test.mjs electron/connect-link.test.mjs electron/desktop-distribution.test.mjs electron/dev-profile.test.mjs electron/electron-builder-config.test.mjs electron/linux-desktop-integration.test.mjs electron/linux-password-store.test.mjs electron/logs-folder.test.mjs electron/media-permissions.test.mjs electron/no-bare-external-fetch.test.mjs electron/nuke.test.mjs electron/omnirush-account.test.mjs electron/omnirush-ui-mcp.test.mjs electron/open-external.test.mjs electron/open-local-path.test.mjs electron/process-resilience.test.mjs electron/runtime.test.mjs electron/runtime-ca.test.mjs electron/system-ca-trust.test.mjs electron/external-fetch.test.mjs electron/runtime-chain-repair.test.mjs electron/sentry.test.mjs electron/server-dependency-mirror.test.mjs electron/skill-folder.test.mjs electron/secure-vault-key.test.mjs electron/stdio-errors.test.mjs electron/terminal-sessions.test.mjs electron/ui-control-server.test.mjs electron/updater.test.mjs electron/update-gate.test.mjs electron/quality.test.mjs electron/buildathon.test.mjs electron/placements-desktop.test.mjs electron/feedback-desktop.test.mjs electron/turn-guard.test.mjs electron/keep-awake.test.mjs electron/computer-use-answers.test.mjs electron/remote-workspace.test.mjs electron/workspace-archive.test.mjs electron/workspace-store.test.mjs electron/start-report.test.mjs electron/start-reset.test.mjs electron/start-store-check.test.mjs",
"test:core": "node --test scripts/prepare-server-constants.test.mjs electron/workspace-store.test.mjs electron/workspace-archive.test.mjs electron/connect-link.test.mjs electron/open-external.test.mjs electron/open-local-path.test.mjs electron/secure-vault-key.test.mjs electron/process-resilience.test.mjs electron/stdio-errors.test.mjs electron/runtime-ca.test.mjs electron/system-ca-trust.test.mjs electron/external-fetch.test.mjs electron/runtime-chain-repair.test.mjs electron/automation-runner.test.mjs",
"pretest:core": "pnpm --filter @omnirush/headless-threads build"
},