fix(desktop): show onboarding when userData has an unrelated .dat file

This commit is contained in:
Dan Smolsky
2026-11-07 06:48:06 -05:00
Unverified
parent ecd2cf2f6f
commit 7d5208b41f
3 changed files with 5 additions and 2 deletions
@@ -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)
@@ -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
+1 -1
View File
@@ -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)
}