From 7d5208b41ff15d1d2ac3f02dd72730de449828ac Mon Sep 17 00:00:00 2001 From: Dan Smolsky Date: Sat, 7 Nov 2026 06:48:06 -0500 Subject: [PATCH] fix(desktop): show onboarding when userData has an unrelated .dat file --- packages/desktop/src/main/storage/install-state.test.ts | 1 + packages/desktop/src/main/storage/install-state.ts | 4 +++- packages/desktop/src/main/storage/legacy.ts | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/desktop/src/main/storage/install-state.test.ts b/packages/desktop/src/main/storage/install-state.test.ts index 86b383642e4..4c121947aa5 100644 --- a/packages/desktop/src/main/storage/install-state.test.ts +++ b/packages/desktop/src/main/storage/install-state.test.ts @@ -9,6 +9,7 @@ describe("hasExistingAppState", () => { test("recognizes state from an earlier OpenCode launch but not files Electron creates on a fresh install", () => { expect(hasExistingAppState([])).toBe(false) expect(hasExistingAppState([file("Local State"), directory("Crashpad")])).toBe(false) + expect(hasExistingAppState([file("unrelated.dat")])).toBe(false) expect(hasExistingAppState([file("opencode.settings")])).toBe(true) expect(hasExistingAppState([file("opencode.global.dat")])).toBe(true) expect(hasExistingAppState([file("drafts.sqlite")])).toBe(true) diff --git a/packages/desktop/src/main/storage/install-state.ts b/packages/desktop/src/main/storage/install-state.ts index 0ff1a4f52d6..c1294d68807 100644 --- a/packages/desktop/src/main/storage/install-state.ts +++ b/packages/desktop/src/main/storage/install-state.ts @@ -1,8 +1,10 @@ +import { isStoreFile } from "./legacy" + export function hasExistingAppState(entries: Array<{ name: string; directory: boolean }>) { return entries.some((entry) => { if (entry.name === "opencode.settings") return true - if (entry.name.endsWith(".dat")) return true + if (isStoreFile(entry.name)) return true if (entry.name === "drafts.sqlite") return true diff --git a/packages/desktop/src/main/storage/legacy.ts b/packages/desktop/src/main/storage/legacy.ts index b6ea21636ed..47693f9e061 100644 --- a/packages/desktop/src/main/storage/legacy.ts +++ b/packages/desktop/src/main/storage/legacy.ts @@ -88,7 +88,7 @@ export const importLegacyStores = Effect.fn("DesktopStorage.importLegacyStores") return { imported: rows.length, removed: candidates.map((file) => file.name) } }) -function isStoreFile(name: string) { +export function isStoreFile(name: string) { return name === "default.dat" || /^opencode\..+\.dat$/.test(name) }