File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ const config: ForgeConfig = {
230230 new VitePlugin ( {
231231 build : [
232232 {
233- entry : "src/main/index .ts" ,
233+ entry : "src/main/bootstrap .ts" ,
234234 config : "vite.main.config.mts" ,
235235 target : "main" ,
236236 } ,
Original file line number Diff line number Diff line change 22 "name" : " @posthog/array" ,
33 "version" : " 0.0.0-dev" ,
44 "description" : " Array - PostHog desktop task manager" ,
5- "main" : " .vite/build/index .js" ,
5+ "main" : " .vite/build/bootstrap .js" ,
66 "versionHash" : " dynamic" ,
77 "engines" : {
88 "node" : " >=22.0.0" ,
2222 "typecheck" : " tsc -p tsconfig.node.json --noEmit && tsc -p tsconfig.web.json --noEmit" ,
2323 "generate-client" : " tsx scripts/update-openapi-client.ts" ,
2424 "test" : " vitest run" ,
25- "postinstall" : " cd ../.. && npx @electron/rebuild -f -m node_modules/node-pty || true"
25+ "postinstall" : " cd ../.. && npx @electron/rebuild -f -m node_modules/node-pty || true && bash apps/array/scripts/patch-electron-name.sh "
2626 },
2727 "keywords" : [
2828 " posthog" ,
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Patches the Electron binary's Info.plist to show "Array (Development)" in the macOS menu bar
3+
4+ set -e
5+
6+ REPO_ROOT=" $( git rev-parse --show-toplevel) "
7+ PLIST_FILE=" $REPO_ROOT /node_modules/electron/dist/Electron.app/Contents/Info.plist"
8+
9+ if [ ! -f " $PLIST_FILE " ]; then
10+ exit 0
11+ fi
12+
13+ if /usr/libexec/PlistBuddy -c " Print :CFBundleName" " $PLIST_FILE " | grep -q " Array (Development)" ; then
14+ exit 0
15+ fi
16+
17+ /usr/libexec/PlistBuddy -c " Set :CFBundleName 'Array (Development)'" " $PLIST_FILE "
18+ /usr/libexec/PlistBuddy -c " Set :CFBundleDisplayName 'Array (Development)'" " $PLIST_FILE "
19+ /usr/libexec/PlistBuddy -c " Set :CFBundleIdentifier 'com.posthog.array.dev'" " $PLIST_FILE "
Original file line number Diff line number Diff line change 1+ /**
2+ * Bootstrap entry point - sets userData path before any service initialization.
3+ *
4+ * This MUST be the entry point for both dev and prod builds. It ensures the
5+ * userData path is set BEFORE any imports that might trigger electron-store
6+ * instantiation (which calls app.getPath('userData') in their constructors).
7+ *
8+ */
9+ import path from "node:path" ;
10+ import { app } from "electron" ;
11+
12+ const isDev = ! app . isPackaged ;
13+
14+ // Set different app names for separate single-instance locks
15+ const appName = isDev ? "array-dev" : "Array" ;
16+ app . setName ( isDev ? "Array (Development)" : "Array" ) ;
17+
18+ const userDataPath = path . join ( app . getPath ( "appData" ) , "@posthog" , appName ) ;
19+ app . setPath ( "userData" , userDataPath ) ;
20+
21+ // Now dynamically import the rest of the application
22+ // Dynamic import ensures the path is set BEFORE index.js is evaluated
23+ // Static imports are hoisted and would run before our setPath() call
24+ import ( "./index.js" ) ;
Original file line number Diff line number Diff line change @@ -52,9 +52,6 @@ let mainWindow: BrowserWindow | null = null;
5252// instead of ::1. This matches how the renderer already reaches the PostHog API.
5353dns . setDefaultResultOrder ( "ipv4first" ) ;
5454
55- // Set app name to ensure consistent userData path across platforms
56- app . setName ( "Array" ) ;
57-
5855// Single instance lock must be acquired FIRST before any other app setup
5956// This ensures deep links go to the existing instance, not a new one
6057// In development, we need to pass the same args that setAsDefaultProtocolClient uses
Original file line number Diff line number Diff line change 11import { exec } from "node:child_process" ;
22import fs from "node:fs/promises" ;
3- import path from "node:path" ;
43import { promisify } from "node:util" ;
54import { app , clipboard } from "electron" ;
65import Store from "electron-store" ;
@@ -63,21 +62,13 @@ export class ExternalAppsService {
6362 constructor ( ) {
6463 this . prefsStore = new Store < ExternalAppsSchema > ( {
6564 name : "external-apps" ,
66- cwd : this . getStorePath ( ) ,
65+ cwd : app . getPath ( "userData" ) ,
6766 defaults : {
6867 externalAppsPrefs : { } ,
6968 } ,
7069 } ) ;
7170 }
7271
73- private getStorePath ( ) : string {
74- const userDataPath = app . getPath ( "userData" ) ;
75- if ( userDataPath . includes ( "@posthog" ) ) {
76- return path . join ( path . dirname ( userDataPath ) , "Array" ) ;
77- }
78- return userDataPath ;
79- }
80-
8172 private async getFileIcon ( ) {
8273 if ( ! this . fileIconModule ) {
8374 this . fileIconModule = await import ( "file-icon" ) ;
Original file line number Diff line number Diff line change @@ -7,14 +7,6 @@ interface SettingsSchema {
77 worktreeLocation : string ;
88}
99
10- function getStorePath ( ) : string {
11- const userDataPath = app . getPath ( "userData" ) ;
12- if ( userDataPath . includes ( "@posthog" ) ) {
13- return path . join ( path . dirname ( userDataPath ) , "Array" ) ;
14- }
15- return userDataPath ;
16- }
17-
1810function getDefaultWorktreeLocation ( ) : string {
1911 return path . join ( os . homedir ( ) , ".array" ) ;
2012}
@@ -29,7 +21,7 @@ const schema = {
2921export const settingsStore = new Store < SettingsSchema > ( {
3022 name : "settings" ,
3123 schema,
32- cwd : getStorePath ( ) ,
24+ cwd : app . getPath ( "userData" ) ,
3325 defaults : {
3426 worktreeLocation : getDefaultWorktreeLocation ( ) ,
3527 } ,
Original file line number Diff line number Diff line change 1- import path from "node:path" ;
21import { WorktreeManager } from "@posthog/agent" ;
32import { app } from "electron" ;
43import Store from "electron-store" ;
@@ -59,23 +58,15 @@ const schema = {
5958 } ,
6059} ;
6160
62- function getStorePath ( ) : string {
63- const userDataPath = app . getPath ( "userData" ) ;
64- if ( userDataPath . includes ( "@posthog" ) ) {
65- return path . join ( path . dirname ( userDataPath ) , "Array" ) ;
66- }
67- return userDataPath ;
68- }
69-
7061export const rendererStore = new Store < RendererStoreSchema > ( {
7162 name : "renderer-storage" ,
72- cwd : getStorePath ( ) ,
63+ cwd : app . getPath ( "userData" ) ,
7364} ) ;
7465
7566export const foldersStore = new Store < FoldersSchema > ( {
7667 name : "folders" ,
7768 schema,
78- cwd : getStorePath ( ) ,
69+ cwd : app . getPath ( "userData" ) ,
7970 defaults : {
8071 folders : [ ] ,
8172 taskAssociations : [ ] ,
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import React from "react";
66import ReactDOM from "react-dom/client" ;
77import "./styles/globals.css" ;
88
9+ document . title = import . meta. env . DEV ? "Array (Development)" : "Array" ;
10+
911const rootElement = document . getElementById ( "root" ) ;
1012if ( ! rootElement ) throw new Error ( "Root element not found" ) ;
1113
You can’t perform that action at this time.
0 commit comments