diff --git a/apps/web/src/components/ApplicationRelease.tsx b/apps/web/src/components/ApplicationRelease.tsx index 4a5c02df..aafff203 100644 --- a/apps/web/src/components/ApplicationRelease.tsx +++ b/apps/web/src/components/ApplicationRelease.tsx @@ -34,14 +34,16 @@ function NoteBlockView({ block }: { block: NoteBlock }) { const Tag = block.level === 1 ? "h3" : block.level === 2 ? "h4" : "h5"; return {renderInlines(block.inlines)}; } - if (block.type === "list") + if (block.type === "list") { + const List = block.ordered ? "ol" : "ul"; return ( - + ); + } if (block.type === "code") return (
@@ -51,8 +53,20 @@ function NoteBlockView({ block }: { block: NoteBlock }) {
   return 

{renderInlines(block.inlines)}

; } -function ReleaseNotes({ source }: { source: string }) { - const blocks = releaseNoteBlocks(source); +function headingText(block: NoteBlock) { + return block.type === "heading" + ? block.inlines + .map((item) => (item.type === "link" ? item.text : item.value)) + .join("") + .trim() + : ""; +} + +function ReleaseNotes({ source, title }: { source: string; title: string }) { + const all = releaseNoteBlocks(source); + // Notes often start with the release's own name, which the entry already shows as its title. + const blocks = + all[0] && headingText(all[0]) === title.trim() ? all.slice(1) : all; if (!blocks.length) return

No notes for this release.

; return ( @@ -86,7 +100,7 @@ function ReleaseEntry({ Available )}

- + View on GitHub diff --git a/apps/web/src/components/releaseNotes.test.ts b/apps/web/src/components/releaseNotes.test.ts index 5a7a21d3..49893b65 100644 --- a/apps/web/src/components/releaseNotes.test.ts +++ b/apps/web/src/components/releaseNotes.test.ts @@ -37,6 +37,7 @@ test("release notes keep headings, lists, code, and safe links", () => { ); assert.deepEqual(blocks[2], { type: "list", + ordered: false, items: [ [{ type: "text", value: "Reading lists" }], [ @@ -57,3 +58,50 @@ test("only a higher stable version counts as newer", () => { assert.equal(releaseIsNewer("v2.0.0", "v1.10.0"), false); assert.equal(releaseIsNewer("1.0.0-dev", "v1.10.0"), false); }); + +test("list items continue on indented lines, and numbered lists keep their order", () => { + const blocks = releaseNoteBlocks( + [ + "- A release history window for each version, with a", + " link to the notes on GitHub.", + " - A nested point.", + "- Second item.", + "", + "1. **Back up** first.", + "2. Pull the new image.", + " Then restart.", + "", + "After the list.", + ].join("\n"), + ); + assert.deepEqual(blocks[0], { + type: "list", + ordered: false, + items: [ + [ + { + type: "text", + value: + "A release history window for each version, with a link to the notes on GitHub.", + }, + ], + [{ type: "text", value: "A nested point." }], + [{ type: "text", value: "Second item." }], + ], + }); + assert.deepEqual(blocks[1], { + type: "list", + ordered: true, + items: [ + [ + { type: "strong", value: "Back up" }, + { type: "text", value: " first." }, + ], + [{ type: "text", value: "Pull the new image. Then restart." }], + ], + }); + assert.deepEqual(blocks[2], { + type: "paragraph", + inlines: [{ type: "text", value: "After the list." }], + }); +}); diff --git a/apps/web/src/components/releaseNotes.ts b/apps/web/src/components/releaseNotes.ts index 463665ad..51521047 100644 --- a/apps/web/src/components/releaseNotes.ts +++ b/apps/web/src/components/releaseNotes.ts @@ -7,7 +7,7 @@ export type Inline = export type NoteBlock = | { type: "heading"; level: 1 | 2 | 3; inlines: Inline[] } | { type: "paragraph"; inlines: Inline[] } - | { type: "list"; items: Inline[][] } + | { type: "list"; ordered: boolean; items: Inline[][] } | { type: "code"; value: string }; const LINK = /\[([^\]\n]{1,200})\]\((https?:\/\/[^\s)]{1,2000})\)/; @@ -80,13 +80,21 @@ export function releaseNoteBlocks(source: string): NoteBlock[] { index += 1; continue; } - if (/^[-*] /.test(line)) { - const items: Inline[][] = []; - while (index < lines.length && /^[-*] /.test(lines[index])) { - items.push(noteInlines(lines[index].slice(2))); + const marker = /^\s*([-*]|\d{1,3}\.) /; + if (marker.test(line)) { + // Items may continue on indented lines, and nested items are flattened into the list. + const ordered = /^\s*\d/.test(line); + const items: string[] = []; + while (index < lines.length) { + const current = lines[index]; + if (marker.test(current)) + items.push(current.replace(marker, "").trim()); + else if (current.trim() && /^\s/.test(current) && items.length) + items[items.length - 1] += ` ${current.trim()}`; + else break; index += 1; } - blocks.push({ type: "list", items }); + blocks.push({ type: "list", ordered, items: items.map(noteInlines) }); continue; } const paragraph: string[] = []; @@ -95,7 +103,7 @@ export function releaseNoteBlocks(source: string): NoteBlock[] { lines[index].trim() && !lines[index].startsWith("```") && !/^#{1,3} /.test(lines[index]) && - !/^[-*] /.test(lines[index]) + !/^\s*([-*]|\d{1,3}\.) /.test(lines[index]) ) { paragraph.push(lines[index].trim()); index += 1; diff --git a/apps/web/src/styles.css b/apps/web/src/styles.css index da3ae78d..b37d5d7b 100644 --- a/apps/web/src/styles.css +++ b/apps/web/src/styles.css @@ -4315,17 +4315,37 @@ img.detail-cover { margin: 8px 0; line-height: 1.55; } -.application-release-history .release-notes h3, +.application-release-history h2, +.application-release-history h3, .application-release-history .release-notes h4, .application-release-history .release-notes h5 { - margin: 16px 0 6px; + font-weight: 650; +} +.application-release-history .release-notes h3 { + margin: 20px 0 6px; + font-size: 17px; +} +.application-release-history .release-notes h4 { + margin: 18px 0 4px; font-size: 15px; } -.application-release-history .release-notes ul { +.application-release-history .release-notes h5 { + margin: 14px 0 4px; + font-size: 14px; +} +.application-release-history .release-notes ul, +.application-release-history .release-notes ol { margin: 0; - padding-left: 1.2rem; + padding-left: 1.4rem; list-style: disc; } +.application-release-history .release-notes ol { + list-style: decimal; +} +.application-release-history .release-notes li { + margin: 4px 0; + padding-left: 2px; +} .application-release-history .release-notes pre { overflow: auto; margin: 8px 0; diff --git a/apps/web/tests/ui/release-notes-layout.spec.ts b/apps/web/tests/ui/release-notes-layout.spec.ts new file mode 100644 index 00000000..e266d099 --- /dev/null +++ b/apps/web/tests/ui/release-notes-layout.spec.ts @@ -0,0 +1,88 @@ +import { expect, test } from "../fixtures"; + +test("release notes keep numbered lists and wrapped items, without a repeated title", async ({ + page, +}) => { + await page.route("**/api/**", (route) => { + const path = new URL(route.request().url()).pathname; + let data: unknown = []; + if (path === "/api/auth/me") + data = { + user: { + id: "reader", + role: "member", + display_name: "Reader", + permissions: [], + access_label: "Member", + onboarding_status: "complete", + }, + csrf_token: "test", + }; + if (path === "/api/setup/onboarding") data = { status: "completed" }; + if (path === "/api/application/release") + data = { + installed_version: "v1.9.0", + installed_url: "https://github.com/example/books/releases/tag/v1.9.0", + latest_version: "v1.9.0", + release_url: "https://github.com/example/books/releases/tag/v1.9.0", + update_available: false, + status: "checked", + }; + if (path === "/api/application/releases") + data = { + installed_version: "v1.9.0", + status: "checked", + releases: [ + { + version: "v1.9.0", + name: "Dewarr v1.9.0", + notes: [ + "# Dewarr v1.9.0", + "", + "## Features", + "", + "- Reading lists for each follow, with a", + " progress bar.", + "", + "## Upgrading", + "", + "1. Back up the database.", + "2. Pull the new image.", + ].join("\n"), + url: "https://github.com/example/books/releases/tag/v1.9.0", + published_at: "2026-09-21T13:58:30Z", + prerelease: false, + }, + ], + }; + if ( + new URL(route.request().url()).pathname.includes( + "/acquisition/preferences/", + ) + ) + data = { effective: { desired_media: "both" } }; + return route.fulfill({ json: data }); + }); + await page.goto("/settings"); + await page + .getByRole("group", { name: "Application version" }) + .getByRole("button", { name: "v1.9.0", exact: true }) + .click(); + const dialog = page.getByRole("dialog", { name: "Release notes" }); + await expect( + dialog.getByRole("heading", { name: "Dewarr v1.9.0" }), + ).toHaveCount(1); + await expect(dialog.locator(".release-notes ul > li")).toHaveText([ + "Reading lists for each follow, with a progress bar.", + ]); + const numbered = dialog.locator(".release-notes ol"); + await expect(numbered.getByRole("listitem")).toHaveText([ + "Back up the database.", + "Pull the new image.", + ]); + await expect(numbered).toHaveCSS("list-style-type", "decimal"); + await expect(dialog.getByRole("heading", { name: "Features" })).toHaveCSS( + "font-weight", + "650", + ); +});