Skip to content

Change hues only through the kit: a lint rule, and every renderer on the kit's change marks - #193

Merged
agorischek merged 4 commits into
mainfrom
agorischek/change-hues
Nov 23, 2026
Merged

agorischek merged 4 commits into
mainfrom
agorischek/change-hues

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

Polish step (e): renderers built on the kit colour changes only through the kit's change marks.

Why

Renderers named change hues themselves (--green, --red-soft, …), which bypasses the kit's change mapping, emphasis and nesting rule. Using the official infrastructure should make that hard.

Rule: check:change-hues

  • What it is: a fast tools check gate (tools/scripts/check-change-hues.mjs, with a unit test), modelled on check-portability.
  • What it reads: the CSS and code of every renderer that depends on the kit. The kit itself, its tooling, tests and fixtures are excluded.
  • What it rejects: naming a change hue, whether a kit alias (--green, --red-soft, …) or the theme's --projections-color-{added,removed,modified,moved}*.
  • Exceptions: a file listed in .change-hues.yaml with its reason; an entry that no longer matches fails. None is needed.
  • Not in scope: the minimal example has no kit dependency and colours changes from the theme's tokens itself, so the rule doesn't read it and it needs no exception.
  • Found on main: 56 uses in 9 renderers.

Kit primitives

  • Variables: a change mark (data-change, pk-region) sets --pk-change-ink, --pk-change-strong (new), --pk-change-highlight (new), --pk-region-fill and --pk-region-edge.
  • New data-change-hue: for a part of a changed item drawn in a change's hue, such as a value's old and new text, an inserted word, a matrix cell or a tag. It sets the same variables but isn't a changed item, so the item around it keeps its own mark under the nesting rule.

Migration

  • What moved: agentic workflows, api, code statistics, database, dependency injection, file packing, runtime policy and text diff now read those variables, adding data-change-hue where a part had only a class.
  • What was removed: text-diff's extra edge beside a removed line; its run edge already draws it.
  • Pixel check: I captured all 78 scenarios × light/dark × (diff, mid-animation) = 312 screenshots before and after. All are pixel-identical, apart from 1–2 antialiased pixels inside the gallery's nested renderer frames, which load asynchronously (capture noise).
  • Also verified:
    • checks.spec, nested-accents.spec, and the api and DI browser specs on chromium-desktop, webkit-desktop and chromium-mobile;
    • every renderer's Node tests (the api and DI markup expectations now include data-change-hue);
    • tools tests;
    • check --fast, docs:check and oxfmt --check.

Follow-up, not in this PR

The SDK's renderer style lint (sdk/src/style-lint.ts) could apply the same rule to third-party renderers that use the kit. That needs kit-usage detection across a bundle's modules and an inline allowance syntax, so it is left for a separate change.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new YAML allow-list lacks required schema coverage and will fail CI, while hue mappings and enforcement still have functional gaps.

4 open issues
What changed in this PR

This PR centralizes change coloring in the renderer kit, migrates built-in renderers to its change variables, and adds a lint gate to prevent direct hue references.

Changes:

  • Adds check:change-hues, with tests, reasoned exceptions, and fast-check integration.
  • Introduces data-change-hue for changed parts and shared strong/highlight variables.
  • Migrates renderer styles and markup, updates assertions, and documents the convention.
