authorgravatar for noah@wts.devNoah Gregory <noah@wts.dev> 2026-04-09 21:27:24-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-04-09 18:27:24-07:00
log5d9eb183123466fdf4b972fe33a4823d089370d3
treea86e7082dd92fa30cf6b93ed6418b24f46d7d8ab
parentabb84c09e3051db4745ba19a65e5d88319d473d2
signature Signed by PGP key B5690EEEBB952194

fix: don't let un-updateable builds check for an update (#1808)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

3 files changed, 50 insertions(+), 11 deletions(-)

apps/desktop/src/main.ts+17-11
......@@ -700,12 +700,15 @@ function dispatchMenuAction(action: string): void {
700700}
701701
702702function handleCheckForUpdatesMenuClick(): void {
703 const hasUpdateFeedConfig =
704 readAppUpdateYml() !== null || Boolean(process.env.T3CODE_DESKTOP_MOCK_UPDATES);
703705 const disabledReason = getAutoUpdateDisabledReason({
704706 isDevelopment,
705707 isPackaged: app.isPackaged,
706708 platform: process.platform,
707709 appImage: process.env.APPIMAGE,
708710 disabledByEnv: process.env.T3CODE_DISABLE_AUTO_UPDATE === "1",
711 hasUpdateFeedConfig,
709712 });
710713 if (disabledReason) {
711714 console.info("[desktop-updater] Manual update check requested, but updates are disabled.");
......@@ -942,6 +945,8 @@ function setUpdateState(patch: Partial<DesktopUpdateState>): void {
942945}
943946
944947function shouldEnableAutoUpdates(): boolean {
948 const hasUpdateFeedConfig =
949 readAppUpdateYml() !== null || Boolean(process.env.T3CODE_DESKTOP_MOCK_UPDATES);
945950 return (
946951 getAutoUpdateDisabledReason({
947952 isDevelopment,
......@@ -949,6 +954,7 @@ function shouldEnableAutoUpdates(): boolean {
949954 platform: process.platform,
950955 appImage: process.env.APPIMAGE,
951956 disabledByEnv: process.env.T3CODE_DISABLE_AUTO_UPDATE === "1",
957 hasUpdateFeedConfig,
952958 }) === null
953959 );
954960}
......@@ -1032,17 +1038,6 @@ async function installDownloadedUpdate(): Promise<{ accepted: boolean; completed
10321038}
10331039
10341040function configureAutoUpdater(): void {
1035 const enabled = shouldEnableAutoUpdates();
1036 setUpdateState({
1037 ...createInitialDesktopUpdateState(app.getVersion(), desktopRuntimeInfo),
1038 enabled,
1039 status: enabled ? "idle" : "disabled",
1040 });
1041 if (!enabled) {
1042 return;
1043 }
1044 updaterConfigured = true;
1045
10461041 const githubToken =
10471042 process.env.T3CODE_DESKTOP_UPDATE_GITHUB_TOKEN?.trim() || process.env.GH_TOKEN?.trim() || "";
10481043 if (githubToken) {
......@@ -1067,6 +1062,17 @@ function configureAutoUpdater(): void {
10671062 });
10681063 }
10691064
1065 const enabled = shouldEnableAutoUpdates();
1066 setUpdateState({
1067 ...createInitialDesktopUpdateState(app.getVersion(), desktopRuntimeInfo),
1068 enabled,
1069 status: enabled ? "idle" : "disabled",
1070 });
1071 if (!enabled) {
1072 return;
1073 }
1074 updaterConfigured = true;
1075
10701076 autoUpdater.autoDownload = false;
10711077 autoUpdater.autoInstallOnAppQuit = false;
10721078 // Keep alpha branding, but force all installs onto the stable update track.
apps/desktop/src/updateState.test.ts+29
......@@ -71,10 +71,37 @@ describe("getAutoUpdateDisabledReason", () => {
7171 platform: "darwin",
7272 appImage: undefined,
7373 disabledByEnv: false,
74 hasUpdateFeedConfig: true,
7475 }),
7576 ).toContain("packaged production builds");
7677 });
7778
79 it("reports packaged local builds without an update feed as disabled", () => {
80 expect(
81 getAutoUpdateDisabledReason({
82 isDevelopment: false,
83 isPackaged: true,
84 platform: "darwin",
85 appImage: undefined,
86 disabledByEnv: false,
87 hasUpdateFeedConfig: false,
88 }),
89 ).toContain("no update feed");
90 });
91
92 it("allows packaged builds with an update feed", () => {
93 expect(
94 getAutoUpdateDisabledReason({
95 isDevelopment: false,
96 isPackaged: true,
97 platform: "darwin",
98 appImage: undefined,
99 disabledByEnv: false,
100 hasUpdateFeedConfig: true,
101 }),
102 ).toBeNull();
103 });
104
78105 it("reports env-disabled auto updates", () => {
79106 expect(
80107 getAutoUpdateDisabledReason({
......@@ -83,6 +110,7 @@ describe("getAutoUpdateDisabledReason", () => {
83110 platform: "darwin",
84111 appImage: undefined,
85112 disabledByEnv: true,
113 hasUpdateFeedConfig: true,
86114 }),
87115 ).toContain("T3CODE_DISABLE_AUTO_UPDATE");
88116 });
......@@ -95,6 +123,7 @@ describe("getAutoUpdateDisabledReason", () => {
95123 platform: "linux",
96124 appImage: undefined,
97125 disabledByEnv: false,
126 hasUpdateFeedConfig: true,
98127 }),
99128 ).toContain("AppImage");
100129 });
apps/desktop/src/updateState.ts+4
......@@ -34,7 +34,11 @@ export function getAutoUpdateDisabledReason(args: {
3434 platform: NodeJS.Platform;
3535 appImage?: string | undefined;
3636 disabledByEnv: boolean;
37 hasUpdateFeedConfig: boolean;
3738}): string | null {
39 if (!args.hasUpdateFeedConfig) {
40 return "Automatic updates are not available because no update feed is configured.";
41 }
3842 if (args.isDevelopment || !args.isPackaged) {
3943 return "Automatic updates are only available in packaged production builds.";
4044 }