feat(tui): browse recent release highlights

The What's new dialog now carries the five newest stable releases'
highlights, read from CHANGELOG.md at build time, and pages between
them with < and > buttons beside a centered version (or left/right).
An update that skipped releases still shows their highlights.

The build reads CHANGELOG.md from the tagged commit instead of the
OPENCODE_RELEASE_NOTES env var, so both parsers share parse().
This commit is contained in:
Daniel Smolsky
2026-11-02 12:41:57 -05:00
Unverified
parent d074773174
commit f3faae353b
15 changed files with 343 additions and 77 deletions
-1
View File
@@ -132,7 +132,6 @@ jobs:
env:
BUN_COMPILE_RELEASE: bun-v1.4.4
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
OPENCODE_RELEASE_NOTES: ${{ needs.plan.outputs.channel == 'latest' && inputs.release_notes || '' }}
GH_TOKEN: ${{ github.token }} # read-only; raises the rate limit for Bun release downloads
- name: Verify bundled models catalog
run: bun packages/cli/script/catalog-smoke.ts packages/cli/dist/cli-linux-x64/bin/opencode
-1
View File
@@ -152,7 +152,6 @@ jobs:
env:
BUN_COMPILE_RELEASE: bun-v1.4.4
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
OPENCODE_RELEASE_NOTES: ${{ needs.plan.outputs.channel == 'latest' && inputs.release_notes || '' }}
GH_TOKEN: ${{ github.token }} # read-only; raises the rate limit for Bun release downloads
- name: Verify bundled models catalog
run: bun packages/cli/script/catalog-smoke.ts packages/cli/dist/cli-linux-x64/bin/opencode
+6 -6
View File
@@ -382,12 +382,12 @@ These changes affect code that imports `@opencode/ai` directly. They don't chang
### Highlights
- Create, install and share [Desktop plugins](https://opencode.ai/v2/docs/build/plugins/gui) (experimental) ([#55246](https://github.com/anomalyco/opencode/pull/55246), [#59469](https://github.com/anomalyco/opencode/pull/59469), [#59489](https://github.com/anomalyco/opencode/pull/59489))
- Refreshed the desktop app experience ([#56898](https://github.com/anomalyco/opencode/pull/56898), [#58865](https://github.com/anomalyco/opencode/pull/58865), [#55838](https://github.com/anomalyco/opencode/pull/55838), [#57962](https://github.com/anomalyco/opencode/pull/57962))
- Add experimental image and decision generation APIs to plugins and sdk, allowing image generation or decision model (think typesafe, clef, etc) workflows. ([#59190](https://github.com/anomalyco/opencode/pull/59190), [#59380](https://github.com/anomalyco/opencode/pull/59380), [#58758](https://github.com/anomalyco/opencode/pull/58758))
- Plugins can now attach and update keyed session instructions with ctx.session.instructions.entry.put/list/remove. Instead of editing the system prompt and busting the prompt cache, each change is added as a small update at the next step. The entries also survive compaction and reverts, and they don't start an extra model turn. ([#56550](https://github.com/anomalyco/opencode/pull/56550))
- Restored the Todo tool in desktop via opt-in ([#59092](https://github.com/anomalyco/opencode/pull/59092))
- Add configurable prompt cache TTLs per provider/model ([#59157](https://github.com/anomalyco/opencode/pull/59157))
- **Desktop Plugins**: Create, install and share [Desktop plugins](https://opencode.ai/v2/docs/build/plugins/gui) (experimental). ([#55246](https://github.com/anomalyco/opencode/pull/55246), [#59469](https://github.com/anomalyco/opencode/pull/59469), [#59489](https://github.com/anomalyco/opencode/pull/59489))
- **Refreshed Desktop App**: The desktop app experience has been refreshed. ([#56898](https://github.com/anomalyco/opencode/pull/56898), [#58865](https://github.com/anomalyco/opencode/pull/58865), [#55838](https://github.com/anomalyco/opencode/pull/55838), [#57962](https://github.com/anomalyco/opencode/pull/57962))
- **Image and Decision Generation APIs**: Plugins and the SDK get experimental image and decision generation APIs for image generation or decision model workflows. ([#59190](https://github.com/anomalyco/opencode/pull/59190), [#59380](https://github.com/anomalyco/opencode/pull/59380), [#58758](https://github.com/anomalyco/opencode/pull/58758))
- **Keyed Session Instructions**: Plugins can attach and update keyed session instructions with `ctx.session.instructions.entry.put/list/remove`. Each change is added at the next step instead of editing the system prompt and busting the prompt cache, and entries survive compaction and reverts. ([#56550](https://github.com/anomalyco/opencode/pull/56550))
- **Opt-In Todo Tool on Desktop**: The Todo tool is back in desktop as an opt-in. ([#59092](https://github.com/anomalyco/opencode/pull/59092))
- **Prompt Cache TTLs**: Configure prompt cache TTLs per provider and model. ([#59157](https://github.com/anomalyco/opencode/pull/59157))
### Breaking changes
+1 -1
View File
@@ -31,7 +31,7 @@ const bundleOnly = process.argv.includes("--bundle-only")
const single = process.argv.includes("--single")
const skipInstall = process.argv.includes("--skip-install")
const appArchiveOnly = process.argv.includes("--app-archive-only")
const highlights = Script.preview ? undefined : embed(process.env.OPENCODE_RELEASE_NOTES)
const highlights = Script.preview ? undefined : await embed()
const requestedArchive = process.env.OPENCODE_APP_ARCHIVE
const archivePath = requestedArchive ? path.resolve(dir, requestedArchive) : undefined
const requested = process.env.OPENCODE_TARGET
+1 -1
View File
@@ -33,7 +33,7 @@ const requestedTarget = process.env.OPENCODE_TARGET
const skipInstall = process.argv.includes("--skip-install")
const skipWebUi = process.argv.includes("--skip-web-ui")
const solidPlugin = createSolidTransformPlugin()
const highlights = Script.preview ? undefined : embed(process.env.OPENCODE_RELEASE_NOTES)
const highlights = Script.preview ? undefined : await embed()
const releaseAssets = new Map<string, Promise<Map<string, string>>>()
const modelsSnapshot = modelsSnapshotPlugin(await bundledModelsSnapshot())
+9 -2
View File
@@ -8,12 +8,19 @@ declare const OPENCODE_RELEASE_HIGHLIGHTS: string
const version = typeof OPENCODE_VERSION === "string" ? OPENCODE_VERSION : "local"
const channel = typeof OPENCODE_CHANNEL === "string" ? OPENCODE_CHANNEL : "local"
const artifact = typeof OPENCODE_ARTIFACT === "string" ? OPENCODE_ARTIFACT : "cli"
// Stable release builds embed the release notes' Highlights; every other build has none.
// Stable release builds embed the newest releases' Highlights from CHANGELOG.md, newest first; every other build has none.
const highlights =
typeof OPENCODE_RELEASE_HIGHLIGHTS === "string"
? Option.getOrElse(
Schema.decodeUnknownOption(
Schema.fromJsonString(Schema.Array(Schema.Struct({ title: Schema.String, body: Schema.String }))),
Schema.fromJsonString(
Schema.Array(
Schema.Struct({
version: Schema.String,
items: Schema.Array(Schema.Struct({ title: Schema.String, body: Schema.String })),
}),
),
),
)(OPENCODE_RELEASE_HIGHLIGHTS),
() => [],
)
+34 -8
View File
@@ -1,6 +1,8 @@
import path from "path"
export type Highlight = { title: string; body: string }
const LIMIT = { items: 5, title: 60, body: 300 }
const LIMIT = { releases: 5, items: 5, title: 60, body: 300 }
/**
* Extracts the `### Highlights` bullets from reviewed release notes. Each bullet is expected to look like
@@ -58,11 +60,35 @@ function truncate(value: string, limit: number) {
return `${(space > limit / 2 ? cut.slice(0, space) : cut).trimEnd()}…`
}
/** Returns the JSON a stable release build embeds as `OPENCODE_RELEASE_HIGHLIGHTS`, warning about malformed notes. */
export function embed(notes: string | undefined) {
if (!notes?.trim()) return
const result = parse(notes)
result.problems.forEach((problem) => console.warn(`release highlights: ${problem}`))
if (!result.items.length) return
return JSON.stringify(result.items)
/**
* Splits CHANGELOG.md at its `## vX.Y.Z` release headings and parses each release's Highlights. Returns the newest
* releases that have highlights, newest first, with the problems in the newest release's notes only: older releases
* have shipped, so their problems are no longer actionable.
*/
export function history(changelog: string) {
const sections = changelog
.replace(/\r\n/g, "\n")
.split(/^(?=## v\d+\.\d+\.\d+(?:\s|$))/m)
.flatMap((section) => {
const version = section.match(/^## v(\d+\.\d+\.\d+)(?:\s|$)/)?.[1]
return version ? [{ version, ...parse(section) }] : []
})
return {
releases: sections
.filter((section) => section.items.length > 0)
.slice(0, LIMIT.releases)
.map((section) => ({ version: section.version, items: section.items })),
problems: sections[0]?.problems ?? [],
}
}
/**
* Returns the JSON a stable release build embeds as `OPENCODE_RELEASE_HIGHLIGHTS`: the newest releases' highlights
* from the repository's CHANGELOG.md, which the release commit has already extended with this release's notes.
*/
export async function embed() {
const result = history(await Bun.file(path.resolve(import.meta.dir, "../../../CHANGELOG.md")).text())
result.problems.forEach((problem) => console.warn(`release highlights: ${problem}`))
if (!result.releases.length) return
return JSON.stringify(result.releases)
}
+60 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"
import path from "path"
import { parse } from "../src/highlights"
import { history, parse } from "../src/highlights"
describe("highlights", () => {
test("parses the v2.0.27 release notes", async () => {
@@ -77,4 +77,63 @@ describe("highlights", () => {
expect(result.items[0].body.endsWith("…")).toBe(true)
expect(result.problems).toEqual(["Kept the first 5 of 7 highlights"])
})
test("reads the newest releases with highlights from CHANGELOG.md, newest first", async () => {
const changelog = await Bun.file(path.resolve(import.meta.dir, "../../../CHANGELOG.md")).text()
const versions = [...changelog.matchAll(/^## v(\d+\.\d+\.\d+) /gm)].map((match) => match[1])
const result = history(changelog)
expect(result.problems).toEqual([])
expect(result.releases).toHaveLength(5)
expect(result.releases[0].version).toBe(versions[0])
// Releases keep the changelog's newest-first order.
expect(result.releases.map((release) => versions.indexOf(release.version))).toEqual(
result.releases.map((release) => versions.indexOf(release.version)).toSorted((a, b) => a - b),
)
expect(result.releases.every((release) => release.items.length > 0 && release.items.length <= 5)).toBe(true)
})
test("skips releases without highlights and reports problems only for the newest", () => {
const release = (version: string, highlights: string) =>
[`## v${version} — 2026-10-30`, "", "### Highlights", "", highlights, "", "### Core", "", "- A fix."].join("\n")
const result = history(
[
"# Changelog",
"",
release("2.0.3", "- Plain bullet without a title."),
release("2.0.2", "- **Two**: The second release."),
release("2.0.1", "- Another plain bullet."),
"## v2.0.0-beta.1 — 2026-10-01",
"",
"### Highlights",
"",
"- **Beta**: Not a release.",
release("1.9.0", "- **One**: The first release."),
].join("\r\n"),
)
expect(result.releases).toEqual([
{ version: "2.0.2", items: [{ title: "Two", body: "The second release." }] },
{ version: "1.9.0", items: [{ title: "One", body: "The first release." }] },
])
expect(result.problems).toEqual([
"Skipped a highlight without a bold title and description: Plain bullet without a title.",
"The Highlights section has no highlights in the expected format",
])
})
test("keeps the newest five releases", () => {
const changelog = Array.from(
{ length: 7 },
(_, index) => `## v2.0.${7 - index}\n\n### Highlights\n\n- **Release ${7 - index}**: Text.\n`,
).join("\n")
expect(history(changelog).releases.map((release) => release.version)).toEqual([
"2.0.7",
"2.0.6",
"2.0.5",
"2.0.4",
"2.0.3",
])
})
})
+4 -4
View File
@@ -732,19 +732,19 @@ function App() {
createEffect(() => {
if (highlighted || !plugins.ready() || client.connection.status() !== "connected") return
highlighted = true
const items = app.highlights ?? []
const releases = app.highlights ?? []
if (config.data.highlights === false) return
if (route.data.type !== "home" || dialog.stack.length > 0 || promptRef.current?.current.text) return
if (args.prompt || args.continue || args.sessionID || args.newSessionID) return
if (process.env.OPENCODE_DRIVE || process.env.OPENCODE_STORY || process.env.OPENCODE_ROUTE) return
void claim(storage, {
version: app.version,
count: items.length,
releases: releases.map((release) => release.version),
history: existsSync(path.join(paths.state, "prompt-history.jsonl")),
})
.then((show) => {
if (show && dialog.stack.length === 0)
dialog.replace(() => <DialogHighlights version={app.version} items={items} />)
dialog.replace(() => <DialogHighlights releases={releases} />)
})
.catch(toast.error)
})
@@ -1036,7 +1036,7 @@ function App() {
name: "opencode.highlights",
title: "Show release highlights",
slash: { name: "highlights" },
run: () => dialog.replace(() => <DialogHighlights version={app.version} items={app.highlights ?? []} />),
run: () => dialog.replace(() => <DialogHighlights releases={app.highlights ?? []} />),
category: "System",
},
]
@@ -1,21 +1,33 @@
import { TextAttributes, type ScrollBoxRenderable } from "@opentui/core"
import { useTerminalDimensions } from "@opentui/solid"
import { createMemo, For } from "solid-js"
import { createMemo, createSignal, For, Show } from "solid-js"
import { useConfig } from "../config"
import { Keymap } from "../context/keymap"
import type { TuiHighlight } from "../context/runtime"
import type { TuiReleaseHighlights } from "../context/runtime"
import { useTheme } from "../context/theme"
import { DIALOG_INSET, DialogBleed, DialogFooter, DialogHeader, DialogLayout, useDialog } from "../ui/dialog"
import { getScrollAcceleration } from "../util/scroll"
export function DialogHighlights(props: { version: string; items: ReadonlyArray<TuiHighlight> }) {
/** Shows one embedded release's highlights at a time, starting at the newest. */
export function DialogHighlights(props: { releases: ReadonlyArray<TuiReleaseHighlights> }) {
const dialog = useDialog()
const theme = useTheme().surface("dialog")
const overlay = useTheme()
const config = useConfig().data
const dimensions = useTerminalDimensions()
const maxHeight = createMemo(() => Math.max(6, Math.floor(dimensions().height * 0.6) - 2))
// Leaves room for the version row above the scrolling highlights.
const maxHeight = createMemo(() => Math.max(6, Math.floor(dimensions().height * 0.6) - 4))
let scroll: ScrollBoxRenderable | undefined
const [index, setIndex] = createSignal(0)
const release = () => props.releases[index()]
const hasOlder = () => index() < props.releases.length - 1
const hasNewer = () => index() > 0
const select = (next: number) => {
if (next < 0 || next >= props.releases.length) return
setIndex(next)
scroll?.scrollTo(0)
}
const older = () => select(index() + 1)
const newer = () => select(index() - 1)
dialog.setCentered(true)
@@ -29,30 +41,39 @@ export function DialogHighlights(props: { version: string; items: ReadonlyArray<
{ bind: "pagedown", title: "Next page", group: "Dialog", run: () => scroll?.scrollBy(maxHeight()) },
{ bind: "home", title: "Scroll to top", group: "Dialog", run: () => scroll?.scrollTo(0) },
{ bind: "end", title: "Scroll to bottom", group: "Dialog", run: () => scroll?.scrollTo(Infinity) },
...["left", "h"].map((bind) => ({ bind, title: "Newer release", group: "Dialog", run: newer })),
...["right", "l"].map((bind) => ({ bind, title: "Older release", group: "Dialog", run: older })),
],
}))
return (
<DialogLayout
header={<DialogHeader title={`What's new in ${props.version}`} />}
header={<DialogHeader title="What's new" />}
footer={{ actions: { primary: [{ title: "ok", key: "enter", onTrigger: () => dialog.clear() }] } }}
legacyFooter={
<box flexDirection="row" justifyContent="space-between" alignItems="center">
<DialogFooter actions={{ secondary: [{ title: "scroll", key: "↑/↓" }] }} />
<box
paddingLeft={3}
paddingRight={3}
backgroundColor={theme.background.action.primary.focused}
onMouseUp={() => dialog.clear()}
>
<text fg={theme.text.action.primary.focused}>ok</text>
</box>
<Button title="ok" onTrigger={() => dialog.clear()} />
</box>
}
>
{/* The band owns the vertical padding so it stays visible while the highlights scroll. */}
<DialogBleed>
<box backgroundColor={overlay.background.raised.high} paddingTop={1} paddingBottom={1}>
<box backgroundColor={overlay.background.raised.high} paddingTop={1} paddingBottom={1} gap={1}>
{/* The version stays centered and put while the highlights below it scroll; each arrow keeps its slot. */}
<box flexDirection="row" justifyContent="center" gap={2}>
<box width={3}>
<Show when={hasNewer()}>
<Button title="<" padding={1} onTrigger={newer} />
</Show>
</box>
<text fg={overlay.text.base}>{release().version}</text>
<box width={3}>
<Show when={hasOlder()}>
<Button title=">" padding={1} onTrigger={older} />
</Show>
</box>
</box>
<scrollbox
ref={(element: ScrollBoxRenderable) => (scroll = element)}
maxHeight={maxHeight()}
@@ -62,7 +83,7 @@ export function DialogHighlights(props: { version: string; items: ReadonlyArray<
scrollAcceleration={getScrollAcceleration(config)}
>
<box gap={1} paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET}>
<For each={props.items}>
<For each={release().items}>
{(item) => (
<box>
<text attributes={TextAttributes.BOLD} fg={overlay.text.base}>
@@ -86,3 +107,18 @@ export function DialogHighlights(props: { version: string; items: ReadonlyArray<
</DialogLayout>
)
}
/** A filled dialog button, shared by ok and the release arrows so they look alike. */
function Button(props: { title: string; padding?: number; onTrigger: () => void }) {
const theme = useTheme().surface("dialog")
return (
<box
paddingLeft={props.padding ?? 3}
paddingRight={props.padding ?? 3}
backgroundColor={theme.background.action.primary.focused}
onMouseUp={props.onTrigger}
>
<text fg={theme.text.action.primary.focused}>{props.title}</text>
</box>
)
}
+7 -2
View File
@@ -5,12 +5,17 @@ export type TuiHighlight = Readonly<{
body: string
}>
export type TuiReleaseHighlights = Readonly<{
version: string
items: ReadonlyArray<TuiHighlight>
}>
export type TuiApp = Readonly<{
name: string
version: string
channel: string
/** The current release's highlights, embedded only in stable release builds. */
highlights?: ReadonlyArray<TuiHighlight>
/** The newest releases' highlights, newest first, embedded only in stable release builds. */
highlights?: ReadonlyArray<TuiReleaseHighlights>
}>
export type TuiPaths = Readonly<{
@@ -5,39 +5,112 @@ import { DialogHighlights } from "../../../component/dialog-highlights"
import type { Story } from "./index"
import { StoryFooter } from "./footer"
// The v2.0.27 release highlights, as a release build embeds them.
const items = [
// The v2.2.1 to v2.2.5 release highlights, as a release build embeds them from CHANGELOG.md.
const releases = [
{
title: "Built-In Worktree Tools",
body: "Ask OpenCode to use `worktree_create`, `worktree_list`, and `worktree_remove` in Code Mode. You can create isolated worktrees, move sessions into them, and remove them with normal edit approval.",
version: "2.2.5",
items: [
{
title: "Worktree and Shell Mode Shortcuts",
body: "Press `⌘⌥O` on macOS or `Ctrl+Alt+O` on Windows and Linux to choose a worktree, and `⌘⌥B` or `Ctrl+Alt+B` to choose its base branch. `⌘⇧X` or `Ctrl+Shift+X` now toggles shell mode in the composer.",
},
{
title: "Send Quotes From the Comment Popup",
body: "Hold `⌘` or `Ctrl` in the quote popup to turn its checkmark into send, or press `⌘Enter` or `Ctrl+Enter`, to send just that quote and comment while leaving the rest of the composer untouched.",
},
{
title: "Percentage Compaction Buffer",
body: "Set `\"compaction\": { \"buffer\": \"20%\" }` in `opencode.json` to keep a share of each model's context window free, so one setting fits models with small and large windows. Token counts still work.",
},
],
},
{
title: "Safer Remote Pairing",
body: "The first `opencode pair --remote` now warns that it will expose your server and asks for confirmation. For non-interactive use, pass `opencode pair --remote --yes`.",
version: "2.2.4",
items: [
{
title: "Persistent Desktop Terminals",
body: "Desktop terminals now belong to the session, survive server restarts with their scrollback, and stay synchronized with the TUI and other windows. Renamed terminals also keep their names across restarts.",
},
{
title: "Publish Interactive Artifacts",
body: "Enable `\"experimental\": { \"artifacts\": true }` in `opencode.json` to let agents publish, update, and serve HTML or static artifacts through the built-in local provider or plugin-provided storage.",
},
{
title: "Guided Claude Agent Setup",
body: "Select Claude Agent from the provider picker to copy `claude auth login`, install Claude Code, and verify the connection before continuing to model selection.",
},
{
title: "Choose a Base Branch Quickly",
body: "While creating a worktree, open Choose base branch with `⌘⌥.` on macOS or `Ctrl+Alt+.` on Windows and Linux. The command is also available in the command palette and Settings › Shortcuts.",
},
],
},
{
title: "Installable Web App",
body: "Use Chrome or Edge’s Install button to install the OpenCode web app, including when it runs behind an authenticating proxy.",
version: "2.2.3",
items: [
{
title: "Use Claude Code in OpenCode",
body: "Install Claude Code, run `claude auth login`, then select Claude Agent in `/connect` to use your Claude Code login and models.",
},
{
title: "Faster Long Sessions in Desktop",
body: "Streaming replies and long conversations now do much less rendering work.",
},
{
title: "Desktop Stability Fixes",
body: "Fixes side-panel tabs, repeated \"Session not found\" toasts, and Open file over HTTP.",
},
],
},
{
title: "Clear Session Failures",
body: "Desktop and TUI timelines now show execution errors that happen before or between model steps instead of ending without an explanation.",
version: "2.2.2",
items: [
{
title: "Image Generation by Default",
body: "When a connected provider supports image models, agents can now use `experimental_image_generate` without additional configuration. Set its preferred model through `experimental.image_generate.model`.",
},
{
title: "Faster Worktree Selection",
body: "On the new-session screen, click the current Git branch to open that project’s “Run session in” worktree picker directly.",
},
{
title: "Unified Quotes and Annotations",
body: "Timeline quotes, terminal quotes, and browser annotations now share a compact optional-comment editor, while source highlights remain attached to local drafts.",
},
],
},
{
title: "Automatic Project Cleanup",
body: "Projects whose directories no longer exist are automatically hidden from the project list. Opening the directory again restores the project.",
version: "2.2.1",
items: [
{
title: "Keep Working Toward a Goal",
body: "Run `/goal <objective>` in the TUI or Desktop to let the session continue until a reviewer confirms the objective is met. Use `/goal pause`, `/goal resume`, or `/goal clear` to control it.",
},
{
title: "Generate Images",
body: "Enable `experimental.image_generate` to let agents create or edit images with the new `image_generate` tool. You can optionally set its default model with `experimental.image_generate.model`.",
},
{
title: "Inspect Background Shells",
body: "Click a running shell in the Desktop activity pill to see its live output and stop it without leaving the menu.",
},
{
title: "New Default Model Picker",
body: "Search favorites, recent models, providers, and variants from the redesigned model picker, which is now the default in Desktop.",
},
],
},
]
function HighlightsStory(props: { context: Plugin.Context }) {
const dimensions = useTerminalDimensions()
const open = (count: number) =>
props.context.ui.dialog.show(() => <DialogHighlights version="2.0.27" items={items.slice(0, count)} />)
props.context.ui.dialog.show(() => <DialogHighlights releases={releases.slice(0, count)} />)
props.context.keymap.layer(() => ({
commands: [
{ bind: "o", title: "Open five highlights", group: "Storybook", run: () => open(5) },
{ bind: "t", title: "Open two highlights", group: "Storybook", run: () => open(2) },
{ bind: "o", title: "Open five releases", group: "Storybook", run: () => open(5) },
{ bind: "t", title: "Open one release", group: "Storybook", run: () => open(1) },
{
bind: "escape",
title: "Back to storybook",
@@ -55,8 +128,8 @@ function HighlightsStory(props: { context: Plugin.Context }) {
context={props.context}
title="storybook / release highlights"
controls={[
{ shortcut: "o", label: "five highlights" },
{ shortcut: "t", label: "two highlights" },
{ shortcut: "o", label: "five releases" },
{ shortcut: "t", label: "one release" },
{ shortcut: "esc", label: "back" },
]}
/>
+10 -5
View File
@@ -2,8 +2,8 @@ import type { Storage } from "../context/storage"
export type HighlightsInput = {
readonly version: string
/** Number of highlights embedded in this build. */
readonly count: number
/** Versions whose highlights are embedded in this build. */
readonly releases: ReadonlyArray<string>
/** Whether this user has used the TUI before, so a first run with no state is still an update. */
readonly history: boolean
}
@@ -11,8 +11,8 @@ export type HighlightsInput = {
type State = { seen?: string }
/**
* Decides what to do with the current release's highlights: `show` opens the dialog and records the version,
* `record` marks a version seen silently, and `none` leaves the state untouched. Only stable versions count.
* Decides what to do with the embedded release highlights after an update: `show` opens the dialog and records the
* version, `record` marks a version seen silently, and `none` leaves the state untouched. Only stable versions count.
*/
export function decide(input: HighlightsInput & { readonly seen?: string }) {
const current = stable(input.version)
@@ -20,7 +20,12 @@ export function decide(input: HighlightsInput & { readonly seen?: string }) {
const seen = input.seen === undefined ? undefined : stable(input.seen)
if (!seen && !input.history) return "record"
if (seen && !newer(current, seen)) return "none"
return input.count > 0 ? "show" : "record"
// An update that skipped releases still shows their highlights, even when this release has none of its own.
const unseen = input.releases.some((release) => {
const version = stable(release)
return version && (!seen || newer(version, seen))
})
return unseen ? "show" : "record"
}
/**
@@ -5,6 +5,7 @@ import { onMount } from "solid-js"
import { DialogHighlights } from "../../src/component/dialog-highlights"
import { ConfigProvider } from "../../src/config"
import { Keymap } from "../../src/context/keymap"
import type { TuiReleaseHighlights } from "../../src/context/runtime"
import { ThemeProvider } from "../../src/context/theme"
import { DialogProvider, useDialog } from "../../src/ui/dialog"
import { ToastProvider } from "../../src/ui/toast"
@@ -18,23 +19,22 @@ const items = Array.from({ length: 5 }, (_, index) => ({
}))
// Dialog key bindings are only active while the dialog is on the stack.
function Open() {
function Open(props: { releases: ReadonlyArray<TuiReleaseHighlights> }) {
const dialog = useDialog()
onMount(() => dialog.replace(() => <DialogHighlights version="2.0.27" items={items} />))
onMount(() => dialog.replace(() => <DialogHighlights releases={props.releases} />))
return null
}
test("scrolls long highlights between a fixed title and footer", async () => {
await using temporary = await tmpdir()
const app = await testRender(
function render(directory: string, releases: ReadonlyArray<TuiReleaseHighlights>) {
return testRender(
() => (
<TestTuiContexts directory={temporary.path} paths={{ state: temporary.path }}>
<TestTuiContexts directory={directory} paths={{ state: directory }}>
<ConfigProvider config={createTuiResolvedConfig()}>
<ThemeProvider mode="dark" source={emptyThemeSource}>
<Keymap.Provider>
<ToastProvider>
<DialogProvider>
<Open />
<Open releases={releases} />
</DialogProvider>
</ToastProvider>
</Keymap.Provider>
@@ -44,11 +44,17 @@ test("scrolls long highlights between a fixed title and footer", async () => {
),
{ width: 70, height: 20, kittyKeyboard: true },
)
}
test("scrolls long highlights between a fixed title and footer", async () => {
await using temporary = await tmpdir()
const app = await render(temporary.path, [{ version: "2.0.27", items }])
try {
app.renderer.start()
await app.waitForFrame((frame) => frame.includes("What's new in 2.0.27") && frame.includes("Highlight 1"))
await app.waitForFrame((frame) => frame.includes("What's new") && frame.includes("Highlight 1"))
const top = app.captureCharFrame()
expect(top).toContain("2.0.27")
expect(top).toContain("command-1")
expect(top).toContain("scroll ↑/↓")
expect(top).not.toContain("Highlight 5")
@@ -57,7 +63,7 @@ test("scrolls long highlights between a fixed title and footer", async () => {
app.mockInput.pressKey("END")
await app.waitForFrame((frame) => frame.includes("Highlight 5"))
const bottom = app.captureCharFrame()
expect(bottom).toContain("What's new in 2.0.27")
expect(bottom).toContain("What's new")
expect(bottom).toContain("scroll ↑/↓")
expect(bottom).not.toContain("Highlight 1")
@@ -71,3 +77,47 @@ test("scrolls long highlights between a fixed title and footer", async () => {
app.renderer.destroy()
}
})
test("switches releases with the arrow buttons, starting at the newest", async () => {
await using temporary = await tmpdir()
const app = await render(temporary.path, [
{ version: "2.0.29", items },
{ version: "2.0.28", items: [{ title: "Middle highlight", body: "From the middle release." }] },
{ version: "2.0.27", items: [{ title: "Oldest highlight", body: "From the oldest release." }] },
])
const click = (label: string) => {
const rows = app.captureCharFrame().split("\n")
const y = rows.findIndex((row) => row.includes(label))
return app.mockMouse.click(rows[y].indexOf(label) + 1, y)
}
try {
app.renderer.start()
await app.waitForFrame((frame) => frame.includes("2.0.29") && frame.includes("Highlight 1"))
// The newest release is first, so only the older-release arrow applies.
expect(app.captureCharFrame()).toContain("2.0.29 >")
expect(app.captureCharFrame()).not.toContain("<")
// Switching releases scrolls back to the top.
app.mockInput.pressKey("END")
await app.waitForFrame((frame) => frame.includes("Highlight 5"))
await click(">")
await app.waitForFrame((frame) => frame.includes("2.0.28") && frame.includes("Middle highlight"))
expect(app.captureCharFrame()).toContain("< 2.0.28 >")
app.mockInput.pressArrow("right")
await app.waitForFrame((frame) => frame.includes("2.0.27") && frame.includes("Oldest highlight"))
expect(app.captureCharFrame()).not.toContain(">")
await click("<")
await app.waitForFrame((frame) => frame.includes("Middle highlight"))
app.mockInput.pressKey("h")
await app.waitForFrame((frame) => frame.includes("2.0.29") && frame.includes("Highlight 1"))
expect(app.captureCharFrame()).not.toContain("Highlight 5")
app.mockInput.pressEnter()
await app.waitForFrame((frame) => !frame.includes("What's new"))
} finally {
app.renderer.destroy()
}
})
+10 -3
View File
@@ -5,18 +5,25 @@ import { createStorage } from "../src/context/storage"
import { claim, decide } from "../src/util/highlights"
import { tmpdir } from "./fixture/fixture"
const input = { version: "2.0.27", count: 5, history: true }
const input = { version: "2.0.27", releases: ["2.0.27", "2.0.26"], history: true }
test("first run shows highlights to existing users and records new installs silently", () => {
expect(decide(input)).toBe("show")
expect(decide({ ...input, history: false })).toBe("record")
expect(decide({ ...input, count: 0 })).toBe("record")
expect(decide({ ...input, releases: [] })).toBe("record")
})
test("newer versions show highlights or record silently when there are none", () => {
expect(decide({ ...input, seen: "2.0.26" })).toBe("show")
expect(decide({ ...input, seen: "1.99.99", history: false })).toBe("show")
expect(decide({ ...input, seen: "2.0.26", count: 0 })).toBe("record")
expect(decide({ ...input, seen: "2.0.26", releases: [] })).toBe("record")
})
test("an update that skipped releases shows their highlights even when it has none of its own", () => {
const update = { ...input, version: "2.0.29", releases: ["2.0.28", "2.0.27"] }
expect(decide({ ...update, seen: "2.0.26" })).toBe("show")
expect(decide({ ...update, seen: "2.0.27" })).toBe("show")
expect(decide({ ...update, seen: "2.0.28" })).toBe("record")
})
test("the same version, downgrades, and unstable versions do nothing", () => {