diff --git a/README.md b/README.md index 3a4605f..93a039b 100644 --- a/README.md +++ b/README.md @@ -389,8 +389,8 @@ Application screens (`type: "desktop-app"`) are built from eight primitives on t | `link` | `label`, `icon`, `iconPosition`, `external`, `ariaLabel`, `state` | A standalone text action, at least 24 tall. With no `label` it hugs its glyphs (14px wide, 30 with `external`) and needs an `ariaLabel` (rendered as `aria-label` and `title`). A `text` node can hold inline links instead: `links: [{ start, end }]` character ranges of its content, drawn underlined and exempt from the 24px floor | | `text-input` | `value`, `placeholder`, `icon`, `size` (`sm` 32 / `md` 40), `rows`, `error` (a message), `disabled`, `state` | A field whose border (`$border-strong` when the design system has it) is its only boundary; `error` draws an icon and the message below and turns the border `$danger` | | `nav-item` | `label`, `icon`, `count`, `dotColor`, `active`, `depth` (0 / 1), `collapsed`, `state` | A 32px sidebar row. `active` draws an `$accent-tint` fill, a 2px `$accent` bar and a heavier label; `collapsed` is the 32×32 rail form, with the label as its accessible name; `dotColor` is an identity dot, never counted as an accent | -| `tabs` | `items: [{ label, count?, active?, disabled?, state? }]`, `variant` (`line` / `contained`), `size` (`sm` 32 / `md` 40) | One tablist; each tab is its own target. The active tab gets an indicator (`line`) or an `$accent-tint` fill (`contained`) | -| `tree-row` | `label`, `depth`, `expanded` (absent for a leaf), `icon`, `active`, `state` | A 32px row indented 16px per level, with a chevron when `expanded` is set | +| `tabs` | `items: [{ label, count?, active?, disabled?, state? }]`, `variant` (`line` / `contained`), `size` (`sm` 32 / `md` 40) | One tablist; each tab is its own target. The active tab gets an indicator (`line`) or an `$accent-tint` fill (`contained`); only the line underline is measured by `desktop-app-state-contrast` | +| `tree-row` | `label`, `depth`, `expanded` (absent for a leaf), `icon`, `active`, `state` | A 32px row indented 16px per level, with a chevron when `expanded` is set; `active` draws an `$accent-tint` fill, a 2px bar in `iconColor` (`$accent` by default) at the row's left edge at every depth, and a heavier label | | `menu-row` | `label`, `icon`, `shortcut`, `checked`, `destructive`, `disabled`, `submenu`, `state` | A 32px menu item; the shortcut right-aligns in a muted `kbd` style, `destructive` uses `$danger` | | `property-row` | `label`, `labelWidth` (96), one child | An inspector row: a muted label column, then its value (a control, a `text-input`, a `button`, a text). A control that is its only target is measured by the row's box. The row's `label` names a control directly inside it; with a blank label only text inside the row itself does (a sibling row's text does not count). The other desktop-app primitives drop any children | | `divider` | `orientation` (`horizontal` / `vertical`), `inset` | A 1px `$border` hairline; vertical dividers separate panes | @@ -933,8 +933,8 @@ Every result also carries a **`surface`** field: `{ type, device, source, rulesO | `desktop-app-primary-count` | structure | info | Desktop-app only: two or more primary `button`s in one pane (any variant but `secondary`, `ghost` or `destructive` renders filled, so it counts; no variant included). A modal's `actions` with `variant: "primary"` count in the modal's pane. Primaries inside three or more same-shaped sibling frames, such as a card grid, don't count. | | `desktop-app-overlay` | usability | warning / info | Desktop-app only: warns on a second `modal`; a `tooltip` with children; inside a modal, a table of more than ten body rows or a frame with `overflow: "auto"` that renders wider than the modal or scrolls sideways; an overlay that leaves the viewport (the root's size, else the window's; a modal wider than the viewport less 32px in both modes, in fast mode a popover or menu with numeric `x`/`y`/`width`/`height` and a placed modal's sides, in detailed mode every rendered overlay); a `popover` or `menu` on a canvas with a modal or a scrimmed drawer, which renders under the scrim. Infos: a second `toast`, a `danger` toast, an `anchor` naming no node or nothing clickable. | | `desktop-app-focus-visible` | color | error / info | Desktop-app only, in each theme: a focus ring (`$focus-ring`, else `$accent`) below 3:1 against the pixels it covers unfocused (the backdrop behind the target; a tab's own fill for its inset ring). One error per ring and backdrop, with `nodeIds` and `count`; a target whose backdrop or ring cannot be read is listed in one info. Disabled targets are skipped. | -| `desktop-app-state-contrast` | color | warning | Desktop-app only, in each theme: an active `nav-item`'s bar or an active line tab's underline below 3:1 against its active fill, at rest or in hover. | -| `desktop-app-boundary` | color | warning | Desktop-app only, in each theme: a `text-input` border, an unchecked `checkbox` or `radio` outline, or an unchecked `toggle` track below 3:1 against what is behind it. A border that draws nothing (`transparent`, an unresolved token) counts as invisible; a field whose own fill clears 3:1 passes. `$border-strong` clears it on `bg-primary` and `bg-surface`. | +| `desktop-app-state-contrast` | color | warning | Desktop-app only, in each theme: an active `nav-item`'s or `tree-row`'s 2px bar, or an active line tab's underline, below 3:1 against its active fill, at rest or in hover. A contained tab draws no mark and is not measured. | +| `desktop-app-boundary` | color | warning | Desktop-app only, in each theme: a `text-input` or `select` border, an unchecked `checkbox` or `radio` outline, or an unchecked `toggle` track below 3:1 against what is behind it. A border that draws nothing (`transparent`, an unresolved token) counts as invisible; a field whose own fill clears 3:1 passes. `$border-strong` clears it on `bg-primary` and `bg-surface`. Not measured: a disabled control, a gradient or unreadable backdrop or colour. | | `desktop-app-disabled` | color | info | Desktop-app only, when the `state` tokens set the disabled opacities: targets whose disabled content would draw within 1.1:1 of their enabled content. On every type, text inside a disabled clickable primitive is exempt from the text-contrast error. | Repeated findings fold in this result: three or more warnings or infos with the same severity, category, rule (or tell) and theme come back as one entry when they also share their message — on its shape for members that carry a fix (each fix op holds its node's specifics), word for word apart from quoted node text for members without one. The entry keeps the first one's message and adds `nodeIds` (distinct), `count` and, when they had fixes, `fixes: [{ nodeId, op }]`. Errors never fold, and `canvas_autofix` works from the unfolded list. @@ -1081,7 +1081,7 @@ Content stress test — does the design survive real data? Re-renders the canvas |---|---| | `long-text` | Non-data text ×2.2 plus one long unbroken token (the wrap-breaker) | | `i18n` | Text ×1.4 — the German/Finnish expansion rule | -| `big-numbers` | Data-like text to its widest realistic form: `9` → `999+`, `$1.5M` → `$1,520,847.33` | +| `big-numbers` | Data-like text to its widest realistic form: `9` → `999+`, `$1.5M` → `$1,520,847.33`; also a `nav-item`'s and a tab's `count` (numbers included; `42` or `1.2K` → `999+`, a word such as `New` untouched), which only this perturbation touches | | `empty` | Detected tables lose their data rows (and runs of two or more consecutive `list-row`s are emptied; on a desktop-app canvas also runs of `nav-item`, `tree-row`, `menu-row` or `property-row`, and card grids) | | `many` | Data rows ×3 (and `list-row` runs ×3; on a desktop-app canvas also runs of `nav-item`, `tree-row`, `menu-row` or `property-row`, and card grids, a grid of three or more same-shaped children). Copies drop `active`, so a tripled list keeps one current row | @@ -1233,7 +1233,7 @@ I("parent", { type: "select" }) # renders a muted "Select I("parent", { type: "toggle", checked: true, disabled: true }) # 38% in $text-primary with disabled state tokens, else 50% ``` -Colors default from the design system — `$accent` (falling back to `$primary`) for active states, `$border` for outlines, `$bg-surface` / `$text-primary` for the select — with neutral fallbacks on unthemed canvases. Explicit `fill` / `stroke` / `color` override. Defaults: toggle 44×24, checkbox/radio 18×18, select `fit-content` (give it a `width` for form layouts). +Colors default from the design system — `$accent` (falling back to `$primary`) for active states, `$border-strong` (else `$border`) for an unchecked control's outline or track and the select's border, `$bg-surface` / `$text-primary` for the select — with neutral fallbacks on unthemed canvases. Explicit `fill` / `stroke` / `color` override. Defaults: toggle 44×24, checkbox/radio 18×18, select `fit-content` (give it a `width` for form layouts). All four controls are keyboard-focusable in the live viewer (`tabindex="0"`, a `:focus-visible` ring in `$focus-ring`, else `$accent`). A live focus never changes a capture, since nothing is focused in one; to draw the ring in a screenshot, set `state: "focus"` (see Element states above). `canvas_evaluate`'s `usability` category checks the things the renderer can't guarantee on its own: hit-target size, label association, and honest action copy — see the categories table below. diff --git a/VISION.md b/VISION.md index d361e62..ea3b116 100644 --- a/VISION.md +++ b/VISION.md @@ -574,10 +574,10 @@ Run on its own viewer (2026-11-08), framesmith scored every page's usability 100 - [x] Slice G — element states: hover, focus, pressed and disabled as a primitive property (and on the items of tabs, tab-bar, nav-bar, modal and toast), drawn from state tokens; focus is a 2px ring at a 2px gap, disabled renders in the on-surface colour, and `state: "disabled"` counts as disabled in the 24px census and the primary count - [x] Follow-up — a disabled control inside a component instance renders undimmed, because instances render after variable resolution (`resolveInstance`); resolve instance subtrees too, so `disabled` and `state` dim inside components as they do outside (done in Phase 32 slice B) - [x] Slice H — state checks: focus rings, active indicators, disabled renders and control boundaries checked analytically on every interactive primitive, without being drawn, in each theme; text inside a disabled target is exempt from text contrast on every type -- [ ] Follow-up — `select` is not in the boundary check, though its `$border` is its only boundary too; and `tree-row` and the contained `tabs` draw no indicator mark when active (a tint and a heavier weight only), so the active-indicator check has nothing to measure on them +- [x] Follow-up — `select` is not in the boundary check, though its `$border` is its only boundary too; and `tree-row` and the contained `tabs` draw no indicator mark when active (a tint and a heavier weight only), so the active-indicator check has nothing to measure on them (done in Phase 32 slice D: `select` and an active `tree-row`'s new bar are measured; contained tabs stay unmeasured by decision, documented) - [x] Slice I — the acceptance re-run: the viewer's gallery, detail with inspector and archive rebuilt as canvases, with the comment popover and delete-confirm states and the empty archive, all six CLEAN in fast and detailed mode in both themes with a CLEAN stress run, and the six baseline defects fixed (`test/e2e/test-viewer-rebuild.ts`); detailed evaluate now lays out in the design system's own fonts, and a drawer or a scrolling popover reads as scrolling under stress - [x] Follow-up — a misspelt `$token` in a non-colour prop (`gap: "$space-xxs"`, which does not exist) resolves to nothing and evaluate says nothing; the slice I rebuild caught one only through its own resolved-tree check. Warn on any `$ref` the merged tokens do not define (done in Phase 32 slice C) -- [ ] Follow-up — `nav-item.count` is not a stress slot, so a sidebar count of "999+" is never exercised; add it (and `tabs.items[].count`) to the big-numbers perturbation +- [x] Follow-up — `nav-item.count` is not a stress slot, so a sidebar count of "999+" is never exercised; add it (and `tabs.items[].count`) to the big-numbers perturbation (done in Phase 32 slice D) All nine slices are merged and the acceptance re-run passed. The phase is closed. @@ -590,7 +590,7 @@ Phases 30 and 31 closed with seven follow-ups open, and five of them are quiet f - [x] Slice A — tests in folders: `test/unit`, `test/browser`, `test/e2e` and `test/manual` set the tier, a Chrome guard on `test/unit` proves it at run time, tests are type-checked under `strict`, and files are named by subject, not phase or issue - [x] Slice B — one tree: instances expanded and resolved once, so the renderer and every rule (contrast, spacing and cliché included) see the same thing inside a component, and findings there name the instance - [x] Slice C — tokens: an `unknown-token` warning for any `$ref` the merged tokens do not define or that is the wrong kind, with a rename autofix when only one name is close; copy props never resolve; tints and `danger` derive from the applied palette, on new stamps and on canvases holding the old seeds -- [ ] Slice D — desktop-app checks: `select` gets a `$border-strong` boundary and joins the boundary check, an active `tree-row` draws a bar the indicator check measures, and stress widens `nav-item` and `tabs` counts +- [x] Slice D — desktop-app checks: `select` gets a `$border-strong` boundary and joins the boundary check, an active `tree-row` draws a bar the indicator check measures, and stress widens `nav-item` and `tabs` counts - [ ] Slice E — phone targets: `link` and `text-input` (with a new 44px `size: "lg"`) join the 44px census, and `modal` and `toast` take a `controlSize` the census measures _Full spec-driven breakdown in [`docs/specs/PHASE-32-SPEC.md`](docs/specs/PHASE-32-SPEC.md). Deliberately out of scope: a test framework, splitting `src/index.ts` and `src/evaluate.ts`, rewriting "Phase N" comments in `src/`, cross-instance autofix, and an indicator bar on contained tabs._ diff --git a/docs/GUIDELINES.md b/docs/GUIDELINES.md index 3c7d557..66ddc63 100644 --- a/docs/GUIDELINES.md +++ b/docs/GUIDELINES.md @@ -102,8 +102,8 @@ Two terms the rules share. A **pane** is a frame that scrolls on its own (`overf The last four rules judge [element states](#element-states-a-property-not-a-variant) without anyone drawing them. Like the rules above they run on desktop-app canvases only. They are in the `color` category and run in each theme the canvas ships, so a canvas with a dark layer is checked twice and its dark findings carry `theme: "dark"` (fix those in the dark token layer). A dark finding that would only repeat the light one (the colours are literals, so the dark layer cannot change them) is dropped. When the targets sit inside a component instance, the finding names the instance and its component, and the fix goes in the component or an override on the instance. They compute what the renderer draws for every target: each clickable primitive and control, each item of a `tabs`, `tab-bar`, `nav-bar`, `modal` or `toast`, and a modal's close button. WCAG 1.4.11 asks 3:1 of each of them, and fast and detailed mode give the same answer. A target inside a component instance is judged as it renders: the instance's overrides applied and the design system resolved inside it, so its ring is the canvas's `$focus-ring` like any other. A target's own `opacity` dims what it draws; an ancestor's is not modelled. A gradient or a fill the checker cannot read behind a target skips it silently in the last three rules (the first one lists it in an info). - **`desktop-app-focus-visible`** (color, **error**). A target's focus ring (`$focus-ring`, else `$accent`, `$primary`, `#2563EB`) below 3:1 against the pixels it covers when the target is not focused. For the ring drawn outside the box, that is the backdrop behind the target. For a tab or a tab-bar item, whose ring is drawn inside, it is the item's own fill over that backdrop: only a contained tab's active tab has one, so a line tab, an inactive contained tab and a tab-bar item meet the backdrop too. Targets that share a ring and a backdrop make one error: `count` is the number of targets (each tab counts), and `nodeIds` lists each node once (a tab, a tab-bar item, a nav-bar action, a modal's actions and close button and a toast's action report their host). A disabled target draws no ring and is skipped. When the backdrop (or a tab's own fill) is a gradient or a fill the checker cannot read (a named colour, `hsl()`, a translucent overlay), or the ring itself does not parse, one **info** per theme lists those targets. `generate_design_system` picks `$focus-ring` to clear 3:1 against every `bg-*` and `*-tint` token, so a generated system's targets pass on any of those surfaces. -- **`desktop-app-state-contrast`** (color, **warning**). The indicator of an active `nav-item` (its 2px bar in `iconColor`) or of an active tab of a line `tabs` (its underline) below 3:1 against the active fill over the backdrop (the backdrop alone when the item has no fill; a line tab never has one), at rest or with the hover layer over it, since hover must not hide the selection. A `tree-row` and a contained tab draw no indicator mark (their active cue is the fill and the heavier weight), so nothing is measured on them. -- **`desktop-app-boundary`** (color, **warning**). The only boundary of a control below 3:1 against what is behind it: a `text-input`'s border (with or without an `error`), the outline of an unchecked `checkbox` or `radio`, the track of an unchecked `toggle`. A translucent border is measured where it is drawn, over the control's own fill, and a border that draws nothing (`transparent`, `none`, a misspelt or unresolved `$token`) counts as invisible, not as absent. A field or checkbox whose own fill clears 3:1 against the backdrop passes whatever its border, since the fill shows the edge. A checked control is not measured, since its filled box, dot or track is the cue. These controls draw `$border-strong` when the design system has it, else `$border`. `$border-strong` clears 3:1 against `bg-primary` and `bg-surface` and `$border` usually does not, so a canvas without `$border-strong` warns here: add the token (`generate_design_system` writes it, or `set_variables`) rather than recolouring each node. A `select` is not measured. +- **`desktop-app-state-contrast`** (color, **warning**). The indicator of an active `nav-item` or `tree-row` (its 2px bar in `iconColor`, `$accent` by default) or of an active tab of a line `tabs` (its underline) below 3:1 against the active fill over the backdrop (the backdrop alone when the item has no fill; a line tab never has one), at rest or with the hover layer over it, since hover must not hide the selection. A disabled row or tab is skipped. A contained tab draws no mark: its active fill and heavier label are its indicator, and this rule does not measure them, so a contained tab whose fill is indistinguishable from the tablist is not reported (generated tints sit close to the surface by design). Check contained tabs by eye, or use the line variant where the selection must carry on its own. +- **`desktop-app-boundary`** (color, **warning**). The only boundary of a control below 3:1 against what is behind it: a `text-input`'s border (with or without an `error`), the outline of an unchecked `checkbox` or `radio`, the track of an unchecked `toggle`. A translucent border is measured where it is drawn, over the control's own fill, and a border that draws nothing (`transparent`, `none`, a misspelt or unresolved `$token`) counts as invisible, not as absent. A field or checkbox whose own fill clears 3:1 against the backdrop passes whatever its border, since the fill shows the edge. A checked control is not measured, since its filled box, dot or track is the cue. A `select` is measured as a `text-input`: its border, with its fill as the field. These controls and `select` draw `$border-strong` when the design system has it, else `$border`. `$border-strong` clears 3:1 against `bg-primary` and `bg-surface` and `$border` usually does not, so a canvas without `$border-strong` warns here: add the token (`generate_design_system` writes it, or `set_variables`) rather than recolouring each node. A desktop-app stamp seeds `$border-strong` only on a canvas that has no `$border` yet, so a realisation stamped after `apply_preset` warns here until you add the token. Not measured, by design: a disabled control (WCAG exempts it), a control on a web or mobile canvas, and a control whose backdrop is a gradient or image or whose colours the checker cannot read (a named colour, `hsl()`); check those by eye. - **`desktop-app-disabled`** (color, **info**). Runs only when the `state` tokens set a disabled opacity (a lone one takes the other's Material value). It is a prediction, so it covers every target, disabled or not: it lists the targets whose disabled content would draw within 1.1:1 of their enabled content, so disabled would look enabled (for example `state.disabledContent: 1` on a row whose label is already `$text-primary`). Lower `state.disabledContent`; Material uses 0.38. - **On every type**, a `text` node inside a disabled target (any node that takes `state`, with `disabled: true` or `state: "disabled"`, or a disabled `tabs`) is exempt from the `color` category's text-contrast check, as WCAG exempts it. - "Inside a modal" means the modal is the node's nearest overlay ancestor: a popover inside a modal is lifted out, so a table in it is the popover's, not the modal's (the popover itself still gets the scrim warning). "Wider than the modal" compares with the modal's outer width. @@ -130,8 +130,8 @@ Build application screens from these primitives, never from hand-built frames: a - **`link`** `{ label, icon?, iconPosition?, external?, ariaLabel?, state? }` is a standalone text action, at least 24 tall, and a measured target. Without a `label` it hugs its glyphs (14px wide, 30 with `external`) and takes `ariaLabel` as its name (rendered as `aria-label` and `title`). For a link inside a sentence, keep it in the `text` node: `links: [{ start, end }]` marks character ranges of its `content`, drawn underlined. Inline links are exempt from the 24px floor, as WCAG exempts them. A `text` node also takes `title`, rendered as a tooltip. - **`text-input`** `{ value?, placeholder?, icon?, size?: "sm" | "md", rows?, error?, disabled?, state? }` is a field (32 or 40 tall; `rows` makes it multi-line). Its border is its only boundary, so it uses `$border-strong` when the design system has one. `error` turns the border `$danger` and draws an icon and the message below the field, so the error is never colour alone. - **`nav-item`** `{ label, icon?, count?, dotColor?, active?, depth?: 0 | 1, collapsed?, state? }` is a 32px sidebar row that spans its sidebar. `active` draws three cues: an `$accent-tint` fill, a 2px `$accent` bar, and a heavier label (and `aria-current`). `collapsed` is the 32×32 rail form, with its label as the accessible name. `dotColor` is an identity dot for a project or label: it is never counted as a competing accent, though the same colour used anywhere else still is. -- **`tabs`** `{ items: [{ label, count?, active?, disabled?, state? }], variant?: "line" | "contained", size?: "sm" | "md" }` is one tablist (32 or 40 tall). Each tab is its own target. The active tab gets an underline indicator (`line`) or an `$accent-tint` fill (`contained`, from the node's `fill`) and a heavier label. -- **`tree-row`** `{ label, depth, expanded?, icon?, active?, state? }` is a 32px row indented 16px per level. `expanded: true` / `false` draws an open / closed chevron; a leaf leaves it out and keeps the slot, so labels align. +- **`tabs`** `{ items: [{ label, count?, active?, disabled?, state? }], variant?: "line" | "contained", size?: "sm" | "md" }` is one tablist (32 or 40 tall). Each tab is its own target. The active tab gets an underline indicator (`line`) or an `$accent-tint` fill (`contained`, from the node's `fill`) and a heavier label. Only the line underline is measured by `desktop-app-state-contrast`; a contained tab's fill and weight are not. +- **`tree-row`** `{ label, depth, expanded?, icon?, active?, state? }` is a 32px row indented 16px per level. `expanded: true` / `false` draws an open / closed chevron; a leaf leaves it out and keeps the slot, so labels align. `active` draws a `nav-item`'s cues: an `$accent-tint` fill, a 2px bar in `iconColor` (`$accent` by default) at the row's left edge (the same x at every depth, outside the indent), and a heavier label. - **`menu-row`** `{ label, icon?, shortcut?, checked?, destructive?, disabled?, submenu?, state? }` is a 32px menu item. The shortcut right-aligns in a muted `kbd` style, `destructive` uses `$danger`, `submenu` adds a chevron, and `checked` reserves a check slot. - **`property-row`** `{ label, labelWidth? }` with one child is an inspector row: a muted label column (96px by default) and the value (a control, a `text-input`, a `button`, a text). Every row's value starts at the same edge. The row's `label` names a control directly inside it; with a blank label only text inside the row itself does, and otherwise the control gets the usability warning "has no text label" (a sibling row's text does not count). A control that is its only target (directly inside, nothing clickable beside it) is measured by the row's 32px box. Only `property-row` renders children; the other desktop-app primitives draw their own anatomy and drop any children you give them. - **`divider`** `{ orientation?: "horizontal" | "vertical", inset? }` is a 1px `$border` hairline; vertical dividers separate panes. Not a target. @@ -333,7 +333,7 @@ The `chart` node owns the value→coordinate math — give it data and domains, - **Unicode glyphs as icon stand-ins.** `✓ ● ▾ ○` read as unfinished. Use the `icon` node type — two sets render by name as inline SVG: 1,900+ [Lucide](https://lucide.dev) (`icon: "check"`) and 3,800+ [Material Symbols](https://fonts.google.com/icons) (`icon: "material:check"`, `iconStyle: "outlined" | "rounded" | "sharp"`, `-fill` suffix for filled variants). `I("parent", { type: "icon", icon: "material:check", iconSize: 16, iconColor: "$primary" })`. For Material-style design systems, prefer the Material set. - **Spelling an icon in the other set's style.** Lucide hyphenates multi-word names (`chevron-right`); Material Symbols keeps underscores and needs the prefix (`material:chevron_right`, `material:chevron_right-fill`). A bare `chevron_right` is looked up in Lucide and renders nothing. A name that resolves in neither set renders an empty slot, so `canvas_evaluate` reports it as a `structure` warning naming the spellings that do resolve — and `canvas_autofix` rewrites it when exactly one does. - **Baking uppercase into `content`.** Use `textTransform: "uppercase"` (with `letterSpacing` for tracking) so the underlying copy stays editable and case-styling lives in the design, not the data. -- **Faking form controls from frames + ellipses.** `toggle`, `checkbox`, `radio`, and `select` are real node types: `I("parent", { type: "toggle", checked: true })`. They style themselves from `$accent`/`$border`/`$bg-surface` tokens (neutral fallbacks when unthemed) and stay pixel-consistent; `fill`/`stroke`/`color` override. For a text field on an application screen use `text-input`. +- **Faking form controls from frames + ellipses.** `toggle`, `checkbox`, `radio`, and `select` are real node types: `I("parent", { type: "toggle", checked: true })`. They style themselves from `$accent`/`$border`/`$bg-surface` tokens, an unchecked control's outline or track and a select's border from `$border-strong` when the design system has it (neutral fallbacks when unthemed) and stay pixel-consistent; `fill`/`stroke`/`color` override. For a text field on an application screen use `text-input`. - **Faking loading states from plain gray rectangles.** Use `{ type: "skeleton" }` — token-derived fill, correct default radius, and it pulses in the live viewer (always static in screenshots/exports so diffs stay deterministic). Stamp `skeleton-table` / `skeleton-card` / `skeleton-stat-card` instead of hand-placing bars — and skeleton EVERY data surface: the coverage check flags a loading variant that leaves live metric values beside skeletoned regions (a half-designed loading screen flashes real-looking data next to placeholders). - **Hand-building app furniture node by node.** A data table, form field, toolbar, stat card, or settings row is one `apply_structure` stamp: component-kind structures insert under any `targetId` with re-keyed IDs and return an `idMap` for populating. Stamp `data-table`, fill the placeholders, copy rows with `C()` — don't place ~90 nodes by hand. On a phone canvas only the components marked for every type stamp (not `data-table`, `toolbar` or `toggle-row`), and a settings row is a `list-row`. @@ -510,7 +510,7 @@ The happy path of one static frame with ideal data is half a design. Real UX liv **The evaluator demands them.** The `coverage` category warns — directive-blocking — when a base canvas carries data-bearing content with no designed states: a detected table demands `empty` + `loading`; a form (3+ input controls: toggles, checkboxes, radios, selects and `text-input`s outside tables, on every type, so an inspector of three text fields counts too) demands `error`. (Table detection requires three matching horizontal rows — two stacked rows are a layout, not data — so the rare header-plus-one-row table goes undetected; name the frame `Table` to claim the shape explicitly. A list whose every row leads with an icon, a dot or a small image is navigation and never detects.) Variant canvases and non-data screens are silent. The result's `coverage: { dataBearing, states, missing }` tells you where you stand, and `canvas_list` shows the designed states per screen. -**Then stress it.** `canvas_stress` re-renders the canvas under hostile-but-realistic content — `long-text` (×2.2 + an unbroken German compound), `i18n` (×1.4), `big-numbers` (`9` → `999+`, `$1.5M` → `$1,520,847.33`), `empty`, `many` (rows ×3; tables and runs of `list-row`s on every type, and on a desktop-app canvas also runs of `nav-item`, `tree-row`, `menu-row` or `property-row` and card grids, a grid of three or more same-shaped children; a tripled list keeps one active row) — and reports what broke, by node id: `clip` (info when a designed ellipsis is doing its job, or when it's a primitive's label hitting its designed ellipsis, or a root with an authored `overflow` clipping or scrolling inside itself; the vertical overflow of a sheet, a `drawer`, or any frame, `popover` or `menu` with `overflow: "auto"` scrolls and is never a clip, while its horizontal overflow still is; warning otherwise), `overflow-x`, `layout-shift` (an untouched node ballooning — perturbed nodes, their ancestors, and a stretch sibling that merely follows a legitimately growing parent, like a full-height sidebar next to a growing table, are all exempt). Only *new* breakage counts. Fix findings with the [width strategies](#width-strategies) above — fluid widths, `minWidth` or `minHeight` floors, wrapping — or give a must-stay-single-line label `textOverflow: "ellipsis"` (the designed-truncation property: the clip downgrades to info because truncating is the design) — and re-run until `CLEAN`. A data screen goes to the user with its states designed and a `CLEAN` stress verdict, the same way it goes with a >95 score. `canvas_evaluate` holds you to it: once stress has recorded a verdict, the evaluate result carries a `stress` field (`{ verdict, warnings, type, current }` — `current` is false after an edit or a type change since the run), and a `FRAGILE` verdict keeps the directive `NOT READY` until a full `CLEAN` run (all five perturbations) replaces it — a subset run can record `FRAGILE` but never clear it. The verdict lives in server memory, so a restart forgets it. Component instances are stressed as they render, and a finding on a node inside one names it by its expanded id, `"/"`: edit the component, or override the child on the instance. +**Then stress it.** `canvas_stress` re-renders the canvas under hostile-but-realistic content — `long-text` (×2.2 + an unbroken German compound), `i18n` (×1.4), `big-numbers` (`9` → `999+`, `$1.5M` → `$1,520,847.33`; a `nav-item`'s `count` and a tab's `count` too, and only by this perturbation: `42` or `1.2K` → `999+`, a word count such as `New` untouched), `empty`, `many` (rows ×3; tables and runs of `list-row`s on every type, and on a desktop-app canvas also runs of `nav-item`, `tree-row`, `menu-row` or `property-row` and card grids, a grid of three or more same-shaped children; a tripled list keeps one active row) — and reports what broke, by node id: `clip` (info when a designed ellipsis is doing its job, or when it's a primitive's label hitting its designed ellipsis, or a root with an authored `overflow` clipping or scrolling inside itself; the vertical overflow of a sheet, a `drawer`, or any frame, `popover` or `menu` with `overflow: "auto"` scrolls and is never a clip, while its horizontal overflow still is; warning otherwise), `overflow-x`, `layout-shift` (an untouched node ballooning — perturbed nodes, their ancestors, and a stretch sibling that merely follows a legitimately growing parent, like a full-height sidebar next to a growing table, are all exempt). Only *new* breakage counts. Fix findings with the [width strategies](#width-strategies) above — fluid widths, `minWidth` or `minHeight` floors, wrapping — or give a must-stay-single-line label `textOverflow: "ellipsis"` (the designed-truncation property: the clip downgrades to info because truncating is the design) — and re-run until `CLEAN`. A data screen goes to the user with its states designed and a `CLEAN` stress verdict, the same way it goes with a >95 score. `canvas_evaluate` holds you to it: once stress has recorded a verdict, the evaluate result carries a `stress` field (`{ verdict, warnings, type, current }` — `current` is false after an edit or a type change since the run), and a `FRAGILE` verdict keeps the directive `NOT READY` until a full `CLEAN` run (all five perturbations) replaces it — a subset run can record `FRAGILE` but never clear it. The verdict lives in server memory, so a restart forgets it. Component instances are stressed as they render, and a finding on a node inside one names it by its expanded id, `"/"`: edit the component, or override the child on the instance. ## Reviewing the set diff --git a/docs/specs/PHASE-32-SPEC.md b/docs/specs/PHASE-32-SPEC.md index c00ad03..27f9085 100644 --- a/docs/specs/PHASE-32-SPEC.md +++ b/docs/specs/PHASE-32-SPEC.md @@ -63,7 +63,7 @@ And one is housekeeping the follow-ups will land in. 140 tests and `test-env.ts` | **FR-C5** | **Tints and `danger` derive.** `applyStructure` stops seeding `accent-tint`, `success-tint`, `warning-tint`, `danger-tint`, `neutral-tint` and `danger`. A missing `danger` resolves to `error`, then to `#DC2626` (the literal `applyPrimitiveDefaults` already ends on). A tint missing from the merged tokens derives from its ink with the generator's own `tintLayer` (`src/color-system.ts:279`): `accent` (through the `accent`, `primary`, `#2563EB` chain `applyControlDefaults` uses), `success` (else `#16A34A`), `warning` (else `#D97706`), `danger` (with its fallbacks), and `text-secondary` (else `#6B7280`) for `neutral`, the literal fallbacks being the ones the code already uses. An ink with alpha (the dark preset's `text-secondary` is `#ffffffa0`) is composited over the surface first. The mode follows the surface, not the theme flag, because `apply_preset dark` and every unthemed stamp put a dark palette in the base layer with no theme set: the surface is `bg-surface`, else `bg-primary`, else white, and the mode is dark when that color contrasts more with white than with black. The `accent-tint` fallback at `variables.ts:230` (a 12% mix) routes through the same helper, so `nav-item` and `tree-row` match what `generate_design_system` emits. This FR fixes the tint, not the ink: preset inks such as the light preset's `success` `#16a34a` fall below 4.5:1 even on white, and the existing contrast check keeps reporting that as it does today. | `status-chip` then `apply_preset light` renders a tint in light mode (it contrasts more with black than with white); under `apply_preset dark`, and unthemed, the tint is in dark mode. Under a generated system the chip's ink clears 4.5:1 on the derived tint in both themes. `settings-app` then `apply_preset light` draws its danger action in the light preset's `error`; unthemed, it resolves with no unknown-token finding. | | **FR-C6** | **Old seeds count as unset.** `getCanvasTokens` (`src/workspaces.ts:360`) drops a canvas-layer tint or `danger` token whose value equals its old seed (`structures.ts:1865-1873`, compared case-insensitively) before merging, so a workspace or project token of that name shows through, and with none the name derives (FR-C5). This is the one place a canvas token yields to an inherited one; the normal precedence (canvas over project over workspace) is unchanged for every other value. Stored JSON is not rewritten. Render, evaluate and the viewer all read tokens through `getCanvasTokens`, so they agree. The version hash (`canvasVersionHash`, `src/version.ts:67`) reads them too, so a canvas holding a seed gets a new `sha256r:` hash once and a recorded approval of it reads STALE; that is correct, since its render changed, and the release notes say so. | A canvas stored with `success-tint: "#0f2e1b"` renders the derived tint under a light preset; one holding `#0F2E1C` keeps it. A canvas holding the seed under a workspace that generated `success-tint` renders the workspace's value. A canvas holding no seed keeps its version hash. | | **FR-D1** | **`select` has a boundary.** `select`'s default stroke becomes `$border-strong` when the token exists, on every type, as FR-B8 of Phase 31 did for `text-input` and the controls; canvases without the token keep `$border`. `desktop-app-boundary` measures `select`, against its own fill as it does for `text-input` (`boundaryPairs` picks the field fill per type at `state-checks.ts:268`; `select` gains its branch). PHASE-31-SPEC R7 is superseded. | A `select` under a generated system measures 3:1 or more and passes; a `select` with `stroke: "$border"` at 1.46:1 on a desktop-app canvas warns; a canvas without `border-strong` renders unchanged. | -| **FR-D2** | **`tree-row` shows where you are.** An active `tree-row` draws `nav-item`'s 2px leading bar in `$accent` (`renderer.ts:1537`), at the row's left edge before the indent, so it lines up across depths; the row takes `position: relative` with the same guard `renderNavItem` uses (none when the node is itself positioned), and keeps `positionStyles`. `indicatorPairs` measures it like a `nav-item`, in rest and hover. The render-versus-model test (`test-state-model-render.ts`) adds an active `tree-row` and a `select`. PHASE-31-SPEC R4 is superseded for `tree-row`. | An active `tree-row` renders the bar at x = 0 at depth 0, 1 and 2; a bar resolving to 2.5:1 against its active fill warns; the model and the render agree. | +| **FR-D2** | **`tree-row` shows where you are.** An active `tree-row` draws `nav-item`'s 2px leading bar in `$accent` (`renderer.ts:1515`), at the row's left edge before the indent, so it lines up across depths; the row takes `position: relative` with the same guard `renderNavItem` uses (none when the node is itself positioned), and keeps `positionStyles`. `indicatorPairs` measures it like a `nav-item`, in rest and hover. The render-versus-model test (`test-state-model-render.ts`) adds an active `tree-row` and a `select`. PHASE-31-SPEC R4 is superseded for `tree-row`. | An active `tree-row` renders the bar at x = 0 at depth 0, 1 and 2; a bar resolving to 2.5:1 against its active fill warns; the model and the render agree. | | **FR-D3** | **Contained tabs stay as they are.** The active contained tab is a filled segment with a heavier label; the fill is the indicator and the weight is the non-color cue. It draws no bar and is not measured by `desktop-app-state-contrast`; GUIDELINES, the `tabs` docstring and the `canvas_evaluate` docstring say so and why. | The docs state it; contained tabs render unchanged. | | **FR-D4** | **Stress exercises counts.** `nav-item` `count` and `tabs` `items[].count` join `PRIMITIVE_TEXT_PROPS`, and `propSlots` (`stress.ts:84`) accepts numbers as well as strings, so the `big-numbers` perturbation widens `42` to `999+`. | `applyPerturbation('big-numbers')` on a `nav-item` with `count: 42` (a number) and a `tabs` node with an item `count: "7"` touches both nodes and sets both counts to `999+`; `canvas_stress` on that canvas reports `touchedCount` 2 for `big-numbers` (its output has no per-node list, `index.ts:2347`). | | **FR-E1** | **`link` and `text-input` are phone targets.** The touch branch of `checkUsability` (`evaluate.ts:2155-2165`) measures both at 44, delegating their boxes to the desktop census's measurement (`desktopTargets`), not by adding them to `TAPPABLE_PRIMITIVES`: that set feeds `CLICKABLE_PRIMITIVES` (`primitives.ts:45`) and is checked first in `pointerTargets` (`evaluate.ts:2016`), so adding them there would drop them from the 24px census. `link` already honors `height` (`renderLink`, min 24). `text-input`'s `size` union already lists `"lg"`, but `TEXT_INPUT_HEIGHT` (`primitives.ts:38`) and `textInputHeight` (`:203`) treat it as 40; it becomes 44. Inline link ranges stay exempt, as on web. The pin at `test-desktop-primitives.ts:142-143` flips. | On a mobile canvas a 40px `text-input` and a default (24px) `link` are `mobile-touch-target` errors; `size: "lg"` and `height: 44` clear them. On desktop-app, both stay in the 24px census and `lg` measures 44. | @@ -172,16 +172,35 @@ And one is housekeeping the follow-ups will land in. 140 tests and `test-env.ts` These fixes were proved red on 2cff888 and green after; no agent re-verified them. **Slice D: desktop-app checks and stress (FR-D1 to FR-D4).** -- `variables.ts` select branch: `$border-strong` when defined. `state-checks.ts:268`: `select` measured. +- `variables.ts` select branch: `$border-strong` when defined. `state-checks.ts:279` (`boundaryPairs`): `select` measured. - `renderTreeRow` (`renderer.ts:1610`): `position: relative` with `renderNavItem`'s guard, and the bar. `indicatorPairs` (`state-checks.ts:211-236`): `tree-row`. - `stress.ts:45-68`: the two count slots; `propSlots` (`:84`) stringifies numbers. +**Slice D — contracts pinned before build (2026-11-22; frozen at the commit that adds this block).** Drafted, then broken on paper by one pre-freeze verifier (9 findings, 7 confirmed); this is the re-frozen version. Departures from the draft are marked *(changed)*. +- **Q1: the `select` default.** `applyControlDefaults`' select branch sets an unset `stroke` to `colors['border-strong']`, else `colors.border`, else the existing fallback, on every type (the same `boundary` the controls use). Explicit strokes win. No stamp seeds a new token. Presets define no `border-strong`, so a preset canvas keeps `$border`; generated systems define it on every type, so their selects move. *(changed)* A stamp seeds `border-strong` (`#666666`) when it holds a desktop primitive and the canvas resolves no `border` (`structures.ts:1939`, `:2119`): the two realisations holding a `select` (`editor-inspector-app`, `settings-app`) seed it unthemed, and stamped after a preset they seed nothing, so their selects warn there as their `text-input`s and toggles already do. That order is not gated today and stays a named limit; the finding's suggestion says to define `border-strong` (set_variables, or generate_design_system) when the canvas has none. The `sha256r:` hash does not move (no token changes). +- **Q2: `select` in `desktop-app-boundary`.** `boundaryPairs` measures a `select` that is not disabled, as it measures a `text-input`: the boundary is the node's `stroke` (unset, an unresolved `$ref`, `transparent` or `none` is measured as what shows there: the backdrop through the fill), the field is the node's `fill`, painted over the backdrop, and a field that clears 3:1 against the backdrop passes the control whatever its border. The finding names the part `border` and carries the fill clause. The rule still runs on desktop-app canvases only, in each theme the canvas has. Named false negatives, in the `desktop-app-boundary` docs *(changed)*: a disabled control (WCAG exempts it); web and mobile canvases (never measured, though Q1 strengthens their default); a backdrop that is a gradient or image, or a fill the checker cannot read (a CSS name such as `white`, `hsl()`), which is silent for `select` as it already is for `text-input` and the controls. +- **Q3: the `tree-row` bar.** An active `tree-row` renders, as the row's first child, the `nav-item` bar markup unchanged: `position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px; border-radius: 1px; background-color: `. The row adds `position: relative` unless the node sets `position` (then `positionStyles` positions it and the bar anchors to that box). The bar ignores `depth`, so it sits at x = 0 of the row at every depth. It draws whenever `active` is set, disabled included, as `nav-item`'s does, and on every type; only desktop-app canvases measure it (named in the docs). +- **Q4: `tree-row` in `desktop-app-state-contrast`.** `indicatorPairs` pairs an active, not disabled `tree-row` exactly as a `nav-item`: indicator `iconColor` (else the accent fallback), fill `fill`, hover ink `color` (else the text fallback), the node's own opacity, the backdrop behind it; `what` is `tree-row