@devries-cameron20 / t3code Mirror · read-only / commits / 3376c8da92
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, 17:15 UTC

fix(desktop): AppImage t3 shim no longer grows the CLI compile cache on every call (#33885)

Julius Marminge committed Nov 12, 2026 at 22:50 UTC 3376c8da92a285ab4348f9fa2a3d92a18d3d7604
4 files changed +30 -4
apps/desktop/src/app/DesktopCliShim.test.ts
+9 -1
@@ -39,7 +39,7 @@ const run = (shim: string, args: ReadonlyArray<string>, env: NodeJS.ProcessEnv =
39 });
40
41 const REPORTER =
42 - '#!/bin/sh\necho "node=$ELECTRON_RUN_AS_NODE cli=$T3CODE_CLI_PATH home=$T3CODE_HOME"\nprintf "%s\\n" "$@"\nexit 3\n';
42 + '#!/bin/sh\necho "node=$ELECTRON_RUN_AS_NODE cli=$T3CODE_CLI_PATH home=$T3CODE_HOME appimage=$APPIMAGE"\nprintf "%s\\n" "$@"\nexit 3\n';
43
44 const fakeAppImage = (canMount = true, app = REPORTER) => {
45 const root = tempRoot();
@@ -150,6 +150,14 @@ describe("renderCliShim", () => {
150 );
151 });
152
153 + // The server skips its compile cache only under APPIMAGE; each mount path is new.
154 + it("tells the CLI it runs from the mounted AppImage", () => {
155 + const { appImage, shim } = fakeAppImage();
156 + const result = run(shim, ["--version"]);
157 + expect(result.status).toBe(3);
158 + expect(result.stdout).toContain(`appimage=${appImage}`);
159 + });
160 +
161 it("keeps the install's T3 home under sudo, unless one is set", () => {
162 const root = tempRoot();
163 writeExecutable(NodePath.join(root, "app"), REPORTER);
apps/desktop/src/app/DesktopCliShim.ts
+2
@@ -109,6 +109,8 @@ export const renderCliShim = (input: {
109 ' (cd "$work" && "$app" --appimage-extract >/dev/null) || { echo "Could not open $app." >&2; exit 1; }',
110 ' mount="$work/squashfs-root"',
111 "fi",
112 + // The runtime sets this when it launches the app; the CLI skips its path-keyed compile cache on it.
113 + 'export APPIMAGE="$app"',
114 run("$mount"),
115 "",
116 ].join("\n");
apps/server/src/cliCompileCache.test.ts
+5
@@ -77,9 +77,14 @@ it.live("loads the CLI with its cache settings only when the command needs it",
77 expect(launcherFlags.exitCode).toBe(1);
78 expect(launcherFlags.stderr).toContain("LOADED_CLI_MAIN");
79 expect(launcherFlags.stderr).toContain("[service-launcher] T3CODE_HOME is required");
80 + const cacheDir = `${root}/cache/t3code/compile-cache`;
81 + yield* fs.makeDirectory(`${cacheDir}/v24.0.0-x64-legacy-1000`, { recursive: true });
82 + yield* fs.writeFileString(`${cacheDir}/v24.0.0-x64-legacy-1000/0123abcd`, "stale");
83 + yield* fs.makeDirectory(`${cacheDir}/server`, { recursive: true });
84 const appImage = yield* run({ APPIMAGE: `${root}/T3Code.AppImage` });
85 expect(appImage.exitCode).toBe(0);
86 expect(appImage.stderr).toContain("CACHE=disabled");
87 + expect((yield* fs.readDirectory(cacheDir)).toSorted()).toEqual(["server"]);
88 const existing = yield* run({ NODE_COMPILE_CACHE: `${root}/explicit` });
89 expect(existing.exitCode).toBe(0);
90 expect(existing.stderr.replaceAll("\\", "/")).toContain(
apps/server/src/cliCompileCache.ts
+14 -3
@@ -1,4 +1,5 @@
1 // @effect-diagnostics nodeBuiltinImport:off -- Runs before the CLI's Effect runtime loads.
2 +import * as NodeFS from "node:fs";
3 import * as NodeModule from "node:module";
4 import * as NodeOS from "node:os";
5 import * as NodePath from "node:path";
@@ -6,12 +7,22 @@ import * as NodeSea from "node:sea";
7
8 export function enableCliCompileCache(): void {
9 try {
9 - // AppImage paths change each launch; SEA has no separate modules to cache.
10 - if (process.env.APPIMAGE || NodeSea.isSea()) return;
10 + // SEA has no separate modules to cache.
11 + if (NodeSea.isSea()) return;
12 const cacheRoot =
13 process.env.XDG_CACHE_HOME ||
14 // oxlint-disable-next-line t3code/no-global-process-runtime -- Runs before the CLI's Effect runtime loads.
15 (process.platform === "linux" ? NodePath.join(NodeOS.homedir(), ".cache") : NodeOS.tmpdir());
15 - NodeModule.enableCompileCache(NodePath.join(cacheRoot, "t3code", "compile-cache"));
16 + const directory = NodePath.join(cacheRoot, "t3code", "compile-cache");
17 + if (process.env.APPIMAGE) {
18 + // AppImage paths change each launch. Older shims cached anyway, filling Node's engine folders.
19 + for (const entry of NodeFS.readdirSync(directory, { withFileTypes: true })) {
20 + if (entry.isDirectory() && /^v\d/.test(entry.name)) {
21 + NodeFS.rmSync(NodePath.join(directory, entry.name), { recursive: true, force: true });
22 + }
23 + }
24 + return;
25 + }
26 + NodeModule.enableCompileCache(directory);
27 } catch {}
28 }