Skip to content

Commit e93bbea

Browse files
committed
fix(desktop): show newest changes in nightly previews
1 parent e898008 commit e93bbea

16 files changed

Lines changed: 600 additions & 127 deletions

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ describe("DesktopUpdates", () => {
336336
version: "1.2.4-nightly.20260709.765",
337337
note: "- [codex] Upgrade Clerk stack by @juliusmarminge in #3821",
338338
},
339+
{ version: "1.2.4-nightly.20260709.764", note: "- Change 764" },
340+
{ version: "1.2.4-nightly.20260709.763", note: "- Change 763" },
341+
{ version: "1.2.4-nightly.20260709.762", note: "- Change 762" },
342+
{ version: "1.2.4-nightly.20260709.761", note: "- Change 761" },
343+
{ version: "1.2.4-nightly.20260709.760", note: "- Change 760" },
339344
],
340345
});
341346
yield* flushCallbacks;
@@ -346,13 +351,21 @@ describe("DesktopUpdates", () => {
346351
{
347352
version: "1.2.4-nightly.20260709.766",
348353
items: ["feat(client): persist offline environment data by @juliusmarminge in #3795"],
354+
totalItems: 1,
349355
},
350356
{
351357
version: "1.2.4-nightly.20260709.765",
352358
items: ["[codex] Upgrade Clerk stack by @juliusmarminge in #3821"],
359+
totalItems: 1,
353360
},
361+
{ version: "1.2.4-nightly.20260709.764", items: ["Change 764"], totalItems: 1 },
362+
{ version: "1.2.4-nightly.20260709.763", items: ["Change 763"], totalItems: 1 },
363+
{ version: "1.2.4-nightly.20260709.762", items: ["Change 762"], totalItems: 1 },
364+
{ version: "1.2.4-nightly.20260709.761", items: ["Change 761"], totalItems: 1 },
354365
]);
366+
assert.equal(state.omittedReleaseCount, 1);
355367
assert.deepEqual(harness.sentStates.at(-1)?.releaseNotes, state.releaseNotes);
368+
assert.equal(harness.sentStates.at(-1)?.omittedReleaseCount, 1);
356369
}),
357370
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
358371
});
@@ -383,8 +396,9 @@ describe("DesktopUpdates", () => {
383396
assert.equal(unchangedState.status, "downloaded");
384397
assert.equal(unchangedState.downloadedVersion, "1.2.4");
385398
assert.deepEqual(unchangedState.releaseNotes, [
386-
{ version: "1.2.4", items: ["fix: queued update"] },
399+
{ version: "1.2.4", items: ["fix: queued update"], totalItems: 1 },
387400
]);
401+
assert.equal(unchangedState.omittedReleaseCount, 0);
388402

389403
const nextResult = yield* updates.check("poll");
390404
assert.isTrue(nextResult.checked);
@@ -424,7 +438,10 @@ describe("DesktopUpdates", () => {
424438
assert.equal(state.status, "downloaded");
425439
assert.equal(state.availableVersion, "1.2.4");
426440
assert.equal(state.downloadedVersion, "1.2.4");
427-
assert.deepEqual(state.releaseNotes, [{ version: "1.2.4", items: ["fix: queued update"] }]);
441+
assert.deepEqual(state.releaseNotes, [
442+
{ version: "1.2.4", items: ["fix: queued update"], totalItems: 1 },
443+
]);
444+
assert.equal(state.omittedReleaseCount, 0);
428445
assert.equal(state.downloadPercent, 100);
429446
}),
430447
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
@@ -454,7 +471,10 @@ describe("DesktopUpdates", () => {
454471
assert.equal(state.status, "downloaded");
455472
assert.equal(state.availableVersion, "1.2.4");
456473
assert.equal(state.downloadedVersion, "1.2.4");
457-
assert.deepEqual(state.releaseNotes, [{ version: "1.2.4", items: ["fix: queued update"] }]);
474+
assert.deepEqual(state.releaseNotes, [
475+
{ version: "1.2.4", items: ["fix: queued update"], totalItems: 1 },
476+
]);
477+
assert.equal(state.omittedReleaseCount, 0);
458478
assert.equal(state.downloadPercent, 100);
459479
}),
460480
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,14 +593,24 @@ export const make = Effect.gen(function* () {
593593
}
594594

595595
const checkedAt = yield* currentIsoTimestamp;
596-
const releaseNotes = normalizeDesktopUpdateReleaseNotes(info.releaseNotes, info.version);
596+
const { releaseNotes, omittedReleaseCount } = normalizeDesktopUpdateReleaseNotes(
597+
info.releaseNotes,
598+
info.version,
599+
);
597600
yield* setState(
598-
reduceDesktopUpdateStateOnUpdateAvailable(state, info.version, checkedAt, releaseNotes),
601+
reduceDesktopUpdateStateOnUpdateAvailable(
602+
state,
603+
info.version,
604+
checkedAt,
605+
releaseNotes,
606+
omittedReleaseCount,
607+
),
599608
);
600609
yield* Ref.set(lastLoggedDownloadMilestoneRef, -1);
601610
yield* logUpdaterInfo("update available", {
602611
version: info.version,
603612
releaseNoteGroups: releaseNotes.length,
613+
omittedReleaseCount,
604614
});
605615
}),
606616
),

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

