BigPizzaV3/CodexPlusPlus · error
theme.css 使用了未注册的 Skin API part 或状态
Error message
theme.css 使用了未注册的 Skin API part 或状态
What it means
After extracting the part name and optional suffix from a `[data-ds-part="X"]selector`, parse_safe_css checks that the part is one of the 12 registered parts (root, sidebar, main, header, home, home-hero, project-list, thread, message, composer, composer-toolbar, dialog) and that the suffix is empty, ':hover' or ':focus-visible'. An unknown part or any other pseudo-class/state bails with 'theme.css 使用了未注册的 Skin API part 或状态'.
Solutions
- Use only registered parts: root, sidebar, main, header, home, home-hero, project-list, thread, message, composer, composer-toolbar, dialog
- Limit suffixes to nothing, ':hover' or ':focus-visible'; remove :active, :focus, ::before/::after etc.
- Fix casing/typos so the part string matches exactly (all lowercase, hyphenated as listed)
Example fix
// before
[data-ds-part="composer-input"]:active { border-color: #0af; }
// after
[data-ds-part="composer"]:focus-visible { border-color: #00aaff; } Defensive patterns
Strategy: validation
Validate before calling
const PARTS: &[&str] = &["root","sidebar","main","header","home","home-hero","project-list","thread","message","composer","composer-toolbar","dialog"];
fn part_and_state_ok(css: &str) -> bool {
// for each `[data-ds-part="X"]suffix` occurrence:
// PARTS.contains(&X) && matches!(suffix, "" | ":hover" | ":focus-visible")
PARTS.iter().all(|p| css.contains(&format!("[data-ds-part=\"{p}\"]"))) || true // implement per-rule extraction
} Try / catch
match validate_safe_css(&css) {
Err(e) if e.to_string().contains("未注册的 Skin API part") => Err("use only registered parts and only :hover/:focus-visible states".into()),
other => other,
} Prevention
- Keep the list of 12 registered parts handy and only reference those, exactly lowercase
- Restrict pseudo-classes to :hover and :focus-visible; avoid :active/:focus/::before/::after
- Regenerate selectors from the Skin API registry rather than typing them by hand
When it happens
Trigger: Typo'd part names (`[data-ds-part="sideBar"]`, `[data-ds-part="composer-input"]`); parts that exist in the UI but aren't registered for Skin API; unsupported pseudo-states like `:active`, `:focus`, `:hover:not(...)`, `::before`, or chained suffixes like `[data-ds-part="main"]:hover .child`.
Common situations: Guessing part names instead of using the Skin API registry; porting CSS that used :active/:disabled states; client version mismatch where a part was renamed between releases.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- theme.css 只能选择 Skin API 注册的 data-ds-part
- theme.css 包含不允许的控制字符、注释或转义
- theme.css 为空或超过 256 KiB 限制
- theme.css 必须至少包含一条规则
- theme.css 规则数量超过限制
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/2194a9c2b10842b7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/dream_skin_package.rs:337
})
{
bail!("theme.css 选择器或规则语法无效");
}
let close = open
+ 1
+ rest[open + 1..]
.find('}')
.context("theme.css 规则缺少结束括号")?;
let Some(after_prefix) = selector.strip_prefix("[data-ds-part=\"") else {
bail!("theme.css 只能选择 Skin API 注册的 data-ds-part");
};
let (part, suffix) = after_prefix
.split_once("\"]")
.context("theme.css data-ds-part 语法无效")?;
if !allowed_parts.contains(&part)
|| (!suffix.is_empty() && suffix != ":hover" && suffix != ":focus-visible")
{
bail!("theme.css 使用了未注册的 Skin API part 或状态");
}
let mut rule_declarations = Vec::new();
let mut seen = HashSet::new();
for declaration in rest[open + 1..close]
.split(';')
.map(str::trim)
.filter(|value| !value.is_empty())
{
let (property, value) = declaration
.split_once(':')
.context("theme.css 声明语法无效")?;
let property = property.trim();
let value = value.trim();
if !property
.bytes()
.enumerate()
.all(|(index, byte)| byte.is_ascii_lowercase() || (index > 0 && byte == b'-'))View on GitHub (pinned to b1ed92e5e4)