The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 07:00 UTC
fix(desktop): prepare macOS x64 bytecode under Rosetta (#29484)
Yash Singh committed
Nov 2, 2026 at 14:26 UTC
bdf5806dfcf31e6fd3ce4d8d028e262f4fe6d7e3
4 files changed
+81
-3
.github/workflows/release-desktop.yml
+8
@@ -203,6 +203,14 @@ jobs:
203
native/hyprland-snap-shot/target/${{ inputs.rust_target }}/release/t3-hyprland-snap-shot
204
key: linux-capture-helpers-${{ inputs.rust_target }}-${{ hashFiles('native/kde-snap-shot/Cargo.lock', 'native/kde-snap-shot/Cargo.toml', 'native/kde-snap-shot/src/**', 'native/hyprland-snap-shot/Cargo.lock', 'native/hyprland-snap-shot/Cargo.toml', 'native/hyprland-snap-shot/src/**', 'native/hyprland-snap-shot/protocols/**') }}
205
206
+ - name: Ensure Rosetta for macOS x64 bytecode generation
207
+ if: inputs.platform == 'mac' && inputs.arch == 'x64'
208
+ shell: bash
209
+ run: |
210
+ if [[ "$(uname -m)" == "arm64" ]] && ! /usr/bin/arch -x86_64 /usr/bin/true; then
211
+ sudo /usr/sbin/softwareupdate --install-rosetta --agree-to-license
212
+ fi
213
+
214
- name: Setup Rust
215
if: steps.resource_monitor_cache.outputs.cache-hit != 'true' || (inputs.platform == 'linux' && steps.capture_helper_cache.outputs.cache-hit != 'true')
216
uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
docs/operations/development.md
+3
-2
@@ -265,8 +265,9 @@ options.
265
266
Native macOS and Windows desktop artifact builds generate server bytecode with the packaged
267
Electron executable, after ASAR creation and before signing. Linux builds skip generation until
268
-native packaging and relocated AppImage reuse have been validated. Cross-platform and
269
-cross-architecture builds also skip generation explicitly. CLI, SEA and WSL runtimes keep their
268
+native packaging and relocated AppImage reuse have been validated. macOS x64 builds on ARM64
269
+hosts run the packaged x64 Electron under Rosetta to generate the cache. Other cross-platform and
270
+cross-architecture builds skip generation explicitly. CLI, SEA and WSL runtimes keep their
271
existing behavior; only desktop backend imports covered by generation receive prepared bytecode.
272
Worker-only modules compile normally.
273
scripts/lib/server-compile-cache.test.ts
+61
@@ -25,6 +25,67 @@ it.each(["x64", "arm64"])("skips prepared bytecode generation on Linux %s", asyn
25
expect(result.stdout).toContain("Skipping unsupported target linux");
26
});
27
28
+it("prepares macOS x64 cache on an ARM64 build host", async () => {
29
+ const { spawnSync } = await import("node:child_process");
30
+ const root = NodeFS.realpathSync(
31
+ NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-rosetta-cache-")),
32
+ );
33
+ try {
34
+ const resources = NodePath.join(root, "Fixture.app", "Contents", "Resources");
35
+ const archive = NodePath.join(resources, "app.asar");
36
+ const dist = NodePath.join(archive, "apps/server/dist");
37
+ const helper = NodePath.join(archive, "apps/desktop/dist-electron/serverCompileCache.cjs");
38
+ NodeFS.mkdirSync(dist, { recursive: true });
39
+ NodeFS.mkdirSync(NodePath.dirname(helper), { recursive: true });
40
+ NodeFS.writeFileSync(NodePath.join(dist, "binCli-fixture.mjs"), "export const answer = 42;");
41
+ NodeFS.writeFileSync(
42
+ helper,
43
+ `module.exports = require(${JSON.stringify(NodeURL.fileURLToPath(new URL("./server-compile-cache.ts", import.meta.url)))});`,
44
+ );
45
+ const hook = NodeURL.fileURLToPath(
46
+ new URL("../prepare-server-compile-cache.cjs", import.meta.url),
47
+ );
48
+ // The fixture uses Node for generation; the hook still sees an ARM64 macOS build host.
49
+ const result = spawnSync(
50
+ process.execPath,
51
+ [
52
+ "-e",
53
+ `
54
+ const childProcess = require("node:child_process");
55
+ const spawn = childProcess.spawnSync;
56
+ childProcess.spawnSync = (executable, args, options) => {
57
+ require("node:assert/strict").equal(executable, ${JSON.stringify(NodePath.join(root, "Fixture.app", "Contents", "MacOS", "Fixture"))});
58
+ return spawn(process.execPath, args, options);
59
+ };
60
+ Object.defineProperty(process, "platform", { value: "darwin" });
61
+ Object.defineProperty(process, "arch", { value: "arm64" });
62
+ require(${JSON.stringify(hook)})({
63
+ appOutDir: ${JSON.stringify(root)}, electronPlatformName: "darwin", arch: 1,
64
+ packager: { appInfo: { productFilename: "Fixture" } }
65
+ }).catch(error => { console.error(error); process.exitCode = 1; });
66
+ `,
67
+ ],
68
+ { encoding: "utf8" },
69
+ );
70
+ expect(result.status, result.stderr).toBe(0);
71
+ const manifest = JSON.parse(
72
+ NodeFS.readFileSync(NodePath.join(resources, "server-compile-cache/manifest.json"), "utf8"),
73
+ );
74
+ expect(manifest.entries).toEqual([
75
+ {
76
+ module: "app.asar/apps/server/dist/binCli-fixture.mjs",
77
+ file: expect.stringMatching(/^[a-f0-9]{8}$/),
78
+ },
79
+ ]);
80
+ expect(
81
+ NodeFS.statSync(NodePath.join(resources, "server-compile-cache", manifest.entries[0].file))
82
+ .size,
83
+ ).toBeGreaterThan(0);
84
+ } finally {
85
+ NodeFS.rmSync(root, { recursive: true, force: true });
86
+ }
87
+});
88
+
89
it("seeds relocated cache entries without allowing writes into shipped resources", () => {
90
const root = NodeFS.realpathSync(
91
NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-prepared-test-")),
scripts/prepare-server-compile-cache.cjs
+9
-1
@@ -12,7 +12,15 @@ module.exports = async ({ appOutDir, electronPlatformName, arch, packager }) =>
12
return;
13
}
14
const targetArch = ["ia32", "x64", "armv7l", "arm64", "universal"][arch];
15
- if (electronPlatformName !== process.platform || targetArch !== process.arch) {
15
+ const runsWithRosetta =
16
+ electronPlatformName === "darwin" &&
17
+ process.platform === "darwin" &&
18
+ process.arch === "arm64" &&
19
+ targetArch === "x64";
20
+ if (
21
+ electronPlatformName !== process.platform ||
22
+ (targetArch !== process.arch && !runsWithRosetta)
23
+ ) {
24
console.log(
25
`[server-compile-cache] Skipping unexecutable target ${electronPlatformName}/${targetArch}`,
26
);