From 190df8119f75fbf0c751d355554dfaf36b8eadb8 Mon Sep 17 00:00:00 2001 From: Algis Dumbris Date: Tue, 14 Apr 2026 20:58:57 +0300 Subject: [PATCH] fix(example): rebuild web dist in start.sh when missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The binary embeds internal/web/dist via go:embed, but .gitignore only tracks index.html. A fresh clone has an empty dist, so the binary serves only the shell HTML + no _app JS — the channel page renders its skeleton placeholder forever because the SPA never loads. start.sh now detects an empty dist, runs `npm run build`, and copies web/build into internal/web/dist before `go build`. Co-Authored-By: Claude Opus 4.6 (1M context) --- examples/doc-gardener/start.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/doc-gardener/start.sh b/examples/doc-gardener/start.sh index 92e7625..60a11a0 100755 --- a/examples/doc-gardener/start.sh +++ b/examples/doc-gardener/start.sh @@ -39,6 +39,28 @@ fi # --- build ------------------------------------------------------------- say "building synapbus + docgardener binaries..." mkdir -p "$BIN_DIR" + +# The Web UI is embedded via go:embed at compile time. If +# internal/web/dist is missing or stale the binary will serve an +# old/empty SPA (symptom: channel messages UI stuck on loading +# skeletons). Rebuild it from web/build whenever the source is newer +# than the embedded copy, or if the embedded copy is missing. +DIST_DIR="$REPO_ROOT/internal/web/dist" +WEB_SRC="$REPO_ROOT/web/build" +if [ ! -d "$DIST_DIR/_app" ] || [ -z "$(ls -A "$DIST_DIR" 2>/dev/null)" ]; then + say "embedded web dist missing — running 'npm run build' and syncing" + if command -v npm >/dev/null && [ -d "$REPO_ROOT/web/node_modules" ]; then + (cd "$REPO_ROOT/web" && npm run build >/dev/null 2>&1) || true + fi + if [ -d "$WEB_SRC/_app" ]; then + rm -rf "$DIST_DIR" + mkdir -p "$DIST_DIR" + cp -r "$WEB_SRC/"* "$DIST_DIR/" + else + say "WARNING: $WEB_SRC not found — embedded web dist may be stale" + fi +fi + (cd "$REPO_ROOT" && CGO_ENABLED=0 go build -o "$BIN" ./cmd/synapbus) (cd "$REPO_ROOT" && CGO_ENABLED=0 go build -o "$DOCGARDENER" ./cmd/docgardener)