From fc1d58b63142c040dafdb125e3d610be31b179f9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 9 Dec 2025 04:36:15 +0000 Subject: [PATCH] WebChat: fix packaged root resolution --- src/webchat/server.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/webchat/server.ts b/src/webchat/server.ts index 4be1648cf..b95ec9ddc 100644 --- a/src/webchat/server.ts +++ b/src/webchat/server.ts @@ -40,16 +40,20 @@ const wsSessions: Map> = new Map(); function resolveWebRoot() { const here = path.dirname(fileURLToPath(import.meta.url)); - const packagedRoot = path.resolve( - path.dirname(process.execPath), - "../WebChat", - ); - if (fs.existsSync(packagedRoot)) return packagedRoot; + const candidates = [ + // Bundled inside Clawdis.app: .../Contents/Resources/WebChat + path.resolve(here, "../../../WebChat"), + // When running from repo without bundling + path.resolve(here, "../../WebChat"), + // Fallback to source tree location + path.resolve(here, "../../apps/macos/Sources/Clawdis/Resources/WebChat"), + ]; - return path.resolve( - here, - "../../apps/macos/Sources/Clawdis/Resources/WebChat", - ); + for (const candidate of candidates) { + if (fs.existsSync(candidate)) return candidate; + } + + throw new Error(`webchat assets not found; tried: ${candidates.join(", ")}`); } function readBody(req: http.IncomingMessage): Promise {