From 97da89d29e38f864c7d9da8e2081829199b8c120 Mon Sep 17 00:00:00 2001 From: dorianzheng Date: Fri, 20 Mar 2026 22:51:43 +0800 Subject: [PATCH 1/4] Fix make package-mac reliability on Apple Silicon - Remove hardcoded arch arrays from electron-builder.yml so the CLI flag (--arm64/--x64) controls which architecture is built - Add dmg.backgroundColor to skip the buggy background.tiff code path in dmg-builder@25.1.8 on APFS volumes - Add hdiutil detach cleanup in Makefile for stale mounts from previous failed builds --- Makefile | 1 + packages/electron/electron-builder.yml | 11 +++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 7e5762e..3759424 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ package: build resolve-deps ## Build installable app for the current platform @$(PNPM) --dir packages/electron dist package-mac: build resolve-deps ## Build .dmg for macOS (current arch) + @hdiutil detach /Volumes/Dune -force 2>/dev/null || true @$(PNPM) --dir packages/electron dist:mac -- --$(shell uname -m | sed 's/x86_64/x64/') package-linux: build resolve-deps ## Build .AppImage/.deb for Linux diff --git a/packages/electron/electron-builder.yml b/packages/electron/electron-builder.yml index 90cda36..c8aac69 100644 --- a/packages/electron/electron-builder.yml +++ b/packages/electron/electron-builder.yml @@ -53,14 +53,8 @@ npmRebuild: true mac: category: public.app-category.developer-tools target: - - target: dmg - arch: - - arm64 - - x64 - - target: zip - arch: - - arm64 - - x64 + - dmg + - zip icon: assets/icon.icns darkModeSupport: true hardenedRuntime: true @@ -69,6 +63,7 @@ mac: dmg: sign: false title: Dune + backgroundColor: '#ffffff' linux: target: From 9a9f6760cc2d677c6a569b633099f60d7b2ea013 Mon Sep 17 00:00:00 2001 From: dorianzheng Date: Fri, 20 Mar 2026 23:22:07 +0800 Subject: [PATCH 2/4] Fix agent-mcp path in electron-builder extraResources The source path was ../backend/src/agent-mcp which doesn't exist. The actual MCP Python files (rpc.py, listener.py) are at ../backend/src/agents/mcp. This caused the packaged app to fail when starting agents. --- packages/electron/electron-builder.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/electron/electron-builder.yml b/packages/electron/electron-builder.yml index c8aac69..2d8c8e5 100644 --- a/packages/electron/electron-builder.yml +++ b/packages/electron/electron-builder.yml @@ -33,7 +33,7 @@ extraResources: filter: - "**/*" - - from: ../backend/src/agent-mcp + - from: ../backend/src/agents/mcp to: backend/agent-mcp filter: - "**/*.py" From ca0780dd00e105307ba6ecd7e0a6ee521101af1e Mon Sep 17 00:00:00 2001 From: dorianzheng Date: Fri, 20 Mar 2026 23:50:40 +0800 Subject: [PATCH 3/4] Fix DUNE_WS_URL not set in packaged app getBackendPort() used join(__dirname, '../../.port') which assumed the unbundled source layout (src/agents/). After esbuild bundles into dist/index.js, __dirname is dist/ so the path resolved one level too high. Fix by using config.port (set via PORT env var from the sidecar) as the primary source, falling back to the .port file with the correct relative path for dev mode. Also fix the test that expected the old wrong agent-mcp path. --- packages/backend/src/agents/agent-manager.ts | 9 +++++---- packages/backend/test/agent-system-prompt.test.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/agents/agent-manager.ts b/packages/backend/src/agents/agent-manager.ts index 4be74bd..a7f4dcd 100644 --- a/packages/backend/src/agents/agent-manager.ts +++ b/packages/backend/src/agents/agent-manager.ts @@ -631,12 +631,13 @@ async function ensureCliInstalled(box: SimpleBox): Promise { console.log('Claude CLI:', check.stdout.trim()) } -/** Read the current backend port from the .port file. - * server.ts writes it to join(__dirname, '../.port') from src/, - * which is packages/backend/.port. From src/agents/, that's ../../.port. */ +/** Returns the agent-facing backend port. + * In packaged mode the sidecar passes PORT via env -> config.port. + * In dev mode we fall back to the .port file written by server.ts. */ function getBackendPort(): number { + if (config.port > 0) return config.port try { - const portFile = join(__dirname, '../../.port') + const portFile = join(__dirname, '../.port') const raw = readFileSync(portFile, 'utf-8').trim() if (raw.startsWith('{')) { const parsed = JSON.parse(raw) diff --git a/packages/backend/test/agent-system-prompt.test.ts b/packages/backend/test/agent-system-prompt.test.ts index 22fb7e0..65f0006 100644 --- a/packages/backend/test/agent-system-prompt.test.ts +++ b/packages/backend/test/agent-system-prompt.test.ts @@ -95,6 +95,6 @@ test('bundled asset resolver falls back from dist to src assets', () => { ) assert.equal( agentManager.__resolveBundledAssetDirForTests('agent-mcp', resolve(backendRoot, 'dist')), - resolve(backendRoot, 'src', 'agent-mcp'), + resolve(backendRoot, 'src', 'agents', 'mcp'), ) }) From 9236b2bc553d074c8fa0b73aab3106806ed18b62 Mon Sep 17 00:00:00 2001 From: dorianzheng Date: Sat, 21 Mar 2026 03:04:37 +0800 Subject: [PATCH 4/4] Fix getAgentMcpPath dev-mode path in Electron paths.ts The dev-mode fallback pointed to src/agent-mcp which doesn't exist. The actual MCP Python files are at src/agents/mcp, matching config.ts and electron-builder.yml. --- packages/electron/src/util/paths.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/electron/src/util/paths.ts b/packages/electron/src/util/paths.ts index fbeb6d1..f704bb5 100644 --- a/packages/electron/src/util/paths.ts +++ b/packages/electron/src/util/paths.ts @@ -55,7 +55,7 @@ export function getAgentMcpPath(): string { if (isPackaged()) { return join(process.resourcesPath!, 'backend', 'agent-mcp') } - return resolve(getRepoRoot(), 'packages', 'backend', 'src', 'agent-mcp') + return resolve(getRepoRoot(), 'packages', 'backend', 'src', 'agents', 'mcp') } export function getAgentPromptsPath(): string {