diff --git a/server/actions.mjs b/server/actions.mjs index 297a60a..bed6656 100644 --- a/server/actions.mjs +++ b/server/actions.mjs @@ -9,7 +9,7 @@ export const actions = { description: "List all available actions and their definitions", params: [], policy: "auto-accept", - handler: async () => { + handler: () => { return Object.entries(actions).map(([name, def]) => ({ action: name, description: def.description, @@ -23,9 +23,9 @@ export const actions = { description: "Open a file in the editor", params: [{ name: "filename", required: true, type: "path" }], policy: "auto-accept", - handler: async ({ filename }) => { + handler: ({ filename }) => { const resolved = resolve_path(filename); - await exec('subl3', [resolved]); + exec('subl3', [resolved]); return { opened: resolved }; }, }, @@ -35,9 +35,9 @@ export const actions = { description: "Open a directory in the file manager", params: [{ name: "path", required: true, type: "path" }], policy: 'queue', - handler: async ({ path }) => { + handler: ({ path }) => { const resolved = resolve_path(path); - // await exec( ... ); + // exec( ... ); return { opened: resolved }; }, }, @@ -47,12 +47,12 @@ export const actions = { description: "Open a URL in the web browser", params: [{ name: "url", required: true, type: "string" }], policy: "queue", - handler: async ({ url }) => { + handler: ({ url }) => { const parsed = new URL(url); if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { throw new Error(`Disallowed protocol: ${parsed.protocol}`); } - await exec('xdg-open', [parsed.href]); + exec('xdg-open', [parsed.href]); return { opened: parsed.href }; }, }, @@ -61,9 +61,9 @@ export const actions = { description: "Open a terminal in a given directory", params: [{ name: "path", required: false, type: "path" }], policy: 'queue', - handler: async ({ path }) => { + handler: ({ path }) => { const resolved = resolve_path(path ?? 'workspace'); - await exec('konsole', ['--workdir', resolved, '-e', 'bash']); + exec('konsole', ['--workdir', resolved, '-e', 'bash']); return { opened: resolved }; }, }, diff --git a/server/helpers.mjs b/server/helpers.mjs index 2fcf345..47c8bd7 100644 --- a/server/helpers.mjs +++ b/server/helpers.mjs @@ -1,4 +1,4 @@ -import { spawnSync } from "child_process"; +import { spawn } from "child_process"; import path from "path"; const CONTAINER_PATH = "/home/devilholk/Projekt/claude-docker/"; @@ -24,14 +24,7 @@ export function resolve_path(user_path) { throw new Error(`Path is outside all known volumes: ${user_path}`); } -// Execute a binary with an argument list — no shell interpolation. +// Launch a binary with an argument list — no shell interpolation, fire and forget. export function exec(bin, args = []) { - return new Promise((resolve, reject) => { - const result = spawnSync(bin, args, { stdio: "inherit" }); - if (result.error) { - reject(result.error); - } else { - resolve(result.status); - } - }); + spawn(bin, args, { stdio: 'ignore', detached: true }).unref(); }