diff --git a/CLAUDE.md b/CLAUDE.md index abdc22f4..aac1a8b7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -48,12 +48,15 @@ pnpm multica credentials init # Initialize credentials pnpm multica help # Show help # Development servers -pnpm dev # Desktop app (default, recommended) -pnpm dev:desktop # Desktop app +pnpm dev # Desktop app (connects to dev gateway by default) +pnpm dev:desktop # Same as above pnpm dev:gateway # WebSocket gateway only pnpm dev:web # Next.js web app pnpm dev:all # Gateway + web app +# Override gateway URL (e.g. local gateway) +GATEWAY_URL=http://localhost:3000 pnpm dev + # Build pnpm build # Build all (turbo-orchestrated) pnpm --filter @multica/desktop build diff --git a/apps/desktop/src/main/ipc/hub.ts b/apps/desktop/src/main/ipc/hub.ts index 9dc407ee..a0b6a511 100644 --- a/apps/desktop/src/main/ipc/hub.ts +++ b/apps/desktop/src/main/ipc/hub.ts @@ -17,6 +17,10 @@ let mainWindowRef: BrowserWindow | null = null // Value is the unsubscribe function returned by agent.subscribe() const ipcAgentSubscriptions = new Map void>() +// Resolve gateway URL: GATEWAY_URL env > MAIN_VITE_GATEWAY_URL (.env file) +const gatewayUrl = + process.env.GATEWAY_URL || import.meta.env.MAIN_VITE_GATEWAY_URL + /** * Safe log function that catches EPIPE errors. * Electron main process stdout can be closed unexpectedly. @@ -39,7 +43,6 @@ export async function initializeHub(): Promise { return } - const gatewayUrl = import.meta.env.MAIN_VITE_GATEWAY_URL safeLog(`[Desktop] Initializing Hub, connecting to Gateway: ${gatewayUrl}`) hub = new Hub(gatewayUrl) @@ -62,7 +65,6 @@ export async function initializeHub(): Promise { */ function getHub(): Hub { if (!hub) { - const gatewayUrl = import.meta.env.MAIN_VITE_GATEWAY_URL safeLog(`[Desktop] Creating Hub, connecting to Gateway: ${gatewayUrl}`) hub = new Hub(gatewayUrl) } diff --git a/package.json b/package.json index 77e620cc..ab7620c2 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "scripts": { "multica": "pnpm --filter @multica/cli dev", "mu": "pnpm --filter @multica/cli dev", - "dev": "pnpm --filter @multica/desktop dev", - "dev:desktop": "pnpm --filter @multica/desktop dev", + "dev": "GATEWAY_URL=https://multica-dev.copilothub.ai/ pnpm --filter @multica/desktop dev", + "dev:desktop": "GATEWAY_URL=https://multica-dev.copilothub.ai/ pnpm --filter @multica/desktop dev", "dev:desktop:reset": "rm -rf ~/.super-multica && echo '✓ Deleted ~/.super-multica - Fresh install state restored'", "dev:desktop:fresh": "pnpm dev:desktop:reset && pnpm dev:desktop", "dev:desktop:onboarding": "pnpm --filter @multica/desktop dev:onboarding",