From 846446935e46403bc780676f6c9c067afa377014 Mon Sep 17 00:00:00 2001 From: Test User Date: Sun, 18 Oct 2026 22:58:26 +0200 Subject: [PATCH 1/2] fix(nix): preserve root dependency peer context Include the root alongside the existing workspace filters instead of merging incompatible Bun store entries. Refs #56856 --- CHANGELOG.md | 8 +++ nix/hashes.json | 2 +- nix/node_modules.nix | 3 +- nix/scripts/dependency-identity.test.ts | 77 +++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 nix/scripts/dependency-identity.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index e46b86ac889e..afeecc439017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ Release notes for OpenCode V2, newest first. +## Unreleased + +### Packaging + +#### Bug fixes + +- Include root dependencies in Nix installs to preserve OpenTUI module identity and prevent TUI startup color crashes. ([#56856](https://github.com/anomalyco/opencode/issues/56856)) + ## v2.0.32 — 2026-10-16 ### Highlights diff --git a/nix/hashes.json b/nix/hashes.json index 93c0017ba805..3c38aae59289 100644 --- a/nix/hashes.json +++ b/nix/hashes.json @@ -1,6 +1,6 @@ { "nodeModules": { - "x86_64-linux": "sha256-+8y80I7VLJUQccgqfM+eCHKcBuEBK/3uSZj3rPFswJs=", + "x86_64-linux": "sha256-WU71OJbvZSJqHXiU8xcEw34SQWOs7z/IyZn0tGYJ4yQ=", "aarch64-linux": "sha256-2zC/QoS1hteGE14dGgp0Iv/wet5ZhmWCYBzn/SjyMA0=", "aarch64-darwin": "sha256-wp7gmpBJfpKCxFAOCqjbhVwB7oUNcn/u4XiipydnEy8=" } diff --git a/nix/node_modules.nix b/nix/node_modules.nix index 00a6d1a149ca..9c1a32f4fea0 100644 --- a/nix/node_modules.nix +++ b/nix/node_modules.nix @@ -49,10 +49,11 @@ stdenvNoCC.mkDerivation { buildPhase = '' runHook preBuild export BUN_INSTALL_CACHE_DIR=$(mktemp -d) + # Include root dependencies so Bun resolves the same peer contexts as a normal install. bun install \ --cpu="${bunCpu}" \ --os="${bunOs}" \ - --filter '!./' \ + --filter './' \ --filter './packages/cli' \ --filter './packages/desktop' \ --filter './packages/app' \ diff --git a/nix/scripts/dependency-identity.test.ts b/nix/scripts/dependency-identity.test.ts new file mode 100644 index 000000000000..e5b2e7b50e10 --- /dev/null +++ b/nix/scripts/dependency-identity.test.ts @@ -0,0 +1,77 @@ +import { expect, test } from "bun:test" +import { lstat, readdir, readlink, realpath } from "node:fs/promises" +import { dirname, isAbsolute, join } from "node:path" +import { migrateV1, resolveThemeDocument } from "../../packages/theme/src/tui/index.js" +import type { ThemeV1Json } from "../../packages/theme/src/tui/v1.js" +import { createColors, deriveInactiveColor, deriveTrailColors } from "../../packages/tui/src/ui/spinner.js" + +const root = join(import.meta.dir, "../..") +const source: ThemeV1Json = await Bun.file(join(root, "packages/tui/src/theme/assets/opencode.json")).json() + +// Run against the installed Nix dependency tree, including after relocation. +test.each(["light", "dark"] as const)("theme colors survive spinner conversion in %s mode", (mode) => { + const color = resolveThemeDocument(migrateV1(source), mode).hue.accent[800] + const trail = deriveTrailColors(color) + expect([trail[0].r, trail[0].g, trail[0].b, trail[0].a]).toEqual([color.r, color.g, color.b, 1]) + const inactive = deriveInactiveColor(color, 0.2) + expect([inactive.r, inactive.g, inactive.b]).toEqual([color.r, color.g, color.b]) + expect(inactive.a).toBeCloseTo(0.2, 2) + const frame = createColors({ colors: [color], defaultColor: color, enableFading: false })(0, 7, 54, 8) + expect(frame).toEqual(color) +}) + +test("OpenTUI consumers resolve one runtime entrypoint", async () => { + const paths = await Promise.all( + ["theme", "tui", "cli", "merman", "latex", "plugin", "simulation"].map((workspace) => + realpath(Bun.resolveSync("@opentui/core", join(root, "packages", workspace))), + ), + ) + expect(new Set(paths).size).toBe(1) + const solid = Bun.resolveSync("@opentui/solid", join(root, "packages/tui")) + const spinner = Bun.resolveSync("opentui-spinner", join(root, "packages/tui")) + expect(await realpath(Bun.resolveSync("@opentui/core", dirname(solid)))).toBe(paths[0]) + expect(await realpath(Bun.resolveSync("@opentui/core", dirname(spinner)))).toBe(paths[0]) +}) + +test.each([ + ["@ai-sdk/provider-utils", "zod"], + ["@opentelemetry/core", "@opentelemetry/api"], +])("%s retains incompatible %s peer contexts", async (name, peer) => { + const store = join(root, "node_modules/.bun") + const entries = (await readdir(store)).filter((entry) => entry.startsWith(name.replaceAll("/", "+") + "@")) + const contexts = new Map>() + for (const entry of entries) { + const dir = join(store, entry, "node_modules", name) + const manifest = await Bun.file(join(dir, "package.json")).json() + const dependency = await realpath(Bun.resolveSync(peer + "/package.json", dir)) + const versions = contexts.get(manifest.version) ?? new Set() + versions.add((await Bun.file(dependency).json()).version) + contexts.set(manifest.version, versions) + } + expect([...contexts.values()].some((versions) => versions.size > 1)).toBe(true) +}) + +test("installed dependency links remain relative and internal after copying", async () => { + const store = join(root, "node_modules/.bun") + const modules = [ + join(root, "node_modules"), + ...(await readdir(store)).filter((entry) => entry !== "node_modules").map((entry) => join(store, entry, "node_modules")), + join(store, "node_modules"), + ...["theme", "tui", "cli", "merman", "latex", "plugin", "simulation"].map((name) => + join(root, "packages", name, "node_modules"), + ), + ] + for (const dir of modules) { + for (const entry of await readdir(dir, { withFileTypes: true })) { + const path = join(dir, entry.name) + const paths = entry.name.startsWith("@") && entry.isDirectory() + ? (await readdir(path)).map((name) => join(path, name)) + : [path] + for (const link of paths) { + if (!(await lstat(link)).isSymbolicLink()) continue + expect(isAbsolute(await readlink(link))).toBe(false) + expect(await realpath(link)).toStartWith(root + "/") + } + } + } +}) From 1c43d4bded8a885010701ae31cbe19ee8a9840da Mon Sep 17 00:00:00 2001 From: Test User Date: Sun, 18 Oct 2026 23:22:20 +0200 Subject: [PATCH 2/2] chore(nix): narrow startup crash fix Leave changelog generation to the release script and remove the install-specific test outside the CI workspace graph. --- CHANGELOG.md | 8 --- nix/scripts/dependency-identity.test.ts | 77 ------------------------- 2 files changed, 85 deletions(-) delete mode 100644 nix/scripts/dependency-identity.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index afeecc439017..e46b86ac889e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,6 @@ Release notes for OpenCode V2, newest first. -## Unreleased - -### Packaging - -#### Bug fixes - -- Include root dependencies in Nix installs to preserve OpenTUI module identity and prevent TUI startup color crashes. ([#56856](https://github.com/anomalyco/opencode/issues/56856)) - ## v2.0.32 — 2026-10-16 ### Highlights diff --git a/nix/scripts/dependency-identity.test.ts b/nix/scripts/dependency-identity.test.ts deleted file mode 100644 index e5b2e7b50e10..000000000000 --- a/nix/scripts/dependency-identity.test.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { expect, test } from "bun:test" -import { lstat, readdir, readlink, realpath } from "node:fs/promises" -import { dirname, isAbsolute, join } from "node:path" -import { migrateV1, resolveThemeDocument } from "../../packages/theme/src/tui/index.js" -import type { ThemeV1Json } from "../../packages/theme/src/tui/v1.js" -import { createColors, deriveInactiveColor, deriveTrailColors } from "../../packages/tui/src/ui/spinner.js" - -const root = join(import.meta.dir, "../..") -const source: ThemeV1Json = await Bun.file(join(root, "packages/tui/src/theme/assets/opencode.json")).json() - -// Run against the installed Nix dependency tree, including after relocation. -test.each(["light", "dark"] as const)("theme colors survive spinner conversion in %s mode", (mode) => { - const color = resolveThemeDocument(migrateV1(source), mode).hue.accent[800] - const trail = deriveTrailColors(color) - expect([trail[0].r, trail[0].g, trail[0].b, trail[0].a]).toEqual([color.r, color.g, color.b, 1]) - const inactive = deriveInactiveColor(color, 0.2) - expect([inactive.r, inactive.g, inactive.b]).toEqual([color.r, color.g, color.b]) - expect(inactive.a).toBeCloseTo(0.2, 2) - const frame = createColors({ colors: [color], defaultColor: color, enableFading: false })(0, 7, 54, 8) - expect(frame).toEqual(color) -}) - -test("OpenTUI consumers resolve one runtime entrypoint", async () => { - const paths = await Promise.all( - ["theme", "tui", "cli", "merman", "latex", "plugin", "simulation"].map((workspace) => - realpath(Bun.resolveSync("@opentui/core", join(root, "packages", workspace))), - ), - ) - expect(new Set(paths).size).toBe(1) - const solid = Bun.resolveSync("@opentui/solid", join(root, "packages/tui")) - const spinner = Bun.resolveSync("opentui-spinner", join(root, "packages/tui")) - expect(await realpath(Bun.resolveSync("@opentui/core", dirname(solid)))).toBe(paths[0]) - expect(await realpath(Bun.resolveSync("@opentui/core", dirname(spinner)))).toBe(paths[0]) -}) - -test.each([ - ["@ai-sdk/provider-utils", "zod"], - ["@opentelemetry/core", "@opentelemetry/api"], -])("%s retains incompatible %s peer contexts", async (name, peer) => { - const store = join(root, "node_modules/.bun") - const entries = (await readdir(store)).filter((entry) => entry.startsWith(name.replaceAll("/", "+") + "@")) - const contexts = new Map>() - for (const entry of entries) { - const dir = join(store, entry, "node_modules", name) - const manifest = await Bun.file(join(dir, "package.json")).json() - const dependency = await realpath(Bun.resolveSync(peer + "/package.json", dir)) - const versions = contexts.get(manifest.version) ?? new Set() - versions.add((await Bun.file(dependency).json()).version) - contexts.set(manifest.version, versions) - } - expect([...contexts.values()].some((versions) => versions.size > 1)).toBe(true) -}) - -test("installed dependency links remain relative and internal after copying", async () => { - const store = join(root, "node_modules/.bun") - const modules = [ - join(root, "node_modules"), - ...(await readdir(store)).filter((entry) => entry !== "node_modules").map((entry) => join(store, entry, "node_modules")), - join(store, "node_modules"), - ...["theme", "tui", "cli", "merman", "latex", "plugin", "simulation"].map((name) => - join(root, "packages", name, "node_modules"), - ), - ] - for (const dir of modules) { - for (const entry of await readdir(dir, { withFileTypes: true })) { - const path = join(dir, entry.name) - const paths = entry.name.startsWith("@") && entry.isDirectory() - ? (await readdir(path)).map((name) => join(path, name)) - : [path] - for (const link of paths) { - if (!(await lstat(link)).isSymbolicLink()) continue - expect(isAbsolute(await readlink(link))).toBe(false) - expect(await realpath(link)).toStartWith(root + "/") - } - } - } -})