Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

[codex] Preserve Linux icon resize fallback failures (#3447)

Julius Marminge9243ead1c3ee
diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts
index f8c354a85..62823f7fc 100644
--- a/scripts/build-desktop-artifact.test.ts
+++ b/scripts/build-desktop-artifact.test.ts
@@ -4,6 +4,9 @@ import * as ConfigProvider from "effect/ConfigProvider";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
+import * as Sink from "effect/Sink";
+import * as Stream from "effect/Stream";
+import { ChildProcessSpawner } from "effect/unstable/process";
import {
BuildScriptError,
@@ -14,6 +17,7 @@ import {
InvalidMacPasskeyRpDomainError,
InvalidMacPasskeyPublishableKeyError,
isMacPasskeySigningConfigurationError,
+ LinuxIconResizeError,
MissingMacPasskeyProvisioningProfileError,
renderMacPasskeyEntitlements,
resolveClerkPasskeyNativeArtifacts,
@@ -27,11 +31,49 @@ import {
resolveGitHubPublishConfig,
resolveMockUpdateServerPort,
resolveMockUpdateServerUrl,
+ stageLinuxIconSize,
STAGE_INSTALL_ARGS,
} from "./build-desktop-artifact.ts";
import { BRAND_ASSET_PATHS } from "./lib/brand-assets.ts";
import { HostProcessArchitecture, HostProcessPlatform } from "@t3tools/shared/hostProcess";
+function mockProcess(exitCode: number) {
+ return ChildProcessSpawner.makeHandle({
+ pid: ChildProcessSpawner.ProcessId(1),
+ exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(exitCode)),
+ isRunning: Effect.succeed(false),
+ kill: () => Effect.void,
+ unref: Effect.succeed(Effect.void),
+ stdin: Sink.drain,
+ stdout: Stream.empty,
+ stderr: Stream.empty,
+ all: Stream.empty,
+ getInputFd: () => Sink.drain,
+ getOutputFd: () => Stream.empty,
+ });
+}
+
+function iconResizeSpawnerLayer(
+ commands: Array<{ readonly command: string; readonly args: ReadonlyArray<string> }>,
+ exitCodes: ReadonlyArray<number>,
+) {
+ let commandIndex = 0;
+ return Layer.succeed(
+ ChildProcessSpawner.ChildProcessSpawner,
+ ChildProcessSpawner.make((command) => {
+ const childProcess = command as unknown as {
+ readonly command: string;
+ readonly args: ReadonlyArray<string>;
+ };
+ commands.push({
+ command: childProcess.command,
+ args: childProcess.args,
+ });
+ return Effect.succeed(mockProcess(exitCodes[commandIndex++] ?? 0));
+ }),
+ );
+}
+
it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
it("resolves the dedicated nightly updater channel from nightly versions", () => {
assert.equal(resolveDesktopUpdateChannel("0.0.17-nightly.20260413.42"), "nightly");
@@ -184,6 +226,40 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
assert.deepStrictEqual(DESKTOP_ASAR_UNPACK, ["node_modules/@ff-labs/fff-bin-*/**/*"]);
});
+ it.effect("preserves both Linux icon resize failures with structural context", () => {
+ const commands: Array<{ readonly command: string; readonly args: ReadonlyArray<string> }> = [];
+
+ return Effect.gen(function* () {
+ const error = yield* stageLinuxIconSize("source.png", "target.png", 512, false).pipe(
+ Effect.provide(iconResizeSpawnerLayer(commands, [1, 2])),
+ Effect.flip,
+ );
+
+ assert.instanceOf(error, LinuxIconResizeError);
+ assert.equal(error.operation, "resize");
+ assert.equal(error.iconSize, 512);
+ assert.equal(error.primaryTool, "magick");
+ assert.equal(error.fallbackTool, "convert");
+ assert.include(error.message, "512x512");
+ assert.include(error.message, "`magick`");
+ assert.include(error.message, "`convert`");
+ assert.notInclude(error.message, "non-zero exit code");
+
+ assert.instanceOf(error.cause, AggregateError);
+ const aggregateCause = error.cause as AggregateError;
+ assert.lengthOf(aggregateCause.errors, 2);
+ assert.strictEqual(aggregateCause.cause, aggregateCause.errors[0]);
+ assert.instanceOf(aggregateCause.errors[0], BuildScriptError);
+ assert.instanceOf(aggregateCause.errors[1], BuildScriptError);
+ assert.include((aggregateCause.errors[0] as BuildScriptError).message, "magick linux icon");
+ assert.include((aggregateCause.errors[1] as BuildScriptError).message, "convert linux icon");
+ assert.deepStrictEqual(
+ commands.map(({ command }) => command),
+ ["magick", "convert"],
+ );
+ });
+ });
+
it("derives macOS passkey signing configuration from the Clerk publishable key", () => {
const configuration = resolveMacPasskeySigningConfiguration({
T3CODE_APPLE_TEAM_ID: "abc1234567",
diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts
index 6f13783f2..f1d03f615 100644
--- a/scripts/build-desktop-artifact.ts
+++ b/scripts/build-desktop-artifact.ts
@@ -142,6 +142,21 @@ export class BuildScriptError extends Data.TaggedError("BuildScriptError")<{
}
}
+export class LinuxIconResizeError extends Schema.TaggedErrorClass<LinuxIconResizeError>()(
+ "LinuxIconResizeError",
+ {
+ operation: Schema.Literal("resize"),
+ iconSize: Schema.Int,
+ primaryTool: Schema.Literal("magick"),
+ fallbackTool: Schema.Literal("convert"),
+ cause: Schema.Defect(),
+ },
+) {
+ override get message(): string {
+ return `Failed to ${this.operation} the Linux desktop icon to ${this.iconSize}x${this.iconSize} with \`${this.primaryTool}\` or \`${this.fallbackTool}\`. Install ImageMagick so either tool is available.`;
+ }
+}
+
const collectStreamAsString = <E>(stream: Stream.Stream<Uint8Array, E>): Effect.Effect<string, E> =>
stream.pipe(
Stream.decodeText(),
@@ -877,7 +892,7 @@ function stageLinuxIcons(stageResourcesDir: string, sourcePng: string, verbose:
});
}
-function stageLinuxIconSize(
+export function stageLinuxIconSize(
sourcePng: string,
targetPng: string,
iconSize: number,
@@ -890,13 +905,20 @@ function stageLinuxIconSize(
);
return resize("magick").pipe(
- Effect.catch(() =>
+ Effect.catch((primaryCause) =>
resize("convert").pipe(
Effect.mapError(
- () =>
- new BuildScriptError({
- message:
- "ImageMagick is required to generate Linux desktop icon sizes. Install ImageMagick so either `magick` or `convert` is available.",
+ (fallbackCause) =>
+ new LinuxIconResizeError({
+ operation: "resize",
+ iconSize,
+ primaryTool: "magick",
+ fallbackTool: "convert",
+ cause: new AggregateError(
+ [primaryCause, fallbackCause],
+ "Both Linux icon resize tool attempts failed.",
+ { cause: primaryCause },
+ ),
}),
),
),