@devries-cameron20 / t3code Mirror · read-only / commits / e07585e5fb
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 updates keep their filename (#36306)

Julius Marminge committed Nov 13, 2026 at 12:32 UTC e07585e5fba9bdc112ace647da6da817ef0d7808
9 files changed +175 -9
apps/desktop/src/app/DesktopLinuxUrlHandler.test.ts
+29
@@ -204,6 +204,35 @@ describe("DesktopLinuxUrlHandler", () => {
204 assert.include(entry, "Icon=/home/al ice/icons/T3\\\\x.png");
205 });
206
207 + it.each([
208 + { from: "T3-Code-0.1.8-x86_64.AppImage", to: "T3-Code-x86_64.AppImage", restored: true },
209 + {
210 + from: "T3-Code-0.1.9-nightly.20261110.4449-arm64.AppImage",
211 + to: "T3-Code-Nightly-arm64.AppImage",
212 + restored: true,
213 + },
214 + { from: "T3-Code-0.1.8-x86_64.AppImage", to: "T3-Code-0.1.9-x86_64.AppImage", restored: false },
215 + { from: "t3code.AppImage", to: "T3-Code-x86_64.AppImage", restored: false },
216 + { from: "T3-Code-x86_64.AppImage", to: "T3-Code-x86_64.AppImage", restored: false },
217 + { from: "../T3-Code-0.1.8-x86_64.AppImage", to: "T3-Code-x86_64.AppImage", restored: false },
218 + ])("finds the launch path an update from $from to $to removed", ({ from, to, restored }) => {
219 + for (const dir of ["/home/alice/Applications", '/home/al ice/My "100%" $Apps\\x']) {
220 + const previous = dir + "/" + from;
221 + const previousEntry = DesktopLinuxUrlHandler.renderUrlHandlerDesktopEntry({
222 + displayName: "T3 Code (Beta)",
223 + execTarget: previous,
224 + scheme: "t3code",
225 + });
226 + assert.equal(
227 + DesktopLinuxUrlHandler.replacedVersionedAppImagePath({
228 + previousEntry,
229 + appImagePath: dir + "/" + to,
230 + }),
231 + restored ? previous : null,
232 + );
233 + }
234 + });
235 +
236 it.effect(
237 "writes the handler entry, refreshes the MIME cache, and claims the scheme default",
238 () => {
apps/desktop/src/app/DesktopLinuxUrlHandler.ts
+32
@@ -96,6 +96,38 @@ export function renderUrlHandlerDesktopEntry(input: {
96 ].join("\n");
97 }
98
99 +function parseUrlHandlerExecTarget(entry: string): string | null {
100 + const exec = /^Exec=(.*) %U$/mu.exec(entry)?.[1];
101 + if (exec === undefined) return null;
102 + const unescaped = exec.replace(/\\([\\nrt])/gu, (_, char: string) =>
103 + char === "n" ? "\n" : char === "r" ? "\r" : char === "t" ? "\t" : char,
104 + );
105 + const quoted = /^"(.*)"$/su.exec(unescaped)?.[1];
106 + return (
107 + quoted === undefined ? unescaped : quoted.replace(/\\([\\`$"])/gu, (_, char: string) => char)
108 + ).replaceAll("%%", "%");
109 +}
110 +
111 +const APPIMAGE_NAME_VERSION = /\d+\.\d+\.\d+/u;
112 +
113 +// An updater from before version-free AppImage names deletes its own file and installs the update
114 +// beside it under the new name. The previous launch's entry still names the path launchers use.
115 +export function replacedVersionedAppImagePath(input: {
116 + readonly previousEntry: string;
117 + readonly appImagePath: string;
118 +}): string | null {
119 + const previous = parseUrlHandlerExecTarget(input.previousEntry);
120 + if (previous === null) return null;
121 + const previousName = previous.slice(previous.lastIndexOf("/") + 1);
122 + const currentName = input.appImagePath.slice(input.appImagePath.lastIndexOf("/") + 1);
123 + return previous.startsWith("/") &&
124 + previous.slice(0, -previousName.length) === input.appImagePath.slice(0, -currentName.length) &&
125 + APPIMAGE_NAME_VERSION.test(previousName) &&
126 + !APPIMAGE_NAME_VERSION.test(currentName)
127 + ? previous
128 + : null;
129 +}
130 +
131 // Docks may look up the Wayland app id without a desktop entry; icon theme lookups are case-sensitive.
132 const LINUX_THEME_ICON_SIZE = "256x256";
133
apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
+45
@@ -16,6 +16,7 @@ const {
16 copyFileSyncMock,
17 execFileSyncMock,
18 readFileSyncMock,
19 + symlinkSyncMock,
20 } = vi.hoisted(() => ({
21 appendSwitchMock: vi.fn(),
22 getSwitchValueMock: vi.fn(),
@@ -27,6 +28,7 @@ const {
28 copyFileSyncMock: vi.fn(),
29 execFileSyncMock: vi.fn(),
30 readFileSyncMock: vi.fn(),
31 + symlinkSyncMock: vi.fn(),
32 }));
33
34 vi.mock("electron", () => ({
@@ -51,6 +53,7 @@ vi.mock("node:fs", () => ({
53 mkdirSync: mkdirSyncMock,
54 writeFileSync: writeFileSyncMock,
55 copyFileSync: copyFileSyncMock,
56 + symlinkSync: symlinkSyncMock,
57 }));
58
59 vi.mock("node:child_process", () => ({
@@ -72,6 +75,7 @@ describe("DesktopPreReadyPlatform", () => {
75 copyFileSyncMock.mockReset();
76 execFileSyncMock.mockReset();
77 readFileSyncMock.mockReset().mockReturnValue("{}");
78 + symlinkSyncMock.mockReset();
79 });
80
81 it.effect("persists Linux scaling synchronously across relaunches and settings rewrites", () => {
@@ -181,6 +185,47 @@ describe("DesktopPreReadyPlatform", () => {
185 ).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
186 });
187
188 + it.effect.each([
189 + { relaunchedByUpdater: "true", restored: true },
190 + { relaunchedByUpdater: "", restored: false },
191 + ])(
192 + "restores the versioned AppImage path an update removed (updater relaunch: $relaunchedByUpdater)",
193 + ({ relaunchedByUpdater, restored }) => {
194 + vi.stubEnv("VITE_DEV_SERVER_URL", "");
195 + getSwitchValueMock.mockReturnValue("");
196 + const entryPath = "/xdg/applications/com.t3tools.T3Code.desktop";
197 + const files = new Map([[entryPath, "Exec=/Applications/T3-Code-0.1.8-x86_64.AppImage %U\n"]]);
198 + readFileSyncMock.mockImplementation((path: string) => files.get(path) ?? "{}");
199 + writeFileSyncMock.mockImplementation((path: string, contents: string | Buffer) => {
200 + files.set(path, String(contents));
201 + });
202 +
203 + return Effect.scoped(
204 + Effect.gen(function* () {
205 + yield* Layer.build(
206 + DesktopPreReadyPlatform.layer.pipe(
207 + Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
208 + Layer.provide(
209 + DesktopConfig.layerTest({
210 + XDG_DATA_HOME: "/xdg",
211 + APPIMAGE: "/Applications/T3-Code-x86_64.AppImage",
212 + APPIMAGE_SILENT_INSTALL: relaunchedByUpdater,
213 + }),
214 + ),
215 + ),
216 + );
217 + assert.deepEqual(
218 + symlinkSyncMock.mock.calls,
219 + restored
220 + ? [["T3-Code-x86_64.AppImage", "/Applications/T3-Code-0.1.8-x86_64.AppImage"]]
221 + : [],
222 + );
223 + assert.include(files.get(entryPath), "Exec=/Applications/T3-Code-x86_64.AppImage %U");
224 + }),
225 + ).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
226 + },
227 + );
228 +
229 it.effect("points the early portal entry at a configured distribution launcher", () => {
230 vi.stubEnv("VITE_DEV_SERVER_URL", "");
231 getSwitchValueMock.mockReturnValue("");
apps/desktop/src/app/DesktopPreReadyPlatform.ts
+25 -2
@@ -14,7 +14,10 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
14 import * as DesktopEarlyElectronStartup from "./DesktopEarlyElectronStartup.ts";
15 import { trimmedString } from "./DesktopConfig.ts";
16 import { resolveDesktopAppBranding } from "./DesktopEnvironment.ts";
17 -import { renderUrlHandlerDesktopEntry } from "./DesktopLinuxUrlHandler.ts";
17 +import {
18 + renderUrlHandlerDesktopEntry,
19 + replacedVersionedAppImagePath,
20 +} from "./DesktopLinuxUrlHandler.ts";
21 import * as ElectronProtocol from "../electron/ElectronProtocol.ts";
22
23 export interface DesktopPreReadyCommandLineReader {
@@ -56,6 +59,8 @@ const LinuxDesktopEntryConfig = Config.all({
59 xdgDataHome: trimmedString("XDG_DATA_HOME"),
60 launcherPath: trimmedString("T3CODE_DESKTOP_LAUNCHER_PATH"),
61 appImagePath: trimmedString("APPIMAGE"),
62 + // electron-updater sets this on the AppImage it relaunches after installing an update.
63 + relaunchedByUpdater: trimmedString("APPIMAGE_SILENT_INSTALL"),
64 });
65
66 /** @public */
@@ -116,8 +121,26 @@ export const make = Effect.gen(function* () {
121 );
122 } catch {}
123 }
124 + const desktopEntryPath = NodePath.posix.join(applicationsDir, linux.linuxDesktopEntryName);
125 + const { appImagePath } = linuxDesktopEntryConfig;
126 + if (
127 + Option.isSome(appImagePath) &&
128 + Option.isNone(linuxDesktopEntryConfig.launcherPath) &&
129 + Option.contains(linuxDesktopEntryConfig.relaunchedByUpdater, "true")
130 + ) {
131 + try {
132 + const replacedPath = replacedVersionedAppImagePath({
133 + previousEntry: NodeFS.readFileSync(desktopEntryPath, "utf8"),
134 + appImagePath: appImagePath.value,
135 + });
136 + // Relative, so the pair survives a moved folder; symlink never overwrites a file.
137 + if (replacedPath !== null) {
138 + NodeFS.symlinkSync(NodePath.posix.basename(appImagePath.value), replacedPath);
139 + }
140 + } catch {}
141 + }
142 NodeFS.writeFileSync(
120 - NodePath.posix.join(applicationsDir, linux.linuxDesktopEntryName),
143 + desktopEntryPath,
144 renderUrlHandlerDesktopEntry({
145 displayName: resolveDesktopAppBranding({
146 isDevelopment: linux.isDevelopment,
packaging/aur/scripts/release.sh
+11 -5
@@ -8,8 +8,10 @@ pkgrel="${PKGREL:-1}"
8
9 if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
10 pkgname='t3code-bin'
11 + asset_name='T3-Code-x86_64.AppImage'
12 elif [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-nightly\.[0-9]{8}\.[0-9]+$ ]]; then
13 pkgname='t3code-nightly-bin'
14 + asset_name='T3-Code-Nightly-x86_64.AppImage'
15 else
16 echo "Release $tag does not publish an AUR package."
17 exit 0
@@ -17,14 +19,17 @@ fi
19
20 version="${tag#v}"
21 pkgver="${version//-/_}"
20 -asset_name="T3-Code-${version}-x86_64.AppImage"
22 release_json="$(gh api "repos/$repo/releases/tags/$tag")"
22 -asset_digest="$(jq -r --arg name "$asset_name" \
23 - '.assets[] | select(.name == $name) | .digest' <<<"$release_json")"
24 -appimage_sha256="${asset_digest#sha256:}"
23 +# Older releases publish the AppImage under a versioned name.
24 +for asset_name in "$asset_name" "T3-Code-${version}-x86_64.AppImage"; do
25 + asset_digest="$(jq -r --arg name "$asset_name" \
26 + '.assets[] | select(.name == $name) | .digest' <<<"$release_json")"
27 + appimage_sha256="${asset_digest#sha256:}"
28 + [[ "$appimage_sha256" =~ ^[0-9a-f]{64}$ ]] && break
29 +done
30
31 if [[ ! "$appimage_sha256" =~ ^[0-9a-f]{64}$ ]]; then
27 - echo "Release $tag is missing $asset_name or its SHA-256 digest." >&2
32 + echo "Release $tag is missing its x86_64 AppImage or its SHA-256 digest." >&2
33 exit 1
34 fi
35
@@ -39,6 +44,7 @@ cd "$package_dir"
44 sed -Ei \
45 -e "s/^pkgver=.*/pkgver=$pkgver/" \
46 -e "s/^pkgrel=.*/pkgrel=$pkgrel/" \
47 + -e "s/^_asset=.*/_asset='$asset_name'/" \
48 -e "/# AppImage$/s/'[0-9a-f]{64}'/'$appimage_sha256'/" \
49 -e "/# upstream license$/s/'[0-9a-f]{64}'/'$license_sha256'/" \
50 PKGBUILD
packaging/aur/t3code-bin/PKGBUILD
+2 -1
@@ -44,8 +44,9 @@ conflicts=('t3code')
44 options=('!debug' '!strip')
45
46 _appimage="T3-Code-${pkgver}-x86_64.AppImage"
47 +_asset="$_appimage"
48 source=(
48 - "$_appimage::https://github.com/pingdotgg/t3code/releases/download/v${pkgver}/$_appimage"
49 + "$_appimage::https://github.com/pingdotgg/t3code/releases/download/v${pkgver}/$_asset"
50 "${pkgname}-${pkgver}-LICENSE::https://raw.githubusercontent.com/pingdotgg/t3code/v${pkgver}/LICENSE"
51 )
52 sha256sums=(
packaging/aur/t3code-nightly-bin/PKGBUILD
+2 -1
@@ -45,8 +45,9 @@ options=('!debug' '!strip')
45
46 _upstream_version="${pkgver/_nightly./-nightly.}"
47 _appimage="T3-Code-${_upstream_version}-x86_64.AppImage"
48 +_asset="$_appimage"
49 source=(
49 - "$_appimage::https://github.com/pingdotgg/t3code/releases/download/v${_upstream_version}/$_appimage"
50 + "$_appimage::https://github.com/pingdotgg/t3code/releases/download/v${_upstream_version}/$_asset"
51 "${pkgname}-${pkgver}-LICENSE::https://raw.githubusercontent.com/pingdotgg/t3code/v${_upstream_version}/LICENSE"
52 )
53 sha256sums=(
scripts/build-desktop-artifact.test.ts
+22
@@ -569,6 +569,28 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
569 }),
570 );
571
572 + it.effect("names updatable AppImages without a version and apart per channel", () =>
573 + Effect.gen(function* () {
574 + const appImageName = (version: string) =>
575 + createBuildConfig("linux", "AppImage", version, false, false, undefined, undefined).pipe(
576 + Effect.map((config) => (config.appImage as { artifactName: string }).artifactName),
577 + );
578 +
579 + const stable = yield* appImageName("0.0.37");
580 + const nightly = yield* appImageName("0.0.38-nightly.20261026.3740");
581 +
582 + assert.notInclude(stable, "${version}");
583 + assert.notInclude(nightly, "${version}");
584 + assert.notEqual(stable, nightly);
585 + }).pipe(
586 + Effect.provide(
587 + ConfigProvider.layer(
588 + ConfigProvider.fromEnv({ env: { GITHUB_REPOSITORY: "pingdotgg/t3code" } }),
589 + ),
590 + ),
591 + ),
592 + );
593 +
594 it.effect("declares Calendar access for hosted commands in macOS builds", () =>
595 Effect.gen(function* () {
596 for (const version of ["0.1.0", "0.1.1-nightly.20261019.1"]) {
scripts/build-desktop-artifact.ts
+7
@@ -2926,6 +2926,13 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
2926 },
2927 },
2928 };
2929 + // electron-updater replaces an installed AppImage in place only when its name has no x.y.z version.
2930 + if (buildConfig.publish) {
2931 + buildConfig.appImage = {
2932 + artifactName:
2933 + updateChannel === "nightly" ? "T3-Code-Nightly-${arch}.${ext}" : "T3-Code-${arch}.${ext}",
2934 + };
2935 + }
2936 buildConfig.deb = {
2937 // FPM runs outside the staged app directory, so source paths must be absolute.
2938 fpm: [