Skip to content

Commit 343367c

Browse files
committed
chore: include additional source files in build and update electron main process to support asar unpacking and robust window loading
1 parent a55ec40 commit 343367c

2 files changed

Lines changed: 43 additions & 5 deletions

File tree

electron-builder.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,25 @@
99
"files": [
1010
"dist/**/*",
1111
"electron/**/*",
12-
"package.json"
12+
"package.json",
13+
"agent-server.js",
14+
"wizard-server.js",
15+
"src/wizard/**/*",
16+
"src/services/**/*",
17+
"src/utils/**/*",
18+
"src/ai/palettes.js",
19+
"src/constants.js",
20+
"src/core/**/*"
21+
],
22+
"asarUnpack": [
23+
"agent-server.js",
24+
"wizard-server.js",
25+
"src/wizard/**/*",
26+
"src/services/**/*",
27+
"src/utils/**/*",
28+
"src/ai/palettes.js",
29+
"src/constants.js",
30+
"src/core/**/*"
1331
],
1432
"mac": {
1533
"entitlements": "entitlements.mac.plist",

electron/main.cjs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

222242
function createMenu() {

0 commit comments

Comments
 (0)