Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions apps/web/src/components/ApplicationRelease.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ function NoteBlockView({ block }: { block: NoteBlock }) {
const Tag = block.level === 1 ? "h3" : block.level === 2 ? "h4" : "h5";
return <Tag>{renderInlines(block.inlines)}</Tag>;
}
if (block.type === "list")
if (block.type === "list") {
const List = block.ordered ? "ol" : "ul";
return (
<ul>
<List>
{block.items.map((item, index) => (
<li key={index}>{renderInlines(item)}</li>
))}
</ul>
</List>
);
}
if (block.type === "code")
return (
<pre>
Expand All @@ -51,8 +53,20 @@ function NoteBlockView({ block }: { block: NoteBlock }) {
return <p>{renderInlines(block.inlines)}</p>;
}

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 <p className="muted">No notes for this release.</p>;
return (
Expand Down Expand Up @@ -86,7 +100,7 @@ function ReleaseEntry({
<span className="available-tag">Available</span>
)}
</p>
<ReleaseNotes source={release.notes} />
<ReleaseNotes source={release.notes} title={release.name} />
<a href={release.url} target="_blank" rel="noreferrer">
View on GitHub
</a>
Expand Down
48 changes: 48 additions & 0 deletions apps/web/src/components/releaseNotes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }],
[
Expand All @@ -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." }],
});
});
22 changes: 15 additions & 7 deletions apps/web/src/components/releaseNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})\)/;
Expand Down Expand Up @@ -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[] = [];
Expand All @@ -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;
Expand Down
28 changes: 24 additions & 4 deletions apps/web/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
88 changes: 88 additions & 0 deletions apps/web/tests/ui/release-notes-layout.spec.ts
Original file line number Diff line number Diff line change
@@ -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",
);
});