Skip to content

chore(plugin-vscode): migrate to OKLCH (color → culori)#759

Open
paanSinghCoder wants to merge 2 commits intomainfrom
chore/plugin-vscode-oklch
Open

chore(plugin-vscode): migrate to OKLCH (color → culori)#759
paanSinghCoder wants to merge 2 commits intomainfrom
chore/plugin-vscode-oklch

Conversation

@paanSinghCoder
Copy link
Copy Markdown
Contributor

@paanSinghCoder paanSinghCoder commented Apr 28, 2026

Summary

  • Mirrored token data from HEX/rgba to oklch() to match the apsara CSS migration
  • Swapped the color npm package for culori (the old one can't parse oklch())
Screen.Recording.2026-04-28.at.2.50.22.PM.mov

paanSinghCoder and others added 2 commits April 28, 2026 14:31
Convert all 157 token color values across the plugin's TS data files to
oklch() strings, matching the apsara CSS token format.

Mechanical, byte-identical: every value is byte-identical in 8-bit sRGB
after re-parsing the rounded oklch() output, with CIEDE2000 ΔE < 0.5.

Files:
- src/tokens/primitives/gray.ts        (12)
- src/tokens/primitives/accent.ts      (13)
- src/tokens/primitives/appearance.ts  (96)
- src/tokens/color.ts                  (24 overlays)
- src/tokens/effects.ts                (12 shadow rgba)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the 'color' npm package (no OKLCH support) with culori across
the plugin's color parsing and serialization paths.

- colorToVSCodeColor: parses oklch()/hex/rgb/etc. via culori, returns
  VS Code's {red,green,blue,alpha} sRGB shape, clamped to [0, 1]
- VSCodeColorToColor: emits oklch() strings on picker writes so user
  edits stay consistent with the apsara design system convention

Bump plugin version 0.1.1 → 0.2.0 (picker writeback format change).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

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

Project Deployment Actions Updated (UTC)
apsara Ready Ready Preview, Comment Apr 28, 2026 9:03am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

The VS Code extension undergoes a color system migration by replacing the color dependency with culori. The package version is bumped to 0.2.0. Color conversion utilities are rewritten to parse CSS colors via culori and handle special cases like transparent, currentColor, and inherit. All color token values across the codebase—including accent, gray, appearance (attention, success, danger, visualization), overlay, and effects tokens—are converted from hex and rgba formats to OKLCH (Oklab-based Chroma-Hue) color space syntax. Token identifiers and structure remain unchanged; only color representations are updated.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore(plugin-vscode): migrate to OKLCH (color → culori)' directly and clearly summarizes the main change: migrating from hex/rgba color format to OKLCH and replacing the color library with culori.
Description check ✅ Passed The description is directly related to the changeset, explaining the migration to OKLCH format and the library swap from color to culori, which matches all file changes in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/plugin-vscode/src/lib/utils.ts (1)

1-13: Add regression coverage for the new color pipeline.

The parser/serializer swap looks coherent, but a few round-trip cases for oklch(), transparent, currentColor, and inherit would help lock down the new behavior.

Also applies to: 55-101

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/plugin-vscode/src/lib/utils.ts` around lines 1 - 13, Add regression
tests that exercise the parser/serializer round-trip for color inputs
`oklch(...)`, `transparent`, `currentColor`, and `inherit` using the same
pipeline referenced in the utils module: call parse and then serialize (the
serializer used by the plugin) and assert the result is equivalent to the input;
specifically exercise conversion paths that use toOklch and toRgb
(converter('oklch') / converter('rgb')), and ensure rounding/clamping behavior
via round and clamp01 does not break fidelity. Implement tests that feed
representative oklch values (including edge cases like zero/chroma extremes),
the literal keywords "transparent", "currentColor", and "inherit", and assert
that parse -> serialize -> parse produces equivalent color semantics (and that
tokens/TOKEN_PREFIX behavior is preserved). Ensure failures are captured as test
assertions so regressions in the new color pipeline are caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/plugin-vscode/src/lib/utils.ts`:
- Around line 1-13: Add regression tests that exercise the parser/serializer
round-trip for color inputs `oklch(...)`, `transparent`, `currentColor`, and
`inherit` using the same pipeline referenced in the utils module: call parse and
then serialize (the serializer used by the plugin) and assert the result is
equivalent to the input; specifically exercise conversion paths that use toOklch
and toRgb (converter('oklch') / converter('rgb')), and ensure rounding/clamping
behavior via round and clamp01 does not break fidelity. Implement tests that
feed representative oklch values (including edge cases like zero/chroma
extremes), the literal keywords "transparent", "currentColor", and "inherit",
and assert that parse -> serialize -> parse produces equivalent color semantics
(and that tokens/TOKEN_PREFIX behavior is preserved). Ensure failures are
captured as test assertions so regressions in the new color pipeline are caught.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc865b7f-53aa-4456-aaa7-221f911e9873

📥 Commits

Reviewing files that changed from the base of the PR and between 5905f2a and 8c01260.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • packages/plugin-vscode/package.json
  • packages/plugin-vscode/src/lib/utils.ts
  • packages/plugin-vscode/src/tokens/color.ts
  • packages/plugin-vscode/src/tokens/effects.ts
  • packages/plugin-vscode/src/tokens/primitives/accent.ts
  • packages/plugin-vscode/src/tokens/primitives/appearance.ts
  • packages/plugin-vscode/src/tokens/primitives/gray.ts

@paanSinghCoder paanSinghCoder self-assigned this Apr 28, 2026
@rohilsurana
Copy link
Copy Markdown
Member

https://www.npmjs.com/package/color-convert

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