spawnSync was blocking the event loop until the subprocess exited, so opening a browser would freeze the server until it closed. Replace with spawn + unref (detached, stdio ignored) and remove the now-pointless awaits and async keywords from action handlers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
1006 B
JavaScript
31 lines
1006 B
JavaScript
import { spawn } from "child_process";
|
|
import path from "path";
|
|
|
|
const CONTAINER_PATH = "/home/devilholk/Projekt/claude-docker/";
|
|
|
|
|
|
// Docker image → host conversation
|
|
const VOLUME_MAPPING = [
|
|
['/home/claude', path.resolve(CONTAINER_PATH, 'claude-home')],
|
|
['/workspace', path.resolve(CONTAINER_PATH, 'workspace')],
|
|
];
|
|
|
|
// Translate a container-side path to its host-side equivalent using VOLUME_MAP.
|
|
// Throws if the path escapes all known volumes.
|
|
export function resolve_path(user_path) {
|
|
const abs = path.resolve(user_path);
|
|
|
|
for (const [container_prefix, host_prefix] of VOLUME_MAPPING) {
|
|
if (abs === container_prefix || abs.startsWith(container_prefix + "/")) {
|
|
return host_prefix + abs.slice(container_prefix.length);
|
|
}
|
|
}
|
|
|
|
throw new Error(`Path is outside all known volumes: ${user_path}`);
|
|
}
|
|
|
|
// Launch a binary with an argument list — no shell interpolation, fire and forget.
|
|
export function exec(bin, args = []) {
|
|
spawn(bin, args, { stdio: 'ignore', detached: true }).unref();
|
|
}
|