Skip to content

Commit 46daf1f

Browse files
committed
fix(desktop): keep the macOS app bundle name stable across updates
1 parent 0bdf33a commit 46daf1f

4 files changed

Lines changed: 50 additions & 4 deletions

File tree

‎docs/operations/connect-setup.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ actual web and server ports. For example, with the default ports:
119119
```sh
120120
VITE_DEV_SERVER_URL=http://127.0.0.1:5733 \
121121
T3CODE_PORT=13773 \
122-
"/Applications/T3 Code (Alpha).app/Contents/MacOS/T3 Code (Alpha)"
122+
"/Applications/T3 Code (Beta).app/Contents/MacOS/T3 Code (Beta)"
123123
```
124124

125125
Rebuild the signed app after native dependency, main-process, preload, entitlement, provisioning,
126126
or signing changes. Renderer edits can reuse it. Verify the installed bundle before testing:
127127

128128
```sh
129-
codesign --verify --deep --strict "/Applications/T3 Code (Alpha).app"
130-
codesign -d --entitlements :- "/Applications/T3 Code (Alpha).app"
129+
codesign --verify --deep --strict "/Applications/T3 Code (Beta).app"
130+
codesign -d --entitlements :- "/Applications/T3 Code (Beta).app"
131131
```
132132

133133
## Restricting sign-ups

‎docs/operations/release.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ This document covers the unified release workflow for stable and nightly desktop
77
Beta is the product label, not a release channel or version suffix. Release channels
88
remain stable and nightly. To ship 0.1.0 Beta, use `channel=stable` and
99
`version=0.1.0`. Removing the Beta label later is a branding change independent of
10-
the version.
10+
the version. The macOS `.app` filename is pinned separately (`MAC_BUNDLE_FILENAME` in
11+
`scripts/build-desktop-artifact.ts`) so label and channel changes never rename the
12+
installed bundle; Squirrel.Mac fails to relaunch after a rename.
1113

1214
## What the workflow does
1315

‎scripts/build-desktop-artifact.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,41 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
473473
}),
474474
);
475475

476+
it.effect("keeps the macOS bundle filename stable across product names", () =>
477+
Effect.gen(function* () {
478+
const stable = yield* createBuildConfig(
479+
"mac",
480+
"dmg",
481+
"0.1.0",
482+
false,
483+
false,
484+
undefined,
485+
undefined,
486+
);
487+
const nightly = yield* createBuildConfig(
488+
"mac",
489+
"dmg",
490+
"0.1.1-nightly.20261017.3238",
491+
false,
492+
false,
493+
undefined,
494+
undefined,
495+
);
496+
497+
assert.notEqual(stable.productName, nightly.productName);
498+
assert.deepStrictEqual(
499+
(stable.mac as { executableName: string }).executableName,
500+
(nightly.mac as { executableName: string }).executableName,
501+
);
502+
}).pipe(
503+
Effect.provide(
504+
ConfigProvider.layer(
505+
ConfigProvider.fromEnv({ env: { GITHUB_REPOSITORY: "pingdotgg/t3code" } }),
506+
),
507+
),
508+
),
509+
);
510+
476511
it.effect("omits update feeds for pull request preview builds", () =>
477512
Effect.gen(function* () {
478513
const preview = yield* createBuildConfig(

‎scripts/build-desktop-artifact.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
6363

6464
const LINUX_ICON_SIZES = [16, 22, 24, 32, 48, 64, 128, 256, 512] as const;
6565
const DESKTOP_APP_ID = "com.t3tools.t3code";
66+
67+
// On-disk name of the macOS .app (and its executable). electron-builder would
68+
// otherwise derive it from productName, and Squirrel.Mac renames the installed
69+
// bundle to the update's name but then tries to relaunch from the old path, so
70+
// any bundle rename leaves the app closed after an update. Display names still
71+
// come from productName. Never change this value: it is the name most installs
72+
// have had since 0.1.0, and changing it fails every install's next relaunch.
73+
const MAC_BUNDLE_FILENAME = "T3 Code (Beta)";
6674
const APPLE_TEAM_ID_PATTERN = /^[A-Z0-9]{10}$/u;
6775

6876
const BuildPlatform = Schema.Literals(["mac", "linux", "win"]);
@@ -2881,6 +2889,7 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
28812889
const path = yield* Path.Path;
28822890
const repoRoot = yield* RepoRoot;
28832891
buildConfig.mac = {
2892+
executableName: MAC_BUNDLE_FILENAME,
28842893
target: target === "dmg" ? [target, "zip"] : [target],
28852894
icon: "icon.icns",
28862895
category: "public.app-category.developer-tools",

0 commit comments

Comments
 (0)