File Description
tools/​scripts/​check-change-hues.test.mjs Tests hue detection, source scope, and exceptions.
tools/​scripts/​check-change-hues.mjs Implements the change-hue lint gate.
tools/​cli/​src/​lib/​gates.ts Registers the fast-check gate.
packages/​renderers/​text-diff/​src/​styles.css Uses kit variables and removes a redundant edge.
packages/​renderers/​runtime-policy/​src/​styles.css Replaces direct hues with kit variables.
packages/​renderers/​runtime-policy/​src/​chips.tsx Marks changed chips with their hue.
packages/​renderers/​kit/​styles/​nesting.css Neutralizes the new variables on containers.
packages/​renderers/​kit/​styles/​diff.css Adds part-level hue mappings and variables.
packages/​renderers/​file-packing/​src/​styles.css Uses kit variables for emphasis rings.
packages/​renderers/​file-packing/​src/​circles.tsx Adds hue marks to emphasis circles.
packages/​renderers/​dependency-injection/​test/​diff.test.mjs Updates expected value-change markup.
packages/​renderers/​dependency-injection/​src/​styles.css Uses kit ink for old and new values.
packages/​renderers/​dependency-injection/​src/​diff-lines.tsx Marks old and new text with hue attributes.
packages/​renderers/​database/​src/​tags.tsx Adds hue attributes to changed tags.
packages/​renderers/​database/​src/​styles.css Uses kit colors for keys and tags.
packages/​renderers/​code-statistics/​src/​styles.css Uses kit variables for deltas and bars.
packages/​renderers/​api/​test/​api.test.mjs Updates signature markup assertions.
packages/​renderers/​api/​src/​styles.css Uses kit variables for signature highlighting.
packages/​renderers/​api/​src/​signature-view.tsx Marks signature lines and changed segments.
packages/​renderers/​agentic-workflows/​src/​styles.css Uses kit colors for directions and cells.
packages/​renderers/​agentic-workflows/​src/​matrix.tsx Marks added and removed matrix cells.
packages/​renderers/​agentic-workflows/​src/​card.tsx Marks widened-direction indicators.
package.json Adds the lint command to repository checks.
docs/​guides/​develop-a-renderer.md Documents kit-only change coloring.
.change-hues.yaml Defines the empty, reasoned exception list.

Review effort: Balanced

Comment thread .change-hues.yaml Resolved
Comment thread packages/renderers/kit/styles/diff.css Resolved
Comment thread tools/scripts/check-change-hues.mjs Resolved
Comment thread tools/scripts/check-change-hues.mjs Resolved
agorischek and others added 2 commits November 22, 2026 18:42
…ed onto the kit's change marks

Polish step (e). A renderer built on the kit colored changes by naming hues itself
(--green, --red-soft, ...), so the kit's mapping, emphasis and nesting rule could be
bypassed. Now:

- check:change-hues (a fast `tools check` gate, tools/scripts/check-change-hues.mjs):
  the CSS and code of every renderer that depends on the kit (not the kit, its
  tooling, tests or fixtures) may not name a change hue: the kit's aliases or the
  theme's --projections-color-{added,removed,modified,moved}*. Exceptions are files
  in .change-hues.yaml, each with its reason; a stale one fails. None is needed.
  The minimal example doesn't use the kit and colors changes from the theme's
  tokens itself, so it isn't read.
- The kit's change marks set --pk-change-ink, --pk-change-strong (new),
  --pk-change-highlight (new), --pk-region-fill and --pk-region-edge. A part of a
  changed item drawn in a change's hue (a value's old and new text, an inserted
  word, a matrix cell, a tag) takes data-change-hue: the same variables, but not a
  changed item, so the item around it keeps its mark under the nesting rule.
- The 56 uses in 9 renderers (agentic workflows, api, code statistics, database,
  dependency injection, file packing, runtime policy, text diff) read those
  variables. text-diff's extra edge beside a removed line is gone: its run edge
  already draws it. Every scenario renders pixel-identically, light and dark, in
  the diff and mid-animation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
.change-hues.yaml is validated like .portability.yaml: an internal schema
generated from packages/schemas/src/repository, associated in .dollarlint.toml.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek force-pushed the agorischek/change-hues branch from 2550ce4 to 634f237 Compare November 23, 2026 02:55
agorischek and others added 2 commits November 22, 2026 19:36
…reads token.color and getPropertyValue; deleted manifests are skipped

- base.css imports the change-mark mappings (data-change, data-change-hue), moved from diff.css into styles/changes.css,
  so a renderer on kit/base.css without React gets --pk-change-ink and the rest.
- check:change-hues also finds token.color('added'), token.color('removed-highlight') and '--red' read by name.
- Tracked manifests deleted from the working tree are skipped instead of throwing ENOENT.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek merged commit 7ebacdf into main Nov 23, 2026
59 checks passed
@agorischek
agorischek deleted the agorischek/change-hues branch November 23, 2026 04:49
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.

2 participants