mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 17:01:37 +03:00
fix(app): show the server's release in the web About page (#61965)
This commit is contained in:
committed by
GitHub
Unverified
parent
a4ce0b0989
commit
19ad73bfe0
@@ -49,7 +49,8 @@ const clearAuthToken = () => {
|
||||
history.replaceState(null, "", location.pathname + (params.size ? `?${params}` : "") + location.hash)
|
||||
}
|
||||
|
||||
const web = createWebPlatform(pkg.version)
|
||||
// package.json carries the last stable version on every channel, so the server's build passes its own release.
|
||||
const web = createWebPlatform(import.meta.env.VITE_OPENCODE_VERSION ?? pkg.version)
|
||||
|
||||
if (import.meta.env.PROD && "serviceWorker" in navigator) {
|
||||
window.addEventListener("load", () => void navigator.serviceWorker.register("/sw.js"), { once: true })
|
||||
|
||||
Vendored
+2
@@ -3,6 +3,8 @@ interface ImportMetaEnv {
|
||||
readonly VITE_OPENCODE_SERVER_HOST: string
|
||||
readonly VITE_OPENCODE_SERVER_PORT: string
|
||||
readonly VITE_OPENCODE_CHANNEL?: "local" | "dev" | "beta" | "prod"
|
||||
/** The release of the CLI whose server embeds this build. Absent in the hosted web app. */
|
||||
readonly VITE_OPENCODE_VERSION?: string
|
||||
|
||||
readonly VITE_SENTRY_DSN?: string
|
||||
readonly VITE_SENTRY_ENVIRONMENT?: string
|
||||
|
||||
@@ -5,12 +5,15 @@ import { brotliCompress, constants } from "node:zlib"
|
||||
import { AppArchive } from "../src/app-archive"
|
||||
import { collectFiles } from "./files"
|
||||
|
||||
export async function buildAppArchive(channel: string, options?: { skipBuild?: boolean }) {
|
||||
export async function buildAppArchive(channel: string, version: string, options?: { skipBuild?: boolean }) {
|
||||
if (options?.skipBuild) return AppArchive.encode([])
|
||||
const root = path.resolve(import.meta.dirname, "../../app")
|
||||
await $`bun run build`
|
||||
.cwd(root)
|
||||
.env({ ...process.env, OPENCODE_CHANNEL: channel, VITE_OPENCODE_SERVER_MODE: "origin" })
|
||||
await $`bun run build`.cwd(root).env({
|
||||
...process.env,
|
||||
OPENCODE_CHANNEL: channel,
|
||||
VITE_OPENCODE_SERVER_MODE: "origin",
|
||||
VITE_OPENCODE_VERSION: version,
|
||||
})
|
||||
return AppArchive.encode(
|
||||
await Promise.all(
|
||||
(await collectFiles(path.join(root, "dist")))
|
||||
|
||||
@@ -53,7 +53,7 @@ if (!skipInstall) run(process.execPath, ["install", "--os=*", "--cpu=*"])
|
||||
if (appArchiveOnly) {
|
||||
if (!archivePath) throw new Error("--app-archive-only requires OPENCODE_APP_ARCHIVE")
|
||||
await mkdir(path.dirname(archivePath), { recursive: true })
|
||||
await writeFile(archivePath, await buildAppArchive(Script.channel))
|
||||
await writeFile(archivePath, await buildAppArchive(Script.channel, Script.version))
|
||||
process.exit(0)
|
||||
}
|
||||
if (targets.length === 0) {
|
||||
@@ -64,7 +64,7 @@ if (!bundleOnly && targets.some((target) => target.platform === "darwin" && targ
|
||||
throw new Error("Node 26.4 SEA does not support macOS x64")
|
||||
}
|
||||
const modelsSnapshot = await bundledModelsSnapshot()
|
||||
const appArchive = archivePath ? await Bun.file(archivePath).bytes() : await buildAppArchive(Script.channel)
|
||||
const appArchive = archivePath ? await Bun.file(archivePath).bytes() : await buildAppArchive(Script.channel, Script.version)
|
||||
if (!bundleOnly) await rm(outdir, { recursive: true, force: true })
|
||||
const builder =
|
||||
!bundleOnly || targets.some((target) => target.platform === process.platform && target.arch === process.arch)
|
||||
|
||||
@@ -73,7 +73,7 @@ if (!targets.length) throw new Error(`Unknown build target: ${requestedTarget}`)
|
||||
if (!skipInstall)
|
||||
await $`bun install --os="*" --cpu="*" --libc="*" @opentui/core@${pkg.dependencies["@opentui/core"]} @opencode/pty@${pkg.dependencies["@opencode/pty"]}`
|
||||
const appArchive = path.join(dir, ".cache", "bun-app-archive.bin")
|
||||
await Bun.write(appArchive, await buildAppArchive(Script.channel, { skipBuild: skipWebUi }))
|
||||
await Bun.write(appArchive, await buildAppArchive(Script.channel, Script.version, { skipBuild: skipWebUi }))
|
||||
const appAssetsPlugin: BunPlugin = {
|
||||
name: "opencode-app-assets",
|
||||
setup(build) {
|
||||
|
||||
Reference in New Issue
Block a user