From 51ad7ef6eb89b63a9e1b13ceceba49e70f0e4f5e Mon Sep 17 00:00:00 2001
From: Michael Heller <21163552+mdheller@users.noreply.github.com>
Date: Mon, 20 Jul 2026 07:53:36 -0400
Subject: [PATCH] =?UTF-8?q?cockpit(up):=20serve=20the=20cockpit=20UI=20+?=
=?UTF-8?q?=20open=20it=20=E2=80=94=20the=20missing=20window?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
bearbrowser-cockpit-up stood up the backend (gate/sidecar/receipts) and staged the
cockpit, but never served the UI or opened a browser — so it 'just sat there' with no
window to use. Now it serves the cockpit on loopback (127.0.0.1:8811, configurable via
BEARBROWSER_COCKPIT_UI_PORT) and opens it (open/xdg-open; skip with BEARBROWSER_NO_OPEN),
then prints a clear status box. Ctrl-C still tears everything down.
Verified: the assembled cockpit renders sovereign (mode=sovereign, agent calls → the
gate :8080, no login wall, 0 errors); cockpit-up now serves it (200,
SocioProphet
Web) and reports the URL.
Note: plain static serve — loading / and in-app nav work; hard-refresh of a deep route
would 404 (SPA index-fallback is a small follow-up).
---
scripts/bearbrowser-cockpit-up | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/scripts/bearbrowser-cockpit-up b/scripts/bearbrowser-cockpit-up
index e186d59..6cad0a1 100755
--- a/scripts/bearbrowser-cockpit-up
+++ b/scripts/bearbrowser-cockpit-up
@@ -64,5 +64,27 @@ done
echo "[cockpit-up] health: gate(→sidecar)=$gate_ok receipts=$rcpt_ok"
[ "$gate_ok" = "200" ] || { echo "[cockpit-up] ERROR: gate not serving"; cat /tmp/bb-cockpit-gate.log; exit 1; }
-echo "[cockpit-up] SOVEREIGN COCKPIT UP — cockpit=$RES/cockpit/index.html gate=$GATE_PORT sidecar=$UPSTREAM_PORT receipts=$RECEIPTS_PORT"
+# 3. Serve the cockpit UI on loopback and open it — the window into the running app.
+# (Standalone, without the full BearBrowser.app; inside the browser this is the
+# resource:// start page instead.) Plain static serve: loading '/' and in-app
+# navigation work; a hard refresh of a deep route would 404 — SPA-fallback is a
+# nice-to-have follow-up.
+UI_PORT="${BEARBROWSER_COCKPIT_UI_PORT:-8811}"
+COCKPIT_DIR="$RES/cockpit"
+URL=""
+if [ -f "$COCKPIT_DIR/index.html" ]; then
+ ( cd "$COCKPIT_DIR" && exec python3 -m http.server "$UI_PORT" --bind 127.0.0.1 ) >/tmp/bb-cockpit-ui.log 2>&1 & pids+=($!)
+ URL="http://127.0.0.1:$UI_PORT"
+ for _ in $(seq 1 12); do [ "$(probe "$URL/")" != "000" ] && break; sleep 0.3; done
+ if [ -z "${BEARBROWSER_NO_OPEN:-}" ]; then
+ { command -v open >/dev/null 2>&1 && open "$URL"; } || { command -v xdg-open >/dev/null 2>&1 && xdg-open "$URL"; } || true
+ fi
+fi
+
+echo ""
+echo " ┌─ SOVEREIGN COCKPIT UP ─ loopback only · Ctrl-C to stop ─"
+echo " │ Cockpit UI ${URL:-(not assembled — run bearbrowser-cockpit-assemble)}"
+echo " │ Gate 127.0.0.1:$GATE_PORT governs → sidecar :$UPSTREAM_PORT"
+echo " │ Receipts 127.0.0.1:$RECEIPTS_PORT"
+echo " └─────────────────────────────────────────────────────────"
wait