@@ -3,7 +3,6 @@ import { EventEmitter } from "node:events"
33import * as http from "node:http"
44import { createServer } from "node:net"
55import { homedir } from "node:os"
6- import { join } from "node:path"
76import { getCACertificates , setDefaultCACertificates } from "node:tls"
87import type { Event } from "electron"
98import { app , BrowserWindow } from "electron"
@@ -53,18 +52,14 @@ import { checkUpdate, checkForUpdates, installUpdate, setupAutoUpdater } from ".
5352import { probeWopalHomeFromShell } from "./onboarding-gate"
5453import { isVmwareVirtualGpu } from "./gpu-detect"
5554import { recoverMainWindow } from "./window-show-guard"
55+ import { resolveAppId , resolveUserDataPath } from "./user-data"
5656import { Deferred , Effect , Fiber } from "effect"
5757
5858const APP_NAMES : Record < string , string > = {
5959 main : "Ellamaka Main" ,
6060 beta : "Ellamaka Beta" ,
6161 stable : "Ellamaka" ,
6262}
63- const APP_IDS : Record < string , string > = {
64- main : "ai.ellamaka.desktop.main" ,
65- beta : "ai.ellamaka.desktop.beta" ,
66- stable : "ai.ellamaka.desktop" ,
67- }
6863const jsCallStackFeature = "DocumentPolicyIncludeJSCallStacksInCrashReports"
6964
7065let logger : ReturnType < typeof initLogging >
@@ -327,18 +322,15 @@ const main = Effect.gen(function* () {
327322 process . chdir ( homedir ( ) )
328323 } catch { }
329324
330- const appId = app . isPackaged ? APP_IDS [ CHANNEL ] : `ai.ellamaka.desktop.${ CHANNEL } `
331- // Electron userData (electron-store) does not follow WOPAL_HOME. When
332- // WOPAL_HOME is customized (dev.sh desktop sandbox), isolate userData under
333- // it so dev runs never mutate the real app's settings.
334- const devUserDataRoot = process . env . WOPAL_HOME ? join ( process . env . WOPAL_HOME , "ellamaka" , "desktop" ) : undefined
325+ const appId = resolveAppId ( app . isPackaged , CHANNEL )
335326 app . setName ( app . isPackaged ? APP_NAMES [ CHANNEL ] : "Ellamaka Dev" )
336327 app . setAppUserModelId ( appId )
337- app . setPath (
338- "userData" ,
339- devUserDataRoot ?? join ( app . getPath ( "appData" ) , appId ) ,
340- )
341- if ( devUserDataRoot ) app . setPath ( "sessionData" , join ( devUserDataRoot , "session" ) )
328+ // Electron userData always lives under the OS standard app-data directory,
329+ // keyed by appId. Development builds use a distinct appId
330+ // (`ai.ellamaka.desktop.<channel>` vs `ai.ellamaka.desktop.local`), so dev
331+ // runs never touch the packaged app's settings without redirecting userData
332+ // into WOPAL_HOME — see #233 for the regression this avoids.
333+ app . setPath ( "userData" , resolveUserDataPath ( app . isPackaged , app . getPath ( "appData" ) , CHANNEL ) )
342334 logger = initLogging ( )
343335 initCrashReporter ( )
344336
0 commit comments