feat(desktop): default dev gateway URL and support GATEWAY_URL env override

`pnpm dev` now connects to dev gateway by default. Support runtime
GATEWAY_URL env var to override, so no per-worktree .env setup needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Naiyuan Qing 2026-02-12 18:39:46 +08:00
parent 143d779376
commit c95b74ffc9
3 changed files with 11 additions and 6 deletions

View file

@ -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

View file

@ -17,6 +17,10 @@ let mainWindowRef: BrowserWindow | null = null
// Value is the unsubscribe function returned by agent.subscribe()
const ipcAgentSubscriptions = new Map<string, () => 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<void> {
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<void> {
*/
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)
}

View file

@ -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",