Repository navigation
feat(themes): paste CSS into the theme editor, with an AI design prompt - #20852
Conversation
|
Determinism proof for the new and changed tests at head The tests are pure parser calls and jsdom renders against mocked theme store, API and clipboard: no timers, sleeps, network or shared state across tests. Each review fix was also checked by reverting it and confirming its test fails. |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the textarea's placeholder ( [DESIGN-REVIEWED] 61ed603 Description read[DESCRIPTION-READ] d05e9fe7f825e069b96a190cc839361bfd0f4b92d9153f4de39456636fab8d68 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The AI-prompt callout hand-rolls copy-confirmation state that Not justified as shipped
What this change shipsInventory (8 items) — 6 justifiedIntent: let a user build a custom theme by pasting CSS variables, and give them a copyable screenshot-to-CSS AI prompt. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 61ed603 Description read[DESCRIPTION-READ] 661bff554b1ae20e8a831c4da7f6df42218fb438072f73af006bd3c73dfe5cc4 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS "Paste JSON" and "Paste CSS (from AI)" look the same to a newcomer, and the skip warnings use words the blind reader couldn't follow. Watch
Suggestions
[UX-REVIEWED] 61ed603 Description read[DESCRIPTION-READ] 2f177eb658a746dc3032ad3b360c5c6fb35a538d14206278ab2d2fb204e55400 That sha256 names everything this verdict read: the PR description, plus the 7 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
71a94ca to
250fa07
Compare
|
|
|
|
|
|
|
|
|
|
|
|
|
Backend Tests (Windows) (5) is red on |
|
The Create Theme dialog gains a Paste CSS tab. A pasted stylesheet of theme custom properties becomes the theme: rules whose selector names "dark" or "light" set that mode, :root and anything else apply to both, and variables left out keep their current value. A live summary names the declarations that will be dropped (not a theme variable, or a value the sanitizer refuses) before the user saves. The tab also offers a copyable "Design it with AI" prompt: paste it into any AI chat with a screenshot and the CSS reply pastes straight back in. Its name and emoji comments fill the editor's fields, and only the fenced code block of a whole pasted reply is read.
250fa07 to
61ed603
Compare
|
|
|
|
|
|
|
|
|
Hold at 61ed603. The parser is sound as far as I read it. Values go through the same What blocks approval:
This clears when each current-head item has a — crew-pr-reviewer (r105) |
Problem / Motivation
Goal: Let a user build a custom theme by pasting CSS variables into the Create Theme dialog, and give them a copyable AI prompt that turns a screenshot into that CSS.
Today a custom theme is made one colour swatch at a time in the picker, or by hand-writing the theme JSON. Theme palettes people find or generate elsewhere arrive as CSS custom properties (
:root { --bg: … },.dark { … }), and there is no way to paste one in. There is also no easy route from "I like how this looks" (a screenshot) to a theme.Why it matters
Theming is one of the first ways a user makes the dashboard theirs. Clicking through roughly 50 swatches twice (dark and light) is slow enough that most people never finish a theme. Pasting CSS, or handing a screenshot plus a prompt to any AI chat and pasting the reply, turns that into a minute of work.
Not a goal
--background,--primary, …). Only the dashboard's own theme variables are read; anything else is listed as ignored.What changed (motivation → approach → change)
dark(.dark,[data-theme="dark"],@media (prefers-color-scheme: dark)) sets dark mode;lightlikewise;:rootor anything else sets both, and a mode named only inside:not(…)selects nothing. Mode-specific beats shared, as in the cascade. Colours left out stay as they are.--BGis listed), or "value must be a color, size or shadow" with the refused value shown as--text: url(x)— and that Save keeps everything else. Lists stop at ten names plus a count. With nothing usable pasted, Save is disabled and the summary, which describes both the text box and the button, says why./* name: … */and/* emoji: … */comments and every theme variable, with contrast and value rules. The copy outcome comes from the shareduseCopiedFlashhook; a failure shows in anErrorNotice(no hand-off, the draft is unsaved) that stays until a later copy succeeds, and opens the prompt so it can be selected.The parser lives in
website/src/lib/themeCssImport.tsand is not a security boundary: it uses the samesanitizeCssValueandALLOWED_CSS_VARS(now exported fromhooks/themeCss.ts) that the stylesheet builder and backend already enforce, so the user sees drops before saving instead of a server refusal. The prompt is model-facing text inwebsite/src/lib/themeDesign.prompt.ts, under the repo's*.prompt.tsi18n convention;website/eslint.i18n.config.jsexempts the parser by path, as it doesthemeCss.ts, because its only literals are stylesheet text. Incomponents/themeEditor.tsx, tab switches go through oneswitchModestep and one JSON→picker parse, so edits carry between all three tabs. The new copy is inen.manual.jsonand translated into all 11 shipped catalogs (locales/<tag>.json), withen-XA.jsonregenerated.Backwards compatibility
Compatible: the Color Picker and Paste JSON tabs, the saved theme format and every save path are unchanged; the new tab only produces the same
dark/lightmaps the picker already saves.Removes nothing: no capability, route or saved data is taken away.
ALLOWED_CSS_VARSwidens from module-private to exported;useThemeEditorstops returningpickerToJson, which had no caller outside its own tests.Tests
website/src/test/themeCssImport.test.ts: which mode each selector form lands in (including nested@media, selector lists naming both modes, and.darknessnot counting as dark); comments,!importantand line-wrapped values; unknown names and refused values reported, not applied, including a value that tries to close the block; refused values reported with the value; case-sensitive names;:not(…)groups selecting no mode; shared-then-mode layering; serialise/parse round trip.website/src/test/themeDesignPrompt.test.ts: the prompt asks for exactly the allowlisted variables, each once; its own example reply parses with nothing dropped and fills name and emoji; a whole chat reply is read from its code block only.website/src/test/ThemeEditorCoverage.test.tsx: the Paste CSS tab prefills from the picker; it saves pasted values over picker values and names what is skipped. With nothing usable pasted it holds Save behind an inline, button-linked hint (no error notice). It caps a long name list, carries a paste into the JSON tab, re-fills name and emoji in a reopened editor and labels each paste tab with its source. Copy prompt confirms only a copy that landed; a failed copy shows anErrorNoticewithout a hand-off that persists past the hook's flash and clears on a later success, and opens the prompt; the toggle reads Show or Hide.website/src/i18n/catalogParity.test.tsand the per-locale style tests cover the 11 new catalog entries.Determinism: pure parser calls plus jsdom renders with mocked theme store, API and clipboard; no timers in assertions, no network, no shared state. Repeats in shuffled order are posted in a PR comment.
Manual verification
Rendered the real
ThemeEditorPanelin Storybook with aQueryClientProvider+ThemeProviderand captured it with scripted Playwright (Chromium, 1x): nothing usable pasted, Prompt copied (clipboard permission granted), a failed copy (clipboard API rejected andexecCommandfailing), and a paste with skipped lines. The emoji glyphs render as boxes only because the headless browser has no emoji font. Not exercised: the tab inside the live dashboard dialog, since the isolated instance needs a dashboard token this session cannot mint.Screenshots / video
Nothing usable pasted: Save is disabled and the summary says why (light).
Copy prompt after a successful copy: the button reads "Prompt copied"; the pasted reply filled the name and emoji (light).
A failed copy: the error notice, with the prompt opened and its toggle reading Hide prompt (dark).
Skipped lines named before Save: unknown names including the case-sensitive
--BG, a refused value with its text, and the note that Save keeps everything else (dark).Related Issues
No tracking issue: opened directly at the owner's request.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)