Lines changed: 110 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,144 @@ import { describe, expect, it } from "vite-plus/test";
33
import { normalizeDesktopUpdateReleaseNotes } from "./releaseNotes.ts";
44

55
describe("normalizeDesktopUpdateReleaseNotes", () => {
6-
it("splits a plain string note into items under the fallback version", () => {
7-
const notes = normalizeDesktopUpdateReleaseNotes(
8-
"## What's changed\n- First fix\n- Second fix",
6+
it("shows the newest changes and counts all real changes", () => {
7+
const result = normalizeDesktopUpdateReleaseNotes(
8+
[
9+
"- feat: first change",
10+
"- fix: second change",
11+
"- fix: third change",
12+
"- fix: fourth change",
13+
"- fix: fifth change",
14+
"- fix: sixth change",
15+
"- fix: seventh change",
16+
"- fix: eighth change",
17+
"- fix(web): keep long task drawers usable on small screens by @human in #8313",
18+
"- fix(opencode): handle child approvals, stops, and model catalogs by @human in #8480",
19+
"## New Contributors",
20+
"- @human made their first contribution in #8435",
21+
"**Full Changelog**: https://github.com/pingdotgg/t3code/compare/old...new",
22+
].join("\n"),
23+
"0.0.36-nightly.20260828.1213",
24+
);
25+
26+
expect(result).toEqual({
27+
releaseNotes: [
28+
{
29+
version: "0.0.36-nightly.20260828.1213",
30+
items: [
31+
"fix(opencode): handle child approvals, stops, and model catalogs by @human in #8480",
32+
"fix(web): keep long task drawers usable on small screens by @human in #8313",
33+
"fix: eighth change",
34+
"fix: seventh change",
35+
"fix: sixth change",
36+
"fix: fifth change",
37+
"fix: fourth change",
38+
"fix: third change",
39+
],
40+
totalItems: 10,
41+
},
42+
],
43+
omittedReleaseCount: 0,
44+
});
45+
});
46+
47+
it("excludes a GitHub HTML contributor section", () => {
48+
const result = normalizeDesktopUpdateReleaseNotes(
49+
"<h2>What's Changed</h2><ul><li>Older fix</li><li>Newer fix</li></ul>" +
50+
"<h2>New Contributors</h2><ul><li>@human made their first contribution</li></ul>" +
51+
"<h2>Full Changelog</h2>",
952
"1.2.3",
1053
);
11-
expect(notes).toEqual([{ version: "1.2.3", items: ["First fix", "Second fix"] }]);
54+
55+
expect(result).toEqual({
56+
releaseNotes: [{ version: "1.2.3", items: ["Newer fix", "Older fix"], totalItems: 2 }],
57+
omittedReleaseCount: 0,
58+
});
1259
});
1360

14-
it("keeps per-version groups and drops empty ones", () => {
15-
const notes = normalizeDesktopUpdateReleaseNotes(
61+
it("keeps per-version order and drops empty groups", () => {
62+
const result = normalizeDesktopUpdateReleaseNotes(
1663
[
17-
{ version: "1.2.3", note: "- Newer change" },
64+
{ version: "1.2.3", note: "- Newer release" },
1865
{ version: "1.2.2", note: "Full changelog: https://example.com/compare/x...y" },
19-
{ version: "1.2.1", note: "- Older change" },
66+
{ version: "1.2.1", note: "- Older release" },
2067
],
2168
"1.2.3",
2269
);
23-
expect(notes).toEqual([
24-
{ version: "1.2.3", items: ["Newer change"] },
25-
{ version: "1.2.1", items: ["Older change"] },
70+
71+
expect(result).toEqual({
72+
releaseNotes: [
73+
{ version: "1.2.3", items: ["Newer release"], totalItems: 1 },
74+
{ version: "1.2.1", items: ["Older release"], totalItems: 1 },
75+
],
76+
omittedReleaseCount: 0,
77+
});
78+
});
79+
80+
it("counts valid groups before applying the six-release limit", () => {
81+
const releaseNotes = [
82+
{ version: "1.3.9", note: "- Change 9" },
83+
{ version: "1.3.8", note: "Full changelog: https://example.com/compare/x...y" },
84+
{ version: "1.3.7", note: "- Change 7" },
85+
{ version: "1.3.6", note: "- Change 6" },
86+
{ version: "1.3.5", note: "- Change 5" },
87+
{ version: "1.3.4", note: "- Change 4" },
88+
{ version: "1.3.3", note: "- Change 3" },
89+
{ version: "1.3.2", note: "- Change 2" },
90+
];
91+
92+
const result = normalizeDesktopUpdateReleaseNotes(releaseNotes, "1.3.9");
93+
94+
expect(result.releaseNotes.map(({ version }) => version)).toEqual([
95+
"1.3.9",
96+
"1.3.7",
97+
"1.3.6",
98+
"1.3.5",
99+
"1.3.4",
100+
"1.3.3",
26101
]);
102+
expect(result.omittedReleaseCount).toBe(1);
27103
});
28104

29105
it("decodes valid HTML entities", () => {
30-
const notes = normalizeDesktopUpdateReleaseNotes("- Fix &amp; polish &#128512;", "1.0.0");
31-
expect(notes).toEqual([{ version: "1.0.0", items: ["Fix & polish 😀"] }]);
106+
const result = normalizeDesktopUpdateReleaseNotes("- Fix &amp; polish &#128512;", "1.0.0");
107+
expect(result).toEqual({
108+
releaseNotes: [{ version: "1.0.0", items: ["Fix & polish 😀"], totalItems: 1 }],
109+
omittedReleaseCount: 0,
110+
});
32111
});
33112

34-
it("ignores malformed entries instead of throwing", () => {
35-
const notes = normalizeDesktopUpdateReleaseNotes(
113+
it("ignores malformed and empty entries instead of throwing", () => {
114+
const result = normalizeDesktopUpdateReleaseNotes(
36115
[
37116
{ version: "1.2.3", note: "- Valid change" },
117+
{ version: "1.2.2", note: "" },
38118
{ version: 42, note: "- Bad version type" },
39119
{ version: "1.2.1", note: { html: "<p>object note</p>" } },
40120
"not an object",
41121
null,
42122
],
43123
"1.2.3",
44124
);
45-
expect(notes).toEqual([{ version: "1.2.3", items: ["Valid change"] }]);
125+
126+
expect(result).toEqual({
127+
releaseNotes: [{ version: "1.2.3", items: ["Valid change"], totalItems: 1 }],
128+
omittedReleaseCount: 0,
129+
});
46130
});
47131

48-
it("returns non-empty groups even when preceded by many boilerplate-only groups", () => {
49-
const boilerplate = Array.from({ length: 7 }, (_, index) => ({
50-
version: `1.3.${9 - index}`,
51-
note: "Full changelog: https://example.com/compare/x...y",
52-
}));
53-
const notes = normalizeDesktopUpdateReleaseNotes(
54-
[...boilerplate, { version: "1.3.2", note: "- Older but real change" }],
55-
"1.3.9",
56-
);
57-
expect(notes).toEqual([{ version: "1.3.2", items: ["Older but real change"] }]);
132+
it("returns an empty result for an invalid payload", () => {
133+
expect(normalizeDesktopUpdateReleaseNotes({ note: "- Invalid" }, "1.0.0")).toEqual({
134+
releaseNotes: [],
135+
omittedReleaseCount: 0,
136+
});
58137
});
59138

60139
it("does not throw on out-of-range numeric entities and keeps the literal", () => {
61-
const notes = normalizeDesktopUpdateReleaseNotes("- Broken entity &#9999999999;", "1.0.0");
62-
expect(notes).toEqual([{ version: "1.0.0", items: ["Broken entity &#9999999999;"] }]);
140+
const result = normalizeDesktopUpdateReleaseNotes("- Broken entity &#9999999999;", "1.0.0");
141+
expect(result).toEqual({
142+
releaseNotes: [{ version: "1.0.0", items: ["Broken entity &#9999999999;"], totalItems: 1 }],
143+
omittedReleaseCount: 0,
144+
});
63145
});
64146
});

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

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,19 @@ function truncateReleaseNoteItem(item: string): string {
7171
return `${item.slice(0, MAX_RELEASE_NOTE_ITEM_LENGTH - 3).trimEnd()}...`;
7272
}
7373

74-
function isIgnoredReleaseNoteLine(line: string): boolean {
75-
const normalized = line
74+
function normalizeReleaseNoteLine(line: string): string {
75+
return line
7676
.toLowerCase()
7777
.replace(/[*_`#]/g, "")
7878
.trim();
79+
}
80+
81+
function isIgnoredReleaseNoteLine(line: string): boolean {
82+
const normalized = normalizeReleaseNoteLine(line);
7983
return (
8084
normalized === "" ||
8185
normalized === "what's changed" ||
8286
normalized === "whats changed" ||
83-
normalized === "full changelog" ||
84-
normalized === "new contributors" ||
8587
normalized.startsWith("compare: ") ||
8688
normalized.includes("/compare/")
8789
);
@@ -97,29 +99,44 @@ function extractReleaseNoteItems(note: string | null | undefined): ReadonlyArray
9799
.replace(/^[-*]\s+/, "")
98100
.replace(/^\d+[.)]\s+/, "")
99101
.replace(/\s+/g, " ");
102+
const normalized = normalizeReleaseNoteLine(item);
103+
if (normalized === "new contributors" || normalized === "full changelog") break;
100104
if (isIgnoredReleaseNoteLine(item)) continue;
101105
items.push(truncateReleaseNoteItem(item));
102-
if (items.length >= MAX_RELEASE_NOTE_ITEMS_PER_GROUP) break;
103106
}
104107
return items;
105108
}
106109

110+
interface NormalizedDesktopUpdateReleaseNotes {
111+
readonly releaseNotes: ReadonlyArray<DesktopUpdateReleaseNote>;
112+
readonly omittedReleaseCount: number;
113+
}
114+
107115
export function normalizeDesktopUpdateReleaseNotes(
108116
releaseNotes: unknown,
109117
fallbackVersion: string,
110-
): ReadonlyArray<DesktopUpdateReleaseNote> {
118+
): NormalizedDesktopUpdateReleaseNotes {
111119
const rawNotes =
112120
typeof releaseNotes === "string"
113121
? [{ version: fallbackVersion, note: releaseNotes }]
114122
: Array.isArray(releaseNotes)
115123
? releaseNotes.filter(isElectronReleaseNoteInfo)
116124
: [];
117125

118-
return rawNotes
119-
.map((entry) => ({
120-
version: entry.version,
121-
items: extractReleaseNoteItems(entry.note),
122-
}))
123-
.filter((entry) => entry.items.length > 0)
124-
.slice(0, MAX_RELEASE_NOTE_GROUPS);
126+
const normalizedNotes = rawNotes.flatMap((entry) => {
127+
const items = extractReleaseNoteItems(entry.note);
128+
if (items.length === 0) return [];
129+
return [
130+
{
131+
version: entry.version,
132+
items: items.toReversed().slice(0, MAX_RELEASE_NOTE_ITEMS_PER_GROUP),
133+
totalItems: items.length,
134+
},
135+
];
136+
});
137+
138+
return {
139+
releaseNotes: normalizedNotes.slice(0, MAX_RELEASE_NOTE_GROUPS),
140+
omittedReleaseCount: Math.max(0, normalizedNotes.length - MAX_RELEASE_NOTE_GROUPS),
141+
};
125142
}

0 commit comments

Comments
 (0)