feat: add CSS theme token validation#372
Merged
Merged
Conversation
mcritzjam
approved these changes
Jun 26, 2026
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.
Summary
This PR makes CSS design-token validation a first-class build/dev-server contract across WebUI. The parser now tracks unresolved
var()fallback chains, reports missing required theme tokens as structured diagnostics, and surfaces likely misspellings that are protected by literal CSS fallbacks as non-fatal warnings.It also makes
webui serveisomorphic withwebui buildfor static component assets:--emit-component-assetsis now accepted by the dev server, parsed on every rebuild, validated against the configured theme, and served from memory as browser-loadable.webui.jsmodules.What changed
Theme-token validation
The parser now understands fallback chains such as:
Each unresolved candidate is validated independently after local/ancestor definitions are removed. For example, this only requires
--token-band--token-cfrom the theme because--token-ais defined locally:Missing required tokens now fail with structured diagnostics:
Literal-fallback warnings
A token used only with a literal fallback remains non-fatal because CSS has a valid runtime fallback:
If the token is absent from every theme, WebUI now emits a warning diagnostic instead of a single-line advisory:
Nested fallback handling now matches CSS semantics more closely:
serve --emit-component-assetsservenow accepts the same static component asset roots asbuild:This means lazily loaded components that are not present in the SSR entry tree are still parsed and validated during development:
The generated component asset is served from memory with a JavaScript MIME type so the WebUI Framework loader can import it directly:
Dev-server reliability and UX
The dev server now:
↻ rebuilt lazy-panel.css in 3ms;Example warning/error shape under
cargo xtask dev:API and docs
BuildResult.warningsis now aVec<Diagnostic>in Rust.string[]and the TypeScriptBuildResulttype now includeswarnings.webui-tokensno longer exposes a no-opTokenWarningAPI; token resolution returnsResolvedTokens { css }.DESIGN.md, CLI docs, CSS token docs, integration docs, AI docs, and package README examples.Validation
Passed locally: