From b53db1b07c38f2444103245853d34a22c0de2d87 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Sun, 8 Mar 2026 17:27:52 -0400 Subject: [PATCH 1/2] fix: always use single database (opencode.db) Remove channel-specific database logic to prevent surprise empty databases in dev mode. Always use opencode.db regardless of channel. This reverts the behavior to always use a single shared database. --- packages/opencode/src/storage/db.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/opencode/src/storage/db.ts b/packages/opencode/src/storage/db.ts index cd920a8907c5..3c87c621de5c 100644 --- a/packages/opencode/src/storage/db.ts +++ b/packages/opencode/src/storage/db.ts @@ -12,9 +12,7 @@ import z from "zod" import path from "path" import { readFileSync, readdirSync, existsSync } from "fs" import * as schema from "./schema" -import { Installation } from "../installation" import { Flag } from "../flag/flag" -import { iife } from "@/util/iife" declare const OPENCODE_MIGRATIONS: { sql: string; timestamp: number; name: string }[] | undefined @@ -28,13 +26,7 @@ export const NotFoundError = NamedError.create( const log = Log.create({ service: "db" }) export namespace Database { - export const Path = iife(() => { - const channel = Installation.CHANNEL - if (["latest", "beta"].includes(channel) || Flag.OPENCODE_DISABLE_CHANNEL_DB) - return path.join(Global.Path.data, "opencode.db") - const safe = channel.replace(/[^a-zA-Z0-9._-]/g, "-") - return path.join(Global.Path.data, `opencode-${safe}.db`) - }) + export const Path = path.join(Global.Path.data, "opencode.db") type Schema = typeof schema export type Transaction = SQLiteTransaction<"sync", void, Schema> From 3feaddceda93c25129cc868fe046cde02e0a2313 Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Fri, 3 Apr 2026 13:22:37 -0400 Subject: [PATCH 2/2] fix: update db test for no-split-database behavior --- packages/opencode/test/storage/db.test.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/opencode/test/storage/db.test.ts b/packages/opencode/test/storage/db.test.ts index f6b60555959f..5099d55438b7 100644 --- a/packages/opencode/test/storage/db.test.ts +++ b/packages/opencode/test/storage/db.test.ts @@ -1,14 +1,8 @@ import { describe, expect, test } from "bun:test" -import path from "path" -import { Global } from "../../src/global" -import { Installation } from "../../src/installation" import { Database } from "../../src/storage/db" describe("Database.Path", () => { - test("returns database path for the current channel", () => { - const expected = ["latest", "beta"].includes(Installation.CHANNEL) - ? path.join(Global.Path.data, "opencode.db") - : path.join(Global.Path.data, `opencode-${Installation.CHANNEL.replace(/[^a-zA-Z0-9._-]/g, "-")}.db`) - expect(Database.getChannelPath()).toBe(expected) + test("respects OPENCODE_DB env override", () => { + expect(Database.Path).toBe(":memory:") }) })