Fix: launch Electron UI separately after A2A servers start

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 <noreply@anthropic.com>
This commit is contained in:
Eli 2026-03-09 13:24:38 +01:00
commit b73b2ca7d8

View file

@ -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