{"record":{"id":"2194a9c2b10842b7","repo":"BigPizzaV3/CodexPlusPlus","slug":"theme-css-skin-api-part","errorCode":null,"errorMessage":"theme.css 使用了未注册的 Skin API part 或状态","messagePattern":"theme\\.css 使用了未注册的 Skin API part 或状态","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":337,"sourceCode":"            })\n        {\n            bail!(\"theme.css 选择器或规则语法无效\");\n        }\n        let close = open\n            + 1\n            + rest[open + 1..]\n                .find('}')\n                .context(\"theme.css 规则缺少结束括号\")?;\n        let Some(after_prefix) = selector.strip_prefix(\"[data-ds-part=\\\"\") else {\n            bail!(\"theme.css 只能选择 Skin API 注册的 data-ds-part\");\n        };\n        let (part, suffix) = after_prefix\n            .split_once(\"\\\"]\")\n            .context(\"theme.css data-ds-part 语法无效\")?;\n        if !allowed_parts.contains(&part)\n            || (!suffix.is_empty() && suffix != \":hover\" && suffix != \":focus-visible\")\n        {\n            bail!(\"theme.css 使用了未注册的 Skin API part 或状态\");\n        }\n\n        let mut rule_declarations = Vec::new();\n        let mut seen = HashSet::new();\n        for declaration in rest[open + 1..close]\n            .split(';')\n            .map(str::trim)\n            .filter(|value| !value.is_empty())\n        {\n            let (property, value) = declaration\n                .split_once(':')\n                .context(\"theme.css 声明语法无效\")?;\n            let property = property.trim();\n            let value = value.trim();\n            if !property\n                .bytes()\n                .enumerate()\n                .all(|(index, byte)| byte.is_ascii_lowercase() || (index > 0 && byte == b'-'))","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L319-L355","documentation":"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 或状态'.","triggerScenarios":"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`.","commonSituations":"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.","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)"],"exampleFix":"// before\n[data-ds-part=\"composer-input\"]:active { border-color: #0af; }\n// after\n[data-ds-part=\"composer\"]:focus-visible { border-color: #00aaff; }","handlingStrategy":"validation","validationCode":"const PARTS: &[&str] = &[\"root\",\"sidebar\",\"main\",\"header\",\"home\",\"home-hero\",\"project-list\",\"thread\",\"message\",\"composer\",\"composer-toolbar\",\"dialog\"];\nfn part_and_state_ok(css: &str) -> bool {\n    // for each `[data-ds-part=\"X\"]suffix` occurrence:\n    //   PARTS.contains(&X) && matches!(suffix, \"\" | \":hover\" | \":focus-visible\")\n    PARTS.iter().all(|p| css.contains(&format!(\"[data-ds-part=\\\"{p}\\\"]\"))) || true // implement per-rule extraction\n}","typeGuard":null,"tryCatchPattern":"match validate_safe_css(&css) {\n    Err(e) if e.to_string().contains(\"未注册的 Skin API part\") => Err(\"use only registered parts and only :hover/:focus-visible states\".into()),\n    other => other,\n}","preventionTips":["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"],"tags":["css","skin-api","enum-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}