Skip to content

refactor(react): reuse core contrast and transfer functions - #217

Merged
pbroom merged 2 commits into
mainfrom
refactor/react-shared-color-math
Oct 10, 2026
Merged

pbroom merged 2 commits into
mainfrom
refactor/react-shared-color-math

Conversation

@pbroom

@pbroom pbroom commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner
  • ContrastRegionLayer scores candidate fill paths with core's
    contrastRatio / contrastAPCA, passing the region's gamut, instead of
    its own unclamped WCAG copy and gamut-less APCA call, so the score
    matches the field the contrast region was traced from.
  • Export linearToSrgbChannel / srgbToLinearChannel from core and use
    them in ColorPlane's CPU path instead of a local transfer-function
    copy (GLSL shader sources keep their own implementation).
  • createWebglState now deletes the shaders, program, and buffer it
    created when compilation, linking, or uniform lookup fails.

Part of a stacked set of PRs (#204 → #221) from the color-kit assessment. Validated per branch with pnpm build and pnpm test; lint, format, typecheck, size, artifact, preprod and agents checks pass at the top of the stack.

🤖 Generated with Claude Code

pbroom commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Moves color math functions to shared core library.

The PR appears safe to merge; the remaining findings are non-blocking gaps in targeted regression coverage.

Fix All in CursorFindings

  1. P2 Gamut-aware fill scoring lacks tests ▶
  2. P2 Cleanup failure branches remain untested ▶

Summary

This PR makes React contrast-fill scoring use core’s gamut-aware metrics, replaces the CPU plane’s local channel transfer with core’s exported function, and releases WebGL objects when setup fails.

  • The inspected metric and transfer paths align with their corresponding core and shader behavior.
  • Targeted fill and additional WebGL failure-branch tests remain worthwhile.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Core contrast region] --> B[Region paths]
  B --> C[React fill candidates]
  D[Core contrast metrics and gamut] --> C
  E[Core channel transfer] --> F[CPU color plane]
  G[WebGL setup] -->|success| H[GPU color plane]
  G -->|failure: release resources| F
Loading

Reviews (1) · Last reviewed commit: "refactor(react): reuse core contrast and..."

Comment thread packages/react/src/contrast-region-layer.tsx
Comment thread packages/react/__tests__/stable-refs.test.tsx
@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
color-kit Ready Ready Preview Oct 10, 2026 7:24pm UTC

@pbroom
pbroom force-pushed the refactor/core-explicit-contrast-engine branch from d9f427e to d127833 Compare October 8, 2026 02:44
@pbroom
pbroom force-pushed the refactor/react-shared-color-math branch from 1ea17cd to 903c45b 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:24 PM UTC: Graphite rebased this pull request as part of a merge.
  • Oct 10, 7:24 PM UTC: @pbroom merged this pull request with Graphite.

@pbroom
pbroom changed the base branch from refactor/core-explicit-contrast-engine to graphite-base/217 October 10, 2026 19:21
@pbroom
pbroom changed the base branch from graphite-base/217 to main October 10, 2026 19:22
pbroom and others added 2 commits October 10, 2026 19:23
- ContrastRegionLayer scores candidate fill paths with core's
  contrastRatio / contrastAPCA, passing the region's gamut, instead of
  its own unclamped WCAG copy and gamut-less APCA call, so the score
  matches the field the contrast region was traced from.
- Export linearToSrgbChannel / srgbToLinearChannel from core and use
  them in ColorPlane's CPU path instead of a local transfer-function
  copy (GLSL shader sources keep their own implementation).
- createWebglState now deletes the shaders, program, and buffer it
  created when compilation, linking, or uniform lookup fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Contrast fill: a Display P3 WCAG fill agrees with the gamut-aware
  check, and APCA polarity decides an ambiguous boundary closure.
- ColorPlane: link failure and a missing uniform free GL objects and
  fall back to the cpu renderer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pbroom
pbroom force-pushed the refactor/react-shared-color-math branch from 903c45b to d103ab3 Compare October 10, 2026 19:23
@pbroom
pbroom merged commit 045bd5d into main Oct 10, 2026
7 checks passed
@pbroom
pbroom deleted the refactor/react-shared-color-math branch October 10, 2026 19:24

This branch was successfully deployed

1 active deployment
Preview — d103ab36 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