Skip to content
TypeScript

feat(release): release notes and the update popover open with a short note (#26893)

Theo Browneb5fc7bedfe5c
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e8f300242f0..e9c731cf6fa 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -762,11 +762,16 @@ jobs:
timeout-minutes: 30
permissions:
contents: write
+ # Release notes read PR bodies and authors.
+ pull-requests: read
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.preflight.outputs.ref }}
+ # Release notes need history back to the previous tag, not file contents.
+ fetch-depth: 0
+ filter: blob:none
sparse-checkout: |
/*
!/.repos/
@@ -892,6 +897,27 @@ jobs:
echo 'EOF'
} >> "$GITHUB_OUTPUT"
+ # A short model summary over GitHub's full list. Without a notes file, the
+ # release falls back to GitHub's generated notes.
+ - name: Write release notes
+ if: needs.preflight.outputs.release_channel != 'preview' && needs.preflight.outputs.previous_tag != ''
+ continue-on-error: true
+ timeout-minutes: 5
+ env:
+ GH_TOKEN: ${{ github.token }}
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
+ run: |
+ node scripts/generate-release-notes.ts \
+ --repository "${{ github.repository }}" \
+ --tag "${{ needs.preflight.outputs.tag }}" \
+ --ref "${{ needs.preflight.outputs.ref }}" \
+ --previous-tag "${{ needs.preflight.outputs.previous_tag }}" \
+ --version "${{ needs.preflight.outputs.version }}" \
+ --output release-notes.md
+ if [[ -f release-notes.md ]]; then
+ cat release-notes.md >> "$GITHUB_STEP_SUMMARY"
+ fi
+
# A preview release gets a warning instead of generated notes. Generated
# notes would list every commit since the previous preview, which is
# unmerged branch history no one should read as a changelog, and would
@@ -917,8 +943,8 @@ jobs:
tag_name: ${{ needs.preflight.outputs.tag }}
target_commitish: ${{ needs.preflight.outputs.ref }}
name: ${{ needs.preflight.outputs.release_name }}
- generate_release_notes: ${{ needs.preflight.outputs.release_channel != 'preview' }}
- body_path: ${{ needs.preflight.outputs.release_channel == 'preview' && 'release-notes.md' || '' }}
+ generate_release_notes: ${{ hashFiles('release-notes.md') == '' }}
+ body_path: ${{ hashFiles('release-notes.md') != '' && 'release-notes.md' || '' }}
previous_tag: ${{ needs.preflight.outputs.previous_tag }}
prerelease: ${{ needs.preflight.outputs.is_prerelease }}
make_latest: ${{ needs.preflight.outputs.make_latest }}
diff --git a/apps/desktop/src/updates/DesktopUpdates.ts b/apps/desktop/src/updates/DesktopUpdates.ts
index 4da742f453a..3a0b41cd9e3 100644
--- a/apps/desktop/src/updates/DesktopUpdates.ts
+++ b/apps/desktop/src/updates/DesktopUpdates.ts
@@ -70,6 +70,7 @@ const UpdateInfo = Schema.Struct({
version: Schema.String,
// Malformed notes must not block update-state decoding; normalizeDesktopUpdateReleaseNotes validates separately.
releaseNotes: Schema.optional(Schema.Unknown),
+ releaseDate: Schema.optional(Schema.String),
});
const DownloadProgressInfo = Schema.Struct({
@@ -895,6 +896,7 @@ export const make = Effect.gen(function* () {
info.releaseNotes,
info.version,
state.channel,
+ info.releaseDate,
);
yield* setState(
reduceDesktopUpdateStateOnUpdateAvailable(
diff --git a/apps/desktop/src/updates/releaseNotes.test.ts b/apps/desktop/src/updates/releaseNotes.test.ts
index 028e42fa6e3..d88838439db 100644
--- a/apps/desktop/src/updates/releaseNotes.test.ts
+++ b/apps/desktop/src/updates/releaseNotes.test.ts
@@ -28,6 +28,7 @@ describe("normalizeDesktopUpdateReleaseNotes", () => {
releaseNotes: [
{
version: "0.0.36-nightly.20260828.1213",
+ releasedAt: "2026-08-28",
items: [
"fix(opencode): handle child approvals, stops, and model catalogs by @human in #8480",
"fix(web): keep long task drawers usable on small screens by @human in #8313",
@@ -60,6 +61,37 @@ describe("normalizeDesktopUpdateReleaseNotes", () => {
});
});
+ it("reads a generated summary as a note and skips the folded full list", () => {
+ const fixes = Array.from({ length: 9 }, (_, index) => `- Fix ${index + 1} (#${index + 1})`);
+ const result = normalizeDesktopUpdateReleaseNotes(
+ [
+ "**v1.2.4** · 12 changes from 3 contributors",
+ "## Highlights",
+ "Link machines (beta).",
+ "## Fixes",
+ ...fixes,
+ "<details>",
+ "<summary>Full changelog</summary>",
+ "* fix: raw entry by @human in https://github.com/pingdotgg/t3code/pull/1",
+ "</details>",
+ ].join("\n"),
+ "1.2.4",
+ "latest",
+ "2026-10-29T10:00:00.000Z",
+ );
+
+ expect(result.releaseNotes).toEqual([
+ {
+ version: "1.2.4",
+ releasedAt: "2026-10-29T10:00:00.000Z",
+ stats: "12 changes from 3 contributors",
+ intro: "Link machines (beta).",
+ items: fixes.map((_, index) => `Fix ${index + 1}`),
+ totalItems: 10,
+ },
+ ]);
+ });
+
it("does not count Markdown or HTML section headings as changes", () => {
const changes = Array.from({ length: 8 }, (_, index) => `Change ${index + 1}`);
const result = normalizeDesktopUpdateReleaseNotes(
@@ -80,6 +112,35 @@ describe("normalizeDesktopUpdateReleaseNotes", () => {
]);
});
+ it("reads handwritten notes with their own <details> as a list", () => {
+ const result = normalizeDesktopUpdateReleaseNotes(
+ "- Older fix\n- Newer fix\n<details><summary>Logs</summary>\n- hidden\n</details>",
+ "1.2.3",
+ "latest",
+ );
+
+ expect(result.releaseNotes).toEqual([
+ { version: "1.2.3", items: ["hidden", "Logs", "Newer fix", "Older fix"], totalItems: 4 },
+ ]);
+ });
+
+ it("dates the offered release from the feed and older nightlies by their build day", () => {
+ const result = normalizeDesktopUpdateReleaseNotes(
+ [
+ { version: "0.0.41-nightly.20260914.1707", note: "- Nightly change 2" },
+ { version: "0.0.41-nightly.20260913.1700", note: "- Nightly change 1" },
+ ],
+ "0.0.41-nightly.20260914.1707",
+ "nightly",
+ "2026-09-14T18:30:00.000Z",
+ );
+
+ expect(result.releaseNotes.map(({ releasedAt }) => releasedAt)).toEqual([
+ "2026-09-14T18:30:00.000Z",
+ "2026-09-13",
+ ]);
+ });
+
it("drops releases from other trains before grouping on nightly", () => {
const releaseNotes = [
{ version: "0.0.41-preview.20260914.1683", note: "- Maintainer test build" },
diff --git a/apps/desktop/src/updates/releaseNotes.ts b/apps/desktop/src/updates/releaseNotes.ts
index 8698d8d4991..2704563cfc0 100644
--- a/apps/desktop/src/updates/releaseNotes.ts
+++ b/apps/desktop/src/updates/releaseNotes.ts
@@ -93,11 +93,46 @@ function isIgnoredReleaseNoteLine(line: string): boolean {
interface ExtractedReleaseNoteItems {
readonly items: ReadonlyArray<string>;
readonly totalItems: number;
+ readonly intro?: string;
+ readonly stats?: string;
+}
+
+/**
+ * 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.
+ */
+function extractReleaseNoteSummary(summary: string): ExtractedReleaseNoteItems {
+ let stats: 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+/, "")
+ .replace(/\s*\((?:#\d+(?:,\s*)?)+\)\.?$/, "")
+ .trim();
+ if (/^[-*]\s+/.test(line)) items.push(text);
+ else intro.push(text);
+ }
+ return {
+ items,
+ totalItems: items.length + intro.length,
+ ...(intro.length > 0 ? { intro: intro.join(" ") } : {}),
+ ...(stats ? { stats } : {}),
+ };
}
function extractReleaseNoteItems(note: string | null | undefined): ExtractedReleaseNoteItems {
if (!note) return { items: [], totalItems: 0 };
+ // Generated summaries fold GitHub's full list under this exact <details> block.
+ const summaryEnd = note.search(/<details>\s*<summary>\s*Full changelog\s*<\/summary>/i);
+ if (summaryEnd >= 0) return extractReleaseNoteSummary(note.slice(0, summaryEnd));
const items: string[] = [];
let totalItems = 0;
for (const rawLine of stripMarkup(note).split("\n")) {
@@ -117,6 +152,15 @@ function extractReleaseNoteItems(note: string | null | undefined): ExtractedRele
return { items: items.toReversed(), totalItems };
}
+// The update feed dates only the offered version; prerelease versions carry their UTC build day.
+const PRERELEASE_BUILD_DAY = /-(?:nightly|preview)\.(\d{4})(\d{2})(\d{2})\.\d+$/;
+
+function resolveReleasedAt(version: string, offeredVersion: string, releaseDate?: string) {
+ if (version === offeredVersion && releaseDate) return releaseDate;
+ const day = PRERELEASE_BUILD_DAY.exec(version);
+ return day ? `${day[1]}-${day[2]}-${day[3]}` : undefined;
+}
+
interface NormalizedDesktopUpdateReleaseNotes {
readonly releaseNotes: ReadonlyArray<DesktopUpdateReleaseNote>;
readonly omittedReleaseCount: number;
@@ -127,6 +171,7 @@ export function normalizeDesktopUpdateReleaseNotes(
releaseNotes: unknown,
fallbackVersion: string,
channel: DesktopUpdateChannel,
+ releaseDate?: string,
): NormalizedDesktopUpdateReleaseNotes {
const rawNotes = (
typeof releaseNotes === "string"
@@ -137,13 +182,17 @@ export function normalizeDesktopUpdateReleaseNotes(
).filter((entry) => desktopUpdateChannelOf(entry.version) === channel);
const normalizedNotes = rawNotes.flatMap((entry) => {
- const { items, totalItems } = extractReleaseNoteItems(entry.note);
+ const { items, totalItems, intro, stats } = extractReleaseNoteItems(entry.note);
if (totalItems === 0) return [];
+ const releasedAt = resolveReleasedAt(entry.version, fallbackVersion, releaseDate);
return [
{
version: entry.version,
items,
totalItems,
+ ...(intro ? { intro } : {}),
+ ...(stats ? { stats } : {}),
+ ...(releasedAt ? { releasedAt } : {}),
},
];
});
diff --git a/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx b/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx
index 714d1564bac..18ebd70c616 100644
--- a/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx
+++ b/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx
@@ -81,7 +81,7 @@ function publish(update: DesktopUpdateState | null) {
});
}
-const releaseNotes = () => document.querySelector('[aria-label="Nightly update release notes"]');
+const releaseNotes = () => document.querySelector('[aria-label="Update release notes"]');
describe("SidebarUpdatePill release notes", () => {
it("closes when the release notes stop applying", async () => {
diff --git a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx
index d9f45cf92f9..7e0ee498cec 100644
--- a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx
+++ b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx
@@ -53,7 +53,7 @@ function shouldUseSidebarUpdateReleaseNotesPopover(
showUpdateDetails: boolean,
state: DesktopUpdateState | null,
): boolean {
- return showUpdateDetails && state?.channel === "nightly" && state.releaseNotes.length > 0;
+ return showUpdateDetails && (state?.releaseNotes.length ?? 0) > 0;
}
function handleSidebarUpdateReleaseNotesPopoverOpenChange(
@@ -542,7 +542,7 @@ function SidebarUpdateControl() {
{showReleaseNotesPopover && state ? (
<PopoverPopup
align="center"
- aria-label="Nightly update release notes"
+ aria-label="Update release notes"
initialFocus={false}
onKeyDownCapture={(event) => {
if (
diff --git a/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx b/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx
index b9f29741bfa..974f81c8d76 100644
--- a/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx
+++ b/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx
@@ -5,8 +5,8 @@ import {
getDesktopUpdateReleaseHistoryUrl,
getDesktopUpdateReleaseUrl,
} from "../desktopUpdate.logic";
+import { formatRelativeTimeLabel } from "../../timestampFormat";
import { openDesktopUpdateReleaseNotes } from "../desktopUpdate.toast";
-import { Separator } from "../ui/separator";
type DesktopUpdateShell = Pick<DesktopBridge, "openExternal">;
@@ -19,6 +19,18 @@ function keyReleaseNoteItems(items: ReadonlyArray<string>) {
});
}
+/** Feed times read "3h ago"; build days from a prerelease version read "today" or "2d ago". */
+function formatReleaseAge(releasedAt: string): string {
+ const day = /^(\d{4})-(\d{2})-(\d{2})$/.exec(releasedAt);
+ if (!day) return formatRelativeTimeLabel(releasedAt);
+ const now = new Date();
+ const today = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
+ const days = Math.round(
+ (today - Date.UTC(Number(day[1]), Number(day[2]) - 1, Number(day[3]))) / 86_400_000,
+ );
+ return days <= 0 ? "today" : `${days}d ago`;
+}
+
function ReleaseLink({
children,
releaseUrl,
@@ -30,7 +42,7 @@ function ReleaseLink({
}) {
return (
<a
- className="mt-2 inline-flex items-center gap-1 rounded-sm text-xs leading-5 text-muted-foreground underline decoration-dotted underline-offset-4 outline-none transition-colors hover:text-foreground focus-visible:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
+ className="mt-1 inline-flex items-center gap-1 rounded-sm text-xs leading-5 text-muted-foreground underline-offset-2 outline-none transition-colors hover:text-foreground hover:underline focus-visible:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
href={releaseUrl}
onClick={(event) => {
event.preventDefault();
@@ -38,7 +50,7 @@ function ReleaseLink({
}}
>
{children}
- <ExternalLinkIcon aria-hidden className="size-3 shrink-0" strokeWidth={2.25} />
+ <ExternalLinkIcon aria-hidden className="size-3 shrink-0" strokeWidth={2} />
</a>
);
}
@@ -52,12 +64,15 @@ export function SidebarUpdateReleaseNotes({
readonly state: DesktopUpdateState;
readonly tooltip: string;
}) {
- if (state.channel !== "nightly" || state.releaseNotes.length === 0) {
+ if (state.releaseNotes.length === 0) {
return <>{tooltip}</>;
}
+ const releasedAt = state.releaseNotes.find(
+ (releaseNote) => releaseNote.version === state.availableVersion,
+ )?.releasedAt;
return (
- <div className="flex max-h-[calc(var(--available-height)-0.5rem)] min-h-0 w-fit max-w-[min(24rem,calc(100vw-2rem))] flex-col text-left">
+ <div className="flex max-h-[calc(var(--available-height)-0.5rem)] min-h-0 w-fit max-w-[min(24rem,calc(100vw-2rem))] flex-col text-left text-pretty">
<div className="shrink-0 px-1">
{state.status === "available" ? (
<div>
@@ -66,7 +81,9 @@ export function SidebarUpdateReleaseNotes({
</div>
{state.availableVersion ? (
<div className="mt-0.5 text-xs leading-4 text-muted-foreground">
- {state.availableVersion}
+ {releasedAt
+ ? `${state.availableVersion} · ${formatReleaseAge(releasedAt)}`
+ : state.availableVersion}
</div>
) : null}
</div>
@@ -74,18 +91,40 @@ export function SidebarUpdateReleaseNotes({
<div className="text-sm leading-5 font-medium">{tooltip}</div>
)}
</div>
- <div className="min-h-0 max-h-[min(28rem,calc(100vh-6rem))] overflow-y-auto px-1 pt-4 pb-1">
+ <div className="min-h-0 max-h-[min(28rem,calc(100vh-6rem))] overflow-y-auto px-1 pt-3 pb-1">
{state.releaseNotes.map((releaseNote, index) => {
const releaseUrl = getDesktopUpdateReleaseUrl(releaseNote.version);
const omittedItemCount = Math.max(0, releaseNote.totalItems - releaseNote.items.length);
const linkLabel =
- omittedItemCount === 0
+ releaseNote.stats ??
+ (omittedItemCount === 0
? "View release on GitHub"
- : `${omittedItemCount} more ${omittedItemCount === 1 ? "change" : "changes"} 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 ? (
+ <h3 className="mb-1 text-xs leading-4 font-medium text-muted-foreground">
+ {releaseNote.releasedAt
+ ? `${releaseNote.version} · ${formatReleaseAge(releaseNote.releasedAt)}`
+ : releaseNote.version}
+ </h3>
+ ) : null}
+ <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 key={releaseNote.version}>
- {index > 0 && <Separator className="my-3" />}
+ <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}`}
@@ -107,8 +146,7 @@ export function SidebarUpdateReleaseNotes({
);
})}
{state.omittedReleaseCount > 0 ? (
- <div>
- <Separator className="my-3" />
+ <div className="mt-3">
<ReleaseLink releaseUrl={getDesktopUpdateReleaseHistoryUrl()} shell={shell}>
{`${state.omittedReleaseCount} older ${state.omittedReleaseCount === 1 ? "release" : "releases"} on GitHub`}
</ReleaseLink>
diff --git a/docs/operations/release.md b/docs/operations/release.md
index 39f4f63ddd9..89003a5e761 100644
--- a/docs/operations/release.md
+++ b/docs/operations/release.md
@@ -42,6 +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.
- 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.ts
index 8d848a86b22..f460619f113 100644
--- a/packages/contracts/src/ipc.ts
+++ b/packages/contracts/src/ipc.ts
@@ -288,12 +288,21 @@ export interface DesktopUpdateReleaseNote {
version: string;
items: ReadonlyArray<string>;
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. */
+ intro?: string;
+ /** Generated summaries only, for example "275 changes from 22 contributors". */
+ stats?: string;
}
export const DesktopUpdateReleaseNoteSchema = Schema.Struct({
version: Schema.String,
items: Schema.Array(Schema.String),
totalItems: Schema.Number,
+ releasedAt: Schema.optionalKey(Schema.String),
+ intro: Schema.optionalKey(Schema.String),
+ stats: Schema.optionalKey(Schema.String),
});
export const DesktopUpdateStateSchema = Schema.Struct({
diff --git a/scripts/generate-release-notes.test.ts b/scripts/generate-release-notes.test.ts
new file mode 100644
index 00000000000..0c55b082dcf
--- /dev/null
+++ b/scripts/generate-release-notes.test.ts
@@ -0,0 +1,65 @@
+import { assert, it } from "@effect/vitest";
+
+import * as Option from "effect/Option";
+
+import {
+ countContributors,
+ isReleaseNoteCommit,
+ summaryText,
+ type PullRequest,
+} from "./generate-release-notes.ts";
+
+const pullRequest = (author: PullRequest["author"]): PullRequest => ({
+ body: "",
+ additions: 1,
+ deletions: 1,
+ changedFiles: 1,
+ author,
+});
+
+it("counts each person once and leaves out bots", () => {
+ const commits = [
+ { subject: "fix(web): one (#1)", authorName: "Ada Lovelace" },
+ { subject: "fix(web): two (#2)", authorName: "Ada Lovelace" },
+ { subject: "chore: bump (#3)", authorName: "dependabot[bot]" },
+ { subject: "fix: direct push by a PR author", authorName: "Ada Lovelace" },
+ { subject: "fix: direct push by someone else", authorName: "Grace Hopper" },
+ { subject: "chore: direct push by a bot", authorName: "t3-code[bot]" },
+ { subject: "fix(web): four (#4)", authorName: "Linus T" },
+ { subject: "fix: direct push by a PR author with no profile name", authorName: "Linus T" },
+ { subject: "fix(web): five, whose PR did not resolve (#5)", authorName: "Ken T" },
+ ];
+ const pullRequests = new Map([
+ [1, pullRequest({ __typename: "User", login: "ada", name: "Ada Lovelace" })],
+ [2, pullRequest({ __typename: "User", login: "ada", name: "Ada Lovelace" })],
+ [3, pullRequest({ __typename: "Bot", login: "dependabot" })],
+ [4, pullRequest({ __typename: "User", login: "linus", name: null })],
+ ]);
+
+ assert.equal(countContributors(commits, pullRequests), 4);
+});
+
+it("leaves mobile-only scopes out and keeps shared ones", () => {
+ const subjects = {
+ "fix(mobile): a": false,
+ "feat(android): b": false,
+ "fix(ios)!: c": false,
+ "fix(web,mobile): d": true,
+ "feat(mobile,web): f": true,
+ "fix(server): e": true,
+ };
+ for (const [subject, kept] of Object.entries(subjects)) {
+ assert.equal(isReleaseNoteCommit({ subject, authorName: "" }), kept, subject);
+ }
+});
+
+it("uses model text only from a completed response", () => {
+ const output = [
+ { type: "message", content: [{ type: "output_text", text: " ## Highlights\nX " }] },
+ ];
+ assert.deepStrictEqual(
+ summaryText({ status: "completed", output }),
+ Option.some("## Highlights\nX"),
+ );
+ assert.deepStrictEqual(summaryText({ status: "incomplete", output }), Option.none());
+});
diff --git a/scripts/generate-release-notes.ts b/scripts/generate-release-notes.ts
new file mode 100644
index 00000000000..909247dae12
--- /dev/null
+++ b/scripts/generate-release-notes.ts
@@ -0,0 +1,370 @@
+#!/usr/bin/env node
+
+import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
+import * as NodeServices from "@effect/platform-node/NodeServices";
+import * as Config from "effect/Config";
+import * as Effect from "effect/Effect";
+import * as FileSystem from "effect/FileSystem";
+import * as Layer from "effect/Layer";
+import * as Logger from "effect/Logger";
+import * as Option from "effect/Option";
+import * as Schema from "effect/Schema";
+import { Command, Flag } from "effect/cli";
+import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
+import { ChildProcess, ChildProcessSpawner } from "effect/process";
+
+// Release notes cover web, desktop, and server. Mobile ships its own store notes.
+const MOBILE_SCOPES = new Set(["mobile", "android", "ios"]);
+const COMMIT_SCOPES = /^[a-z]+\(([^)]*)\)!?:/i;
+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).
+
+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.
+
+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.
+
+Output Markdown in exactly this shape and nothing else:
+
+## 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)"`;
+
+class EmptyReleaseRangeError extends Schema.TaggedError<EmptyReleaseRangeError>()(
+ "EmptyReleaseRangeError",
+ { range: Schema.String },
+) {}
+
+interface ReleaseCommit {
+ readonly subject: string;
+ readonly authorName: string;
+}
+
+const PullRequest = Schema.Struct({
+ body: Schema.String,
+ additions: Schema.Number,
+ deletions: Schema.Number,
+ changedFiles: Schema.Number,
+ author: Schema.NullOr(
+ Schema.Struct({
+ __typename: Schema.String,
+ login: Schema.String,
+ name: Schema.optional(Schema.NullOr(Schema.String)),
+ }),
+ ),
+});
+export type PullRequest = typeof PullRequest.Type;
+
+const PullRequestQueryResponse = Schema.Struct({
+ data: Schema.Struct({
+ repository: Schema.Record(Schema.String, Schema.NullOr(PullRequest)),
+ }),
+});
+
+const GeneratedNotes = Schema.Struct({ body: Schema.String });
+
+const SummaryResponse = Schema.Struct({
+ status: Schema.String,
+ output: Schema.Array(
+ Schema.Struct({
+ type: Schema.String,
+ content: Schema.optional(
+ Schema.Array(Schema.Struct({ type: Schema.String, text: Schema.optional(Schema.String) })),
+ ),
+ }),
+ ),
+ usage: Schema.optional(
+ Schema.Struct({ input_tokens: Schema.Number, output_tokens: Schema.Number }),
+ ),
+});
+
+const pullRequestNumber = (subject: string) => {
+ const match = PULL_REQUEST_NUMBER.exec(subject);
+ return match ? Number(match[1]) : undefined;
+};
+
+/** Drops a commit only when every scope is mobile, so `fix(web,mobile)` stays. */
+export function isReleaseNoteCommit(commit: ReleaseCommit): boolean {
+ const scopes = COMMIT_SCOPES.exec(commit.subject)?.[1]?.split(",");
+ return !scopes?.every((scope) => MOBILE_SCOPES.has(scope.trim().toLowerCase()));
+}
+
+/** Keeps the prose of a PR body: no images, tables, headings, HTML, or verification sections. */
+function trimPullRequestBody(body: string, limit = PULL_REQUEST_BODY_LIMIT): string {
+ const [prose = ""] = body.split(/\n#+\s*(?:Verification|Council|Test|Testing|Screenshots)\b/i);
+ const text = prose
+ .split("\n")
+ .filter((line) => line.trim() !== "" && !/^\s*[!|#<]/.test(line))
+ .join(" ")
+ .replace(/\s+/g, " ")
+ .trim();
+ return text.length > limit ? `${text.slice(0, limit)}...` : text;
+}
+
+function buildSummaryInput(
+ commits: ReadonlyArray<ReleaseCommit>,
+ pullRequests: ReadonlyMap<number, PullRequest>,
+): string {
+ return commits
+ .flatMap(({ 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]`;
+ const body = trimPullRequestBody(pullRequest.body);
+ return body ? [line, ` > ${body}`] : [line];
+ })
+ .join("\n");
+}
+
+/** PR authors without bots, plus authors of direct pushes who have no PR in the range. */
+export function countContributors(
+ commits: ReadonlyArray<ReleaseCommit>,
+ pullRequests: ReadonlyMap<number, PullRequest>,
+): number {
+ const people = new Set<string>();
+ // A PR's squash commit carries its author's git name, which may differ from the profile name.
+ const prAuthorNames = new Set<string>();
+ const directAuthors: string[] = [];
+ for (const commit of commits) {
+ const number = pullRequestNumber(commit.subject);
+ const author = number === undefined ? undefined : pullRequests.get(number)?.author;
+ if (!author) {
+ directAuthors.push(commit.authorName);
+ continue;
+ }
+ if (author.__typename === "Bot" || author.login.endsWith("[bot]")) continue;
+ people.add(author.login);
+ prAuthorNames.add(commit.authorName);
+ if (author.name) prAuthorNames.add(author.name);
+ }
+ for (const name of directAuthors) {
+ if (!name.endsWith("[bot]") && !prAuthorNames.has(name)) people.add(name);
+ }
+ return people.size;
+}
+
+/** No date here: the app shows how long ago a release shipped, and GitHub shows the date. */
+function buildReleaseHeader(version: string, changes: number, contributors: number): string {
+ const plural = (count: number, word: string) => `${count} ${word}${count === 1 ? "" : "s"}`;
+ return `**v${version.replace(/^v/, "")}** · ${plural(changes, "change")} from ${plural(contributors, "contributor")}`;
+}
+
+/** 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 run = Effect.fn("generateReleaseNotes.run")(function* (
+ command: string,
+ args: ReadonlyArray<string>,
+) {
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
+ return yield* spawner.string(ChildProcess.make(command, args));
+});
+
+const decodeJson = <S extends Schema.Top>(schema: S) =>
+ Schema.decodeUnknownEffect(Schema.fromJsonString(schema));
+
+const readCommits = Effect.fn("generateReleaseNotes.readCommits")(function* (
+ previousTag: string,
+ ref: string,
+) {
+ const log = yield* run("git", [
+ "log",
+ "--reverse",
+ "--format=%s%x1f%an",
+ `${previousTag}..${ref}`,
+ ]);
+ return log
+ .split("\n")
+ .filter((line) => line !== "")
+ .map((line): ReleaseCommit => {
+ const [subject = "", authorName = ""] = line.split("\x1f");
+ return { subject, authorName };
+ });
+});
+
+const readPullRequests = Effect.fn("generateReleaseNotes.readPullRequests")(function* (
+ repository: string,
+ numbers: ReadonlyArray<number>,
+) {
+ const [owner, name] = repository.split("/");
+ const pullRequests = new Map<number, PullRequest>();
+ for (let start = 0; start < numbers.length; start += 100) {
+ const fields = numbers
+ .slice(start, start + 100)
+ .map(
+ (number) =>
+ `pr${number}: pullRequest(number: ${number}) { body additions deletions changedFiles author { __typename login ... on User { name } } }`,
+ )
+ .join("\n");
+ const query = `query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { ${fields} } }`;
+ const response = yield* decodeJson(PullRequestQueryResponse)(
+ yield* run("gh", [
+ "api",
+ "graphql",
+ "-f",
+ `query=${query}`,
+ "-f",
+ `owner=${owner}`,
+ "-f",
+ `name=${name}`,
+ ]),
+ );
+ for (const [alias, pullRequest] of Object.entries(response.data.repository)) {
+ if (pullRequest) pullRequests.set(Number(alias.slice(2)), pullRequest);
+ }
+ }
+ return pullRequests;
+});
+
+const readFullChangelog = Effect.fn("generateReleaseNotes.readFullChangelog")(function* (options: {
+ readonly repository: string;
+ readonly tag: string;
+ readonly ref: string;
+ readonly previousTag: string;
+}) {
+ const response = yield* run("gh", [
+ "api",
+ `repos/${options.repository}/releases/generate-notes`,
+ "-f",
+ `tag_name=${options.tag}`,
+ "-f",
+ `target_commitish=${options.ref}`,
+ "-f",
+ `previous_tag_name=${options.previousTag}`,
+ ]);
+ return (yield* decodeJson(GeneratedNotes)(response)).body;
+});
+
+export function summaryText(response: typeof SummaryResponse.Type): Option.Option<string> {
+ // 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
+ .flatMap((item) => item.content ?? [])
+ .flatMap((part) => (part.type === "output_text" && part.text ? [part.text] : []))
+ .join("")
+ .trim();
+ return text === "" ? Option.none() : Option.some(text);
+}
+
+const summarize = Effect.fn("generateReleaseNotes.summarize")(function* (input: string) {
+ const apiKey = yield* Config.Redacted("OPENAI_API_KEY");
+ const httpClient = yield* HttpClient.HttpClient;
+ const response = yield* HttpClientRequest.post("https://api.openai.com/v1/responses").pipe(
+ HttpClientRequest.bearerToken(apiKey),
+ HttpClientRequest.bodyJson({
+ model: SUMMARY_MODEL,
+ reasoning: { effort: "low" },
+ instructions: SUMMARY_INSTRUCTIONS,
+ input: `Commits:\n${input}`,
+ }),
+ Effect.flatMap(httpClient.execute),
+ Effect.flatMap(HttpClientResponse.filterStatusOk),
+ Effect.flatMap((response) => response.json),
+ Effect.flatMap(Schema.decodeUnknownEffect(SummaryResponse)),
+ Effect.timeout("3 minutes"),
+ );
+ yield* Effect.logInfo("release summary generated").pipe(
+ Effect.annotateLogs({
+ model: SUMMARY_MODEL,
+ inputTokens: response.usage?.input_tokens,
+ outputTokens: response.usage?.output_tokens,
+ }),
+ );
+ return summaryText(response);
+});
+
+const command = Command.make(
+ "generate-release-notes",
+ {
+ repository: Flag.String("repository").pipe(Flag.withDescription("GitHub owner/name.")),
+ tag: Flag.String("tag").pipe(Flag.withDescription("Tag being released.")),
+ ref: Flag.String("ref").pipe(Flag.withDescription("Commit being released.")),
+ previousTag: Flag.String("previous-tag").pipe(Flag.withDescription("Previous release tag.")),
+ version: Flag.String("version").pipe(Flag.withDescription("Version shown in the header.")),
+ output: Flag.String("output").pipe(Flag.withDescription("File to write the notes to.")),
+ },
+ ({ 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) ?? [])),
+ ];
+ const [pullRequests, fullChangelog] = yield* Effect.all(
+ [
+ readPullRequests(repository, numbers),
+ readFullChangelog({ repository, tag, ref, previousTag }),
+ ],
+ { concurrency: "unbounded" },
+ );
+ const header = buildReleaseHeader(
+ version,
+ 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));
+ if (Option.isNone(summary)) {
+ return yield* Effect.logWarning("no release summary, leaving GitHub's notes in place");
+ }
+ const fs = yield* FileSystem.FileSystem;
+ // Publish uses the file when it exists, so a partial write must never land at `output`.
+ yield* fs.writeFileString(
+ `${output}.tmp`,
+ assembleReleaseNotes(header, summary.value, fullChangelog),
+ );
+ yield* fs.rename(`${output}.tmp`, output);
+ yield* Effect.logInfo("release notes written").pipe(
+ Effect.annotateLogs({ output, commits: commits.length }),
+ );
+ }),
+).pipe(
+ Command.withDescription("Write release notes with a model summary over GitHub's full list."),
+);
+
+if (import.meta.main) {
+ Command.run(command, { version: "0.0.0" }).pipe(
+ Effect.provide(
+ Layer.mergeAll(
+ Logger.layer([Logger.consolePretty()]),
+ NodeServices.layer,
+ FetchHttpClient.layer,
+ ),
+ ),
+ NodeRuntime.runMain,
+ );
+}
diff --git a/scripts/notify-discord-release.test.ts b/scripts/notify-discord-release.test.ts
index 6e57ffb56a7..84a43869be6 100644
--- a/scripts/notify-discord-release.test.ts
+++ b/scripts/notify-discord-release.test.ts
@@ -132,6 +132,15 @@ it("preserves custom notes and links outside generated GitHub pull request entri
);
});
+it("posts a generated summary without its folded full list", () => {
+ const summary = "**v1.2.3** · 4 changes\n\n## Fixes\n- Stop works again (#1)";
+ const releaseNotes = `${summary}\n\n<details>\n<summary>Full changelog</summary>\n\n* fix: raw by @someone in https://github.com/pingdotgg/t3code/pull/1\n\n</details>\n`;
+ assert.equal(
+ payloadDescription(buildDiscordReleaseAnnouncement({ ...nightlyAnnouncement, releaseNotes })),
+ `${intro}\n\n**v1.2.3** · 4 changes\n\n## Fixes\n- Stop works again ([#1](https://github.com/pingdotgg/t3code/pull/1))\n\n[Full changelog](${nightlyAnnouncement.releaseUrl.href})`,
+ );
+});
+
it("falls back when notes are missing, empty, or whitespace", () => {
const fallback = buildDiscordReleaseAnnouncement(nightlyAnnouncement);
assert.equal(payloadDescription(fallback), intro);
diff --git a/scripts/notify-discord-release.ts b/scripts/notify-discord-release.ts
index 0eb3bf34853..29d94561c8f 100644
--- a/scripts/notify-discord-release.ts
+++ b/scripts/notify-discord-release.ts
@@ -135,6 +135,12 @@ const suppressMentions = (text: string) =>
const escapeLinkLabel = (text: string) => text.replace(/[\\[\]]/g, "\\$&");
+/** GitHub links `(#123)` on the release page; Discord needs the link written out. */
+function linkPullRequestNumbers(notes: string, releaseUrl: URL) {
+ const repositoryUrl = releaseUrl.href.split("/releases/")[0];
+ return notes.replace(/#(\d+)\b/g, `[#$1](${repositoryUrl}/pull/$1)`);
+}
+
function formatReleaseNotes(notes: string) {
return notes
.replace(
@@ -193,9 +199,15 @@ export const buildDiscordReleaseAnnouncement = (
options.target === "prerelease"
? "A new T3 Code prerelease is available for nightly testers."
: `[View full release notes on GitHub](${options.releaseUrl.href})`;
+ // Generated summaries fold the full list under <details>, which Discord cannot render.
+ const [summary = "", folded] = (options.releaseNotes ?? "").split(/^<details>/m);
const notes =
options.target === "prerelease"
- ? suppressMentions(formatReleaseNotes(options.releaseNotes?.trim() ?? ""))
+ ? suppressMentions(
+ folded === undefined
+ ? formatReleaseNotes(summary.trim())
+ : `${linkPullRequestNumbers(summary.trim(), options.releaseUrl)}\n\n[Full changelog](${options.releaseUrl.href})`,
+ )
: "";
const description = notes ? `${intro}\n\n${notes}` : intro;
// Separate embeds avoid URL deduplication; reserve title and footer space within Discord's 6000-character limit.