@devries-cameron20 / t3code Mirror · read-only / commits / 658367016c
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 21, 21:00 UTC

fix(desktop): Linux launches no longer leave an icon copy in /tmp (#25775)

Julius Marminge committed Nov 11, 2026 at 15:36 UTC 658367016c110446685837416101956884e92097
4 files changed +54 -22
apps/desktop/src/app/DesktopLinuxUrlHandler.test.ts
+28 -10
@@ -26,8 +26,11 @@ interface RecordedRegistration {
26 readonly files: Array<{ readonly path: string; readonly content: string }>;
27 readonly commands: Array<{ readonly command: string; readonly args: ReadonlyArray<string> }>;
28 readonly copies: Array<{ readonly source: string; readonly destination: string }>;
29 + readonly icons: Array<{ readonly path: string; readonly bytes: ReadonlyArray<number> }>;
30 }
31
32 +const ICON_BYTES = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
33 +
34 const makeEnvironment = (path: Path.Path, overrides: Record<string, unknown> = {}) =>
35 DesktopEnvironment.DesktopEnvironment.of({
36 platform: "linux",
@@ -69,7 +72,7 @@ const layerHandler = (
72 readonly writeError?: PlatformError.PlatformError;
73 readonly existingEntry?: string;
74 readonly iconSource?: string;
72 - readonly iconCopyError?: PlatformError.PlatformError;
75 + readonly iconWriteError?: PlatformError.PlatformError;
76 } = {},
77 ) =>
78 DesktopLinuxUrlHandler.layer.pipe(
@@ -92,10 +95,25 @@ const layerHandler = (
95 }),
96 FileSystem.layerNoop({
97 copyFile: (source, destination) =>
95 - input.iconCopyError
96 - ? Effect.fail(input.iconCopyError)
98 + Effect.sync(() => {
99 + recorded.copies.push({ source, destination });
100 + }),
101 + readFile: (path) =>
102 + path === input.iconSource
103 + ? Effect.succeed(ICON_BYTES)
104 + : Effect.fail(
105 + PlatformError.systemError({
106 + _tag: "NotFound",
107 + module: "FileSystem",
108 + method: "readFile",
109 + pathOrDescriptor: path,
110 + }),
111 + ),
112 + writeFile: (path, bytes) =>
113 + input.iconWriteError
114 + ? Effect.fail(input.iconWriteError)
115 : Effect.sync(() => {
98 - recorded.copies.push({ source, destination });
116 + recorded.icons.push({ path, bytes: [...bytes] });
117 }),
118 readFileString: () => Effect.succeed(input.existingEntry ?? ""),
119 makeDirectory: (path) =>
@@ -162,6 +180,7 @@ const emptyRecording = (): RecordedRegistration => ({
180 files: [],
181 commands: [],
182 copies: [],
183 + icons: [],
184 });
185
186 describe("DesktopLinuxUrlHandler", () => {
@@ -290,22 +309,21 @@ describe("DesktopLinuxUrlHandler", () => {
309 }),
310 });
311 assert.deepEqual(recorded.files, []);
293 - assert.deepEqual(recorded.copies, [
294 - { source: "/tmp/.mount_T3/resources/icon.png", destination: iconPath },
295 - ]);
312 + assert.deepEqual(recorded.copies, [], "icon must not be copied out of the app bundle");
313 + assert.deepEqual(recorded.icons, [{ path: iconPath, bytes: [...ICON_BYTES] }]);
314 assert.equal(recorded.commands.at(-1)?.command, "xdg-mime");
315 });
316 });
317
300 - it.effect("still registers the handler when copying its icon fails", () => {
318 + it.effect("still registers the handler when installing its icon fails", () => {
319 const recorded = emptyRecording();
320 return Effect.gen(function* () {
321 yield* runRegister(recorded, {
322 iconSource: "/tmp/.mount_T3/resources/icon.png",
305 - iconCopyError: PlatformError.systemError({
323 + iconWriteError: PlatformError.systemError({
324 _tag: "PermissionDenied",
325 module: "FileSystem",
308 - method: "copyFile",
326 + method: "writeFile",
327 description: "read-only icon directory",
328 }),
329 });
apps/desktop/src/app/DesktopLinuxUrlHandler.ts
+3 -2
@@ -298,10 +298,11 @@ export const make = Effect.gen(function* () {
298 if (Option.isNone(png)) return;
299 // The AppImage mount is temporary; the chooser needs the icon after exit.
300 yield* fileSystem.makeDirectory(iconsDir, { recursive: true });
301 - yield* fileSystem.copyFile(png.value, iconPath);
301 + // Electron's copyFile from app.asar extracts to a temp file it never deletes.
302 + yield* fileSystem.writeFile(iconPath, yield* fileSystem.readFile(png.value));
303 }).pipe(
304 Effect.catch((error) =>
304 - logWarning("URL handler icon copy failed", { iconPath, category: error.reason._tag }),
305 + logWarning("URL handler icon install failed", { iconPath, category: error.reason._tag }),
306 ),
307 );
308
apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
+15 -5
@@ -129,14 +129,19 @@ describe("DesktopPreReadyPlatform", () => {
129 let desktopName = "t3code.desktop";
130 let desktopEntry = previousEntry;
131 let iconInstalled = false;
132 - copyFileSyncMock.mockImplementation((_source: string, destination: string) => {
133 - iconInstalled = destination === "/xdg/icons/com.t3tools.T3Code.desktop.png";
132 + const iconSource = "/tmp/.mount_T3/resources/app.asar/apps/desktop/prod-resources/icon.png";
133 + const iconPath = "/xdg/icons/com.t3tools.T3Code.desktop.png";
134 + const iconBytes = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
135 + readFileSyncMock.mockImplementation((path: string) => {
136 + if (path === iconSource) return iconBytes;
137 + return "{}";
138 });
139 setDesktopNameMock.mockImplementation((name: string) => {
140 desktopName = name;
141 });
138 - writeFileSyncMock.mockImplementation((path: string, contents: string) => {
139 - if (path === "/xdg/applications/com.t3tools.T3Code.desktop") desktopEntry = contents;
142 + writeFileSyncMock.mockImplementation((path: string, contents: string | Buffer) => {
143 + if (path === "/xdg/applications/com.t3tools.T3Code.desktop") desktopEntry = String(contents);
144 + if (path === iconPath) iconInstalled = Buffer.compare(Buffer.from(contents), iconBytes) === 0;
145 });
146
147 return Effect.scoped(
@@ -166,7 +171,12 @@ describe("DesktopPreReadyPlatform", () => {
171 identity.desktopEntry ?? "",
172 "Icon=/xdg/icons/com.t3tools.T3Code.desktop.png",
173 );
169 - assert.isTrue(identity.iconInstalled);
174 + assert.equal(
175 + copyFileSyncMock.mock.calls.length,
176 + 0,
177 + "icon must not be copied out of the app bundle",
178 + );
179 + assert.isTrue(identity.iconInstalled, "icon must be written from the bundled bytes");
180 }),
181 ).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
182 });
apps/desktop/src/app/DesktopPreReadyPlatform.ts
+8 -5
@@ -104,12 +104,15 @@ export const make = Effect.gen(function* () {
104 if (iconPath !== undefined) {
105 try {
106 NodeFS.mkdirSync(NodePath.posix.dirname(iconPath), { recursive: true });
107 - NodeFS.copyFileSync(
108 - NodePath.posix.join(
109 - Electron.app.getAppPath(),
110 - "apps/desktop/prod-resources/icon.png",
111 - ),
107 + // Electron's copyFileSync from app.asar extracts to a temp file it never deletes.
108 + NodeFS.writeFileSync(
109 iconPath,
110 + NodeFS.readFileSync(
111 + NodePath.posix.join(
112 + Electron.app.getAppPath(),
113 + "apps/desktop/prod-resources/icon.png",
114 + ),
115 + ),
116 );
117 } catch {}
118 }