Skip to content

feat(native): add THEME_CSS_HOOKS slot parser, compiler, and GPUI ThemeSlot engine - #467

Merged
rynfar merged 2 commits into
nativefrom
feat/native-theme-css-slot-engine
Nov 20, 2026
Merged

rynfar merged 2 commits into
nativefrom
feat/native-theme-css-slot-engine

Conversation

@rynfar

@rynfar rynfar commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Part of #457 (Wave H4A — core CSS slot parser/compiler + GPUI ThemeSlot engine; Wave H4B will wire all 29 UI component call sites right after this merges).

Problem

Custom theme CSS in the native GPUI client previously only evaluated :root / sidebar custom properties, leaving all 29 THEME_CSS_HOOKS selectors unmapped.

Solution

  • apps/native/crates/core/src/themes/slots.rs + css.rs + mod.rs:
    • Added ThemeSlot covering all 29 THEME_CSS_HOOKS selectors (plus ::-webkit-scrollbar / ::-webkit-scrollbar-thumb aliases and [data-timeline-row-kind="<kind>"] matchers).
    • Extended ParsedCss with selector matching for .dark, :root:not(.dark), html.dark, @media (prefers-color-scheme: ...), comma-separated selector lists, :hover/:active pseudo-states, CSS nesting (&), !important, CSS specificity, and per-longhand cascade order.
    • Added SlotStylesheet (SlotStyleSet { base, hover, active } + kind-specific timeline_row) with typed SlotStyleOverride covering display: none, solid/transparent/linear-gradient/scoped var(--theme-background-image) backgrounds, colors, borders, border radii, padding/margin/gap, dimensions, box shadows, opacity, typography, and flex layout, with safety clamps (blur <= 256px, border-width <= 64px, font-size 8..=96px, remote-fetch rejection).
    • Updated CssDiagnostics with applied_slot_rules while keeping unmapped_dom_rules strictly counting unsupported/unrecognized rules, and exposed palette_and_slots_for_with_css so each theme half parses CSS once.
  • apps/native/crates/app/src/theme/slots.rs + theme/mod.rs + workspace.rs + theme_editor.rs:
    • Cached compiled Arc<SlotStylesheet> in SavedTheme, PreparedPreview, and GPUI global ActiveSlotStylesheet (zero per-frame CSS parsing, O(1) slot lookup, zero-mutation fast path on stock themes).
    • Exposed slot_stylesheet, slot_style, apply_slot_override, refine_slot_hover, refine_slot_active, ThemeSlotExt, ThemeSlotHoverExt, ThemeSlotInteractiveExt, and theme_slot_background_layer.
    • Scoped workspace.rs's global background image layer behind !slot_stylesheet(cx).has_scoped_background_image() so scoped wallpaper rules do not double-paint globally.
    • Updated theme_editor.rs CSS footer diagnostics to show applied_slot_rules and unmapped_dom_rules.

Verification

  • Gate 1: vp fmt --check apps/native/parity/LEDGER.md — pass
  • Gate 2: node apps/native/scripts/gen-theme.ts --check — pass
  • Gate 3: node apps/native/conformance/generate.ts --check — pass
  • Gate 4: node --test apps/native/parity/sync.test.ts — 47 passed, 0 failed
  • Gate 5: CARGO_INCREMENTAL=0 cargo clippy --manifest-path apps/native/Cargo.toml --workspace --all-targets -- -D warnings — pass (0 warnings)
  • Gate 6: CARGO_INCREMENTAL=0 cargo test --manifest-path apps/native/Cargo.toml -p t3-core — 1894 passed + 8 conformance passed, 0 failed
  • Gate 7: CARGO_INCREMENTAL=0 cargo test --manifest-path apps/native/Cargo.toml -p t3-client -- --test-threads=1 — 170/171 passed (1 pre-existing mcp_apps::tests::* test_server.rs:232 socket-open timeout flake; crates/client untouched)
  • Gate 8: T3_NATIVE_HOME=$(mktemp -d) CARGO_INCREMENTAL=0 cargo test --manifest-path apps/native/Cargo.toml -p t3-native -- --test-threads=1 — 232 passed, 0 failed
  • Gate 9: T3_NATIVE_HOME=$(mktemp -d) CARGO_INCREMENTAL=0 cargo test --manifest-path apps/native/Cargo.toml -p t3-native --features snapshot theme -- --test-threads=1 — 13 passed, 0 failed
  • Gate 10: CARGO_INCREMENTAL=0 cargo build --manifest-path apps/native/Cargo.toml -p t3-native — pass

Implemented with Antigravity (Gemini).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant