The best way to control Claude Code, Codex and more from any computer or phone
fix(dev): Fix electron dev launch and add test (#3662)
Theo Browne committed
Jul 2, 2026 at 18:57 UTC
6d35a87c5d0e6dcf16be5b1d9a236a1d5e12c8c7
2 files changed
+34
-7
apps/desktop/scripts/electron-launcher.mjs
+13
-6
@@ -358,10 +358,7 @@ function resolveLinuxSandboxArgs(electronBinaryPath) {
358
}
359
360
export function resolveElectronPath() {
361
- ensureElectronRuntime();
362
-
363
- const require = NodeModule.createRequire(import.meta.url);
364
- const electronBinaryPath = require("electron");
361
+ const electronBinaryPath = resolveElectronBinaryPath();
362
363
if (hostPlatform !== "darwin") {
364
return electronBinaryPath;
@@ -378,13 +375,23 @@ export function resolveElectronLaunchCommand(args = []) {
375
};
376
}
377
378
+export function resolveElectronBinaryPath({
379
+ ensureRuntime = ensureElectronRuntime,
380
+ createRequire = NodeModule.createRequire,
381
+ moduleUrl = import.meta.url,
382
+} = {}) {
383
+ ensureRuntime();
384
+
385
+ const require = createRequire(moduleUrl);
386
+ return require("electron");
387
+}
388
+
389
export function resolveDevProtocolClient() {
390
if (hostPlatform !== "darwin" || !isDevelopment) {
391
return null;
392
}
393
386
- const require = NodeModule.createRequire(import.meta.url);
387
- const electronBinaryPath = require("electron");
394
+ const electronBinaryPath = resolveElectronBinaryPath();
395
const launcherBinaryPath = buildMacLauncher(electronBinaryPath);
396
return {
397
appBundlePath: NodePath.resolve(launcherBinaryPath, "..", "..", ".."),
apps/desktop/scripts/electron-launcher.test.mjs
+21
-1
@@ -1,6 +1,6 @@
1
import { assert, describe, it } from "vite-plus/test";
2
3
-import { makeDevelopmentLauncherScript } from "./electron-launcher.mjs";
3
+import { makeDevelopmentLauncherScript, resolveElectronBinaryPath } from "./electron-launcher.mjs";
4
5
describe("electron development launcher", () => {
6
it("uses captured values only as fallbacks for a live runner environment", () => {
@@ -25,4 +25,24 @@ describe("electron development launcher", () => {
25
"exec '/repo/node_modules/electron/Electron' --t3code-dev-root='/repo/apps/desktop' '/repo/apps/desktop/dist-electron/main.cjs' \"$@\"",
26
);
27
});
28
+
29
+ it("repairs Electron before loading the package entrypoint", () => {
30
+ const calls = [];
31
+ const electronPath = resolveElectronBinaryPath({
32
+ ensureRuntime: () => {
33
+ calls.push("ensure");
34
+ },
35
+ createRequire: () => (specifier) => {
36
+ calls.push(`require:${specifier}`);
37
+ return "/repo/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron";
38
+ },
39
+ moduleUrl: import.meta.url,
40
+ });
41
+
42
+ assert.equal(
43
+ electronPath,
44
+ "/repo/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron",
45
+ );
46
+ assert.deepEqual(calls, ["ensure", "require:electron"]);
47
+ });
48
});