GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(desktop): refresh queued updates before install · pingdotgg/t3code@6413b0f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps
    • desktop/src/updates
      • DesktopUpdates.test.ts
      • DesktopUpdates.ts
      • updateMachine.test.ts
      • updateMachine.ts
    • web/src/components
      • desktopUpdate.logic.test.ts
      • desktopUpdate.logic.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: apps/desktop/src/updates/DesktopUpdates.test.ts
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,41 @@ describe("DesktopUpdates", () => {
337337
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
338338
});
339339

340+
it.effect("checks for newer releases after an update has been downloaded", () => {
341+
const harness = makeHarness();
342+
343+
return Effect.scoped(
344+
Effect.gen(function* () {
345+
const updates = yield* DesktopUpdates.DesktopUpdates;
346+
yield* updates.configure;
347+
348+
harness.emit("update-downloaded", { version: "1.2.4" });
349+
yield* flushCallbacks;
350+
351+
const result = yield* updates.check("poll");
352+
assert.isTrue(result.checked);
353+
354+
harness.emit("update-available", { version: "1.2.4" });
355+
yield* flushCallbacks;
356+
357+
const unchangedState = yield* updates.getState;
358+
assert.equal(unchangedState.status, "downloaded");
359+
assert.equal(unchangedState.downloadedVersion, "1.2.4");
360+
361+
const nextResult = yield* updates.check("poll");
362+
assert.isTrue(nextResult.checked);
363+
364+
harness.emit("update-available", { version: "1.2.5" });
365+
yield* flushCallbacks;
366+
367+
const state = yield* updates.getState;
368+
assert.equal(state.status, "available");
369+
assert.equal(state.availableVersion, "1.2.5");
370+
assert.isNull(state.downloadedVersion);
371+
}),
372+
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
373+
});
374+
340375
it.effect("keeps raw updater event failures out of update state", () => {
341376
const harness = makeHarness();
342377
const cause = new Error(
Collapse file

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

Copy file name to clipboardExpand all lines: apps/desktop/src/updates/DesktopUpdates.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ export const make = Effect.gen(function* () {
353353
if (yield* Ref.get(updateCheckInFlightRef)) return false;
354354

355355
const state = yield* Ref.get(updateStateRef);
356-
if (state.status === "downloading" || state.status === "downloaded") {
356+
if (state.status === "downloading") {
357357
yield* logUpdaterInfo("skipping update check while update is active", {
358358
reason,
359359
status: state.status,
Collapse file

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

Copy file name to clipboardExpand all lines: apps/desktop/src/updates/updateMachine.test.ts
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,54 @@ describe("updateMachine", () => {
5555
expect(state.canRetry).toBe(true);
5656
});
5757

58+
it("preserves an already-downloaded update while checking the feed", () => {
59+
const downloadedState = {
60+
...createInitialDesktopUpdateState("1.0.0", runtimeInfo, "latest"),
61+
enabled: true,
62+
status: "downloaded" as const,
63+
availableVersion: "1.1.0",
64+
downloadedVersion: "1.1.0",
65+
releaseNotes: [{ version: "1.1.0", items: ["fix: queued update"] }],
66+
downloadPercent: 100,
67+
};
68+
const checking = reduceDesktopUpdateStateOnCheckStart(
69+
downloadedState,
70+
"2026-03-04T00:00:00.000Z",
71+
);
72+
const failed = reduceDesktopUpdateStateOnCheckFailure(
73+
checking,
74+
"network unavailable",
75+
"2026-03-04T00:00:01.000Z",
76+
);
77+
78+
expect(checking.status).toBe("checking");
79+
expect(checking.downloadedVersion).toBe("1.1.0");
80+
expect(checking.releaseNotes).toEqual(downloadedState.releaseNotes);
81+
expect(failed.status).toBe("downloaded");
82+
expect(failed.downloadedVersion).toBe("1.1.0");
83+
expect(failed.releaseNotes).toEqual(downloadedState.releaseNotes);
84+
expect(failed.message).toBeNull();
85+
});
86+
87+
it("keeps the installer when the feed still offers its version", () => {
88+
const state = reduceDesktopUpdateStateOnUpdateAvailable(
89+
{
90+
...createInitialDesktopUpdateState("1.0.0", runtimeInfo, "latest"),
91+
enabled: true,
92+
status: "downloaded",
93+
availableVersion: "1.1.0",
94+
downloadedVersion: "1.1.0",
95+
downloadPercent: 100,
96+
},
97+
"1.1.0",
98+
"2026-03-04T00:00:00.000Z",
99+
);
100+
101+
expect(state.status).toBe("downloaded");
102+
expect(state.downloadedVersion).toBe("1.1.0");
103+
expect(state.downloadPercent).toBe(100);
104+
});
105+
58106
it("preserves available version on download failure for retry", () => {
59107
const state = reduceDesktopUpdateStateOnDownloadFailure(
60108
{
Collapse file

‎apps/desktop/src/updates/updateMachine.ts‎

Copy file name to clipboardExpand all lines: apps/desktop/src/updates/updateMachine.ts
+20-6Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ export function reduceDesktopUpdateStateOnCheckStart(
4343
state: DesktopUpdateState,
4444
checkedAt: string,
4545
): DesktopUpdateState {
46+
const hasDownloadedUpdate = state.downloadedVersion !== null;
4647
return {
4748
...state,
4849
status: "checking",
4950
checkedAt,
50-
releaseNotes: [],
51+
releaseNotes: hasDownloadedUpdate ? state.releaseNotes : [],
5152
message: null,
52-
downloadPercent: null,
53+
downloadPercent: hasDownloadedUpdate ? 100 : null,
5354
errorContext: null,
5455
canRetry: false,
5556
};
@@ -60,6 +61,18 @@ export function reduceDesktopUpdateStateOnCheckFailure(
6061
message: string,
6162
checkedAt: string,
6263
): DesktopUpdateState {
64+
if (state.downloadedVersion !== null) {
65+
return {
66+
...state,
67+
status: "downloaded",
68+
message: null,
69+
checkedAt,
70+
downloadPercent: 100,
71+
errorContext: null,
72+
canRetry: true,
73+
};
74+
}
75+
6376
return {
6477
...state,
6578
status: "error",
@@ -77,17 +90,18 @@ export function reduceDesktopUpdateStateOnUpdateAvailable(
7790
checkedAt: string,
7891
releaseNotes: ReadonlyArray<DesktopUpdateReleaseNote> = [],
7992
): DesktopUpdateState {
93+
const isDownloadedVersion = state.downloadedVersion === version;
8094
return {
8195
...state,
82-
status: "available",
96+
status: isDownloadedVersion ? "downloaded" : "available",
8397
availableVersion: version,
84-
downloadedVersion: null,
98+
downloadedVersion: isDownloadedVersion ? version : null,
8599
releaseNotes,
86-
downloadPercent: null,
100+
downloadPercent: isDownloadedVersion ? 100 : null,
87101
checkedAt,
88102
message: null,
89103
errorContext: null,
90-
canRetry: false,
104+
canRetry: isDownloadedVersion,
91105
};
92106
}
93107

Collapse file

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

Copy file name to clipboardExpand all lines: apps/web/src/components/desktopUpdate.logic.test.ts
+15-4Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,25 @@ describe("desktop update button state", () => {
7373
expect(getDesktopUpdateButtonTooltip(state)).toContain("Click to retry");
7474
});
7575

76-
it("prefers install when a downloaded version already exists", () => {
76+
it("prefers a newly available release over a stale downloaded version", () => {
7777
const state: DesktopUpdateState = {
7878
...baseState,
7979
status: "available",
80+
availableVersion: "1.2.0",
81+
downloadedVersion: "1.1.0",
82+
};
83+
expect(resolveDesktopUpdateButtonAction(state)).toBe("download");
84+
});
85+
86+
it("hides the install action while checking for a newer release", () => {
87+
const state: DesktopUpdateState = {
88+
...baseState,
89+
status: "checking",
8090
availableVersion: "1.1.0",
8191
downloadedVersion: "1.1.0",
92+
downloadPercent: 100,
8293
};
83-
expect(resolveDesktopUpdateButtonAction(state)).toBe("install");
94+
expect(resolveDesktopUpdateButtonAction(state)).toBe("none");
8495
});
8596

8697
it("hides the button for non-actionable check errors", () => {
@@ -290,15 +301,15 @@ describe("canCheckForUpdate", () => {
290301
);
291302
});
292303

293-
it("returns false once an update has been downloaded", () => {
304+
it("returns true once an update has been downloaded so newer releases can be found", () => {
294305
expect(
295306
canCheckForUpdate({
296307
...baseState,
297308
status: "downloaded",
298309
availableVersion: "1.1.0",
299310
downloadedVersion: "1.1.0",
300311
}),
301-
).toBe(false);
312+
).toBe(true);
302313
});
303314

304315
it("returns true when idle", () => {
Collapse file

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

Copy file name to clipboardExpand all lines: apps/web/src/components/desktopUpdate.logic.ts
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export function getDesktopUpdateReleaseUrl(version: string | null): string | nul
2424
export function resolveDesktopUpdateButtonAction(
2525
state: DesktopUpdateState,
2626
): DesktopUpdateButtonAction {
27-
if (state.downloadedVersion) {
27+
if (
28+
state.downloadedVersion &&
29+
(state.status === "downloaded" || state.errorContext === "install")
30+
) {
2831
return "install";
2932
}
3033
if (state.status === "available") {
@@ -125,9 +128,6 @@ export function shouldHighlightDesktopUpdateError(state: DesktopUpdateState | nu
125128
export function canCheckForUpdate(state: DesktopUpdateState | null): boolean {
126129
if (!state || !state.enabled) return false;
127130
return (
128-
state.status !== "checking" &&
129-
state.status !== "downloading" &&
130-
state.status !== "downloaded" &&
131-
state.status !== "disabled"
131+
state.status !== "checking" && state.status !== "downloading" && state.status !== "disabled"
132132
);
133133
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.