Skip to content

Commit c259374

Browse files
fix(desktop): preserve disabled update explanations across channels
1 parent e6f37cb commit c259374

5 files changed

Lines changed: 25 additions & 18 deletions

File tree

‎apps/desktop/src/updates/DesktopUpdates.test.ts‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,35 @@ describe("DesktopUpdates", () => {
101101

102102
const deb = yield* linuxState("deb\n");
103103
assert.equal(deb.status, "idle");
104-
assert.equal(deb.message, null);
105104

106105
const unmarked = yield* linuxState(undefined);
107106
assert.equal(unmarked.status, "disabled");
108-
assert.equal(
109-
unmarked.message,
110-
"Automatic updates on Linux require the AppImage or the .deb package.",
111-
);
112107
}),
113108
);
114109

110+
it.effect("keeps the disabled reason available after configuration and channel changes", () => {
111+
const harness = makeHarness({ env: { T3CODE_DISABLE_AUTO_UPDATE: "true" } });
112+
const reason = "Automatic updates are disabled by the T3CODE_DISABLE_AUTO_UPDATE setting.";
113+
114+
return Effect.scoped(
115+
Effect.gen(function* () {
116+
const updates = yield* DesktopUpdates.DesktopUpdates;
117+
yield* updates.configure;
118+
119+
const configured = yield* updates.getState;
120+
assert.equal(configured.message, reason);
121+
122+
const changed = yield* updates.setChannel("nightly");
123+
assert.equal(changed.channel, "nightly");
124+
assert.equal(changed.enabled, false);
125+
assert.equal(changed.status, "disabled");
126+
assert.equal(changed.message, reason);
127+
assert.equal(harness.sentStates.at(-1)?.message, reason);
128+
assert.equal(harness.checkCount(), 0);
129+
}),
130+
).pipe(Effect.provide(harness.layer));
131+
});
132+
115133
it.effect("subscribe delivers the latest state plus subsequent changes", () => {
116134
const harness = makeHarness();
117135

‎apps/web/src/components/desktopUpdate.logic.test.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,6 @@ describe("disabled update reason", () => {
410410
title: "Updates unavailable",
411411
detail: "Automatic updates are only available in packaged production builds.",
412412
});
413-
});
414-
415-
it("falls back to a generic reason when the desktop app sent none", () => {
416413
expect(getDesktopUpdateDisabledReason({ ...disabledState, message: null })).toBe(
417414
"Automatic updates are not available in this build.",
418415
);

‎apps/web/src/components/desktopUpdate.logic.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,16 @@ export function canCheckForUpdate(state: DesktopUpdateState | null): boolean {
149149
);
150150
}
151151

152-
/**
153-
* Why update checks are off, or null when they are available. The desktop app puts
154-
* the reason it computed into `message` when it builds the disabled state.
155-
*/
156152
export function getDesktopUpdateDisabledReason(
157153
state: Pick<DesktopUpdateState, "enabled" | "status" | "message"> | null,
158154
): string | null {
159155
if (!state || (state.enabled && state.status !== "disabled")) return null;
160156
return state.message?.trim() || "Automatic updates are not available in this build.";
161157
}
162158

163-
/** Hover text for the update button when there is nothing to download or install. */
164159
export function getDesktopUpdateIdleTooltip(
165160
state: Pick<DesktopUpdateState, "enabled" | "status" | "message"> | null,
166-
): { readonly title: string; readonly detail: string | null } {
161+
) {
167162
const disabledReason = getDesktopUpdateDisabledReason(state);
168163
return disabledReason
169164
? { title: "Updates unavailable", detail: disabledReason }

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ function AboutVersionSection() {
417417
};
418418
const buttonLabel =
419419
actionLabel[action] ?? statusLabel[updateState?.status ?? ""] ?? "Check for Updates";
420-
// A disabled button has pointer-events: none, so the row explains why checks are off.
421420
const description =
422421
action === "download" || action === "install"
423422
? "Update available."

‎apps/web/src/components/sidebar/SidebarUpdatePill.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ function SidebarUpdateControl() {
238238
showCheckIcon,
239239
});
240240
const idleTooltip =
241-
!runsEverything && !showUpdateDetails && !showCheckIcon
242-
? getDesktopUpdateIdleTooltip(state)
243-
: null;
241+
!showUpdateDetails && !showCheckIcon ? getDesktopUpdateIdleTooltip(state) : null;
244242
const tooltip = runsEverything
245243
? everything.summary
246244
: showUpdateDetails

0 commit comments

Comments
 (0)