GeezerVison is showing github.com — fix(desktop): a broken release opens an error window instead of hangi… · pingdotgg/t3code@3087e60
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/app/DesktopApp.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,7 @@ import * as DesktopShutdown from "./DesktopShutdown.ts"; | 29 | 29 | import * as DesktopServerExposure from "../backend/DesktopServerExposure.ts"; | 30 | 30 | import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts"; | 31 | 31 | import * as DesktopShellEnvironment from "../shell/DesktopShellEnvironment.ts"; | | 32 | +import * as DesktopStartupRecovery from "./DesktopStartupRecovery.ts"; | 32 | 33 | import * as DesktopState from "./DesktopState.ts"; | 33 | 34 | import * as DesktopRemoteUpdates from "../updates/DesktopRemoteUpdates.ts"; | 34 | 35 | import * as DesktopUpdates from "../updates/DesktopUpdates.ts"; | @@ -325,6 +326,7 @@ const startup = Effect.gen(function* () { | 325 | 326 | yield* applicationMenu.configure; | 326 | 327 | yield* updates.configure; | 327 | 328 | yield* DesktopRemoteUpdates.listen; | | 329 | + yield* DesktopStartupRecovery.listen; | 328 | 330 | yield* linuxUrlHandler.register; | 329 | 331 | yield* bootstrap.pipe(Effect.catchCause((cause) => fatalStartupCause("bootstrap", cause))); | 330 | 332 | }).pipe(Effect.withSpan("desktop.startup")); | |
Collapse file Copy file name to clipboard +70Lines changed: 70 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import type { DesktopUpdateState } from "@t3tools/contracts"; | | 2 | +import { describe, expect, it } from "vite-plus/test"; | | 3 | + | | 4 | +import { createInitialDesktopUpdateState } from "../updates/updateMachine.ts"; | | 5 | +import { resolveStartupRecoveryOffer } from "./DesktopStartupRecovery.ts"; | | 6 | + | | 7 | +const updateState = (patch: Partial<DesktopUpdateState>): DesktopUpdateState => ({ | | 8 | + ...createInitialDesktopUpdateState( | | 9 | + "0.1.3", | | 10 | + { hostArch: "arm64", appArch: "arm64", runningUnderArm64Translation: false }, | | 11 | + "latest", | | 12 | + ), | | 13 | + enabled: true, | | 14 | + ...patch, | | 15 | +}); | | 16 | + | | 17 | +describe("resolveStartupRecoveryOffer", () => { | | 18 | + it("offers a newer version before going back", () => { | | 19 | + expect( | | 20 | + resolveStartupRecoveryOffer( | | 21 | + updateState({ status: "available", availableVersion: "0.1.4" }), | | 22 | + "0.1.2", | | 23 | + ), | | 24 | + ).toEqual({ _tag: "Update", version: "0.1.4" }); | | 25 | + }); | | 26 | + | | 27 | + it("offers a retained download after a later check fails", () => { | | 28 | + expect( | | 29 | + resolveStartupRecoveryOffer( | | 30 | + updateState({ status: "error", errorContext: "check", downloadedVersion: "0.1.4" }), | | 31 | + null, | | 32 | + ), | | 33 | + ).toEqual({ _tag: "Update", version: "0.1.4" }); | | 34 | + }); | | 35 | + | | 36 | + it("waits for the update check before offering to go back", () => { | | 37 | + expect(resolveStartupRecoveryOffer(updateState({ status: "checking" }), "0.1.2")).toEqual({ | | 38 | + _tag: "Checking", | | 39 | + }); | | 40 | + }); | | 41 | + | | 42 | + it("offers the last version that started when no update exists", () => { | | 43 | + expect(resolveStartupRecoveryOffer(updateState({ status: "up-to-date" }), "0.1.2")).toEqual({ | | 44 | + _tag: "Reinstall", | | 45 | + version: "0.1.2", | | 46 | + }); | | 47 | + }); | | 48 | + | | 49 | + it("does not offer an update that already failed to apply here", () => { | | 50 | + expect( | | 51 | + resolveStartupRecoveryOffer( | | 52 | + updateState({ | | 53 | + status: "downloaded", | | 54 | + downloadedVersion: "0.1.4", | | 55 | + notAppliedVersion: "0.1.4", | | 56 | + }), | | 57 | + "0.1.2", | | 58 | + ), | | 59 | + ).toEqual({ _tag: "Reinstall", version: "0.1.2" }); | | 60 | + }); | | 61 | + | | 62 | + it("falls back to the releases page when this version never started", () => { | | 63 | + expect(resolveStartupRecoveryOffer(updateState({ status: "disabled" }), "0.1.3")).toEqual({ | | 64 | + _tag: "Releases", | | 65 | + }); | | 66 | + expect(resolveStartupRecoveryOffer(updateState({ status: "up-to-date" }), null)).toEqual({ | | 67 | + _tag: "Releases", | | 68 | + }); | | 69 | + }); | | 70 | +}); |
|