@devries-cameron20 / t3code Mirror · read-only / commits / ea7d46ac10
Fork 0

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 23, 21:45 UTC

fix(build): validate Linux node-pty prebuilds in Windows artifacts (#13867)

Yash Singh committed Sep 26, 2026 at 15:38 UTC ea7d46ac107e6a3461b81065ebc86dfd5483095f
3 files changed +73 -20
pnpm-lock.yaml
+4 -13
@@ -10438,10 +10438,6 @@ packages:
10438 resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==}
10439 engines: {node: '>=6'}
10440
10441 - tough-cookie@6.0.1:
10442 - resolution: {integrity: sha512-LktZQb3IeoUWB9lqR5EWTHgW/VTITCXg4D21M+lvybRVdylLrRMnqaIONLVb5mav8vM19m44HIcGq4qASeu2Qw==}
10443 - engines: {node: '>=16'}
10444 -
10441 tough-cookie@6.0.2:
10442 resolution: {integrity: sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==}
10443 engines: {node: '>=16'}
@@ -18908,7 +18904,7 @@ snapshots:
18904 decimal.js: 10.6.0
18905 html-encoding-sniffer: 6.0.0(@noble/hashes@1.8.0)
18906 is-potential-custom-element-name: 1.0.1
18911 - lru-cache: 11.5.2
18907 + lru-cache: 11.5.3
18908 parse5: 8.0.1
18909 saxes: 6.0.0
18910 tough-cookie: 6.0.2
@@ -20013,7 +20009,7 @@ snapshots:
20009 rettime: 0.10.1
20010 statuses: 2.0.2
20011 strict-event-emitter: 0.5.1
20016 - tough-cookie: 6.0.1
20012 + tough-cookie: 6.0.2
20013 type-fest: 5.7.0
20014 until-async: 3.0.2
20015 yargs: 17.7.2
@@ -20039,7 +20035,7 @@ snapshots:
20035 rettime: 0.10.1
20036 statuses: 2.0.2
20037 strict-event-emitter: 0.5.1
20042 - tough-cookie: 6.0.1
20038 + tough-cookie: 6.0.2
20039 type-fest: 5.7.0
20040 until-async: 3.0.2
20041 yargs: 17.7.2
@@ -20516,7 +20512,7 @@ snapshots:
20512
20513 path-scurry@2.0.2:
20514 dependencies:
20519 - lru-cache: 11.5.2
20515 + lru-cache: 11.5.3
20516 minipass: 7.1.3
20517
20518 path-to-regexp@6.1.0: {}
@@ -21953,11 +21949,6 @@ snapshots:
21949
21950 totalist@3.0.1: {}
21951
21956 - tough-cookie@6.0.1:
21957 - dependencies:
21958 - tldts: 7.4.2
21959 - optional: true
21960 -
21952 tough-cookie@6.0.2:
21953 dependencies:
21954 tldts: 7.4.2
scripts/build-desktop-artifact.test.ts
+61 -2
@@ -175,6 +175,8 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu
175 readonly copyUnpackedNatives: boolean;
176 readonly serverEntrySource?: string;
177 readonly wslRuntime?: "valid" | "loose-server-tree" | "missing-pty" | "bad-digest";
178 + readonly targetArch?: "x64" | "arm64";
179 + readonly ptyPrebuildArch?: "x64" | "arm64";
180 }) {
181 const fs = yield* FileSystem.FileSystem;
182 const path = yield* Path.Path;
@@ -212,7 +214,7 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu
214 yield* fs.writeFileString(path.join(packagedAppDir, "chrome_crashpad_handler.exe"), "crashpad");
215
216 if (input.wslRuntime !== undefined) {
215 - const stem = wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, "x64");
217 + const stem = wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, input.targetArch ?? "x64");
218 const sourceArchivePath =
219 input.wslRuntime === "loose-server-tree"
220 ? // The old hand-rolled runtime: apps/server/dist + node_modules at the
@@ -226,9 +228,16 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu
228 : yield* makeLinuxCliArchiveFixture({
229 root: path.join(tempDir, "wsl-runtime"),
230 stem,
229 - ...(input.wslRuntime === "missing-pty"
231 + ...(input.wslRuntime === "missing-pty" || input.ptyPrebuildArch !== undefined
232 ? { omitMembers: [`${stem}/node_modules/node-pty/build/Release/pty.node`] }
233 : {}),
234 + ...(input.ptyPrebuildArch !== undefined
235 + ? {
236 + extraMembers: [
237 + `${stem}/node_modules/node-pty/prebuilds/linux-${input.ptyPrebuildArch}/pty.node`,
238 + ],
239 + }
240 + : {}),
241 });
242 const archivePath = path.join(resourcesDir, WSL_RUNTIME_ARCHIVE_NAME);
243 const hashPath = path.join(resourcesDir, WSL_RUNTIME_ARCHIVE_HASH_NAME);
@@ -1206,6 +1215,55 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
1215 ).pipe(Effect.provideService(HostProcessPlatform, "linux")),
1216 );
1217
1218 + for (const targetArch of ["x64", "arm64"] as const) {
1219 + it.effect(`accepts an embedded archive with the Linux ${targetArch} node-pty prebuild`, () =>
1220 + Effect.scoped(
1221 + Effect.gen(function* () {
1222 + const fixture = yield* makeWindowsPayloadFixture({
1223 + copyUnpackedNatives: true,
1224 + wslRuntime: "valid",
1225 + targetArch,
1226 + ptyPrebuildArch: targetArch,
1227 + });
1228 + const result = yield* validateWindowsPackagedPayload({
1229 + stageDistDir: fixture.stageDistDir,
1230 + appExecutableName: fixture.appExecutableName,
1231 + targetArch,
1232 + appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION,
1233 + expectWslRuntime: true,
1234 + });
1235 +
1236 + assert.equal(result.packagedAppDir, fixture.packagedAppDir);
1237 + }),
1238 + ).pipe(Effect.provideService(HostProcessPlatform, "linux")),
1239 + );
1240 +
1241 + it.effect(
1242 + `rejects a node-pty prebuild for the wrong architecture in a Linux ${targetArch} archive`,
1243 + () =>
1244 + Effect.scoped(
1245 + Effect.gen(function* () {
1246 + const fixture = yield* makeWindowsPayloadFixture({
1247 + copyUnpackedNatives: true,
1248 + wslRuntime: "valid",
1249 + targetArch,
1250 + ptyPrebuildArch: targetArch === "x64" ? "arm64" : "x64",
1251 + });
1252 + const error = yield* validateWindowsPackagedPayload({
1253 + stageDistDir: fixture.stageDistDir,
1254 + appExecutableName: fixture.appExecutableName,
1255 + targetArch,
1256 + appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION,
1257 + expectWslRuntime: true,
1258 + }).pipe(Effect.flip);
1259 +
1260 + assert.instanceOf(error, WindowsPackagedPayloadValidationError);
1261 + assert.equal(error.reason, "wsl-runtime-invalid");
1262 + }),
1263 + ),
1264 + );
1265 + }
1266 +
1267 it.effect("rejects an embedded archive built for a different release version", () =>
1268 Effect.scoped(
1269 Effect.gen(function* () {
@@ -1285,6 +1343,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
1343 assert.equal(error.reason, "wsl-runtime-invalid");
1344 assert.deepStrictEqual(error.missingFiles, [
1345 `${wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, "x64")}/node_modules/node-pty/build/Release/pty.node`,
1346 + `${wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, "x64")}/node_modules/node-pty/prebuilds/linux-x64/pty.node`,
1347 ]);
1348 }),
1349 ),
scripts/build-desktop-artifact.ts
+8 -5
@@ -3291,13 +3291,16 @@ export const validateWindowsPackagedPayload = Effect.fn(
3291 ),
3292 );
3293 }
3294 - const requiredMembers = [
3295 - `${stem}/t3`,
3296 - `${stem}/client`,
3297 - `${stem}/node_modules`,
3294 + const requiredMembers = [`${stem}/t3`, `${stem}/client`, `${stem}/node_modules`];
3295 + const missingMembers = requiredMembers.filter((member) => !members.includes(member));
3296 + // node-pty can load a source build or the prebuild for the WSL target.
3297 + const ptyCandidates = [
3298 `${stem}/node_modules/node-pty/build/Release/pty.node`,
3299 + `${stem}/node_modules/node-pty/prebuilds/linux-${input.targetArch}/pty.node`,
3300 ];
3300 - const missingMembers = requiredMembers.filter((member) => !members.includes(member));
3301 + if (!ptyCandidates.some((member) => members.includes(member))) {
3302 + missingMembers.push(...ptyCandidates);
3303 + }
3304 if (missingMembers.length > 0) {
3305 return yield* new WindowsPackagedPayloadValidationError({
3306 reason: "wsl-runtime-invalid",