fix(desktop): address the browser import review left over from the stack (#9516)

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Utkarsh Patil <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-09-03 16:57:10 -07:00
1 parent 8ea52c8f2f
commit 3653cb22ff
9 files changed
+385 -26

No files matched your search

+80
View File
@@ -66,6 +66,8 @@ import {
STAGE_INSTALL_ARGS,
ancestorNodeModulesPaths,
copyDirectoryPreservingSymlinks,
LinuxBrowserSecretHostError,
stageBrowserSecret,
validateWindowsPackagedPayload,
WindowsPrimaryNativeProbeError,
WindowsDesktopBuildPrerequisitesMissingError,
@@ -1207,6 +1209,84 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
);
});
it.effect("builds the Linux browser secret helper for a concrete architecture", () => {
const commands: Array<{ readonly command: string; readonly args: ReadonlyArray<string> }> = [];
const spawnerLayer = Layer.succeed(
ChildProcessSpawner.ChildProcessSpawner,
ChildProcessSpawner.make((command) => {
commands.push(command as unknown as (typeof commands)[number]);
return Effect.succeed(mockProcess(0));
}),
);
return Effect.gen(function* () {
// `universal` is a mac-only arch the option type still admits. The helper
// script only knows x64 and arm64, so the request maps to x64, the same
// concrete target the Linux resource monitor resolves it to.
yield* stageBrowserSecret({
repoRoot: "/repo",
stageResourcesDir: "/stage/resources",
platform: "linux",
arch: "universal",
verbose: false,
});
const helper = commands.find((command) =>
command.args.some((arg) => arg.endsWith("build-browser-secret.mjs")),
);
assert.isDefined(helper);
assert.deepStrictEqual(helper.args.slice(-4), [
"--arch",
"x64",
"--output",
"/stage/resources/browser-secret/t3-browser-secret",
]);
}).pipe(
Effect.provide(
Layer.mergeAll(
spawnerLayer,
Layer.succeed(HostProcessPlatform, "linux"),
Layer.succeed(HostProcessArchitecture, "x64"),
),
),
);
});
it.effect("refuses a Linux build on a host that cannot build the browser secret helper", () => {
const commands: Array<{ readonly command: string }> = [];
const spawnerLayer = Layer.succeed(
ChildProcessSpawner.ChildProcessSpawner,
ChildProcessSpawner.make((command) => {
commands.push(command as unknown as (typeof commands)[number]);
return Effect.succeed(mockProcess(0));
}),
);
return Effect.gen(function* () {
// The helper links against the host's libsecret and its build script is
// a no-op elsewhere, so a Linux artifact built on macOS would ship
// without it and report the keyring as unavailable on every import.
const error = yield* stageBrowserSecret({
repoRoot: "/repo",
stageResourcesDir: "/stage/resources",
platform: "linux",
arch: "x64",
verbose: false,
}).pipe(Effect.flip);
assert.instanceOf(error, LinuxBrowserSecretHostError);
assert.equal(error.hostPlatform, "darwin");
assert.include(error.message, "Linux host");
assert.lengthOf(commands, 0);
}).pipe(
Effect.provide(
Layer.mergeAll(
spawnerLayer,
Layer.succeed(HostProcessPlatform, "darwin"),
Layer.succeed(HostProcessArchitecture, "arm64"),
),
),
);
});
it.effect("skips the primary native probe for cross-architecture Windows payloads", () => {
const commands: Array<{
readonly command: string;
+21 -1
View File
@@ -447,6 +447,15 @@ const desktopIconPlatformNames = {
win: "Windows",
} satisfies Record<typeof BuildPlatform.Type, string>;
export class LinuxBrowserSecretHostError extends Schema.TaggedErrorClass<LinuxBrowserSecretHostError>()(
"LinuxBrowserSecretHostError",
{ hostPlatform: Schema.String },
) {
override get message(): string {
return `Linux desktop builds must run on a Linux host: the browser secret helper links against libsecret and cannot be built on '${this.hostPlatform}'.`;
}
}
export class DesktopIconSourceMissingError extends Schema.TaggedErrorClass<DesktopIconSourceMissingError>()(
"DesktopIconSourceMissingError",
{
@@ -2220,6 +2229,17 @@ export const stageBrowserSecret = Effect.fn("stageBrowserSecret")(function* (inp
readonly verbose: boolean;
}) {
if (input.platform !== "linux") return;
// The helper links against the host's libsecret, so it can only be built on
// Linux; the build script is a no-op elsewhere. A Linux artifact from
// another host would ship without it and every v11 cookie import would
// report the keyring as unavailable, so refuse rather than package that
// silently. `universal` is a mac-only arch the option type still admits;
// the helper script rejects it, so it maps to the concrete x64 the Linux
// resource monitor uses for the same request.
const hostPlatform = yield* HostProcessPlatform;
if (hostPlatform !== "linux") {
return yield* new LinuxBrowserSecretHostError({ hostPlatform });
}
const path = yield* Path.Path;
yield* runCommand(
ChildProcess.make(
@@ -2227,7 +2247,7 @@ export const stageBrowserSecret = Effect.fn("stageBrowserSecret")(function* (inp
[
path.join(input.repoRoot, "apps/desktop/scripts/build-browser-secret.mjs"),
"--arch",
input.arch,
input.arch === "arm64" ? "arm64" : "x64",
"--output",
path.join(input.stageResourcesDir, "browser-secret", "t3-browser-secret"),
],