Skip to content

Commit 3f075a7

Browse files
Cheticclaude
andcommitted
feat: display offline bundle version in TUI
Read bundleVersion from manifest.json in offline mode and display it as "offline-v{N}" in the TUI instead of the build version. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bfc10c9 commit 3f075a7

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

packages/opencode/src/cli/cmd/tui/routes/home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function Home() {
132132
</box>
133133
<box flexGrow={1} />
134134
<box flexShrink={0}>
135-
<text fg={theme.textMuted}>{Installation.VERSION}</text>
135+
<text fg={theme.textMuted}>{Installation.DISPLAY_VERSION}</text>
136136
</box>
137137
</box>
138138
</>

packages/opencode/src/cli/cmd/tui/routes/session/header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function Header() {
116116
<box flexGrow={1} flexShrink={1} />
117117
<box flexDirection="row" gap={1} flexShrink={0}>
118118
<ContextInfo context={context} cost={cost} />
119-
<text fg={theme.textMuted}>v{Installation.VERSION}</text>
119+
<text fg={theme.textMuted}>{Installation.DISPLAY_VERSION}</text>
120120
</box>
121121
</box>
122122
</Match>
@@ -125,7 +125,7 @@ export function Header() {
125125
<Title session={session} />
126126
<box flexDirection="row" gap={1} flexShrink={0}>
127127
<ContextInfo context={context} cost={cost} />
128-
<text fg={theme.textMuted}>v{Installation.VERSION}</text>
128+
<text fg={theme.textMuted}>{Installation.DISPLAY_VERSION}</text>
129129
</box>
130130
</box>
131131
</Match>

packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
303303
<span style={{ fg: theme.text }}>
304304
<b>Code</b>
305305
</span>{" "}
306-
<span>{Installation.VERSION}</span>
306+
<span>{Installation.DISPLAY_VERSION}</span>
307307
</text>
308308
</box>
309309
</box>

packages/opencode/src/installation/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
import { BusEvent } from "@/bus/bus-event"
22
import path from "path"
3+
import fs from "fs"
34
import { $ } from "bun"
45
import z from "zod"
56
import { NamedError } from "@opencode-ai/util/error"
67
import { Log } from "../util/log"
78
import { iife } from "@/util/iife"
89
import { Flag } from "../flag/flag"
910

11+
function readBundleVersion(): string | undefined {
12+
if (!Flag.OPENCODE_OFFLINE_DEPS_PATH) return undefined
13+
try {
14+
// The manifest is in the parent directory of deps (bundle root)
15+
const bundleRoot = path.dirname(Flag.OPENCODE_OFFLINE_DEPS_PATH)
16+
const manifestPath = path.join(bundleRoot, "manifest.json")
17+
const content = fs.readFileSync(manifestPath, "utf-8")
18+
const manifest = JSON.parse(content)
19+
return manifest.bundleVersion
20+
} catch {
21+
return undefined
22+
}
23+
}
24+
1025
declare global {
1126
const OPENCODE_VERSION: string
1227
const OPENCODE_CHANNEL: string
@@ -183,6 +198,9 @@ export namespace Installation {
183198
export const CHANNEL = typeof OPENCODE_CHANNEL === "string" ? OPENCODE_CHANNEL : "local"
184199
export const USER_AGENT = `opencode/${CHANNEL}/${VERSION}/${Flag.OPENCODE_CLIENT}`
185200

201+
const BUNDLE_VERSION = readBundleVersion()
202+
export const DISPLAY_VERSION = BUNDLE_VERSION ? `offline-v${BUNDLE_VERSION}` : VERSION
203+
186204
export async function latest(installMethod?: Method) {
187205
const detectedMethod = installMethod || (await method())
188206

0 commit comments

Comments
 (0)