@@ -20,6 +20,7 @@ import {
2020// Legacy type kept for backwards compatibility with taskControllers map
2121type TaskController = unknown ;
2222
23+ import { shellManager } from "./lib/shellManager.js" ;
2324import { setupAgentHotReload } from "./services/dev-reload.js" ;
2425import { registerFileWatcherIpc } from "./services/fileWatcher.js" ;
2526import { registerFoldersIpc } from "./services/folders.js" ;
@@ -57,8 +58,15 @@ const taskControllers = new Map<string, TaskController>();
5758// instead of ::1. This matches how the renderer already reaches the PostHog API.
5859dns . setDefaultResultOrder ( "ipv4first" ) ;
5960
60- // Set app name to ensure consistent userData path across platforms
61- app . setName ( "Array" ) ;
61+ // Set app name based on workspace (for unique userData paths per workspace)
62+ const workspaceName = process . env . ARRAY_WORKSPACE_NAME ;
63+ const appName = workspaceName ? `Array (${ workspaceName } )` : "Array" ;
64+ app . setName ( appName ) ;
65+
66+ // Use workspace-specific data directory if provided
67+ if ( process . env . ARRAY_WORKSPACE_DATA_DIR ) {
68+ app . setPath ( "userData" , process . env . ARRAY_WORKSPACE_DATA_DIR ) ;
69+ }
6270
6371function ensureClaudeConfigDir ( ) : void {
6472 const existing = process . env . CLAUDE_CONFIG_DIR ;
@@ -87,13 +95,16 @@ function setupExternalLinkHandlers(window: BrowserWindow): void {
8795}
8896
8997function createWindow ( ) : void {
98+ const windowTitle = workspaceName ? `Array (${ workspaceName } )` : "Array" ;
99+
90100 mainWindow = new BrowserWindow ( {
91101 width : 900 ,
92102 height : 600 ,
93103 minWidth : 900 ,
94104 minHeight : 600 ,
95105 backgroundColor : "#0a0a0a" ,
96106 titleBarStyle : "hiddenInset" ,
107+ title : windowTitle ,
97108 show : false ,
98109 webPreferences : {
99110 nodeIntegration : true ,
@@ -111,6 +122,13 @@ function createWindow(): void {
111122
112123 setupExternalLinkHandlers ( mainWindow ) ;
113124
125+ // Kill all shell sessions when renderer reloads (dev hot reload or CMD R)
126+ mainWindow . webContents . on ( "did-start-loading" , ( ) => {
127+ if ( mainWindow ?. webContents ) {
128+ shellManager . destroyByWebContents ( mainWindow . webContents ) ;
129+ }
130+ } ) ;
131+
114132 // Set up menu for keyboard shortcuts
115133 const template : MenuItemConstructorOptions [ ] = [
116134 {
@@ -249,6 +267,10 @@ app.on("activate", () => {
249267registerAutoUpdater ( ( ) => mainWindow ) ;
250268
251269ipcMain . handle ( "app:get-version" , ( ) => app . getVersion ( ) ) ;
270+ ipcMain . handle (
271+ "app:get-workspace-name" ,
272+ ( ) => process . env . ARRAY_WORKSPACE_NAME || null ,
273+ ) ;
252274
253275// Register IPC handlers via services
254276registerPosthogIpc ( ) ;
0 commit comments