Repository navigation
✨ perf: progressively load the dashboard shell and live panels - #16457
Conversation
Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. clubanderson this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. Review findings from Read the tree at the PR head (not just the diff). The externalization is sound; nothing blocking. Verified
Low
Looks correct to me. Review findings from docs-currency review (read at head 8e1b32b) 1. New and bump 2. 3. Recovery state hides a root that does not exist (low) — Review findings from Correctness review (read at head 8e1b32b; 1. Two-slot background queue has head-of-line blocking with no slot timeout (medium)
Consequences vs. the pre-PR behaviour (independent
Suggested fix — release the slot (and the coalescing key) after a ceiling while letting the late job still settle its own promise: --- a/src/pkg/dashboard/static-src/js/progressive.js
+++ b/src/pkg/dashboard/static-src/js/progressive.js
@@
const DASHBOARD_BACKGROUND_DELAY_MS = 350;
+ // A stalled response must not pin a slot (or its coalescing key) forever.
+ const DASHBOARD_SLOT_TIMEOUT_MS = 20000;
@@
job.running = true;
_dashboardBackgroundRunning++;
- function finished() {
- _dashboardBackgroundJobs.delete(job.key);
- _dashboardBackgroundRunning--;
- dashboardWakeBackground();
- }
+ let released = false;
+ function finished() {
+ if (released) return;
+ released = true;
+ clearTimeout(slotTimer);
+ if (_dashboardBackgroundJobs.get(job.key) === job) _dashboardBackgroundJobs.delete(job.key);
+ _dashboardBackgroundRunning--;
+ dashboardWakeBackground();
+ }
+ const slotTimer = setTimeout(function() {
+ console.warn('dashboard work ' + job.key + ' exceeded ' + DASHBOARD_SLOT_TIMEOUT_MS + 'ms; releasing its slot');
+ finished();
+ }, DASHBOARD_SLOT_TIMEOUT_MS);A test for "a never-settling job releases its slot and a later tick for the same key starts a fresh flight" would close the gap in 2. Selected-section priority misses hashes with a query string or alias (low)
|
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
Post-PR integration review found a defer-specific initialization-order bug: the modal observer could run while later main-script constants were still in their temporal dead zone. Fixed in 6e32aa8 by deferring its non-loading startup to a microtask; added executable regressions for loading, interactive, and complete ready states using the production initializer/helper order. The earlier hidden-tab tracker redraw race also has an executable regression. CI-reported source citation drift was regenerated with the prescribed fixer. No local test/build/lint execution and no hosted deployment or measured live speedup claimed. |
Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
CI iteration: the new executable progressive-loading suite, existing idle behavior, lint, and reviewed modal initialization regressions passed. Corrected four integration contracts from failed shards: asset registration is now a literal static route with exact-hash validation; interval replacement/cleanup remains directly guardable; review and throughput wiring assertions now pin the queued form instead of the removed burst form. Added real mux/unknown-hash/HEAD/304/method regressions and an executable five-panel bootstrap concurrency test. Source citations regenerated after final route wiring. Waiting for full exact-head CI and coverage rather than bypassing failed gates. |
There was a problem hiding this comment.
Read against head d87dea3 (the push that fixes the three test (dashboard …) failures on 6e32aa8); no defects found in the parts that carry real risk. CI for this head was still running when I looked.
What I verified in the tree, not just the diff:
- Auth boundary.
/assets/dashboard-main.<sha256>.jsis registered ons.mux(server.go:1709) behind the sameauthenticate → roleEnforcement → securityHeaderschain asGET /{$}(server.go:1738), and/assets/is not inisPublicPath(server.go:2377+). Browser auth is session-cookie / proxy-header based (server.go:2030-2075), which a same-origin<script src>carries, so a client that could load the shell can load the script. No new unauthenticated surface. - CSP.
ExternalizeDashboardScriptruns beforeNewIndexDocument(branded)and before the bytes are handed tosetBrandedIndex, so the new inline bootstrap listener is hashed intoscript-src-elemfrom the served bytes, andwebstatic/csp_script_src.go:92already seeds the list with'self', which the external script needs. SRIintegrityis the SHA-256 of the exact extracted body (dashboard_script.go:97-103). - Fail-safe extraction.
dashboard_script.go:87-96: a marker count ≠ 1, a missing</script>, or any later<scriptfalls back to the original inline document with a warn log (server.go:1712), so a future generator change degrades to today's behaviour rather than a broken shell.ServeHTTP404s any path other than its own (dashboard_script.go:135-139), soGET /assets/{script}is not a file-server. - Interval/scheduler behaviour.
history-sparklines.js:20-45still clears and re-creates the timer per key;dashboardRunIntervalonly routes keys present inDASHBOARD_TASK_SECTIONSthroughdashboardScheduleWork, which dedupes by key so a slow fetch does not stack.progressive.js:113-135drops a queued render whose snapshot failsdashboardStatusCanRender(refresh.js:144-148), so the mutation seq floor fromnoteMutationSnapshotFlooris honoured for deferred paints as well as immediate ones. d87dea3movesdashboardClearIntervaladjacent to the newsetIntervalwrapper to satisfyTestDashboardIntervalsAreGuardedOrDocumented, and updates the two string-wiring tests to the new[key, fn]task tuples thatindex.html:67704actually contains.
One thing to be aware of (info, not a defect): the asset URL embeds the hash of the branded bytes, so two processes with different branding/kiosk settings behind one hostname serve different URLs. The bootstrap at dashboard_script.go:21-63 handles that with the reload dialog as the body says, but a reload against a round-robin pair can loop; if that topology exists anywhere, a sticky-session note in the operator docs would help.
PR body vs diff: consistent — the ~154 KB shell figure is reproduced by TestDashboardScriptRealIndexShellBudget, and no runtime speedup is claimed. Looks correct to me; I have not approved or merged anything.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
Final live-update consistency fix: agent-status SSE now coalesces the cost-table redraw as well as agent tables, rather than rebuilding the hidden cost table on every incoming frame. Added a production-handler regression proving a hidden ten-frame burst performs zero table rebuilds, then one latest-state rebuild per table on resume. Hive bot integration of current v5 was fast-forwarded and preserved, including unrelated tracker/header improvements. All merges remain gated on the actual latest source head. |
There was a problem hiding this comment.
docs-currency — delta re-review at 935ddb0 (delta = merge of v5 abf91a8 #16454; no new author commits). Regenerated static/index.html from static-src/ at head and it is byte-identical, so the merge resolution of the generated artifact is clean. Verdict: approve, with two doc gaps the author may want to close:
- New served route is missing from the API reference.
pkg/dashboard/server.go:1709registersGET /assets/{script}(the content-addressed/assets/dashboard-main.<sha256>.js,Cache-Control: private, max-age=31536000, immutable,ETag/304, 404 for any other name —webstatic/dashboard_script.go:130-145). Its siblingGET /branding/custom.css(server.go:1733) is documented indocs/api-reference/snapshots-and-style.md:9, which this PR already edits; the new route is not. Suggested row:
| `GET` | `/assets/{script}` | Dashboard auth/session | The dashboard's main application script, externalized from the index document as a content-addressed deferred asset (`/assets/dashboard-main.<sha256>.js`, SRI `sha256-…`, `Cache-Control: private, max-age=31536000, immutable`, `ETag` + 304); any other name is `404` | `pkg/dashboard/server.go:1709` |
docs/dashboard-source-layout.mdis now stale against this PR. Line 3 ("the single document the spoke dashboard serves") and line 24 ("the served bytes are identical") no longer hold:ExternalizeDashboardScript(webstatic/dashboard_script.go:81-111) splits the main script out at serve time, keyed on the literal first line ofstatic-src/js/core.js:1(pinned byTestDashboardScriptRealIndexShellBudget,dashboard_script_test.go:107). The JS areas list (lines 188-207) also omits the newprogressivearea added tomanifest.txt:61. Suggested: addprogressiveafterlayouton line 188 and a sentence under "Why a generated artifact" noting that the committedindex.htmlis still the canonical source document, but the server externalizes the final script (marker =js/core.js:1) so editing that first comment line changes the shell/script boundary.
Previous finding [correctness] webstatic/dashboard_script.go:26 (top-level throw surfaces as fatal load dialog): still present, unchanged by the delta; it was advisory under the prior approve.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 8e1b32b. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Change
Show the dashboard shell before downloading the application script; serve the exact classic-script bytes through a content-addressed, privately cached deferred asset with SRI and an explicit reload recovery state.
Prioritize the selected and visible panels, cap background work at two concurrent jobs through decoding, coalesce overlapping polls and hidden-tab snapshots, render one status section per idle turn, and restore navigation without awaiting every API. Preserve auth/session guards and mutation snapshot floors.
Evidence and verification
Authenticated Chrome baseline: approximately 1.2 MB compressed HTML, 9.1 seconds download, 75 requests in 45 seconds. Repository-byte extraction reduces the initial compressed shell to approximately 154 KB; the application script remains a separate cacheable download. This is a byte comparison, not a post-deployment timing claim.
Added HTTP cache/gzip/HEAD/304/CSP/recovery tests plus executable progressive-loading regressions. Pre-commit review identified and fixed a queued tracker redraw race. Canonical dashboard regenerated; Go formatting clean. Per AGENTS.md, CI is the sole test/build/lint verdict. No deployment or live speedup claimed.