WebChat: fix packaged root resolution

main
Peter Steinberger 2025-12-09 04:36:15 +00:00
parent 2ebad55a59
commit fc1d58b631
1 changed files with 13 additions and 9 deletions

View File

@ -40,16 +40,20 @@ const wsSessions: Map<string, Set<WebSocket>> = new Map();
function resolveWebRoot() { function resolveWebRoot() {
const here = path.dirname(fileURLToPath(import.meta.url)); const here = path.dirname(fileURLToPath(import.meta.url));
const packagedRoot = path.resolve( const candidates = [
path.dirname(process.execPath), // Bundled inside Clawdis.app: .../Contents/Resources/WebChat
"../WebChat", path.resolve(here, "../../../WebChat"),
); // When running from repo without bundling
if (fs.existsSync(packagedRoot)) return packagedRoot; path.resolve(here, "../../WebChat"),
// Fallback to source tree location
path.resolve(here, "../../apps/macos/Sources/Clawdis/Resources/WebChat"),
];
return path.resolve( for (const candidate of candidates) {
here, if (fs.existsSync(candidate)) return candidate;
"../../apps/macos/Sources/Clawdis/Resources/WebChat", }
);
throw new Error(`webchat assets not found; tried: ${candidates.join(", ")}`);
} }
function readBody(req: http.IncomingMessage): Promise<Buffer> { function readBody(req: http.IncomingMessage): Promise<Buffer> {