Repository navigation
feat(dashboard): per-type renderers for every dashboard package block - #18784
chenmingwei23 wants to merge 2 commits into
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK The Not justified as shipped
What this change shipsInventory (8 items) — 3 justifiedIntent: turn a validated dashboard package into a readable HTML page, one renderer per block type. ADDITION.
Blockers
[FIRST-PRINCIPLES-REVIEWED] 1303279 Description read[DESCRIPTION-READ] 43a50f79d7acdcf28c14f9a51696400844d7cbe7fb6df8c7c640e8807962372b That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The description claims removals that are not in this diff: Watch
[DESIGN-REVIEWED] 1303279 Description read[DESCRIPTION-READ] f90ed025d6c67202203813362cfa4e31ff2d65a7dd3cc8a673d5dd545f5d725d That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings that block the merge. FINDING — src/kiro_crew/dashboard_package_render.py:1095 — a refill (a full-read [OPUS-REVIEWED] 1303279 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
7aa51dc to
fddc0ea
Compare
fddc0ea to
b8cd232
Compare
8ed8ff0 to
c553bb1
Compare
b8cd232 to
17ce3eb
Compare
c553bb1 to
6aeec47
Compare
84e5e19 to
5ce145d
Compare
4d7bf2f to
42f6ae9
Compare
5ce145d to
299c440
Compare
299c440 to
0f8929a
Compare
42f6ae9 to
4ae57d9
Compare
0f8929a to
1eaa70c
Compare
4ae57d9 to
05ab809
Compare
1eaa70c to
0e8df76
Compare
The block catalog in the dashboard package was a four-entry stub whose own docstring said the display line owns it. This fills it in and adds the other half: a renderer per block type, and a rendering for every data type each block admits. `view_block_catalog()` now holds ten block types -- stat, stat_band, table, list, note, bars, gauge, pills, timeline, orbit -- and each carries `accepts`, the data types it can draw. That is a GATE: `_validate_view` refuses a block naming a field it cannot draw (a bar chart over a line of text), and refuses a timeline with no timestamp to order by. Without it the catalog could only describe the limit in prose, and a block that silently dropped a field would render a blank cell with every gate green. `kiro_crew.dashboard_package_render` builds the whole document. Its CSP starts at `default-src 'none'` and grants inline script and inline style only -- no origin, no connect-src, no unsafe-eval -- so three.js r159 and anime.js 3.2.2 are vendored into `dashboard_package_vendor/` byte-identical to their npm tarballs, licences intact, and inlined. three.js only for a view that has a 3D block, which is a 650 KB difference. Theme tokens are re-checked at render time over the bytes about to be written, not trusted from the write gate: a token whose value could close its own declaration, or CSS that fetches or leaves the stylesheet, is dropped and the page still renders. `display_values` is the one formatter, in Python, so a cell and the number inside a chart cannot disagree. Tests enumerate the catalogs rather than restating them, in both directions: a block type with no renderer and a renderer with no block type both fail, and every (block type, accepted data type) pair is rendered and looked for. Six mutations were run to show the suite sees a failure; one of them found that the type marker also appears as a CSS selector, so the central pin was asserting on a string present in every document and has been moved to the class attribute.
The renderer could build a whole document and one block's markup, but the page only initialised itself once. So a controller pushing an update to the blocks that subscribe to an advancing fold had two problems: a 3D block repainted that way got no scene, and a second initialisation pass would append a second canvas and leave two scenes animating over each other. Every painter now takes a root -- the document on first paint, one block's own section on a patch -- and the 3D init is idempotent, so running it again over a stage that already has a canvas does nothing. Repainting only the named blocks is not just cheaper: repainting the rest would re-run their count-up animation for numbers that did not change, which is the decoration the brief rules out. `BLOCK_PATCH_MESSAGE_TYPE` is the wire type and `block_patch()` builds the payload. It carries VALUES and never markup: the model and the view change only when the package is versioned, and that is a reload, so a patch has nothing to rebuild and this boundary cannot introduce an element. Each block gets only the fields it renders, so a patch cannot leak a value onto a block the view never put it on, and the strings come from `display_values` -- the same formatter the first render used. `blocks_reading()` answers which blocks a set of moved fields belongs to, so a caller holding a fold's new values does not also have to hold the subscription map. Verified in a real browser, not by string match: a patch posted from the parent of a sandboxed frame moved 7 of 40 cells and left 33 alone, advanced seq 1842 -> 1843, rescaled all four bars in the group whose largest value moved, took the ring from offset 94.75 to 34.85, and left exactly one canvas. A patch naming a block the page does not have changed nothing, and a post from the page's own window was ignored -- the sender check is now asserted against every type branch, not one spelling of it.
05ab809 to
1303279
Compare
|
Superseded: pages are agent-written HTML on the dashboard_frame contract; see #18642. |
Problem / Motivation
Goal: a validated dashboard package becomes a page a crewmate can read, with
one renderer per block type and no block silently drawn as something else.
The stack below gives a layout package a validated home and a model reader, but
nothing turns a package into HTML: a
viewnames block types and the fieldseach shows, a
modelsays what type every field is, and no code maps either tomarkup. So a composed package has no page.
The catalog below this PR is also a four-type stub (
stat,table,list,timeline), and every type an agent is offered must actually draw: a catalogtype with no renderer validates on write and then appears as an empty box on
somebody's dashboard.
Why it matters
A dashboard is only worth the trust a reader puts in it, and the ways markup
betrays that are specific. A number without its unit reads as a different
quantity; a timestamp drawn as a number reads as a count; a block whose type has
no renderer leaves a hole that looks like missing data rather than a missing
feature. None of those is visible in a diff, which is why this PR's evidence is
38 rendered captures rather than assertions alone.
Not a goal
What changed (motivation -> approach -> change)
Goal: every block type a package may name draws its own markup.
Approach. A chain of conditionals inside one render function is how a type ends
up half-handled, so instead there is one formatter table keyed by field type and
one renderer table keyed by block type, and a test asserts each table's keys ARE
the corresponding catalog. A type added to a catalog with no renderer is then a
test failure here rather than an empty box on a dashboard.
src/kiro_crew/dashboard_package_render.py(new): per-type renderers forevery block type and per-type formatters for every field type. A
numbercarries its
unitand honoursprecision; atimestamprenders as<time>;an
enumrenders against itschoices, and a value outside them is SHOWN,because a fold disagreeing with the model is information.
view_block_catalog()stays the single point of truth: validation, the JSONSchema and the dispatch table all read that one function.
block_patch()renders one block's values, so a page updates in place withoutre-initialising the whole document.
dashboard_package_vendor/(
anime-3.2.2.min.js,three-0.159.0.min.js) with their licences and theMANIFEST.in/setup.cfgentries that ship them. Committed and servedlocally because the page's CSP allows no network, so a CDN reference would
silently fail to load.
prefers-reduced-motionrather than animating anyway or disappearing.Backwards compatibility
Compatible with ONE exception:
dashboard_package_renderis a new module with noprior callers, and widening
view_block_catalog()otherwise only makes validwhat the stub refused. The exception is
timeline, whichrequiresatimestampamong its fields -- nothing to order by without one -- so a timelinecarrying none is refused where the stub accepted it. The
setup.cfg/MANIFEST.inentries add files and remove none.Tightened, once:
revert_package()REFUSES a revert whose live package doesnot parse, rather than falling back to the target version's own
bound_to. Theevidence is this PR's own review finding that the fallback rebinds wrongly:
bound_tois the one field a revert must not restore, so an unreadable livecopy has no live binding to keep, and taking the target's can hand the page to
whoever that stale binding named -- silently. Its only caller is the store's
dashboard revert; a readable live package is unaffected.
Removed, both unreachable:
block_catalog_summary(), whose only caller wasits own test (now reading the catalogs directly), and the repo-wide
':(exclude)*.min.js'pathspec -- every minified file in the tree sits under avendor directory the scan already excludes. Both vendor exclusions stay.
Fixed: a timestamp's day comes from
moment.day, notstrftime, so thestring no longer differs by platform.
%-dis a glibc extension Windowsrejects, which gave "Oct 9" here and "Oct 09" there and made the formatter test
red on Windows.
_supports_dash_d()goes with it.Otherwise additive; one test moved rather than vanished, see Tests.
Tests
What they lock in: every block type renders its own markup, parameterised over
the whole catalog, asserting the type's own class AND the absence of the
unrenderable fallback class; the formatter table's keys ARE
data_type_catalog(); the catalog is no longer the four-type stub, asserted asa property rather than a frozen list; a value outside an
enum's choices isshown, not dropped; one block's patch leaves its neighbours alone.
One test moved rather than being deleted. The pin that the JSON Schema's
block enum equals this PR's
BLOCK_TYPESnow lives beside the generator in#18760, against the catalog FUNCTIONS rather than a frozen list, so it keeps
holding as this PR widens the catalog.
The suite was shown able to fail: pointing the
timestampformatter at_format_numbergives2 failed. The mutation was reverted and the restoresha256-verified.
Gates all exit 0:
flake8,isort --check-only,black --check,mypy, thecomment-history gate with its self-test, take-away and fold-catalogue.
Manual verification
Each captured page is the actual HTML this module produced for a validated
package, loaded in a browser with the document's own stylesheet and the vendored
scripts, not a mock. The VALUES are fixtures, so they prove only that the
renderer's rules formatted them. A probe recorded computed styles per shot, so
"the token reached the page" is checked rather than eyeballed; that file is in a
PR comment.
Screenshots / video
All 38 are on branch
screenshots/18642-rendererswith the full captiontable; this branch carries no images. Load-bearing shots are inline.
R1 -- every block type renders its own markup. One pair per type in the
branch README, both themes, because the renderers read theme tokens.
R3 -- a page is patched one block at a time. Only the patched block's
values changed; no other block re-initialised.
R5 -- theme tokens apply, and a hostile one is dropped. A token trying to
close its own CSS declaration is dropped and the page still renders.
Related Issues
Refs #18642
Depends on #18707
The T3 one-pager for #18642 was approved, so this line opens its PRs.
Pattern harvest
Not generalizable: a new rendering surface, not a fix. The habit worth naming
is already enforced by the dispatch-table tests above.
Checklist
Contribution License Agreement
I confirm that this contribution is made under the terms of the Apache-2.0
license, per the Licensing section of CONTRIBUTING.md.