@@ -38,20 +38,25 @@ function startAgentServer() {
3838 return ;
3939 }
4040
41- const agentServerPath = path . join ( __dirname , '..' , 'agent-server.js' ) ;
41+ let agentServerPath = path . join ( __dirname , '..' , 'agent-server.js' ) ;
42+ let agentCwd = path . join ( __dirname , '..' ) ;
43+ if ( app . isPackaged ) {
44+ agentServerPath = agentServerPath . replace ( 'app.asar' , 'app.asar.unpacked' ) ;
45+ agentCwd = agentCwd . replace ( 'app.asar' , 'app.asar.unpacked' ) ;
46+ }
4247
4348 // Check if agent-server.js exists
4449 if ( ! fsSync . existsSync ( agentServerPath ) ) {
4550 console . error ( '[Electron] Agent server not found at:' , agentServerPath ) ;
4651 return ;
4752 }
4853
49- console . log ( '[Electron] Starting agent server...' ) ;
54+ console . log ( '[Electron] Starting agent server from:' , agentServerPath ) ;
5055
5156 // Fork the agent server as a child process
5257 // Using fork with execArgv to handle ES modules
5358 agentServerProcess = fork ( agentServerPath , [ ] , {
54- cwd : path . join ( __dirname , '..' ) ,
59+ cwd : agentCwd ,
5560 stdio : [ 'pipe' , 'pipe' , 'pipe' , 'ipc' ] ,
5661 env : {
5762 ...process . env ,
@@ -211,12 +216,27 @@ function createWindow() {
211216 } else {
212217 // In production, load the built index.html
213218 const indexPath = path . join ( __dirname , '../dist/index.html' ) ;
219+ console . log ( '[Electron] Loading production index:' , indexPath ) ;
214220 const query = { } ;
215221 if ( isTestMode ) query . test = 'true' ;
216222 if ( sessionName ) query . session = sessionName ;
217223
218- mainWindow . loadFile ( indexPath , { query } ) ;
224+ mainWindow . webContents . on ( 'did-fail-load' , ( event , errorCode , errorDescription , validatedURL ) => {
225+ console . error ( '[Electron] Failed to load:' , { errorCode, errorDescription, validatedURL } ) ;
226+ } ) ;
227+
228+ mainWindow . loadFile ( indexPath , { query } ) . catch ( err => {
229+ console . error ( '[Electron] loadFile error:' , err ) ;
230+ } ) ;
219231 }
232+
233+ // Fallback: show the window after 5s even if ready-to-show hasn't fired
234+ setTimeout ( ( ) => {
235+ if ( mainWindow && ! mainWindow . isVisible ( ) ) {
236+ console . warn ( '[Electron] ready-to-show did not fire, showing window anyway' ) ;
237+ mainWindow . show ( ) ;
238+ }
239+ } , 5000 ) ;
220240}
221241
222242function createMenu ( ) {
0 commit comments