Skip to content

Commit bc0a569

Browse files
committed
fix(update): compare preview installs to stable
1 parent 6edec46 commit bc0a569

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/update/notify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function gt(a: number[], b: number[]): boolean {
9292
export function isNewer(latest: string, current: string, channel: Channel): boolean {
9393
if (channel === "latest") {
9494
const l = parseStable(latest);
95-
const c = parseStable(current);
95+
const c = parseStable(current) ?? parsePreview(current)?.slice(0, 3);
9696
if (!l || !c) return false;
9797
return gt(l, c);
9898
}

tests/update-job.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ describe("GUI update check", () => {
8585
expect(result.canUpdate).toBe(false);
8686
expect(result.reason).toBe("already_latest");
8787
});
88+
89+
test("offers a stable update from an older preview but not the same base", () => {
90+
const olderPreview = checkForUpdate("latest", {
91+
currentVersion: () => "2.8.2-preview.20260731",
92+
detectInstall: () => "npm",
93+
latestVersion: () => "2.9.1",
94+
});
95+
expect(olderPreview.updateAvailable).toBe(true);
96+
expect(olderPreview.canUpdate).toBe(true);
97+
98+
const sameBasePreview = checkForUpdate("latest", {
99+
currentVersion: () => "2.9.1-preview.20260731",
100+
detectInstall: () => "npm",
101+
latestVersion: () => "2.9.1",
102+
});
103+
expect(sameBasePreview.updateAvailable).toBe(false);
104+
expect(sameBasePreview.canUpdate).toBe(false);
105+
});
88106
});
89107

90108
describe("GUI update execution decisions", () => {

tests/update-notify.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ describe("isNewer — latest channel", () => {
3838
test("prereleases are ignored on the stable channel", () => {
3939
expect(isNewer("2.7.0-preview.1", "2.6.4", "latest")).toBe(false);
4040
});
41+
test("stable releases compare against a preview current by its base version", () => {
42+
expect(isNewer("2.9.1", "2.8.2-preview.20260731", "latest")).toBe(true);
43+
expect(isNewer("2.9.1", "2.9.1-preview.20260731", "latest")).toBe(false);
44+
});
4145
});
4246

4347
describe("isNewer — preview channel", () => {

0 commit comments

Comments
 (0)