Skip to content

feat(driver,react): keep the previous hue when an achromatic color is entered - #229

Merged
pbroom merged 3 commits into
mainfrom
feat/preserve-hue-on-achromatic-input
Oct 10, 2026
Merged

pbroom merged 3 commits into
mainfrom
feat/preserve-hue-on-achromatic-input

Conversation

@pbroom

@pbroom pbroom commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Grays, black and white entered through non-OKLCH paths (hex/rgb/hsl
strings, setFromRgb/Hsl/Hsv, RGB/HSL ColorInput edits, ColorStringInput)
used to store the converted hue 0, so raising chroma afterwards jumped to
red. The state layer now keeps the latest requested hue unless the input
states an OKLCH hue (an oklch() string with a hue other than none, or an
OKLCH object). Core parse() and conversions are unchanged.

Adds driver helpers resolveIncomingRequested and hasExplicitOklchHue, and
an explicitHue option on setColorRequested, setMultiColorRequested and
SetRequestedOptions.

Behavior

  • When an achromatic color (chroma ≈ 0, including black and white) arrives through hex, rgb/hsl/hwb/lch strings, setFromRgb/setFromHsl/setFromHsv, or a ColorInput RGB/HSL edit, the state keeps the previous requested hue instead of resetting to 0.
  • An explicit oklch(L 0 H) string, or an OKLCH object passed to setRequested, keeps its own hue. oklch(... none) carries the previous hue.
  • Core parse() and the conversions are unchanged and deterministic.
  • Shared driver helpers are resolveIncomingRequested and hasExplicitOklchHue. setColorRequested / setMultiColorRequested take { explicitHue }, which defaults to true.
  • Trade-off: the stored hue of a gray now depends on history, so two visually identical grays can serialize with different OKLCH hues.

Validation of the latest correction: lint, full build including DTS, test (core 888, driver 142, React 215), format:check and agents:check:strict pass locally. The control-kit dependency was built from the pinned source after installation with scripts disabled; hosted CI remains a separate check.

Multiline oklch() input now preserves an explicit hue consistently with the core parser. Regression coverage includes LF/CR/CRLF/tab/form-feed, zero and angle-unit hues, none, and alpha. The three line-break cases fail before the correction and pass after it.

Part of the color-kit assessment stack (#204 → #229).

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T20:23:58.332299Z c7fd7bf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This was referenced Oct 7, 2026
@pbroom
pbroom force-pushed the feat/preserve-hue-on-achromatic-input branch from 2142348 to 65f7643 Compare October 8, 2026 02:44
@pbroom
pbroom force-pushed the refactor/core-chroma-contrast-solver branch from 23b69a0 to 319683f Compare October 8, 2026 02:44

pbroom commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner Author

Merge activity

  • Oct 10, 6:47 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Oct 10, 7:49 PM UTC: Graphite rebased this pull request as part of a merge.
  • Oct 10, 7:50 PM UTC: @pbroom merged this pull request with Graphite.

@pbroom
pbroom changed the base branch from refactor/core-chroma-contrast-solver to graphite-base/229 October 10, 2026 19:45
@pbroom
pbroom changed the base branch from graphite-base/229 to main October 10, 2026 19:47
pbroom and others added 3 commits October 10, 2026 19:48
… entered

Grays, black and white entered through non-OKLCH paths (hex/rgb/hsl
strings, setFromRgb/Hsl/Hsv, RGB/HSL ColorInput edits, ColorStringInput)
used to store the converted hue 0, so raising chroma afterwards jumped to
red. The state layer now keeps the latest requested hue unless the input
states an OKLCH hue (an oklch() string with a hue other than none, or an
OKLCH object). Core parse() and conversions are unchanged.

Adds driver helpers resolveIncomingRequested and hasExplicitOklchHue, and
an explicitHue option on setColorRequested, setMultiColorRequested and
SetRequestedOptions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…om a gray

An HSL ColorInput edit of a gray started from toHsl(gray), whose hue is the
canonical 0, so raising saturation again produced red even though the
requested OKLCH hue had been kept.

For an achromatic color with a stored hue, HSL reads and edits now go
through that hue:
- the HSL hue field shows the HSL hue of the stored OKLCH hue (measured on
  a 1%-saturated color at the same lightness) instead of 0;
- a saturation edit bisects for the HSL hue at which the new saturation
  and lightness have the stored OKLCH hue, so the result lands on it to
  within 0.01 degrees;
- an HSL hue edit keeps the color gray and stores the OKLCH hue of the
  typed HSL hue (React ColorInput passes it as an explicit hue);
- lightness and alpha edits, black and white keep the stored hue.

The colorFromColorInputChannelValue JSDoc now states these guarantees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pbroom
pbroom force-pushed the feat/preserve-hue-on-achromatic-input branch from 3d7b3aa to 67081ab Compare October 10, 2026 19:48
@pbroom
pbroom merged commit 85a3bb6 into main Oct 10, 2026
6 of 7 checks passed
@pbroom
pbroom deleted the feat/preserve-hue-on-achromatic-input branch October 10, 2026 19:50

This branch was successfully deployed

1 active deployment
Preview — 67081ab1 Deployed Oct 10, 2026 by vercel[bot]
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.

1 participant