Skip to content

ADFA-5339 feat(dashboard): rebuild-log endpoint, opt-in website refresh (server half) - #516

Merged
luisguzman-adfa merged 3 commits into
mainfrom
feat/ADFA-5339-dashboard-update-server
Sep 1, 2026
Merged

ADFA-5339 feat(dashboard): rebuild-log endpoint, opt-in website refresh (server half)#516
luisguzman-adfa merged 3 commits into
mainfrom
feat/ADFA-5339-dashboard-update-server

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

Phase 1 server half of the Dashboard-update card. Two additive, localhost-only endpoints the app
UI will build on (in a separate PR), plus two robustness fixes that device verification surfaced.
No user-facing change here; verified end-to-end by curl on device (dash-node 1.2.11 → 1.2.12).

Touches only static/dashboard/ + tools/ — no controller/app/, so it can't conflict with the
app PRs.

Endpoints

  • GET /system/dashboard/rebuild/log — read-only tail of /var/log/dash-rebuild.log (last ~200
    lines; a whole rebuild fits). No rebuild yet = empty log, not an error. Feeds the card's Details.
  • POST /system/dashboard/rebuild accepts { site: true } → refreshes the served landing page in
    the same run via site-updater.sh, from the same clone the rebuild's git fetch+reset refreshes,
    in finalize after the core swap verifies live, so the site matches the new source.

Semantics (per the ticket's "read first")

The REST core and the landing site are separate artifacts. The version belongs to the core; the site
never carries one. Enforced by construction: site-updater.sh touches neither package.json nor the
reported version, and a site failure is logged, never a rollback of the already-verified core update.
Verified on device: after a site:true rebuild, system/version was unchanged and /home/ served
the fresh landing page.

Two fixes device verification caught

  • shbash for site-updater (rebuild-dashboard.sh). It's a bash script (${BASH_SOURCE[0]},
    arrays); invoking it with sh (dash) tripped on the bash-isms and mis-resolved its own source dir to
    /root. The best-effort guard had contained it — the core stayed 1.2.12 — but the site step failed.
  • Validate the source before wiping the destination (site-updater.sh). The mirror wiped the
    served dir before checking the source, so the mis-resolved /root deleted the site and copied the
    wrong tree with no rollback. The [ -d ] guard was too weak (a wrong-but-existing dir passes);
    replaced with [ -f "$SITE_SRC/index.html" ], which only the real site satisfies — one stronger
    guard instead of two, refusing (changing nothing) on a bad source.

Deploy note

Because rebuild-dashboard.sh self-updates via git reset, a box needs the rebuild run twice to
pick up these script changes: the first run executes the pre-fix script in memory while fetching the
new one; the second runs the new one.

dash-node 1.2.11 → 1.2.12.

…ocalhost-only endpoints that

the UI surfaces (Update⇄Rebuild button, expandable Details, the confirm-dialog checkbox) will build
on in their own PRs. Nothing user-facing here; verifiable entirely by `curl`.

dash-node serves two separate artifacts from one process: the **REST core** (`static/dashboard/`,
has a `package.json` version) and the **landing site** (`static/site/`, no version of its own). The
version belongs strictly to the core; the site never carries one. This PR honours that by
construction — `site-updater.sh` touches neither `package.json` nor the reported version, so the
core can never present a "site version".

- **`GET /system/dashboard/rebuild/log`** — read-only tail of `/var/log/dash-rebuild.log` (last
  ~200 lines; a whole rebuild fits, so the client replaces the panel each poll rather than tracking
  a cursor). No rebuild ever ran = empty log, not an error.
- **`POST /system/dashboard/rebuild` accepts `{ site: true }`** → passes `K2GO_SITE=1` to the
  script; the response echoes `site`. Absent/false keeps the previous behaviour exactly.
- **`rebuild-dashboard.sh`** runs `site-updater.sh` in **finalize** — from the same clone the
  rebuild's `git fetch+reset` just refreshed, and only **after** the core swap has verified live, so
  the deployed site matches the new source. It is **best-effort**: a site failure is logged, never a
  rollback of the already-verified core update. Runs on any rebuild (Update or a same-version
  Rebuild), which is why the site action is versionless and idempotent.

Lifecycle worth stating: the site deploys **only if the core reached finalize**. If the staging
build or smoke test fails, finalize is never reached and the site is untouched — it matches the new
source or is not deployed, never half.

dash-node **1.2.11 → 1.2.12** (both changes are REST-facing; CHANGELOG updated).

- Shell syntax checked (`sh -n` / `bash -n`) on both scripts.
- TypeScript reviewed by hand; **not** typechecked here (no Node on the build machine) — the
  deploy's `yarn build` (= `tsc`) is the real gate, same as ADFA-5361.
- On device, after deploying this branch:
site-updater.sh mirrors static/site into the served home dir, but it wiped the destination BEFORE
checking the source — so a mis-resolved SITE_SRC (what the sh-vs-bash bug produced: /root) deleted
the served site and copied the wrong tree with no rollback. The `[ -d ]` guard was too weak: a
wrong-but-existing dir passes it. Replaced with `[ -f "$SITE_SRC/index.html" ]`, which only the real
site satisfies — one stronger guard instead of two, and it refuses (printing why, changing nothing)
instead of destroying on a bad source. Device-caught while verifying ADFA-5339.
@luisguzman-adfa
luisguzman-adfa merged commit 4cb051d into main Sep 1, 2026
4 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the feat/ADFA-5339-dashboard-update-server branch September 1, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant