GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(tui): show release highlights after updating (#54969) · jonBoone/opencode@2bf145b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • publish.yml
  • packages
    • cli
      • script
        • build-node.ts
        • build.ts
      • src
        • commands/handlers
          • default.ts
        • version.ts
      • vite.node.config.ts
    • script
      • package.json
      • src
        • highlights.ts
      • test
        • highlights.test.ts
    • tui
      • src
        • app.tsx
        • component
          • dialog-config.tsx
          • dialog-highlights.tsx
        • config
          • index.tsx
        • context
          • runtime.tsx
        • feature-plugins/system/storybook
          • highlights.tsx
          • index.tsx
        • util
          • highlights.ts
      • test
        • component
          • dialog-highlights.test.tsx
        • highlights.test.ts
  • script
    • release.ts
  • services/www/src/docs/content/cli
    • config.mdx
    • tui.mdx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/publish.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/publish.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ jobs:
112112
BUN_COMPILE_RELEASE: bun-v1.4.2
113113
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
114114
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
115+
OPENCODE_RELEASE_NOTES: ${{ (github.ref_name == 'dev' && inputs.release_notes) || '' }}
115116
GH_REPO: ${{ needs.version.outputs.repo }}
116117
GH_TOKEN: ${{ steps.committer.outputs.token }}
117118

@@ -258,6 +259,7 @@ jobs:
258259
env:
259260
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
260261
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
262+
OPENCODE_RELEASE_NOTES: ${{ (github.ref_name == 'dev' && inputs.release_notes) || '' }}
261263

262264
- name: Verify service lifecycle
263265
if: matrix.settings.target != 'windows-arm64'
Collapse file

‎packages/cli/script/build-node.ts‎

Copy file name to clipboardExpand all lines: packages/cli/script/build-node.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import os from "node:os"
77
import path from "node:path"
88
import { build } from "vite"
99
import { Script } from "@opencode/script"
10+
import { embed } from "@opencode/script/highlights"
1011
import pkg from "../package.json"
1112
import { collectNodeAssets, copyNodeAssets, hashNodeAssets, seaAssetMap } from "./node-assets"
1213
import { appArchiveAsset, mainConfig } from "../vite.node.config"
@@ -28,6 +29,7 @@ const bundleOnly = process.argv.includes("--bundle-only")
2829
const single = process.argv.includes("--single")
2930
const skipInstall = process.argv.includes("--skip-install")
3031
const appArchiveOnly = process.argv.includes("--app-archive-only")
32+
const highlights = Script.preview ? undefined : embed(process.env.OPENCODE_RELEASE_NOTES)
3133
const requestedArchive = process.argv.find((arg) => arg.startsWith("--app-archive="))?.slice("--app-archive=".length)
3234
const archivePath = requestedArchive ? path.resolve(dir, requestedArchive) : undefined
3335
const requested = process.argv.find((arg) => arg.startsWith("--target="))?.slice("--target=".length)
@@ -93,6 +95,7 @@ for (const target of targets) {
9395
const input = {
9496
version: Script.version,
9597
channel: Script.channel,
98+
highlights,
9699
assetHash,
97100
target,
98101
}
Collapse file

‎packages/cli/script/build.ts‎

Copy file name to clipboardExpand all lines: packages/cli/script/build.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { $ } from "bun"
44
import { mkdir, rm } from "fs/promises"
55
import path from "path"
66
import { Script } from "@opencode/script"
7+
import { embed } from "@opencode/script/highlights"
78
import { createSolidTransformPlugin } from "@opentui/solid/bun-plugin"
89
import type { BunPlugin } from "bun"
910
import pkg from "../package.json"
@@ -29,6 +30,7 @@ const requestedTarget = process.argv.find((arg) => arg.startsWith("--target="))?
2930
const skipInstall = process.argv.includes("--skip-install")
3031
const skipWebUi = process.argv.includes("--skip-web-ui")
3132
const solidPlugin = createSolidTransformPlugin()
33+
const highlights = Script.preview ? undefined : embed(process.env.OPENCODE_RELEASE_NOTES)
3234
const releaseAssets = new Map<string, Promise<Map<string, string>>>()
3335

3436
const allTargets: {
@@ -189,6 +191,7 @@ export default { path: file, version: ${JSON.stringify(opencodePty.version)}, sh
189191
OPENCODE_CLI_NAME: "'opencode'",
190192
OPENCODE_CHANNEL: `'${Script.channel}'`,
191193
OPENCODE_ARTIFACT: `'cli'`,
194+
...(highlights ? { OPENCODE_RELEASE_HIGHLIGHTS: JSON.stringify(highlights) } : {}),
192195
OPENCODE_LIBC: item.os === "linux" ? `'${item.abi ?? "glibc"}'` : "undefined",
193196
// FFF_LIBC selects the fff native lib variant: "musl" or "gnu".
194197
FFF_LIBC: item.os === "linux" ? `'${item.abi ?? "gnu"}'` : "undefined",
Collapse file

‎packages/cli/src/commands/handlers/default.ts‎

Copy file name to clipboardExpand all lines: packages/cli/src/commands/handlers/default.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ServerConnection } from "../../services/server-connection"
99
import { Updater } from "../../services/updater"
1010
import { UpdatePreflight } from "../../services/update-preflight"
1111
import { Npm } from "@opencode/util/npm"
12-
import { OPENCODE_ARTIFACT, OPENCODE_CHANNEL, OPENCODE_VERSION } from "../../version"
12+
import { OPENCODE_ARTIFACT, OPENCODE_CHANNEL, OPENCODE_HIGHLIGHTS, OPENCODE_VERSION } from "../../version"
1313
import { Env } from "../../env"
1414
import { Service } from "@opencode/client/effect/service"
1515
import { OpenCode } from "@opencode/client/promise"
@@ -98,6 +98,7 @@ export default Runtime.handler(Commands, (input) =>
9898
name: process.env.OPENCODE_CLIENT ?? OPENCODE_ARTIFACT,
9999
version: OPENCODE_VERSION,
100100
channel: process.env.OPENCODE_TUI_CHANNEL ?? OPENCODE_CHANNEL,
101+
highlights: OPENCODE_HIGHLIGHTS,
101102
},
102103
server: {
103104
endpoint: server.endpoint,
Collapse file

‎packages/cli/src/version.ts‎

Copy file name to clipboard
+19-1Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
import { Option, Schema } from "effect"
2+
13
declare const OPENCODE_VERSION: string
24
declare const OPENCODE_CHANNEL: string
35
declare const OPENCODE_ARTIFACT: string
6+
declare const OPENCODE_RELEASE_HIGHLIGHTS: string
47

58
const version = typeof OPENCODE_VERSION === "string" ? OPENCODE_VERSION : "local"
69
const channel = typeof OPENCODE_CHANNEL === "string" ? OPENCODE_CHANNEL : "local"
710
const artifact = typeof OPENCODE_ARTIFACT === "string" ? OPENCODE_ARTIFACT : "cli"
11+
// Stable release builds embed the release notes' Highlights; every other build has none.
12+
const highlights =
13+
typeof OPENCODE_RELEASE_HIGHLIGHTS === "string"
14+
? Option.getOrElse(
15+
Schema.decodeUnknownOption(
16+
Schema.fromJsonString(Schema.Array(Schema.Struct({ title: Schema.String, body: Schema.String }))),
17+
)(OPENCODE_RELEASE_HIGHLIGHTS),
18+
() => [],
19+
)
20+
: []
821

9-
export { version as OPENCODE_VERSION, channel as OPENCODE_CHANNEL, artifact as OPENCODE_ARTIFACT }
22+
export {
23+
version as OPENCODE_VERSION,
24+
channel as OPENCODE_CHANNEL,
25+
artifact as OPENCODE_ARTIFACT,
26+
highlights as OPENCODE_HIGHLIGHTS,
27+
}
1028
export const OPENCODE_LOCAL = channel === "local"
Collapse file

‎packages/cli/vite.node.config.ts‎

Copy file name to clipboardExpand all lines: packages/cli/vite.node.config.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ if (process.platform === "linux") process.env.OPENTUI_LIBC = "glibc"`
251251
export type NodeBuildInput = {
252252
readonly version: string
253253
readonly channel: string
254+
readonly highlights?: string
254255
readonly assetHash: string
255256
readonly target: NodeTarget
256257
}
@@ -278,6 +279,7 @@ export function mainConfig(input: NodeBuildInput): UserConfig {
278279
OPENCODE_CLI_NAME: JSON.stringify("opencode2-node"),
279280
OPENCODE_CHANNEL: JSON.stringify(input.channel),
280281
OPENCODE_ARTIFACT: JSON.stringify("cli-node"),
282+
...(input.highlights ? { OPENCODE_RELEASE_HIGHLIGHTS: JSON.stringify(input.highlights) } : {}),
281283
OPENCODE_LIBC: input.target.platform === "linux" ? JSON.stringify("glibc") : "undefined",
282284
FFF_LIBC: input.target.platform === "linux" ? JSON.stringify("gnu") : "undefined",
283285
"process.env.WS_NO_BUFFER_UTIL": JSON.stringify("1"),
Collapse file

‎packages/script/package.json‎

Copy file name to clipboardExpand all lines: packages/script/package.json
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"name": "@opencode/script",
44
"type": "module",
55
"license": "MIT",
6+
"scripts": {
7+
"test": "bun test"
8+
},
69
"dependencies": {
710
"semver": "^7.6.3"
811
},
@@ -11,6 +14,7 @@
1114
"@types/semver": "^7.5.8"
1215
},
1316
"exports": {
14-
".": "./src/index.ts"
17+
".": "./src/index.ts",
18+
"./highlights": "./src/highlights.ts"
1519
}
1620
}
Collapse file

‎packages/script/src/highlights.ts‎

Copy file name to clipboard
+68Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
export type Highlight = { title: string; body: string }
2+
3+
const LIMIT = { items: 5, title: 60, body: 300 }
4+
5+
/**
6+
* Extracts the `### Highlights` bullets from reviewed release notes. Each bullet is expected to look like
7+
* `- **Title**: One or two sentences. ([#123](https://github.com/...))`; trailing pull request links are dropped and
8+
* inline Markdown is reduced to plain text, keeping backticks for code spans. Problems are reported instead of thrown
9+
* so a formatting mistake never fails a release build.
10+
*/
11+
export function parse(notes: string) {
12+
const problems: string[] = []
13+
const lines = notes.replace(/\r\n/g, "\n").split("\n")
14+
const start = lines.findIndex((line) => /^###\s+Highlights\s*$/i.test(line.trim()))
15+
if (start === -1) return { items: [] as Highlight[], problems }
16+
const end = lines.findIndex((line, index) => index > start && /^#{1,3}\s/.test(line))
17+
const bullets = lines.slice(start + 1, end === -1 ? undefined : end).reduce(
18+
(state, line) => {
19+
if (line.trim().startsWith("```")) return { ...state, fenced: !state.fenced }
20+
if (state.fenced) return state
21+
const bullet = line.match(/^[-*]\s+(.*)$/)
22+
if (bullet) return { ...state, items: [...state.items, bullet[1]] }
23+
if (state.items.length && /^\s+\S/.test(line))
24+
return { ...state, items: [...state.items.slice(0, -1), `${state.items.at(-1)} ${line.trim()}`] }
25+
return state
26+
},
27+
{ fenced: false, items: [] as string[] },
28+
).items
29+
30+
const items = bullets.flatMap((bullet) => {
31+
const match = bullet.match(/^\*\*(.+?)\*\*:?\s*(.*)$/)
32+
const title = match && plain(match[1].replace(/:$/, ""))
33+
const body = match && plain(match[2].replace(/\s*\((?:\[[^\]]*\]\([^)]*\)(?:,\s*)?)+\)\s*$/, ""))
34+
if (!title || !body) {
35+
problems.push(`Skipped a highlight without a bold title and description: ${bullet.slice(0, 80)}`)
36+
return []
37+
}
38+
return [{ title: truncate(title, LIMIT.title), body: truncate(body, LIMIT.body) }]
39+
})
40+
41+
if (items.length > LIMIT.items) problems.push(`Kept the first ${LIMIT.items} of ${items.length} highlights`)
42+
if (!items.length) problems.push("The Highlights section has no highlights in the expected format")
43+
return { items: items.slice(0, LIMIT.items), problems }
44+
}
45+
46+
function plain(value: string) {
47+
return value
48+
.replace(/\*\*(.+?)\*\*/g, "$1")
49+
.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")
50+
.replace(/\s+/g, " ")
51+
.trim()
52+
}
53+
54+
function truncate(value: string, limit: number) {
55+
if (value.length <= limit) return value
56+
const cut = value.slice(0, limit - 1)
57+
const space = cut.lastIndexOf(" ")
58+
return `${(space > limit / 2 ? cut.slice(0, space) : cut).trimEnd()}…`
59+
}
60+
61+
/** Returns the JSON a stable release build embeds as `OPENCODE_RELEASE_HIGHLIGHTS`, warning about malformed notes. */
62+
export function embed(notes: string | undefined) {
63+
if (!notes?.trim()) return
64+
const result = parse(notes)
65+
result.problems.forEach((problem) => console.warn(`release highlights: ${problem}`))
66+
if (!result.items.length) return
67+
return JSON.stringify(result.items)
68+
}
Collapse file

‎packages/script/test/highlights.test.ts‎

Copy file name to clipboard
+80Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { describe, expect, test } from "bun:test"
2+
import path from "path"
3+
import { parse } from "../src/highlights"
4+
5+
describe("highlights", () => {
6+
test("parses the v2.0.27 release notes", async () => {
7+
const changelog = await Bun.file(path.resolve(import.meta.dir, "../../../CHANGELOG.md")).text()
8+
const notes = changelog.split(/^## v2\.0\.27 .*$/m)[1].split(/^## /m)[0]
9+
const result = parse(notes)
10+
11+
expect(result.problems).toEqual([])
12+
expect(result.items.map((item) => item.title)).toEqual([
13+
"Built-In Worktree Tools",
14+
"Safer Remote Pairing",
15+
"Installable Web App",
16+
"Clear Session Failures",
17+
"Automatic Project Cleanup",
18+
])
19+
expect(result.items[0].body).toBe(
20+
"Ask OpenCode to use `worktree_create`, `worktree_list`, and `worktree_remove` in Code Mode. You can create " +
21+
"isolated worktrees, move sessions into them, and remove them with normal edit approval.",
22+
)
23+
expect(result.items[2].body).toBe(
24+
"Use Chrome or Edge’s Install button to install the OpenCode web app, including when it runs behind an " +
25+
"authenticating proxy.",
26+
)
27+
expect(result.items.some((item) => item.body.includes("github.com") || item.body.includes("(["))).toBe(false)
28+
})
29+
30+
test("joins wrapped lines and drops multiple trailing links", () => {
31+
const result = parse(
32+
[
33+
"### Highlights",
34+
"",
35+
"- **Reopen Closed Tabs:** Right-click the new-session button to bring back a session you closed by",
36+
" mistake. ([#123](https://github.com/anomalyco/opencode/pull/123), [#124](https://github.com/anomalyco/opencode/pull/124))",
37+
"* **Faster [Search](https://example.com)**: Results now stream in.",
38+
"",
39+
"### Core",
40+
"",
41+
"- **Not a Highlight**: Ignored.",
42+
].join("\n"),
43+
)
44+
45+
expect(result).toEqual({
46+
items: [
47+
{
48+
title: "Reopen Closed Tabs",
49+
body: "Right-click the new-session button to bring back a session you closed by mistake.",
50+
},
51+
{ title: "Faster Search", body: "Results now stream in." },
52+
],
53+
problems: [],
54+
})
55+
})
56+
57+
test("returns nothing without a Highlights section", () => {
58+
expect(parse("### Core\n\n- Fixed a bug.")).toEqual({ items: [], problems: [] })
59+
})
60+
61+
test("reports malformed highlights instead of failing", () => {
62+
const result = parse("### Highlights\n\n- Plain bullet without a title.\n")
63+
expect(result.items).toEqual([])
64+
expect(result.problems).toHaveLength(2)
65+
})
66+
67+
test("limits the number and length of highlights", () => {
68+
const result = parse(
69+
[
70+
"### Highlights",
71+
...Array.from({ length: 7 }, (_, index) => `- **Item ${index}**: ${"word ".repeat(100)}`),
72+
].join("\n"),
73+
)
74+
75+
expect(result.items).toHaveLength(5)
76+
expect(result.items[0].body.length).toBeLessThanOrEqual(300)
77+
expect(result.items[0].body.endsWith("…")).toBe(true)
78+
expect(result.problems).toEqual(["Kept the first 5 of 7 highlights"])
79+
})
80+
})
Collapse file

‎packages/tui/src/app.tsx‎

Copy file name to clipboardExpand all lines: packages/tui/src/app.tsx
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { existsSync } from "fs"
2+
import path from "path"
13
import { render, useRenderer, useTerminalDimensions } from "@opentui/solid"
24
import { registerOpencodeSpinner } from "./component/register-spinner"
35
import { Effect, Latch } from "effect"
@@ -37,6 +39,7 @@ import {
3739
TuiStartupProvider,
3840
TuiTerminalEnvironmentProvider,
3941
useTuiApp,
42+
useTuiPaths,
4043
useTuiStartup,
4144
useTuiTerminalEnvironment,
4245
type TuiApp,
@@ -64,6 +67,8 @@ import { DialogStatus } from "./component/dialog-status"
6467
import { DialogConfig } from "./component/dialog-config"
6568
import { DialogDebug } from "./component/dialog-debug"
6669
import { DialogPair } from "./component/dialog-pair"
70+
import { DialogHighlights } from "./component/dialog-highlights"
71+
import { claim } from "./util/highlights"
6772
import { DialogThemeList } from "./component/dialog-theme-list"
6873
import { DialogHelp } from "./ui/dialog-help"
6974
import { DialogAgent } from "./component/dialog-agent"
@@ -685,6 +690,30 @@ function App() {
685690
.catch(toast.error)
686691
})
687692

693+
// Opens the release highlights once after an update, but only into an idle home screen during startup.
694+
const storage = useStorage()
695+
const paths = useTuiPaths()
696+
let highlighted = false
697+
createEffect(() => {
698+
if (highlighted || !plugins.ready() || client.connection.status() !== "connected") return
699+
highlighted = true
700+
const items = app.highlights ?? []
701+
if (config.data.highlights === false) return
702+
if (route.data.type !== "home" || dialog.stack.length > 0 || promptRef.current?.current.text) return
703+
if (args.prompt || args.continue || args.sessionID || args.newSessionID) return
704+
if (process.env.OPENCODE_DRIVE || process.env.OPENCODE_STORY || process.env.OPENCODE_ROUTE) return
705+
void claim(storage, {
706+
version: app.version,
707+
count: items.length,
708+
history: existsSync(path.join(paths.state, "prompt-history.jsonl")),
709+
})
710+
.then((show) => {
711+
if (show && dialog.stack.length === 0)
712+
dialog.replace(() => <DialogHighlights version={app.version} items={items} />)
713+
})
714+
.catch(toast.error)
715+
})
716+
688717
const connected = useConnected()
689718
const appCommands = createMemo(() =>
690719
[
@@ -957,6 +986,17 @@ function App() {
957986
},
958987
category: "Integration",
959988
},
989+
...(app.highlights?.length
990+
? [
991+
{
992+
name: "opencode.highlights",
993+
title: "Show release highlights",
994+
slash: { name: "highlights" },
995+
run: () => dialog.replace(() => <DialogHighlights version={app.version} items={app.highlights ?? []} />),
996+
category: "System",
997+
},
998+
]
999+
: []),
9601000
{
9611001
name: "opencode.settings",
9621002
title: "Open settings",

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.