@devries-cameron20 / t3code-1 / commits / f423a4dba0
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(desktop): a failed update-track save keeps offering the current track's updates (#34917)

Julius Marminge committed Nov 12, 2026 at 00:14 UTC f423a4dba04e74ca3c3083cfe3c88bcfadd4cf5e
2 files changed +36 -8
apps/desktop/src/updates/DesktopUpdates.test.ts
+26
@@ -932,6 +932,32 @@ describe("DesktopUpdates", () => {
932 ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
933 });
934
935 + it.effect("keeps the current track's offers when a track switch fails to save", () => {
936 + const harness = makeHarness({
937 + setUpdateChannelError: new DesktopAppSettings.DesktopSettingsWriteError({
938 + operation: "replace-settings-file",
939 + path: "desktop-settings.json",
940 + cause: new Error("rename failed"),
941 + }),
942 + });
943 +
944 + return Effect.scoped(
945 + Effect.gen(function* () {
946 + const updates = yield* DesktopUpdates.DesktopUpdates;
947 + yield* updates.configure;
948 + const error = yield* updates
949 + .setChannel("nightly", { minimumVersion: "1.2.5-nightly.20261028.1" })
950 + .pipe(Effect.flip);
951 + assert.equal(error._tag, "DesktopUpdateChannelPersistenceError");
952 + assert.equal((yield* updates.getState).channel, "latest");
953 +
954 + harness.emit("update-available", { version: "1.2.4" });
955 + yield* flushCallbacks;
956 + assert.equal((yield* updates.getState).availableVersion, "1.2.4");
957 + }),
958 + ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
959 + });
960 +
961 it.effect("keeps a saved Stable track across a restart without offering an older release", () => {
962 // A Nightly build whose switch to Stable did not finish before the app quit.
963 const harness = makeHarness({ appVersion: "1.2.4-nightly.20261027.1", savedChannel: "latest" });
apps/desktop/src/updates/DesktopUpdates.ts
+10 -8
@@ -1229,7 +1229,10 @@ export const make = Effect.gen(function* () {
1229 }
1230
1231 return yield* Effect.gen(function* () {
1232 - yield* Ref.set(releaseFloorRef, Option.fromNullishOr(options?.minimumVersion));
1232 + const previousFloor = yield* Ref.getAndSet(
1233 + releaseFloorRef,
1234 + Option.fromNullishOr(options?.minimumVersion),
1235 + );
1236 const state = yield* Ref.get(updateStateRef);
1237 const retained = state.downloadedVersion ?? state.availableVersion;
1238 // A build from another track re-checks, so retrying a track switch finds an older release.
@@ -1242,13 +1245,12 @@ export const make = Effect.gen(function* () {
1245 return state;
1246 }
1247
1245 - yield* desktopSettings
1246 - .setUpdateChannel(nextChannel)
1247 - .pipe(
1248 - Effect.mapError(
1249 - (cause) => new DesktopUpdateChannelPersistenceError({ channel: nextChannel, cause }),
1250 - ),
1251 - );
1248 + yield* desktopSettings.setUpdateChannel(nextChannel).pipe(
1249 + Effect.onError(() => Ref.set(releaseFloorRef, previousFloor)),
1250 + Effect.mapError(
1251 + (cause) => new DesktopUpdateChannelPersistenceError({ channel: nextChannel, cause }),
1252 + ),
1253 + );
1254
1255 const disabledReason = yield* resolveDisabledReason;
1256 yield* setState(yield* baseUpdateState(nextChannel, disabledReason));