diff --git a/packages/core/src/database/database.ts b/packages/core/src/database/database.ts index 6879212c4..d0d201c16 100644 --- a/packages/core/src/database/database.ts +++ b/packages/core/src/database/database.ts @@ -50,8 +50,8 @@ export function path() { process.env.OPENCODE_DISABLE_CHANNEL_DB === "1" || process.env.OPENCODE_DISABLE_CHANNEL_DB === "true" ) - return join(Global.Path.data, "opencode.db") - return join(Global.Path.data, `opencode-${InstallationChannel.replace(/[^a-zA-Z0-9._-]/g, "-")}.db`) + return join(Global.Path.data, "bcode.db") + return join(Global.Path.data, `bcode-${InstallationChannel.replace(/[^a-zA-Z0-9._-]/g, "-")}.db`) } export const defaultLayer = Layer.unwrap( diff --git a/packages/core/test/database-path.test.ts b/packages/core/test/database-path.test.ts new file mode 100644 index 000000000..94ee78979 --- /dev/null +++ b/packages/core/test/database-path.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, test } from "bun:test" +import path from "path" +import { Database } from "@opencode-ai/core/database/database" +import { Global } from "@opencode-ai/core/global" +import { InstallationChannel } from "@opencode-ai/core/installation/version" + +describe("Database.path", () => { + test("uses BrowserCode database filenames", () => { + delete process.env.OPENCODE_DISABLE_CHANNEL_DB + + expect(Database.path()).toBe( + ["latest", "beta", "prod"].includes(InstallationChannel) + ? path.join(Global.Path.data, "bcode.db") + : path.join(Global.Path.data, `bcode-${InstallationChannel.replace(/[^a-zA-Z0-9._-]/g, "-")}.db`), + ) + + process.env.OPENCODE_DISABLE_CHANNEL_DB = "1" + expect(Database.path()).toBe(path.join(Global.Path.data, "bcode.db")) + delete process.env.OPENCODE_DISABLE_CHANNEL_DB + }) +})