-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: show nightly update changelog tooltip #3832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juliusmarminge
merged 7 commits into
pingdotgg:main
from
HugoVizcainoSantana:feature/nightly-update-changelog-tooltip
Jul 17, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
75635ff
feat: show nightly update changelog tooltip
HugoVizcainoSantana f5341c3
Merge branch 'main' into feature/nightly-update-changelog-tooltip
HugoVizcainoSantana 997e093
fix: address review feedback on nightly changelog tooltip
HugoVizcainoSantana 5c49a36
fix: make nightly changelog tooltip scrollable under pointer-events-none
HugoVizcainoSantana f29eac0
Merge branch 'main' into feature/nightly-update-changelog-tooltip
HugoVizcainoSantana 88b4261
Merge branch 'main' into feature/nightly-update-changelog-tooltip
HugoVizcainoSantana dc03b5d
fix: harden release notes handling against malformed payloads
HugoVizcainoSantana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| import { normalizeDesktopUpdateReleaseNotes } from "./releaseNotes.ts"; | ||
|
|
||
| describe("normalizeDesktopUpdateReleaseNotes", () => { | ||
| it("splits a plain string note into items under the fallback version", () => { | ||
| const notes = normalizeDesktopUpdateReleaseNotes( | ||
| "## What's changed\n- First fix\n- Second fix", | ||
| "1.2.3", | ||
| ); | ||
| expect(notes).toEqual([{ version: "1.2.3", items: ["First fix", "Second fix"] }]); | ||
| }); | ||
|
|
||
| it("keeps per-version groups and drops empty ones", () => { | ||
| const notes = normalizeDesktopUpdateReleaseNotes( | ||
| [ | ||
| { version: "1.2.3", note: "- Newer change" }, | ||
| { version: "1.2.2", note: "Full changelog: https://example.com/compare/x...y" }, | ||
| { version: "1.2.1", note: "- Older change" }, | ||
| ], | ||
| "1.2.3", | ||
| ); | ||
| expect(notes).toEqual([ | ||
| { version: "1.2.3", items: ["Newer change"] }, | ||
| { version: "1.2.1", items: ["Older change"] }, | ||
| ]); | ||
| }); | ||
|
|
||
| it("decodes valid HTML entities", () => { | ||
| const notes = normalizeDesktopUpdateReleaseNotes("- Fix & polish 😀", "1.0.0"); | ||
| expect(notes).toEqual([{ version: "1.0.0", items: ["Fix & polish 😀"] }]); | ||
| }); | ||
|
|
||
| it("ignores malformed entries instead of throwing", () => { | ||
| const notes = normalizeDesktopUpdateReleaseNotes( | ||
| [ | ||
| { version: "1.2.3", note: "- Valid change" }, | ||
| { version: 42, note: "- Bad version type" }, | ||
| { version: "1.2.1", note: { html: "<p>object note</p>" } }, | ||
| "not an object", | ||
| null, | ||
| ], | ||
| "1.2.3", | ||
| ); | ||
| expect(notes).toEqual([{ version: "1.2.3", items: ["Valid change"] }]); | ||
| }); | ||
|
|
||
| it("returns non-empty groups even when preceded by many boilerplate-only groups", () => { | ||
| const boilerplate = Array.from({ length: 7 }, (_, index) => ({ | ||
| version: `1.3.${9 - index}`, | ||
| note: "Full changelog: https://example.com/compare/x...y", | ||
| })); | ||
| const notes = normalizeDesktopUpdateReleaseNotes( | ||
| [...boilerplate, { version: "1.3.2", note: "- Older but real change" }], | ||
| "1.3.9", | ||
| ); | ||
| expect(notes).toEqual([{ version: "1.3.2", items: ["Older but real change"] }]); | ||
| }); | ||
|
|
||
| it("does not throw on out-of-range numeric entities and keeps the literal", () => { | ||
| expect(() => | ||
| normalizeDesktopUpdateReleaseNotes("- Broken entity �", "1.0.0"), | ||
| ).not.toThrow(); | ||
| const notes = normalizeDesktopUpdateReleaseNotes("- Broken entity �", "1.0.0"); | ||
| expect(notes).toEqual([{ version: "1.0.0", items: ["Broken entity �"] }]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| import type { DesktopUpdateReleaseNote } from "@t3tools/contracts"; | ||
|
|
||
| interface ElectronReleaseNoteInfo { | ||
| readonly version: string; | ||
| readonly note: string | null | undefined; | ||
| } | ||
|
|
||
| function isElectronReleaseNoteInfo(value: unknown): value is ElectronReleaseNoteInfo { | ||
| if (typeof value !== "object" || value === null) return false; | ||
| const candidate = value as { readonly version?: unknown; readonly note?: unknown }; | ||
| return ( | ||
| typeof candidate.version === "string" && | ||
| (typeof candidate.note === "string" || candidate.note === null || candidate.note === undefined) | ||
| ); | ||
| } | ||
|
|
||
| const MAX_RELEASE_NOTE_GROUPS = 6; | ||
| const MAX_RELEASE_NOTE_ITEMS_PER_GROUP = 8; | ||
| const MAX_RELEASE_NOTE_ITEM_LENGTH = 220; | ||
|
|
||
| const HTML_ENTITY_REPLACEMENTS: Readonly<Record<string, string>> = { | ||
| amp: "&", | ||
| apos: "'", | ||
| gt: ">", | ||
| lt: "<", | ||
| nbsp: " ", | ||
| quot: '"', | ||
| }; | ||
|
|
||
| function decodeCodePoint(codePoint: number, entity: string): string { | ||
| // String.fromCodePoint throws RangeError outside the valid Unicode range, and | ||
| // Number.isFinite alone lets oversized values (e.g. �) through. | ||
| if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 0x10ffff) { | ||
| return `&${entity};`; | ||
| } | ||
| return String.fromCodePoint(codePoint); | ||
| } | ||
|
|
||
| function decodeHtmlEntity(entity: string): string { | ||
| const named = HTML_ENTITY_REPLACEMENTS[entity]; | ||
| if (named) return named; | ||
| if (entity.startsWith("#x")) { | ||
| return decodeCodePoint(Number.parseInt(entity.slice(2), 16), entity); | ||
| } | ||
| if (entity.startsWith("#")) { | ||
| return decodeCodePoint(Number.parseInt(entity.slice(1), 10), entity); | ||
| } | ||
| return `&${entity};`; | ||
|
macroscopeapp[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| function decodeHtmlEntities(input: string): string { | ||
| return input.replace(/&([a-zA-Z]+|#\d+|#x[0-9a-fA-F]+);/g, (_, entity: string) => | ||
| decodeHtmlEntity(entity), | ||
| ); | ||
| } | ||
|
|
||
| function stripMarkup(input: string): string { | ||
| return decodeHtmlEntities( | ||
| input | ||
| .replace(/<br\s*\/?>/gi, "\n") | ||
| .replace(/<li\b[^>]*>/gi, "\n- ") | ||
| .replace(/<\/(?:p|div|li|h[1-6]|ul|ol|blockquote)>/gi, "\n") | ||
| .replace(/<[^>]*>/g, "") | ||
| .replace(/\[([^\]]+)\]\([^)]+\)/g, "$1") | ||
| .replace(/\*\*([^*]+)\*\*/g, "$1"), | ||
| ); | ||
| } | ||
|
|
||
| function truncateReleaseNoteItem(item: string): string { | ||
| if (item.length <= MAX_RELEASE_NOTE_ITEM_LENGTH) return item; | ||
| return `${item.slice(0, MAX_RELEASE_NOTE_ITEM_LENGTH - 3).trimEnd()}...`; | ||
| } | ||
|
|
||
| function isIgnoredReleaseNoteLine(line: string): boolean { | ||
| const normalized = line | ||
| .toLowerCase() | ||
| .replace(/[*_`#]/g, "") | ||
| .trim(); | ||
| return ( | ||
| normalized === "" || | ||
| normalized === "what's changed" || | ||
| normalized === "whats changed" || | ||
| normalized === "full changelog" || | ||
| normalized === "new contributors" || | ||
| normalized.startsWith("compare: ") || | ||
| normalized.includes("/compare/") | ||
| ); | ||
| } | ||
|
|
||
| function extractReleaseNoteItems(note: string | null | undefined): ReadonlyArray<string> { | ||
| if (!note) return []; | ||
|
|
||
| const items: string[] = []; | ||
| for (const rawLine of stripMarkup(note).split("\n")) { | ||
| const item = rawLine | ||
| .trim() | ||
| .replace(/^[-*]\s+/, "") | ||
| .replace(/^\d+[.)]\s+/, "") | ||
| .replace(/\s+/g, " "); | ||
| if (isIgnoredReleaseNoteLine(item)) continue; | ||
| items.push(truncateReleaseNoteItem(item)); | ||
| if (items.length >= MAX_RELEASE_NOTE_ITEMS_PER_GROUP) break; | ||
| } | ||
| return items; | ||
| } | ||
|
|
||
| export function normalizeDesktopUpdateReleaseNotes( | ||
| releaseNotes: unknown, | ||
| fallbackVersion: string, | ||
| ): ReadonlyArray<DesktopUpdateReleaseNote> { | ||
| const rawNotes = | ||
| typeof releaseNotes === "string" | ||
| ? [{ version: fallbackVersion, note: releaseNotes }] | ||
| : Array.isArray(releaseNotes) | ||
| ? releaseNotes.filter(isElectronReleaseNoteInfo) | ||
| : []; | ||
|
|
||
| return rawNotes | ||
| .map((entry) => ({ | ||
| version: entry.version, | ||
| items: extractReleaseNoteItems(entry.note), | ||
| })) | ||
| .filter((entry) => entry.items.length > 0) | ||
| .slice(0, MAX_RELEASE_NOTE_GROUPS); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.