TypeScript
feat(release): update notes lead with up to 7 highlights (#28593)
Theo Browne460b88bc425f
diff --git a/apps/desktop/src/updates/releaseNotes.test.ts b/apps/desktop/src/updates/releaseNotes.test.tsindex 30db8274c20..6f05b1e9e94 100644--- a/apps/desktop/src/updates/releaseNotes.test.ts+++ b/apps/desktop/src/updates/releaseNotes.test.ts@@ -92,6 +92,26 @@ describe("normalizeDesktopUpdateReleaseNotes", () => {]);});+ it.each([+ "**v1.2.4** · 3 changes from 2 contributors\n- **One-time tasks.** Pick a date.\n\n### Plus 2 more bug fixes and performance improvements.",+ "<p><strong>v1.2.4</strong> · 3 changes from 2 contributors</p><ul><li><strong>One-time tasks.</strong> Pick a date.</li></ul><h3>Plus 2 more bug fixes and performance improvements.</h3>",+ ])("keeps highlight labels and the remaining change count from the feed", (summary) => {+ const { releaseNotes } = normalizeDesktopUpdateReleaseNotes(+ summary + "\n<details><summary>Full changelog</summary>raw list</details>",+ "1.2.4",+ "latest",+ );+ expect(releaseNotes).toEqual([+ {+ version: "1.2.4",+ stats: "3 changes from 2 contributors",+ items: ["**One-time tasks.** Pick a date."],+ totalItems: 1,+ footer: "Plus 2 more bug fixes and performance improvements.",+ },+ ]);+ });+it("does not count Markdown or HTML section headings as changes", () => {const changes = Array.from({ length: 8 }, (_, index) => `Change ${index + 1}`);const result = normalizeDesktopUpdateReleaseNotes(diff --git a/apps/desktop/src/updates/releaseNotes.ts b/apps/desktop/src/updates/releaseNotes.tsindex 1fb81088175..a3198982220 100644--- a/apps/desktop/src/updates/releaseNotes.ts+++ b/apps/desktop/src/updates/releaseNotes.ts@@ -54,17 +54,18 @@ function decodeHtmlEntities(input: string): string {);}-function stripMarkup(input: string): string {- return decodeHtmlEntities(+function stripMarkup(input: string, keepBold = false): string {+ const markdown = decodeHtmlEntities(input.replace(/<br\s*\/?>/gi, "\n").replace(/<li\b[^>]*>/gi, "\n- ").replace(/<h([1-6])\b[^>]*>/gi, (_, level: string) => `\n${"#".repeat(Number(level))} `).replace(/<\/(?:p|div|li|h[1-6]|ul|ol|blockquote)>/gi, "\n")+ .replace(/<\/?(?:strong|b)\b[^>]*>/gi, "**").replace(/<[^>]*>/g, "")- .replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")- .replace(/\*\*([^*]+)\*\*/g, "$1"),+ .replace(/\[([^\]]+)\]\([^)]+\)/g, "$1"),);+ return keepBold ? markdown : markdown.replace(/\*\*([^*]+)\*\*/g, "$1");}function truncateReleaseNoteItem(item: string): string {@@ -92,40 +93,42 @@ function isIgnoredReleaseNoteLine(line: string): boolean {);}-interface ExtractedReleaseNoteItems {- readonly items: ReadonlyArray<string>;- readonly totalItems: number;- readonly intro?: string;- readonly stats?: string;-}+type ExtractedReleaseNoteItems = Omit<DesktopUpdateReleaseNote, "version" | "releasedAt">;-/**- * Reads a generated summary (`scripts/generate-release-notes.ts`): a `v1.2.3 · N changes…`- * header, a highlights paragraph, and fix bullets. PR numbers are left to the GitHub page.- */+/** Older generated notes have a highlights paragraph followed by a separate list of fixes. */function extractReleaseNoteSummary(summary: string): ExtractedReleaseNoteItems {let stats: string | undefined;+ let footer: string | undefined;const intro: string[] = [];const items: string[] = [];- for (const rawLine of stripMarkup(summary).split("\n")) {- const line = rawLine.trim().replace(/\s+/g, " ");- if (line === "" || /^#{1,6}\s+/.test(line)) continue;- if (stats === undefined && /^v\S+ · /.test(line)) {- stats = line.slice(line.indexOf(" · ") + 3);- continue;- }- const text = line- .replace(/^[-*]\s+/, "")+ for (const rawLine of stripMarkup(summary, true).split("\n")) {+ const line = rawLine+ .trim()+ .replace(/\s+/g, " ").replace(/\s*\((?:#\d+(?:,\s*)?)+\)\.?$/, "").trim();- if (/^[-*]\s+/.test(line)) items.push(text);- else intro.push(text);+ const plain = line.replace(/\*\*([^*]+)\*\*/g, "$1");+ if (/^### Plus \d+ more /.test(plain)) {+ footer = plain.slice(4);+ continue;+ }+ if (plain === "" || /^#{1,6}\s+/.test(plain)) continue;+ if (stats === undefined && /^v\S+ · /.test(plain)) {+ stats = plain.slice(plain.indexOf(" · ") + 3);+ continue;+ }+ if (/^[-*]\s+/.test(line)) {+ items.push(line.replace(/^[-*]\s+/, ""));+ } else {+ intro.push(plain);+ }}return {items,totalItems: items.length + intro.length,...(intro.length > 0 ? { intro: intro.join(" ") } : {}),...(stats ? { stats } : {}),+ ...(footer ? { footer } : {}),};}@@ -184,16 +187,13 @@ export function normalizeDesktopUpdateReleaseNotes().filter((entry) => desktopUpdateChannelOf(entry.version) === channel);const normalizedNotes = rawNotes.flatMap((entry) => {- const { items, totalItems, intro, stats } = extractReleaseNoteItems(entry.note);- if (totalItems === 0) return [];+ const note = extractReleaseNoteItems(entry.note);+ if (note.totalItems === 0 && !note.stats) return [];const releasedAt = resolveReleasedAt(entry.version, fallbackVersion, releaseDate);return [{version: entry.version,- items,- totalItems,- ...(intro ? { intro } : {}),- ...(stats ? { stats } : {}),+ ...note,...(releasedAt ? { releasedAt } : {}),},];diff --git a/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx b/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsxindex 18ebd70c616..03bb2c72849 100644--- a/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx+++ b/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx@@ -100,8 +100,19 @@ describe("SidebarUpdatePill release notes", () => {await userEvent.tab();expect(releaseNotes()).toBeNull();- await publish(nightlyUpdate(RELEASE_NOTES));- await vi.waitFor(() => expect(releaseNotes()).not.toBeNull());+ await publish(+ nightlyUpdate([+ {+ version: "0.0.50-nightly.2",+ items: ["**One-time tasks.** Pick a date."],+ totalItems: 1,+ stats: "3 changes from 2 contributors",+ footer: "Plus 2 more bug fixes.",+ },+ ]),+ );+ await expect.element(page.getByText("One-time tasks.", { exact: true })).toBeVisible();+ await expect.element(page.getByText("Plus 2 more bug fixes.")).toBeVisible();});});diff --git a/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx b/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsxindex 974f81c8d76..34c4403a20e 100644--- a/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx+++ b/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx@@ -101,48 +101,53 @@ export function SidebarUpdateReleaseNotes({? "View release on GitHub": `${omittedItemCount} more ${omittedItemCount === 1 ? "change" : "changes"} on GitHub`);- if (releaseNote.intro !== undefined) {- return (- <section className={index > 0 ? "mt-4" : undefined} key={releaseNote.version}>- {releaseNote.version !== state.availableVersion ? (+ const generated = releaseNote.stats !== undefined || releaseNote.intro !== undefined;+ return (+ <section className={index > 0 ? "mt-4" : undefined} key={releaseNote.version}>+ {generated ? (+ releaseNote.version !== state.availableVersion && (<h3 className="mb-1 text-xs leading-4 font-medium text-muted-foreground">{releaseNote.releasedAt? `${releaseNote.version} · ${formatReleaseAge(releaseNote.releasedAt)}`: releaseNote.version}</h3>- ) : null}+ )+ ) : (+ <h3 className="mb-2 text-foreground text-xs leading-4 font-semibold">+ {index === 0 ? "What's changed" : `Changes in ${releaseNote.version}`}+ </h3>+ )}+ {releaseNote.intro ? (<p className="break-words text-xs leading-5 text-popover-foreground">{releaseNote.intro}</p>- {releaseUrl ? (- <ReleaseLink releaseUrl={releaseUrl} shell={shell}>- {releaseNote.stats ?? "View release on GitHub"}- </ReleaseLink>- ) : null}- </section>- );- }-- return (- <div className={index > 0 ? "mt-4" : undefined} key={releaseNote.version}>- <section>- <h3 className="text-foreground text-xs leading-4 font-semibold">- {index === 0 ? "What's changed" : `Changes in ${releaseNote.version}`}- </h3>- <ul className="mt-2 space-y-1.5 pl-4 text-xs leading-5 text-popover-foreground/90">- {keyReleaseNoteItems(releaseNote.items).map(({ item, key }) => (- <li className="list-disc break-words" key={key}>- {item}- </li>- ))}+ ) : releaseNote.items.length > 0 ? (+ <ul className="space-y-1.5 pl-4 text-xs leading-5 text-popover-foreground/90">+ {keyReleaseNoteItems(releaseNote.items).map(({ item, key }) => {+ const highlight = /^\*\*([^*]+)\*\* (.+)$/.exec(item);+ return (+ <li className="list-disc break-words" key={key}>+ {highlight ? (+ <>+ <strong>{highlight[1]}</strong> {highlight[2]}+ </>+ ) : (+ item+ )}+ </li>+ );+ })}</ul>- {releaseUrl ? (- <ReleaseLink releaseUrl={releaseUrl} shell={shell}>- {linkLabel}- </ReleaseLink>- ) : null}- </section>- </div>+ ) : null}+ {releaseNote.footer && (+ <p className="mt-2 text-xs leading-5 font-semibold">{releaseNote.footer}</p>+ )}+ {releaseUrl && (+ <ReleaseLink releaseUrl={releaseUrl} shell={shell}>+ {linkLabel}+ </ReleaseLink>+ )}+ </section>);})}{state.omittedReleaseCount > 0 ? (diff --git a/docs/operations/release.md b/docs/operations/release.mdindex 18daadc5f27..29b9a2b9bfb 100644--- a/docs/operations/release.md+++ b/docs/operations/release.md@@ -42,7 +42,7 @@ the version.- Only plain stable `X.Y.Z` releases are marked as the repository's latest release.- Nightly runs are always GitHub prereleases and never marked latest.- Automatically generated release notes are pinned to the previous tag in the same channel, so stable compares to the previous stable tag and nightly compares to the previous nightly tag.- - The release job's **Write release notes** step (`scripts/generate-release-notes.ts`) builds the body: a computed header line, a short summary from `gpt-6.1-terra`, and GitHub's generated list folded under `<details>`. It needs the `OPENAI_API_KEY` secret. The summary leaves out commits whose scopes are all mobile; the header counts every commit. The desktop update popover, on every channel, shows the highlights paragraph and the header counts as a short note per release, with the offered release's age from the update feed's `releaseDate`. The nightly Discord post shows the part above `<details>`. If the step fails or there is nothing to summarize, it writes no file and the release uses GitHub's generated notes as before.+ - The release job's **Write release notes** step (`scripts/generate-release-notes.ts`) builds the body: a computed header line, a short summary from `gpt-6.1-terra`, and GitHub's generated list folded under `<details>`. It needs the `OPENAI_API_KEY` secret. The desktop update popover shows up to seven highlights and the number of other fixes and performance improvements. Mobile-only commits count toward release totals but cannot be highlights. The offered release's age comes from the update feed's `releaseDate`. The nightly Discord post shows the part above `<details>`. If summary generation fails, the release uses GitHub's generated notes.- Includes Electron auto-update metadata (for example `latest*.yml`, `nightly*.yml`, and `*.blockmap`) in release assets.- Builds a self-contained CLI archive per platform (`t3-<version>-<platform>-<arch>.tar.gz`, `.zip` on Windows) in the same job as that target's desktop artifact and attaches them to the GitHub Release with a `SHA256SUMS` file, on every channel, for five targets: macOS arm64, Linux x64 and arm64, Windows x64 and arm64. Every archive is smoke-tested on hardware of its own architecture, and every one but the Windows archives is also built and signed there. There is no macOS x64 archive: Node single-executables are unsupported on x64 macOS (the SEA docs list macOS as arm64 only) and the binary segfaults on start; the x64 desktop app is Electron and unaffected.- The archive holds the server as a Node single-executable (`scripts/build-cli-archive.ts`), so unpacking it needs neither Node, npm, nor a compiler. It is the only form in which T3 Code manages a runtime: the desktop's SSH environments, the boot service, `t3 update`, and the install scripts all download and verify this archive against `SHA256SUMS`. The `t3` npm package exists for people who run `npx t3` or `npm install -g t3` themselves, and it downloads this same archive too; nothing in the product installs from npm. The `curl | sh` installers are `scripts/install.sh` and `scripts/install.ps1`; the marketing site copies them into its `public/` at build time (`apps/marketing/scripts/stage-install-scripts.mjs`) and serves them at `t3.codes/install.sh` and `/install.ps1`.diff --git a/packages/contracts/src/ipc.ts b/packages/contracts/src/ipc.tsindex f14452fec5a..0466f245844 100644--- a/packages/contracts/src/ipc.ts+++ b/packages/contracts/src/ipc.ts@@ -290,10 +290,11 @@ export interface DesktopUpdateReleaseNote {totalItems: number;/** ISO time from the update feed for the offered version, else `YYYY-MM-DD` from a prerelease version. */releasedAt?: string;- /** Generated summaries only: the highlights paragraph. `items` then holds the fixes. */+ /** Paragraph-style summaries from older releases keep their fixes in `items`. */intro?: string;/** Generated summaries only, for example "275 changes from 22 contributors". */stats?: string;+ footer?: string;}export const DesktopUpdateReleaseNoteSchema = Schema.Struct({@@ -303,6 +304,7 @@ export const DesktopUpdateReleaseNoteSchema = Schema.Struct({releasedAt: Schema.optionalKey(Schema.String),intro: Schema.optionalKey(Schema.String),stats: Schema.optionalKey(Schema.String),+ footer: Schema.optionalKey(Schema.String),});export const DesktopUpdateStateSchema = Schema.Struct({diff --git a/scripts/generate-release-notes.test.ts b/scripts/generate-release-notes.test.tsindex 0c55b082dcf..7dbe4bf60ba 100644--- a/scripts/generate-release-notes.test.ts+++ b/scripts/generate-release-notes.test.ts@@ -4,8 +4,9 @@ import * as Option from "effect/Option";import {countContributors,+ formatReleaseSummary,isReleaseNoteCommit,- summaryText,+ readReleaseHighlights,type PullRequest,} from "./generate-release-notes.ts";@@ -53,13 +54,54 @@ it("leaves mobile-only scopes out and keeps shared ones", () => {}});-it("uses model text only from a completed response", () => {+it("reads highlights only from a completed JSON response", () => {const output = [- { type: "message", content: [{ type: "output_text", text: " ## Highlights\nX " }] },+ { type: "message", content: [{ type: "output_text", text: ' {"highlights":[]} ' }] },];+ assert.deepStrictEqual(readReleaseHighlights({ status: "completed", output }), Option.some([]));+ assert.deepStrictEqual(readReleaseHighlights({ status: "incomplete", output }), Option.none());+});++it("counts fixes and performance changes once, outside the selected highlights", () => {+ const commits = [+ "feat: schedule a task once",+ "fix: use the selected time",+ "perf(server): read less history",+ "fix(mobile): restore the chat position",+ "docs: update instructions",+ ].map((subject) => ({ subject, authorName: "" }));+ const selected = [+ { label: "One-time tasks", detail: "Schedule a task for a specific time.", commits: [1, 2] },+ ] as const;+ assert.deepStrictEqual(+ formatReleaseSummary(commits, selected),+ Option.some(+ "- **One-time tasks.** Schedule a task for a specific time.\n\n### Plus 2 more bug fixes and performance improvements.",+ ),+ );assert.deepStrictEqual(- summaryText({ status: "completed", output }),- Option.some("## Highlights\nX"),+ formatReleaseSummary(commits.slice(0, 2), selected),+ Option.some("- **One-time tasks.** Schedule a task for a specific time."),);- assert.deepStrictEqual(summaryText({ status: "incomplete", output }), Option.none());+ assert.deepStrictEqual(formatReleaseSummary(commits.slice(2), selected), Option.none());+ assert.deepStrictEqual(+ formatReleaseSummary(commits, []),+ Option.some("**3 bug fixes and performance improvements.**"),+ );+ assert.deepStrictEqual(formatReleaseSummary(commits.slice(-1), []), Option.some(""));+});++it("counts fixes beyond the seven displayed highlights in the footer", () => {+ const commits = Array.from({ length: 8 }, (_, i) => ({+ subject: `fix: change ${i + 1}`,+ authorName: "",+ }));+ const highlights = commits.map((_, i) => ({+ label: `Fix ${i + 1}`,+ detail: "A fix.",+ commits: [i + 1] as const,+ }));+ const summary = Option.getOrThrow(formatReleaseSummary(commits, highlights));+ assert.lengthOf(summary.match(/^- /gm) ?? [], 7);+ assert.include(summary, "Plus 1 more bug fix.");});diff --git a/scripts/generate-release-notes.ts b/scripts/generate-release-notes.tsindex 909247dae12..b9d1121a661 100644--- a/scripts/generate-release-notes.ts+++ b/scripts/generate-release-notes.ts@@ -20,38 +20,15 @@ const PULL_REQUEST_NUMBER = /\(#(\d+)\)$/;const PULL_REQUEST_BODY_LIMIT = 300;const SUMMARY_MODEL = "gpt-6.1-terra";-const SUMMARY_INSTRUCTIONS = `You write release notes for T3 Code, a GUI for coding agents (web and desktop apps backed by a server; providers like Codex, Claude, Cursor, OpenCode).+const SUMMARY_INSTRUCTIONS = `Write up to 7 bullet points for the T3 Code update popover. Cover web, desktop, and server. Mobile has its own release notes.-These notes cover the web app, desktop app, and server only. The mobile app has its own release notes, so leave out anything only about mobile, iOS, or Android.+Give a feature a bullet only when it lets users do something they could not do before, removes a real limitation they hit in normal use, or cuts meaningful steps or wait time from a common task. Judge the outcome, regardless of the commit prefix. A new setting, a large diff, or support for one more edge case is not enough.-You get the commit subjects merged since the last release, oldest first. Most end with a PR number like (#1234). Each commit shows lines added and removed and files changed, then a trimmed PR description on the next line starting with ">". Use the descriptions to understand what changed for users and why it matters. Line counts hint at size, but a small change can still matter most.+Lead with new capabilities. Give a bug fix its own bullet only when the source shows lost work or a core workflow that users could not complete in normal use. Leave isolated failures, cosmetic polish, and routine fixes in the count. Skip internal work, docs, tests, and dependency bumps. Group commits only when they deliver the same user outcome. Seven is a ceiling. Stop when the qualifying changes run out, even if that leaves zero bullets.-Output Markdown in exactly this shape and nothing else:+Each bullet has a short feature name and one sentence of at most 20 words. Say what the user can do or what now works. Use product names people see in the app and leave out protocol or implementation details. Describe the shipped behavior at the end of the range. Mark user-accessible Labs or beta features "(beta)". Skip dev-only features. No title, headings, introduction, example prompts, hype, PR numbers, or em dashes.-## Highlights-Up to 4 short sentences. Name only the new features a user would care about most. If no new feature matters to users, write one sentence about the most important fix. Each feature gets a few words that make the benefit clear, not a description of how it works or where the button is.--## Fixes-- Up to 10 bullets, one fix each, under 10 words, ending with the PR number like (#123). Fewer is fine. Never pad.-- Each bullet names what was broken and says it works now. A user who hit the bug should recognize it.-- Only list fixes from fix commits. New abilities go in Highlights or nowhere. Say "again" only if the commit says it.--How to write:-- Pick only significant, user-facing changes. Leave out visual polish (focus rings, spacing, colors), layout tweaks, refactors, tests, CI, build, docs, deps, internal tooling, and performance or efficiency work a user would not feel.-- Include Labs and beta features, with "(beta)" after the feature. Leave out work marked internal testing or dev-only.-- Describe each feature as it is at the end of the range. If a beta feature became standard later in the range, it is not beta.-- Say what the user gets, as short as possible. Cut details, conditions, and mechanics.-- No defaults or rollout state ("on by default", "now available", "behind a flag").-- For lists of file types or formats, use common extensions: "previews for .docx, .ttf, .sqlite, .zip and more".-- No internal names, env vars, file paths, or code terms.-- No em dashes. No hype words. Do not invent anything that is not in the input.--Examples of the tone:-- Bad: "Cmd+K now finds the right thread first, and it searches message text too." Good: "Much better Cmd+K search."-- Bad: "You can share a thread with a guest who watches it live and sends messages that you approve." Good: "Share threads with guests, safely."-- Bad: "Triage issues from the command palette." Good: "Fix and debug T3 Code itself with a new 'triage' command."-- Bad: "Settings and Usage open as large modals over your thread." Good: leave it out.-- Bad: "Cmd/Ctrl+W closes tabs safely (#25860)" Good: "Cmd/Ctrl+W no longer closes the whole window (#25860)"`;+Return JSON with a "highlights" array. For each highlight, give "label" (plain text, no final period), "detail" (one sentence), and "commits" (the bracketed input numbers of all commits it covers). Use the subjects and PR descriptions as source material. The release script adds the formatting, count of remaining fixes and performance improvements, and contributor credit.`;class EmptyReleaseRangeError extends Schema.TaggedError<EmptyReleaseRangeError>()("EmptyReleaseRangeError",@@ -101,6 +78,49 @@ const SummaryResponse = Schema.Struct({),});+const ReleaseHighlights = Schema.Struct({+ highlights: Schema.Array(+ Schema.Struct({+ label: Schema.NonEmptyString,+ detail: Schema.NonEmptyString,+ commits: Schema.NonEmptyArray(Schema.Int),+ }),+ ),+});+const decodeHighlights = Schema.decodeUnknownOption(Schema.fromJsonString(ReleaseHighlights));++export function formatReleaseSummary(+ commits: ReadonlyArray<ReleaseCommit>,+ selected: (typeof ReleaseHighlights.Type)["highlights"],+): Option.Option<string> {+ const highlights = selected.slice(0, 7);+ const covered = new Set(highlights.flatMap((highlight) => highlight.commits));+ for (const id of covered) {+ const commit = commits[id - 1];+ if (!commit || !isReleaseNoteCommit(commit)) return Option.none();+ }+ const bullets = highlights.map(+ ({ label, detail }) => `- **${label.replace(/\.$/, "")}.** ${detail}`,+ );+ const remaining = commits.flatMap(({ subject }, index) => {+ if (covered.has(index + 1)) return [];+ return /^(fix|perf)(?:\([^)]*\))?!?:/i.exec(subject)?.[1]?.toLowerCase() ?? [];+ });+ if (remaining.length === 0) return Option.some(bullets.join("\n"));++ const count = remaining.length;+ let kind = "bug fixes and performance improvements";+ if (!remaining.includes("perf")) kind = count === 1 ? "bug fix" : "bug fixes";+ if (!remaining.includes("fix"))+ kind = count === 1 ? "performance improvement" : "performance improvements";+ // Older popovers skip headings. A footer paragraph would hide the bullets on those clients.+ return Option.some(+ bullets.length+ ? `${bullets.join("\n")}\n\n### Plus ${count} more ${kind}.`+ : `**${count} ${kind}.**`,+ );+}+const pullRequestNumber = (subject: string) => {const match = PULL_REQUEST_NUMBER.exec(subject);return match ? Number(match[1]) : undefined;@@ -129,11 +149,14 @@ function buildSummaryInput(pullRequests: ReadonlyMap<number, PullRequest>,): string {return commits- .flatMap(({ subject }) => {+ .flatMap((commit, index) => {+ if (!isReleaseNoteCommit(commit)) return [];+ const { subject } = commit;+ const source = `[${index + 1}] ${subject}`;const number = pullRequestNumber(subject);const pullRequest = number === undefined ? undefined : pullRequests.get(number);- if (!pullRequest) return [subject];- const line = `${subject} [+${pullRequest.additions} -${pullRequest.deletions}, ${pullRequest.changedFiles} files]`;+ if (!pullRequest) return [source];+ const line = `${source} [+${pullRequest.additions} -${pullRequest.deletions}, ${pullRequest.changedFiles} files]`;const body = trimPullRequestBody(pullRequest.body);return body ? [line, ` > ${body}`] : [line];})@@ -175,7 +198,8 @@ function buildReleaseHeader(version: string, changes: number, contributors: numb/** The summary leads; GitHub's full list folds under it. Clients cut the body at `<details>`. */function assembleReleaseNotes(header: string, summary: string, fullChangelog: string): string {- return `${header}\n\n${summary.trim()}\n\n<details>\n<summary>Full changelog</summary>\n\n${fullChangelog.trim()}\n\n</details>\n`;+ const folded = `<details>\n<summary>Full changelog</summary>\n\n${fullChangelog.trim()}\n\n</details>\n`;+ return [header, summary, folded].filter(Boolean).join("\n\n");}const run = Effect.fn("generateReleaseNotes.run")(function* (@@ -261,7 +285,7 @@ const readFullChangelog = Effect.fn("generateReleaseNotes.readFullChangelog")(fureturn (yield* decodeJson(GeneratedNotes)(response)).body;});-export function summaryText(response: typeof SummaryResponse.Type): Option.Option<string> {+export function readReleaseHighlights(response: typeof SummaryResponse.Type) {// An incomplete response can carry partial text; publishing it would cut the notes short.if (response.status !== "completed") return Option.none();const text = response.output@@ -269,7 +293,7 @@ export function summaryText(response: typeof SummaryResponse.Type): Option.Optio.flatMap((part) => (part.type === "output_text" && part.text ? [part.text] : [])).join("").trim();- return text === "" ? Option.none() : Option.some(text);+ return Option.map(decodeHighlights(text), ({ highlights }) => highlights);}const summarize = Effect.fn("generateReleaseNotes.summarize")(function* (input: string) {@@ -281,7 +305,8 @@ const summarize = Effect.fn("generateReleaseNotes.summarize")(function* (input:model: SUMMARY_MODEL,reasoning: { effort: "low" },instructions: SUMMARY_INSTRUCTIONS,- input: `Commits:\n${input}`,+ text: { format: { type: "json_object" } },+ input: `Choose highlights as JSON from these commits:\n${input}`,}),Effect.flatMap(httpClient.execute),Effect.flatMap(HttpClientResponse.filterStatusOk),@@ -296,7 +321,7 @@ const summarize = Effect.fn("generateReleaseNotes.summarize")(function* (input:outputTokens: response.usage?.output_tokens,}),);- return summaryText(response);+ return readReleaseHighlights(response);});const command = Command.make(@@ -311,13 +336,11 @@ const command = Command.make(},({ repository, tag, ref, previousTag, version, output }) =>Effect.gen(function* () {- // The header counts every commit in the range; the summary skips mobile-only work.const allCommits = yield* readCommits(previousTag, ref);// The spawner ignores exit codes, so a failed git log shows up as an empty range.if (allCommits.length === 0) {return yield* new EmptyReleaseRangeError({ range: `${previousTag}..${ref}` });}- const commits = allCommits.filter(isReleaseNoteCommit);const numbers = [...new Set(allCommits.flatMap(({ subject }) => pullRequestNumber(subject) ?? [])),];@@ -333,11 +356,11 @@ const command = Command.make(allCommits.length,countContributors(allCommits, pullRequests),);- // With no summary, write nothing: the release falls back to GitHub's generated notes.- const summary =- commits.length === 0- ? Option.none<string>()- : yield* summarize(buildSummaryInput(commits, pullRequests));+ const input = buildSummaryInput(allCommits, pullRequests);+ const selected = input === "" ? Option.some([]) : yield* summarize(input);+ const summary = Option.flatMap(selected, (highlights) =>+ formatReleaseSummary(allCommits, highlights),+ );if (Option.isNone(summary)) {return yield* Effect.logWarning("no release summary, leaving GitHub's notes in place");}@@ -349,7 +372,7 @@ const command = Command.make();yield* fs.rename(`${output}.tmp`, output);yield* Effect.logInfo("release notes written").pipe(- Effect.annotateLogs({ output, commits: commits.length }),+ Effect.annotateLogs({ output, commits: allCommits.length }),);}),).pipe(