Skip to content

feat(native): upgrade GPUI THEME_CSS_HOOKS compiler and renderer for Kraken themes - #473

Merged
rynfar merged 2 commits into
nativefrom
nw/h5-kraken-theme-engine
Nov 20, 2026
Merged

rynfar merged 2 commits into
nativefrom
nw/h5-kraken-theme-engine

Conversation

@rynfar

@rynfar rynfar commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Problem

Custom CSS themes such as kraken-glass and kraken-kinetic only partially translated to the native GPUI client because the slot compiler rejected compound attribute qualifiers ([class*="border-input"]), complex active/selected selectors (:is(...), :has(...), ::before), calc(100% - <px>) floating card sizing, multi-stop linear gradients, radial gradients, background-clip: padding-box, border-box prismatic rims, and embedded data: @font-face payloads.

Solution

  1. Slot compiler & selector upgrades (crates/core/src/themes/slots.rs):
    • Added SettingsGroup, SwitchThumb, and Checkbox slots while preserving all 29 canonical THEME_CSS_HOOKS in order; added selector aliases (input-control, select-popup / select-popup > .dropdown-glass, sidebar > *).
    • Added AttrOp support for *=, ^=, ``, ~=, `|=` qualifiers, `:root.dark` / `:root:not(.dark)`, `SlotState::{Selected, Unchecked, FocusWithin}`, complex `:is(...)` / `:has(...)` / `:is(...) > [data-thread-item]` matching (without clobbering inner descendant resets), state-scoped `SlotVarDecl`, `::before` `SlotPseudoBar`, and `SlotLength::FullMinusPx(f32)`.
    • Parsed multi-layer background-image / background, background-clip: padding-box, border-box -> border_gradient, elliptical radial-gradient(...), and preserved underlay background_color beneath gradient layers.
  2. GPU gradient rasterizer & prismatic rim rendering (crates/app/src/theme/slots.rs):
    • Added a cached 128x128 BGRA8 gradient rasterizer (cleared on stylesheet changes) with premultiplied RGBA stop interpolation for multi-stop linear-gradient and elliptical radial-gradient.
    • Rendered border_gradient prismatic rims (outer rounded gradient + inset inner padding-box fill), SlotPseudoBar (::before), and state-aware background layers cleanly without wash-out.
  3. UI call-site wiring:
    • Wired floating SidebarInner inset sizing (workspace.rs, sidebar/mod.rs), selected ThreadItem rim + ::before bar (sidebar/row.rs), focused ComposerHost halo (composer/view.rs), Switch/SwitchThumb/Select/SettingsGroup/DialogFrame/Tooltip (settings/controls.rs), Checkbox/Tooltip (composer/controls.rs), dialogs, menus, popovers, transcript bubbles/code blocks, and thread details without duplicate .hover(...) panics.
  4. Theme CSS typography & embedded @font-face (crates/core/src/themes/css.rs, crates/app/src/theme/mod.rs):
    • Extracted --font-sans, --font-mono, body/html font-family defaults (yielding to explicit user typography settings) and local data: @font-face payloads, decoding WOFF2/WOFF via wuff and registering deduplicated SFNT bytes into GPUI's TextSystem with FontInventory refresh.

Verification

  • CARGO_INCREMENTAL=0 cargo clippy --manifest-path apps/native/Cargo.toml --workspace --all-targets -- -D warnings: PASS (0 warnings)
  • CARGO_INCREMENTAL=0 T3_NATIVE_HOME=$(mktemp -d) cargo test --manifest-path apps/native/Cargo.toml -p t3-core --lib themes: 74 passed, 0 failed
  • CARGO_INCREMENTAL=0 T3_NATIVE_HOME=$(mktemp -d) cargo test --manifest-path apps/native/Cargo.toml -p t3-native -- --test-threads=1: 241 passed, 1 unrelated failure (onboarding::tests::onboarding_rpc_retries_ambiguous_creates_and_partial_history_without_duplicates, missing node_modules/.pnpm in Rust-only worktree)

…Kraken themes

Upgrades the native theme CSS slot compiler and GPUI rendering engine so custom themes like kraken-glass and kraken-kinetic translate faithfully:
- Adds SettingsGroup, SwitchThumb, and Checkbox slots (keeping all 29 canonical THEME_CSS_HOOKS intact), plus input-control, select-popup > .dropdown-glass, and sidebar > * aliases.
- Supports substring/prefix/suffix attribute qualifiers ([class*="border-input"]), :root.dark / :root:not(.dark), complex :is(...) / :has(...) selected thread selectors without clobbering inner descendants, SlotState::{Selected, Unchecked, FocusWithin}, state-scoped CSS vars, ::before SlotPseudoBar accent bars, and calc(100% - <px>) floating inset sizing.
- Parses multi-stop linear gradients, elliptical radial gradients (preserving underlay background-color), and background-clip: padding-box, border-box prismatic border_gradient rims, rendered via a cached 128x128 BGRA8 GPU texture rasterizer.
- Extracts theme CSS font stacks (--font-sans, --font-mono, body/html font-family) and local data: @font-face payloads (decoding WOFF2/WOFF via wuff and registering deduplicated SFNT bytes into GPUI TextSystem).
- Wires new states, floating sidebar card sizing, prismatic rims, and ::before bars cleanly across workspace, sidebar, composer, settings controls, dialogs, menus, popovers, tooltips, transcript bubbles/code blocks, and thread details without duplicate hover panics.
@rynfar
rynfar merged commit 922857f into native Nov 20, 2026
@rynfar
rynfar deleted the nw/h5-kraken-theme-engine branch November 20, 2026 18:54
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