From 887fb93b3bb3ca28f28defd6be16eb377628d168 Mon Sep 17 00:00:00 2001 From: Kacper Date: Sun, 21 Dec 2025 14:54:26 +0100 Subject: [PATCH] fix: address additional code review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add path.normalize() for Windows mixed separator handling - Add validation to check Node executable exists after finding it - Improve error dialog with specific troubleshooting advice for Node.js related errors vs general errors - Include source info in validation error message 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- apps/ui/src/main.ts | 14 +++++++++++++- libs/platform/src/node-finder.ts | 6 ++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/ui/src/main.ts b/apps/ui/src/main.ts index 2d1a0c2f..f4b181c1 100644 --- a/apps/ui/src/main.ts +++ b/apps/ui/src/main.ts @@ -134,6 +134,12 @@ async function startServer(): Promise { logger: (msg) => console.log(`[Electron] ${msg}`), }); const command = nodeResult.nodePath; + + // Validate that the found Node executable actually exists + if (command !== 'node' && !fs.existsSync(command)) { + throw new Error(`Node.js executable not found at: ${command} (source: ${nodeResult.source})`); + } + let args: string[]; let serverPath: string; @@ -338,9 +344,15 @@ app.whenReady().then(async () => { createWindow(); } catch (error) { console.error('[Electron] Failed to start:', error); + const errorMessage = (error as Error).message; + const isNodeError = errorMessage.includes('Node.js'); dialog.showErrorBox( 'Automaker Failed to Start', - `The application failed to start.\n\n${(error as Error).message}\n\nPlease ensure Node.js is installed and accessible.` + `The application failed to start.\n\n${errorMessage}\n\n${ + isNodeError + ? 'Please install Node.js from https://nodejs.org or via a package manager (Homebrew, nvm, fnm).' + : 'Please check the application logs for more details.' + }` ); app.quit(); } diff --git a/libs/platform/src/node-finder.ts b/libs/platform/src/node-finder.ts index 9b45d9e8..cc130478 100644 --- a/libs/platform/src/node-finder.ts +++ b/libs/platform/src/node-finder.ts @@ -334,8 +334,10 @@ export function buildEnhancedPath(nodePath: string, currentPath: string = ''): s // Don't add if already present or if it's just '.' // Use path segment matching to avoid false positives (e.g., /opt/node vs /opt/node-v18) - const pathSegments = currentPath.split(path.delimiter); - if (nodeDir === '.' || pathSegments.includes(nodeDir)) { + // Normalize paths for comparison to handle mixed separators on Windows + const normalizedNodeDir = path.normalize(nodeDir); + const pathSegments = currentPath.split(path.delimiter).map((s) => path.normalize(s)); + if (normalizedNodeDir === '.' || pathSegments.includes(normalizedNodeDir)) { return currentPath; }