feat(desktop): show beta changes after updates

Beta builds embed their commit and the feat, fix and perf commits among their newest 200. The app remembers the commit of the build the user last saw and, after an update, shows the changes since then in a What's new in beta dialog. No network calls and no update service changes. The first update after rollout only records the commit.
This commit is contained in:
Dax Raad
2026-10-19 11:07:37 -04:00
Unverified
parent cb07a38a91
commit 776186fda2
13 changed files with 642 additions and 4 deletions
+7
View File
@@ -531,6 +531,13 @@ jobs:
# The macOS zip (7z deflate, default -mx=7) and DMG (UDZO zlib, default level 9) at level 1.
if [ "$RUNNER_OS" = "macOS" ]; then echo "ELECTRON_BUILDER_COMPRESSION_LEVEL=1" >> "$GITHUB_ENV"; fi
# The beta build embeds the subjects of its newest commits for "What's new in beta"
# (packages/desktop/scripts/beta-notes.ts). Commits without file contents are enough.
- name: Fetch beta history (beta)
if: github.ref_name == 'beta'
shell: bash
run: git fetch --no-tags --filter=blob:none --depth=300 origin "$GITHUB_SHA"
# Beta builds the app before its CLI exists. `bun run build` would run the prebuild hook, which copies the CLI;
# Prepare runs it once the CLI is here.
- name: Build (beta)
+5
View File
@@ -47,6 +47,11 @@ the `beta` update channel. Beta publishes only the desktop app and `beta.opencod
from `dev`. Install it from `https://opencode.ai/download/beta/<platform>`, for example `darwin-aarch64-dmg` or
`windows-x64-nsis`. Installed builds update in place on every platform.
Each beta build compiles in its commit and the `feat`, `fix` and `perf` commits among its newest 200
(`scripts/beta-notes.ts`, embedded by `electron.vite.config.ts`; run `bun scripts/beta-notes.ts` to preview them). After an
update, the beta app lists the ones after the commit of the build the user saw last in a "What's new in beta" dialog,
unless release notes are turned off in Settings.
## Startup benchmark
`bun run bench:startup` measures a **packaged** build from process spawn to the restored tab being ready and the
+5
View File
@@ -1,5 +1,6 @@
import { defineConfig } from "electron-vite"
import type { Plugin } from "vite"
import { BetaNotes } from "./scripts/beta-notes"
import { pickerPlugin } from "./scripts/picker"
import { nodePtyPackage } from "./scripts/utils"
@@ -53,6 +54,8 @@ const initialChunk: Plugin = {
export default defineConfig(({ command }) => {
const channel = resolveChannel()
const nodePtyPkg = nodePtyPackage()
// Beta builds carry their commit and recent history for the updater's "What's new in beta"; other channels none.
const betaNotes = channel === "beta" ? BetaNotes.embed() : undefined
return {
main: {
@@ -123,6 +126,8 @@ const require = __cjs_mod__.createRequire(import.meta.url);
define: {
"import.meta.env.OPENCODE_VERSION": JSON.stringify(process.env.OPENCODE_VERSION),
"import.meta.env.VITE_OPENCODE_CHANNEL": JSON.stringify(channel),
"import.meta.env.OPENCODE_COMMIT": betaNotes ? JSON.stringify(betaNotes.sha) : "undefined",
"import.meta.env.OPENCODE_BETA_NOTES": betaNotes ? JSON.stringify(JSON.stringify(betaNotes)) : "undefined",
"import.meta.env.OPENCODE_TEST_ONBOARDING": JSON.stringify(
command === "serve" && process.env.OPENCODE_TEST_ONBOARDING === "1",
),
+103
View File
@@ -0,0 +1,103 @@
import { afterAll, expect, test } from "bun:test"
import { $ } from "bun"
import { mkdtemp, rm } from "node:fs/promises"
import { tmpdir } from "node:os"
import path from "node:path"
import { BetaNotes } from "./beta-notes"
test.each([
[
"feat(app): merge projects across servers in the location dialog",
{ type: "feat", scope: "app", summary: "merge projects across servers in the location dialog" },
],
[
"fix(desktop): disable animated wheel scrolling on linux (#57120)",
{ type: "fix", scope: "desktop", summary: "disable animated wheel scrolling on linux", pr: 57120 },
],
["perf: cache model list", { type: "perf", summary: "cache model list" }],
[
"Feat(core)!: drop legacy sessions",
{ type: "feat", scope: "core", summary: "drop legacy sessions", breaking: true },
],
[
"fix(app): keep (#1) in the middle of a summary",
{ type: "fix", scope: "app", summary: "keep (#1) in the middle of a summary" },
],
["chore(sdk): regenerate types", undefined],
["refactor(app): split dialog", undefined],
["docs: update guide", undefined],
["test(app): cover dialog", undefined],
["ci: cache bun", undefined],
["Merge branch 'dev' into beta", undefined],
["fix the thing without a type", undefined],
["fix(app): (#12)", undefined],
])("parses %p", (subject, expected) => {
expect(BetaNotes.parseSubject(subject)).toEqual(expected)
})
const repos: string[] = []
afterAll(() => Promise.all(repos.map((dir) => rm(dir, { recursive: true, force: true }))))
async function repo(subjects: string[]) {
const dir = await mkdtemp(path.join(tmpdir(), "beta-notes-"))
repos.push(dir)
await $`git init -q -b beta && git config user.email a@b.c && git config user.name Ada`.cwd(dir).quiet()
// One fast-import writes every commit, where a commit per process is slow on Windows.
const stream = subjects
.map((subject, i) =>
[
"commit refs/heads/beta",
`committer Ada <a@b.c> ${1_700_000_000 + i} +0000`,
`data ${Buffer.byteLength(subject)}`,
subject,
"",
].join("\n"),
)
.join("")
await $`git fast-import --quiet < ${new Response(stream)}`.cwd(dir).quiet()
await $`git reset -q --hard beta`.cwd(dir).quiet()
return { dir, shas: (await $`git rev-list --reverse HEAD`.cwd(dir).text()).trim().split("\n") }
}
test("embeds the build's commit, its history and the notes of its non-merge feat and fix commits", async () => {
const git = await repo([
"feat(app): old feature",
"fix(app): first fix (#10)",
"chore: bump",
"feat(desktop): new dialog",
])
await $`git checkout -q -b side HEAD~1 && git commit -q --allow-empty -m ${"fix(app): side fix"} && git checkout -q beta && git merge -q --no-ff side -m ${"fix(app): merge side"}`
.cwd(git.dir)
.quiet()
const head = (await $`git rev-parse HEAD`.cwd(git.dir).text()).trim()
const side = (await $`git rev-parse side`.cwd(git.dir).text()).trim()
const short = (sha: string) => sha.slice(0, 12)
const embedded = BetaNotes.embed({ head: "HEAD", cwd: git.dir })
expect(embedded.sha).toBe(head)
expect(embedded.commits).toHaveLength(6)
expect(embedded.commits[0]).toBe(short(head))
expect(embedded.notes).toEqual([
{ type: "fix", scope: "app", summary: "side fix", sha: short(side) },
{ type: "feat", scope: "desktop", summary: "new dialog", sha: short(git.shas[3]!) },
{ type: "fix", scope: "app", summary: "first fix", pr: 10, sha: short(git.shas[1]!) },
{ type: "feat", scope: "app", summary: "old feature", sha: short(git.shas[0]!) },
])
})
test("embeds at most the newest 200 commits", async () => {
const git = await repo(Array.from({ length: 205 }, (_, i) => `fix(app): fix ${i}`))
const embedded = BetaNotes.embed({ head: "HEAD", cwd: git.dir })
expect(embedded.commits).toHaveLength(200)
expect(embedded.notes[0]?.summary).toBe("fix 204")
expect(embedded.notes.at(-1)?.summary).toBe("fix 5")
})
+90
View File
@@ -0,0 +1,90 @@
// The user-facing changes compiled into a beta build: the build's commit, the newest commits of its history, and the
// feat, fix and perf commits among them. electron.vite.config.ts embeds them in the renderer as
// import.meta.env.OPENCODE_BETA_NOTES; the updater's "What's new in beta" dialog lists the ones after the commit of the
// build the user saw last.
// Usage: bun scripts/beta-notes.ts [head]
export * as BetaNotes from "./beta-notes"
import { execFileSync } from "node:child_process"
export type BetaNote = {
type: "feat" | "fix" | "perf"
scope?: string
summary: string
breaking?: true
pr?: number
sha: string
}
/** How many commits of history a build carries. A previous build further back shows the newest notes instead. */
const LIMIT = 200
/** Commits are identified by this many hex digits, enough to be unique in this repository. */
const SHORT = 12
const KEPT = new Set(["feat", "fix", "perf"])
const FIELD = "\x1f"
const RECORD = "\x1e"
/**
* Reads the commit `head` resolves to (GITHUB_SHA in CI) and its newest commits, newest first: every commit's short
* sha, merges included so a previous build at a merge is found, and the notes of the non-merge feat, fix and perf ones.
*/
export function embed(input: { head?: string; cwd?: string } = {}) {
// electron-vite loads its config, which calls this, in Node, so this cannot use Bun's shell.
const git = (...args: string[]) => execFileSync("git", args, { cwd: input.cwd, encoding: "utf8" })
const sha = git("rev-parse", input.head ?? process.env.GITHUB_SHA ?? "HEAD").trim()
const log = git("log", "--topo-order", `--max-count=${LIMIT}`, `--format=%H${FIELD}%P${FIELD}%s${RECORD}`, sha)
const records = log
.split(RECORD)
.map((record) => record.trim().split(FIELD))
.filter((fields) => fields.length === 3 && fields[0])
return {
sha,
commits: records.map(([commit]) => commit!.slice(0, SHORT)),
notes: records.flatMap(([commit, parents, subject]): BetaNote[] => {
// A merge commit repeats the commits it merges.
if (parents!.trim().split(/\s+/).length > 1) return []
const note = parseSubject(subject!)
return note ? [{ ...note, sha: commit!.slice(0, SHORT) }] : []
}),
}
}
/** Parses a conventional commit header `type(scope)!: summary (#123)`; anything else is not a note. */
export function parseSubject(subject: string) {
const match = subject.trim().match(/^(\w+)(?:\(([^)]*)\))?(!)?:\s*(.+)$/)
const type = match?.[1]?.toLowerCase()
if (!match || !type || !isKept(type)) return undefined
const pr = match[4]!.match(/\s*\(#(\d+)\)\s*$/)
const summary = (pr ? match[4]!.slice(0, pr.index) : match[4]!).trim()
if (!summary) return undefined
const note: Omit<BetaNote, "sha"> = { type, summary }
const scope = match[2]?.trim()
if (scope) note.scope = scope
if (match[3]) note.breaking = true
if (pr) note.pr = Number(pr[1])
return note
}
function isKept(type: string): type is BetaNote["type"] {
return KEPT.has(type)
}
if (import.meta.main) console.log(JSON.stringify(embed({ head: process.argv[2] }), null, 2))
+6
View File
@@ -0,0 +1,6 @@
interface ImportMetaEnv {
/** The commit a beta desktop build was built from; undefined in every other build. */
readonly OPENCODE_COMMIT?: string
/** A beta desktop build's commit, recent history and notes as JSON (packages/desktop/scripts/beta-notes.ts). */
readonly OPENCODE_BETA_NOTES?: string
}
@@ -0,0 +1,94 @@
import { Button } from "@opencode/ui/button"
import { useDialog } from "@opencode/ui/context/dialog"
import { Option } from "effect"
import { onMount } from "solid-js"
import { DialogBetaNotes } from "./beta-dialog"
import { sliceBetaNotes, type EmbeddedNotes } from "./beta-notes"
const commits: [type: "feat" | "fix", scope: string, summary: string, pr?: number][] = [
["fix", "app", "open select dialogs at the top"],
["feat", "app", "merge projects across servers in the location dialog"],
["feat", "app", "open the right panel on a new tab", 57094],
["fix", "app", "open activity panel above the capsule"],
["fix", "desktop", "disable animated wheel scrolling on linux"],
["feat", "desktop", "pick models from a model dialog with favorites and recent", 55838],
["fix", "session-ui", "keep table frame visible over header", 57050],
["feat", "session-ui", "style markdown tables like generated UI tables", 57002],
["fix", "app", "fit connect dialog steps to their content under a fixed top edge", 57006],
["feat", "app", "add an experimental session inbox to the sidebar", 55647],
["fix", "core", "debounce compatibility skill reloads", 56260],
["fix", "session-ui", "restore blue user bubbles with grey pending steers", 57001],
["feat", "ui", "open images from their place in the message", 56896],
["fix", "desktop", "install each Windows channel into its own directory", 56904],
["feat", "app", "show MCP errors from a failed status link"],
["fix", "ui", "open dialogs with their input focused"],
["fix", "app", "default agent notifications to off"],
["feat", "app", "add Focus and Pro interface picker to preferences", 56898],
]
const sha = (n: number) => n.toString(16).padStart(4, "0").padEnd(40, "a")
// A build's embedded history: one commit per entry, newest first, with a chore between the notes.
const embedded = (picked: typeof commits): EmbeddedNotes => ({
sha: sha(1000),
commits: [sha(1000), ...picked.flatMap((_, i) => [sha(i * 2 + 1), sha(i * 2 + 2)]), sha(999)].map((value) =>
value.slice(0, 12),
),
notes: picked.map(([type, scope, summary, pr], i) => ({
type,
scope,
summary,
pr,
sha: sha(i * 2 + 1).slice(0, 12),
})),
})
function Fixture(props: { picked: typeof commits; previous?: string; previousCommit?: string }) {
const dialog = useDialog()
const notes = Option.getOrThrow(sliceBetaNotes(embedded(props.picked), props.previousCommit ?? sha(999)))
const open = () =>
dialog.show(() => (
<DialogBetaNotes
notes={notes}
previous={props.previous ?? "0.0.0-beta-21180"}
dialog={{ close: () => dialog.close() }}
open={(href) => window.open(href, "_blank")}
/>
))
onMount(open)
return <Button onClick={open}>Open What's new in beta</Button>
}
export default {
title: "Extensions/Updater/What's new in beta",
id: "extensions-updater-beta-notes",
parameters: {
docs: {
description: {
component:
"The dialog a beta desktop build shows after an update: the features and fixes since the build the user last saw.",
},
},
},
}
/** A typical update: a few features and fixes. */
export const Typical = { render: () => <Fixture picked={commits.slice(0, 8)} /> }
/** More than ten changes: the rest are linked on GitHub. */
export const Many = {
render: () => <Fixture picked={commits} previous="0.0.0-beta-21012" />,
}
/** Only fixes, so the New section is not shown. */
export const FixesOnly = {
render: () => <Fixture picked={commits.filter(([type]) => type === "fix").slice(0, 4)} />,
}
/** The previous build is older than the embedded history: the newest changes stand in, and the rest are linked. */
export const PreviousBuildUnknown = {
render: () => <Fixture picked={commits} previous="0.0.0-beta-20500" previousCommit={sha(5000)} />,
}
@@ -0,0 +1,112 @@
import { For, Show } from "solid-js"
import { Option } from "effect"
import { Button } from "@opencode/ui/button"
import { Dialog, DialogBody, DialogFooter, DialogHeader, DialogTitleGroup } from "@opencode/ui/dialog"
import { useExtension, type DialogHandle, type SetupContext } from "../sdk"
import { betaBuild, decodeEmbeddedNotes, sliceBetaNotes, type BetaNote, type BetaNotes } from "./beta-notes"
import type definition from "./index"
/**
* Shows the features and fixes this beta build carries since the commit of the build the user saw last, and remembers
* this build as seen. Everything comes from the build itself; only the links reach the network, when clicked.
*/
export function showBetaNotes(
ctx: SetupContext<typeof definition>,
input: { readonly previous: string; readonly previousCommit: string | undefined; readonly markSeen: () => void },
) {
const notes = Option.flatMap(decodeEmbeddedNotes(import.meta.env.OPENCODE_BETA_NOTES), (embedded) =>
sliceBetaNotes(embedded, input.previousCommit),
)
input.markSeen()
if (Option.isNone(notes)) return
ctx.dialogs.open(
(dialog) => (
<DialogBetaNotes
notes={notes.value}
previous={input.previous}
dialog={dialog}
open={(href) => ctx.system.openExternal(href)}
/>
),
{ replace: true },
)
}
/** What's new in beta: the listed features and fixes, and a link to the whole range when some are not listed. */
export function DialogBetaNotes(props: {
notes: BetaNotes
previous: string
dialog: DialogHandle
open: (href: string) => void
}) {
const ctx = useExtension<typeof definition>()
return (
<Dialog fit containerClass="w-[min(calc(100vw-32px),520px)]!">
<DialogHeader>
<DialogTitleGroup
title={ctx.t("beta.title")}
description={ctx.plural("beta.since", props.notes.total, { build: betaBuild(props.previous) })}
/>
</DialogHeader>
<DialogBody class="max-h-[min(calc(100vh-220px),440px)] !overflow-y-auto gap-4 px-4 pb-1">
<Section title={ctx.t("beta.added")} notes={props.notes.added} open={props.open} />
<Section title={ctx.t("beta.fixed")} notes={props.notes.fixed} open={props.open} />
</DialogBody>
<DialogFooter>
<Show when={props.notes.more}>
{(href) => (
<Button type="button" variant="ghost" class="me-auto" onClick={() => props.open(href())}>
{ctx.t("beta.viewAll")}
</Button>
)}
</Show>
<Button type="button" variant="contrast" autofocus onClick={() => props.dialog.close()}>
{ctx.t("beta.done")}
</Button>
</DialogFooter>
</Dialog>
)
}
function Section(props: { title: string; notes: readonly BetaNote[]; open: (href: string) => void }) {
return (
<Show when={props.notes.length > 0}>
<section class="flex flex-col gap-1.5">
<h2 class="m-0 text-12-medium leading-[var(--line-height-compact)] text-v2-text-text-muted">{props.title}</h2>
<ul class="m-0 flex list-none flex-col gap-1 p-0">
<For each={props.notes}>
{(note) => (
<li class="flex min-w-0 items-start gap-2 text-13-regular leading-[var(--line-height-base)] text-v2-text-text-base">
<span aria-hidden="true" class="mt-[9px] size-1 shrink-0 rounded-full bg-v2-icon-icon-muted" />
<span class="min-w-0 flex-1 [overflow-wrap:anywhere]">
{note.summary}
<Show when={note.scope}>
{(scope) => <span class="ms-1.5 text-12-regular text-v2-text-text-faint">{scope()}</span>}
</Show>
<Show when={note.pr}>
{(pr) => (
<a
href={pr().url}
class="ms-1.5 rounded-[4px] text-12-regular text-v2-text-text-muted underline-offset-2 hover:text-v2-text-text-base hover:underline focus-visible:underline focus-visible:outline-none"
onClick={(event) => {
event.preventDefault()
props.open(pr().url)
}}
>
#{pr().number}
</a>
)}
</Show>
</span>
</li>
)}
</For>
</ul>
</section>
</Show>
)
}
@@ -0,0 +1,99 @@
import { expect, test } from "bun:test"
import { Option } from "effect"
import { betaBuild, decodeEmbeddedNotes, sliceBetaNotes, type EmbeddedNotes } from "./beta-notes"
const sha = (n: number) => n.toString(16).padStart(4, "0").padEnd(40, "a")
const short = (n: number) => sha(n).slice(0, 12)
// A build at commit 30 whose history runs from 30 down to 1, with the note type `notes` gives each commit.
function embedded(input: { notes: (n: number) => "feat" | "fix" | "chore" }): EmbeddedNotes {
const commits = Array.from({ length: 30 }, (_, i) => 30 - i)
return {
sha: sha(30),
commits: commits.map(short),
notes: commits.flatMap((n) => {
const type = input.notes(n)
return type === "chore" ? [] : [{ type, summary: `change ${n}`, sha: short(n) }]
}),
}
}
const compare = (from: number) => `https://github.com/anomalyco/opencode/compare/${sha(from)}...${sha(30)}`
test("lists the notes after the previous commit, features first, humanized, with pull request links", () => {
const notes = sliceBetaNotes(
{
sha: sha(30),
commits: [short(30), short(29), short(28), short(27), short(26)],
notes: [
{
type: "fix",
scope: "desktop",
summary: "disable animated wheel scrolling on linux.",
pr: 57120,
sha: short(30),
},
{ type: "feat", scope: "app", summary: "merge projects across servers", sha: short(29) },
{ type: "perf", summary: "cache the model list", sha: short(28) },
{ type: "feat", summary: "already seen", sha: short(26) },
],
},
sha(27),
)
expect(Option.getOrThrow(notes)).toEqual({
added: [{ sha: short(29), summary: "Merge projects across servers", scope: "app", pr: undefined }],
fixed: [
{
sha: short(30),
summary: "Disable animated wheel scrolling on linux",
scope: "desktop",
pr: { number: 57120, url: "https://github.com/anomalyco/opencode/pull/57120" },
},
{ sha: short(28), summary: "Cache the model list", scope: undefined, pr: undefined },
],
total: 3,
more: undefined,
})
})
test.each([
// previous commit, note types, [features, fixes] listed, total, more
["found, all listed", sha(20), (n: number) => (n % 3 === 0 ? "feat" : "chore"), [4, 0], 4, undefined],
["found, more than 10", sha(5), (n: number) => (n % 2 ? "fix" : "feat"), [5, 5], 25, compare(5)],
["found, mostly features", sha(10), (n: number) => (n < 28 ? "feat" : "fix"), [7, 3], 20, compare(10)],
["missing from the history", sha(99), (n: number) => (n % 2 ? "fix" : "feat"), [5, 5], 10, compare(99)],
] as const)("previous commit %s", (_, previous, notes, shown, total, more) => {
const sliced = Option.getOrThrow(sliceBetaNotes(embedded({ notes }), previous))
expect([sliced.added.length, sliced.fixed.length]).toEqual([...shown])
expect(sliced.total).toBe(total)
expect(sliced.more).toBe(more)
})
test.each([
["no previous commit", undefined, () => "feat" as const],
["the same build", sha(30), () => "feat" as const],
["only chores since the previous commit", sha(25), (n: number) => (n < 25 ? "feat" : "chore")],
] as const)("shows nothing for %s", (_, previous, notes) => {
expect(Option.isNone(sliceBetaNotes(embedded({ notes }), previous))).toBe(true)
})
test("decodes the embedded notes, and none from a build without them", () => {
const value = embedded({ notes: () => "fix" })
expect(Option.getOrThrow(decodeEmbeddedNotes(JSON.stringify(value)))).toEqual(value)
expect(Option.isNone(decodeEmbeddedNotes(undefined))).toBe(true)
})
test.each([
["0.0.0-beta-21180", "21180"],
["0.0.0-beta-21180.2", "21180.2"],
["0.0.0-next-900", "900"],
["1.2.3", "1.2.3"],
])("names build %s", (version, build) => {
expect(betaBuild(version)).toBe(build)
})
@@ -0,0 +1,93 @@
import { Option, Schema } from "effect"
const REPOSITORY = "https://github.com/anomalyco/opencode"
/** The dialog lists at most this many changes and links the rest. */
const SHOWN = 10
const Note = Schema.Struct({
type: Schema.Literals(["feat", "fix", "perf"]),
scope: Schema.optional(Schema.String),
summary: Schema.String,
pr: Schema.optional(Schema.Number),
sha: Schema.String,
})
/** What a beta build embeds (packages/desktop/scripts/beta-notes.ts), newest first. */
const Embedded = Schema.Struct({
/** The build's commit. */
sha: Schema.String,
/** The short shas of the build's newest commits, merges included. */
commits: Schema.Array(Schema.String),
/** The feat, fix and perf commits among them. */
notes: Schema.Array(Note),
})
export type EmbeddedNotes = typeof Embedded.Type
/** Decodes the notes a beta build embeds as JSON. Other builds embed none. */
export const decodeEmbeddedNotes = Schema.decodeUnknownOption(Schema.fromJsonString(Embedded))
export type BetaNote = {
readonly sha: string
readonly summary: string
readonly scope?: string
readonly pr?: { readonly number: number; readonly url: string }
}
export type BetaNotes = {
/** New features, newest first. */
readonly added: readonly BetaNote[]
/** Fixes and performance improvements, newest first. */
readonly fixed: readonly BetaNote[]
/** How many changes the header counts: every one since the previous build, or the listed ones when that is unknown. */
readonly total: number
/** The GitHub compare page of the whole range, when some changes are not listed. */
readonly more?: string
}
/**
* The changes since the build at `previous`: the notes of the commits newer than it, features first, then fixes, at
* most 10 in all and at least half of them features when there are enough. When `previous` is older than the embedded
* history (or was force-pushed away), the newest notes stand in, with the rest linked. None without a previous commit,
* or without a change.
*/
export function sliceBetaNotes(embedded: EmbeddedNotes, previous: string | undefined): Option.Option<BetaNotes> {
if (!previous || previous === embedded.sha) return Option.none()
const cut = embedded.commits.findIndex((commit) => previous.startsWith(commit))
const position = new Map(embedded.commits.map((commit, index) => [commit, index]))
const notes = cut === -1 ? embedded.notes : embedded.notes.filter((note) => (position.get(note.sha) ?? cut) < cut)
if (notes.length === 0) return Option.none()
const features = notes.filter((note) => note.type === "feat")
const fixes = notes.filter((note) => note.type !== "feat")
// Features get at least half of the list when there are more fixes than fit, fixes whatever features leave.
const added = features.slice(0, Math.max(SHOWN / 2, SHOWN - fixes.length))
const fixed = fixes.slice(0, SHOWN - added.length)
const listed = added.length + fixed.length
return Option.some({
added: added.map(item),
fixed: fixed.map(item),
total: cut === -1 ? listed : notes.length,
more: cut === -1 || listed < notes.length ? `${REPOSITORY}/compare/${previous}...${embedded.sha}` : undefined,
})
}
/** The beta run number of a version such as `0.0.0-beta-21180`, or the version itself. */
export function betaBuild(version: string) {
return version.match(/^v?0\.0\.0-(?:beta|next)-(\d+(?:\.\d+)?)$/)?.[1] ?? version
}
function item(note: typeof Note.Type): BetaNote {
const summary = note.summary.trim().replace(/\.$/, "")
return {
sha: note.sha,
summary: summary.charAt(0).toUpperCase() + summary.slice(1),
scope: note.scope,
pr: note.pr === undefined ? undefined : { number: note.pr, url: `${REPOSITORY}/pull/${note.pr}` },
}
}
@@ -29,4 +29,11 @@ export default {
"releaseNotes.action.next": "Next",
"releaseNotes.action.hideFuture": "Don't show these in the future",
"releaseNotes.media.alt": "Release preview",
"beta.title": "What's new in beta",
"beta.since.one": "Since build {{build}} · {{count}} change",
"beta.since.other": "Since build {{build}} · {{count}} changes",
"beta.added": "New",
"beta.fixed": "Fixes",
"beta.viewAll": "View all on GitHub",
"beta.done": "Got it",
}
+3 -2
View File
@@ -5,7 +5,7 @@ import en from "./i18n/en"
const ReleaseNotes = Schema.Struct({ enabled: Schema.Boolean })
const Seen = Schema.Struct({ version: Schema.optional(Schema.String) })
const Seen = Schema.Struct({ version: Schema.optional(Schema.String), commit: Schema.optional(Schema.String) })
export default Extension.define({
id: "updater",
@@ -24,7 +24,8 @@ export default Extension.define({
},
},
),
// The version whose What's New was last shown or skipped; stored before under the app's own key.
// The version whose What's New was last shown or skipped, and on beta its commit; stored before under the app's
// own key.
seen: Store.global(Seen, {}, "highlights.v1"),
// The update main staged for the next start; stored before in the updater's settings file.
ready: Store.main(Schema.NullOr(Schema.Struct({ version: Schema.String })), null, {
@@ -87,8 +87,8 @@ const setup: Setup<typeof definition> = (ctx) => {
}
/**
* What's New after an update, on every platform: the release highlights since the version last seen. The first run
* and a disabled What's New only remember the version.
* What's New after an update, on every platform: the release highlights since the version last seen, or on beta the
* features and fixes of the beta builds since then. The first run and a disabled What's New only remember the version.
*/
function whatsNew(ctx: SetupContext<typeof definition>) {
const version = ctx.build.version
@@ -97,13 +97,29 @@ function whatsNew(ctx: SetupContext<typeof definition>) {
if (!version || previous === version) return
const commit = import.meta.env.OPENCODE_COMMIT
const previousCommit = seen.value.commit
const markSeen = () =>
seen.update((draft) => {
draft.version = version
// Beta remembers the build's commit even when nothing shows, so the next update lists what came after it.
if (commit) draft.commit = commit
})
if (!previous || !ctx.stores.releaseNotes.value.enabled) return markSeen()
if (ctx.build.channel === "beta") {
void import("./beta-dialog").then((module) => {
if (ctx.signal.aborted) return
module.showBetaNotes(ctx, { previous, previousCommit, markSeen })
})
return
}
void import("./whats-new").then((module) => {
if (ctx.signal.aborted) return