formats/components has robust cssdoc declarations including structure. We should be able…
Private research annotation
Sign in to add a private research label or note.
- User
formats/components has robust cssdoc declarations including structure. We should be able to automate robust DOM testing and fixtures across all (or most) variants and ensure that the display resolves to the actual css declarations / token IR value for 1:1 matching of components to instui values.
Assistant
I'll start by exploring the codebase to understand
formats/components, its cssdoc structure, the token IR, and existing testing patterns before proposing an approach.Assistant
I've launched three parallel exploration agents. While they work, let me note the plan file location and wait for their findings.
The agents are exploring:
formats/componentsstructure — records, cssdoc structure blocks, CSS emission- Testing infrastructure — runners, DOM/browser test setup, existing fixtures
- Token IR + InstUI resolution — how to get the "1:1 match" reference values
I'll wait for these to complete before designing the approach.
Assistant
Testing agent done. Waiting on the other two (components structure and token IR).
Assistant
Two of three done. Waiting on the token IR / InstUI resolution agent before I design the plan — that one is critical for the "1:1 match to InstUI values" part.
Assistant
All three explorations are in. Let me read the critical files myself to ground the plan — the validate helper, a
@structureexample, the token JSON shape, and the existing browser runner.Assistant
The demo runner confirms the injection pattern (link the multi-theme sheet, set
data-pantoken-theme+color-scheme, render fixture HTML). Now let me confirm two design-critical facts: whether a token→literal resolver already exists in@pantoken/utils, and whether Playwright/browser testing is actually available in the toolchain.Assistant
makeResolverin@pantoken/utilsalready does exactly the token→literal resolution I need (withlight-dark()mode handling), and@vitest/browserwith thebrowser-previewprovider is installed. Let me read the resolver signature to confirm the API.Assistant
No Playwright binary — only
@vitest/browserwith thebrowser-previewprovider is installed. One more grep to locate where the shipped--instui-*custom-property sheet comes from (the tests must inject it sovar()resolves), then I'll confirm scope with you.Assistant
I now have a complete picture. Here's what I found:
- Components are pure CSS referencing
var(--instui-*); rich cssdoc (@structureon 28 records, plus@example,@modifier,@part,@cssstate) already describes the DOM and every variant. - The expected-value resolver already exists:
makeResolver(byTheme(theme), { mode })in@pantoken/utilsresolves anyvar(--instui-*)to its concrete literal (#hex/rem), withlight-dark()mode handling. No new resolver needed. - The token sheet (
@pantoken/css→style.css) defines all--instui-*properties — inject it + the component sheet so the browser resolves the cascade. - The gap: nothing renders CSS in a real browser to read
getComputedStyle.@vitest/browser(v4.1.10) with thebrowser-previewprovider is installed; jsdom/happy-dom are not (and jsdom can't resolve custom properties anyway).
- Components are pure CSS referencing
Assistant
All three decisions noted: token-IR match, full theme × light/dark matrix, and add Playwright. One last check — how the shipped token sheet encodes the three themes (so the harness knows what to toggle per cell).
Assistant
The default
style.cssis single-theme (rebrand) withlight-dark(). To cover canvas + canvasHighContrast I'll generate the token property sheet per theme via theformats/cssemitter (a different code path from the resolver, so the assertion stays non-circular). Let me confirm that emitter's export name, then write the plan.Assistant
toCss(byTheme(theme))from@pantoken/cssgives me a per-theme token property sheet — exactly what I need. I have everything. Writing the plan.Assistant
The plan is written. Let me present it for approval.
Assistant
Good calls — Playwright drives real hover/focus/active across all three engines, so we can assert accessibility states instead of skipping them. Let me update the plan.
Assistant
Now the edge-cases note, the config/deps, and verification need to reflect state-driving + three engines.
Assistant
Plan updated to drive real hover/focus/active states via Playwright and run across chromium, firefox (gecko), and webkit. Re-submitting for approval.
Assistant
Let me look at
buttonconcretely to validate the combination claim and count the real variant surface before I commit to a combination strategy.Assistant
buttonis the perfect stress test. It declares ~18 modifiers (-color-secondary/tertiary/danger/success/ai/ai-secondary/primary-inverse,-size-sm/lg,-shape-square/circle,-display-block,-condensed,-toggle,-ghost,-without-background,-without-border,-icon-*) and ~40 authored CSS rules once you count states (:hover,:active,:disabled,[aria-pressed]) and compounds like.-color-secondary.-ghost:hover.That surfaces a real design decision. A naive cartesian product — every modifier present/absent × every state — is 2¹⁸ × states × 3 engines × 3 themes × 2 modes = millions of renders. Infeasible, and mostly meaningless: a combination the author wrote no rule for produces no new token-level value to assert. So I want to confirm the combination strategy, because it changes what "hundreds of combinations" means.
Assistant
Selector-derived exhaustive it is. Let me update the plan with the combination strategy (validated against
button) and the fixture-caching design.Assistant
Now update the matrix wording and add the fixture-caching design.
Assistant
Now update the Files section to reflect the combination + cache split.
Assistant
Finally, add cache + coverage validation to the verification section.
Assistant
The plan now covers real state-driving across chromium/firefox/webkit, selector-derived exhaustive coverage (validated against
button's ~40 rules), and content-hash fixture caching. Submitting for approval.Assistant
Good addition — the web components are the runtime counterpart and deserve the same parity guarantee. Let me explore
renderers/web-componentsto design its slice correctly (shadow CSS, custom-element attributes, how it relates toformats/components).Assistant
Exploring
renderers/web-componentsnow. I'll extend the plan once I understand its shadow-CSS model and how variants map to markup.- User
Summary for a 1:1 comparison harness
- IR value =
Token.value(authored reference/literal) in@pantoken/modelshape; get the concrete literal by walkingrefersToto a primitive informats/tokens/generated/{rebrand,canvas,canvasHighContrast}.json. - Emitted component CSS keeps
var()references (formats/components/generated/*.css), so a rendered pantoken component's computed style is the browser's resolution of those vars — compare that computed value to the resolved IR literal. - InstUI upstream values come from
@instructure/instructure-design-tokensviabuildTokens(); a byte-exact committed snapshot exists attools/upstream-diff/baseline/manifest.jsonguarded by theupgrade:check/upgrade:blessdrift gate. - Real InstUI React components render only in
renderers/react-markdown(SSR markup, no computed-style capture). No existing harness extracts InstUI's computed CSS — that side would need to be built with@instructure/ui-themes+ emotion. <subagent_tokens>65228</subagent_tokens><tool_uses>26</tool_uses><duration_ms>145003</duration_ms>
- IR value =
- User
Assistant
Comprehensive picture. The key insight: presentational web components inject the same
@pantoken/componentsbuilder CSS into their shadow roots, so the assertion table is identical — the web-components slice mostly reuses the components machinery, plus a per-element attribute→modifier map and shadow-boundary reads. Behavioral elements (calendar, date-input, drawer-layout, etc.) have their ownvar(--instui-*)shadow CSS needing separate extraction. Let me fold this into the plan.Assistant
Now let me structure it into two parts and insert the web-components design before the shared Files/Verification sections.
Assistant
Let me verify the insertion landed in the right place.
Assistant
Part 2 isn't in yet. Let me read the anchor before
## Filesand insert it.Assistant
Now extend the Files and Verification sections to cover Part 2 and the shared/relocated helpers.
Assistant
Two refinements the Files section needs: browser tests run in the browser, so the postcss/fs extraction + cache must run Node-side (a Vitest
globalSetup) and hand fixtures to the test viaprovide/inject; and the shared harness should be one internal package both suites import rather than a cross-package relative path. Let me update.Assistant
Now extend Verification with the web-components checks.
Assistant
The plan now spans both packages: Part 1 (
@pantoken/components) renders CSS fixtures and asserts computed styles resolve to token literals; Part 2 (@pantoken/web-components) reuses that assertion table in shadow roots plus an equivalence cross-check, with a sharedtools/css-parityharness and Node-side fixture generation feeding the browser tests. Submitting for approval.Assistant
Makes sense — the strategy should be a knob, not a hard-coded choice. Let me read the current combination section and rework it into a configurable one.
Assistant
Now reflect the knob in the coverage matrix, the
buildFixturessignature, config, and verification.Assistant
The plan now makes fixture generation a configurable strategy —
rulesetby default, withpairwiseandcartesianopt-in viaPARITY_COMBINATIONS, a cascade resolver to score synthesized combinations, and aPARITY_MAX_FIXTURESguard against silent blowup. Submitting for approval.Assistant
Yes — caching is already in the plan (the
Fixture cachingsection, and I madestrategypart of the cache key). But you're right that it matters much more now, since a cartesian expansion is the expensive thing worth persisting. Let me make the caching section explicitly cover the combinatorial strategies.Assistant
To answer directly: yes, caching is in the plan, and I've now made it explicitly persist the fully-expanded fixture set keyed by strategy. So a
pairwiseorcartesianexpansion (plus its per-combination cascade resolve — the actually-expensive part) is computed once and reused on every later run until the record's emitted CSS, the strategy,maxFixtures, or the generator version changes. Switching back to a previously-run strategy is an instant cache hit, not a recompute.- User
[Request interrupted by user]