Repository navigation
perf(cli): the theme contrast check works out each setting's parts once per check - #13474
Closed
josephfarina wants to merge 1 commit into
Closed
josephfarina wants to merge 1 commit into
josephfarina wants to merge 1 commit into
Conversation
…ce per check `contrastProblems` asked `partsOf` for the parts a setting lands on at every lookup, for each pair, side and mode, and `partsOf` walks the groups and the members' fill and border parts each time. A setting's parts depend only on the setting and the project, which the check does not change, so the check now keeps them in a map for that one check. The callers only read the lists. Tests change the theme between checks in one process (a later fill, a fill for a state, and a fill that reaches every input then the same fill kept to one input) and show that each check reads the settings and their parts as they are then. [skip ci]
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
AI review status for this pull request.
|
Contributor
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The head commit's message carries [skip ci], so push a commit without it so the required checks run before merge.
The per-check parts map leaves every contrast result unchanged, because partsOf only reads the setting and the project's part data and no caller changes the kept lists. The contrast tests pass on this head, and one contrast-heavy test file runs about 24% faster.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims:
- Changeset: the theme editor checks contrast faster: verified (
theme-readers-part-named-color43.0 to 32.8 test-seconds on base against head) - Changeset: a setting's parts are worked out once per check, not per pair, side and mode: verified (
_settings.mjs:11857-11870and its eight call sites) - Changeset: what the check finds does not change: verified (
partsOfis a pure read,_settings.mjs:5210-5256; the contrast tests pass) - Description: each lookup re-walked the groups and the members' fill and border parts: verified (
_settings.mjs:5217-5223) - Description: the map belongs to one check: verified (local map at
_settings.mjs:11861;commitTheme's two checks each make their own) - Description: callers only read the lists: verified (all eight call sites use
includes,some,findorfor … of) - Description:
show,setand the other contrast-checking commands get faster: verified (_edit.mjs:8833;_settings.mjs:17815,:17821) - Description: the new tests show each check reads the current settings and parts, and pass on main too: verified (they pass on base and head)
- Description: no record names how the check reads a setting's parts: verified
- Description: test-time figures and the differential comparison: the timings agree with this review's run; the comparison harness is not in the pull request and was not reproduced
- Description: the whole theme editor test folder passes (560 files): not reproduced in full; the folder holds 561 test files at this head, so that run predates the new test file
- Description: no public API, product behavior, CI or workflow change: verified
Files:
.changeset/theme-contrast-parts-once.md: clearpackages/cli/api/theme-edit/_settings.mjs: clearpackages/cli/api/theme-edit/theme-contrast-settings-each-check.test.mjs: clear
josephfarina
marked this pull request as ready for review
November 21, 2026 21:41
josephfarina
requested review from
cixzhang and
imdreamrunner
as code owners
November 21, 2026 21:41
josephfarina
added a commit
that referenced
this pull request
Nov 21, 2026
josephfarina
added a commit
that referenced
this pull request
Nov 21, 2026
…ng's parts once per check
josephfarina
added a commit
that referenced
this pull request
Nov 21, 2026
josephfarina
added a commit
that referenced
this pull request
Nov 22, 2026
josephfarina
added a commit
that referenced
this pull request
Nov 22, 2026
- #13409 experimental theme editor how: "zebra rows taller" is the rows' size, with no stripe (#12971 on main) Author: @josephfarina - #13474 perf(cli): the theme contrast check works out each setting's parts once per check Author: @josephfarina
Contributor
Author
|
Landed in #13489. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Maintainer impact
The theme editor's contrast check (
contrastProblems) looks up, for each color pair on each side and in each mode, the latest setting for a part, a token or a fill. Every lookup askedpartsOffor the parts each setting lands on, andpartsOfwalks the groups and each member's fill and border parts every time. A setting's parts depend only on the setting and the project, and the check changes neither, so the same lists were worked out again and again within one check.Now the check keeps each setting's parts in a map for that one check.
In user terms:
show,setand the other theme editor commands that check contrast are faster, and every result is unchanged.Intended invariant
includes,some,find,for … of), so a kept list is never changed.Change
api/theme-edit/_settings.mjs:contrastProblemsreads each setting's parts through a per-check map.api/theme-edit/theme-contrast-settings-each-check.test.mjs: in one process, a later fill, a fill for a state, and a fill that reaches every input followed by the same fill kept to one input each change what the next check finds.Evidence
theme-readers-part-named-color53.1 → 41.7 test-s (−21.5%),theme-palette126.2 → 123.2 (−2.4%),theme-part-own-fill-contrast5.76 → 5.32 (−8%),theme-contrast-problem-listed-change7.88 → 7.46 (−5%); the whole theme editor test folder 5,103 → 5,005 test-s (−1.9%, lower in each of the three runs).Scope
Components: cli (experimental theme editor)
Testing
vitest run --project node packages/cli/api/theme-edit(CI=1): 560 files, 6,111 tests pass.vitest run --project node packages/cli/api/theme-edit/theme-contrast-settings-each-check.test.mjs: 2 tests pass (they pass on main too: they guard against a cache that outlives one check).replay: worse 0 at 65d9fe3
preflight: pass 65d9fe3