From b73b2ca7d87c26939f4720a473517d9021025966 Mon Sep 17 00:00:00 2001 From: Karamelmar Date: Mon, 9 Mar 2026 13:24:38 +0100 Subject: [PATCH] Fix: launch Electron UI separately after A2A servers start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CS Core's start.js only starts A2A servers in electron mode — it does NOT launch the Electron app itself (it says 'Electron app started separately'). Switch to --ui-mode=headless for the background servers, then explicitly launch electron from app/node_modules/.bin/electron. Wait for registry /health before opening UI. Shut down servers when Electron window is closed. Co-Authored-By: Claude Sonnet 4.6 --- lib/container.sh | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/container.sh b/lib/container.sh index 11072fb..a5b2a86 100644 --- a/lib/container.sh +++ b/lib/container.sh @@ -115,14 +115,37 @@ fi # ── Put claude wrapper first on PATH ──────────────────────────────────── export PATH="\$PROJECT_DIR/bin:\$PATH" -# ── Launch CS Core on the host ─────────────────────────────────────────── -echo "→ Starting Context Studio Core..." +# ── Launch CS Core A2A servers in background ───────────────────────────── +echo "→ Starting Context Studio Core (A2A servers)..." CS_CORE_DIR="\$CS_CORE" \\ CS_WORKFLOW_DIR="\$PROJECT_DIR/workflow" \\ PROJECT_ROOT_DIR="\$PROJECT_DIR" \\ -node "\$CS_CORE/core/start.js" +node "\$CS_CORE/core/start.js" --ui-mode=headless & +CS_CORE_PID=\$! -# ── CS Core exited — stop container ───────────────────────────────────── +# ── Wait for registry to be ready (port 8000) ─────────────────────────── +echo -n "→ Waiting for A2A registry..." +for _i in \$(seq 1 30); do + if curl -sf http://localhost:8000/health >/dev/null 2>&1; then + echo " ready." + break + fi + echo -n "." + sleep 0.5 +done +echo "" + +# ── Launch Electron UI ─────────────────────────────────────────────────── +echo "→ Launching Context Studio UI..." +CS_CORE_DIR="\$CS_CORE" \\ +CS_WORKFLOW_DIR="\$PROJECT_DIR/workflow" \\ +PROJECT_ROOT_DIR="\$PROJECT_DIR" \\ +"\$CS_CORE/app/node_modules/.bin/electron" "\$CS_CORE/app" + +# ── Electron closed — stop A2A servers and container ───────────────────── +echo "→ UI closed. Stopping A2A servers..." +kill "\$CS_CORE_PID" 2>/dev/null || true +wait "\$CS_CORE_PID" 2>/dev/null || true echo "→ Stopping agents container..." "\$RUNTIME" rm -f "\$CONTAINER_NAME" 2>/dev/null || true START