diff --git a/electron/main.ts b/electron/main.ts index ba5ed4d..9afcbd0 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -5,6 +5,25 @@ import fs from 'fs'; import net from 'net'; import os from 'os'; +/** + * Return a copy of process.env without __NEXT_PRIVATE_* variables. + * + * The bundled Next.js standalone server sets these at runtime + * (e.g. __NEXT_PRIVATE_STANDALONE_CONFIG, __NEXT_PRIVATE_ORIGIN). + * If they leak into child-process environments they cause every + * other Next.js project on the machine to skip its own config + * loading, breaking builds and dev servers. + */ +function sanitizedProcessEnv(): Record { + const env: Record = {}; + for (const [key, value] of Object.entries(process.env)) { + if (!key.startsWith('__NEXT_PRIVATE_') && value !== undefined) { + env[key] = value; + } + } + return env; +} + let mainWindow: BrowserWindow | null = null; let serverProcess: Electron.UtilityProcess | null = null; let serverPort: number | null = null; @@ -388,7 +407,7 @@ function startServer(port: number): Electron.UtilityProcess { const env: Record = { ...userShellEnv, - ...(process.env as Record), + ...sanitizedProcessEnv(), // Ensure user shell env vars override (especially API keys) ...userShellEnv, PORT: String(port), @@ -551,7 +570,7 @@ app.whenReady().then(async () => { ipcMain.handle('install:check-prerequisites', async () => { const expandedPath = getExpandedShellPath(); - const execEnv = { ...process.env, ...userShellEnv, PATH: expandedPath }; + const execEnv = { ...sanitizedProcessEnv(), ...userShellEnv, PATH: expandedPath }; const execOpts = { timeout: 5000, encoding: 'utf-8' as const, env: execEnv }; let hasNode = false; @@ -615,7 +634,7 @@ app.whenReady().then(async () => { const expandedPath = getExpandedShellPath(); const execEnv: Record = { ...userShellEnv, - ...(process.env as Record), + ...sanitizedProcessEnv(), ...userShellEnv, PATH: expandedPath, }; diff --git a/src/lib/bridge/conversation-engine.ts b/src/lib/bridge/conversation-engine.ts index c213fd5..e097988 100644 --- a/src/lib/bridge/conversation-engine.ts +++ b/src/lib/bridge/conversation-engine.ts @@ -363,7 +363,7 @@ async function consumeStream( : contentBlocks .filter((b): b is Extract => b.type === 'text') .map((b) => b.text) - .join('') + .join('\n\n') .trim(); if (content) { @@ -400,7 +400,7 @@ async function consumeStream( : contentBlocks .filter((b): b is Extract => b.type === 'text') .map((b) => b.text) - .join('') + .join('\n\n') .trim(); if (content) { addMessage(sessionId, 'assistant', content);