It seems there are some thing outstanding related to gtk and design tokens?
Assistant
I'll investigate the outstanding GTK and design token items.
Assistant
Yes. Here's what's outstanding.
The main gap: GTK renderer has no design-token support
The design-token work landed everywhere exceptpathland-render-gtk (recent commits: 61b02ec spec, f0e776e HTML/JS DOM renderers, bacf1e4 Rust DSL/engine, 980e345 Java DSL). GTK is now the only renderer that ignores tokens:
host.rs:147 — STYLE::SET_DESIGN_TOKEN is swallowed (let _ = op;)
host.rs:128-141 — SET_PROPERTY treats a DESIGN_TOKEN-typed value as a raw u32 (stores the arena offset, never resolves the path), while STRING is handled
No default token table (Tier 1 light+dark), no scheme detection, no re-resolution
This violates the spec/TOKENS.md renderer contract (a renderer MUST: provide light+dark Tier 1 defaults, accept SET_DESIGN_TOKEN, derive the effective scheme, resolve DESIGN_TOKEN refs, fall back to defaults). Note GTK CSS has no var()/custom properties, so resolution must happen in Rust at apply time (vs. the HTML renderers' var(--pl-…)).
Related (already documented) outstanding items
Rust DSL pathland-view/status.md:35 — no SET_DESIGN_TOKEN global override helper / Theme object
Java pathland-view/status.md:110 — same, no setDesignToken on the emitter/sink
pathland-render-gtk/status.md — doesn't mention design tokens at all (out of sync)
Proposed plan (GTK renderer)
New tokens.rs (or module in host.rs): a Theme with built-in Tier 1 light/dark defaults + app overrides (HashMap<String, (u8, u32)>), the dark.* layer, and the space.<N> generative family (space.base × N).
host.rs: parse SET_DESIGN_TOKEN (arena path, valueType, value) into the store; resolve DESIGN_TOKEN value type in SET_PROPERTY to a concrete value at apply time, recording that it's token-backed.
Scheme detection via gtk::Settings (gtk-application-prefer-dark-theme/theme-name) + notify handler to re-apply token-backed properties (re-run the existing CSS-provider/Pango paths).
Wire token resolution into the existing apply paths: colors → style_css()/Pango color, font size/weight → Pango, spacing/padding → margins/spacing, radius → border-radius, etc. (mirroring HTML's token_ref resolution).
Update pathland-render-gtk/status.md.
Want me to scope it to just the GTK renderer, or also include the DSL Theme/setDesignToken helpers (Rust + Java)? And should default token values map onto GTK native semantic colors (e.g. GtkThemeAdvisor/system colors) or concrete defaults?
User
This is want I want:
User
This is want I want: # Pathland — continue the design-tokens & theming branch
You are picking up an in-progress feature branch. Read AGENTS.md first — it is
the mandatory project guide (architecture, non-negotiable principles, and the
rule that every change MUST keep the affected project's status.md in sync;
specs in spec/ never carry implementation status).
Context
Branch: feature/design-tokens-theming (6 commits, clean tree). It implements
the design-token system / theming end-to-end. The canonical contract is
spec/TOKENS.md:
Tokens are dot-separated paths (color.primary, space.2). base = light;
dark.-prefixed paths are the dark variant (dark.color.primary).
Scheme selection is renderer-derived (browser prefers-color-scheme,
GTK native variant). There is deliberately NO META::SET_THEME — do not add one.
Any COLOR/F32/STRING/ENUM property MAY carry the DESIGN_TOKEN
value type (0x08): C = arenaRef to the token path.
STYLE::SET_DESIGN_TOKEN (A=arenaRef path, B=valueType, C=value) is a global
override. dark.* overrides are emitted scoped inside
@media (prefers-color-scheme: dark) (HTML renderers) so SSR needs no client
scheme.
Spacing is a generative family: space.<N> resolves to space.base × N.
Leave it as-is (a "direct override wins" rule was explicitly deferred).
CSS variable mapping: --pl- + path with . → - (the dark. prefix is
stripped — the dark variant overrides the same variable inside the media query).
JS DOM renderer (lib/typescript): src/tokens.ts (managed
<style data-pathland-tokens>: :root base rules + dark-media-scoped dark
rules; var()/ for refs), (),
routing.
Assistant
I'll research the current state of the branch and each outstanding item before drafting the plan.
Assistant
GTK4 is actually available on this machine. Let me verify the GTK crate builds, then continue research on each item.
Assistant
GTK4 is available and pathland-render-gtk builds here, so item 6 is buildable/verifiable. Let me research the remaining items.
Assistant
Now the DSL layers — engine, Rust view, and Java view.
Assistant
Let me examine the Quarkus/Spring demo setup and the demo-views tests to plan the theming demo and item 5.
Assistant
I have a complete picture. One important correction to the brief: GTK4 is available on this machine (pkg-config gtk4 → 4.22.4, and cargo build -p pathland-render-gtk succeeds), so item 6 is buildable and verifiable here, not just "on a GTK machine".
Here's my plan.
Plan: complete the design-tokens & theming branch
Item 1 — Enforce the token conformance vectors
pathland-core (conformance.rs, lib.rs)
Add vector 17 (STYLE:SET_DESIGN_TOKEN, path="color.primary" @ arenaRef 0, COLOR 0xFF0000FF) and vector 18 (SET_PROPERTY id=1, prop=COLOR=0x100A, valueType=DESIGN_TOKEN, C=arenaRef 0) to VECTORS + the decode-rebuild case list.
Add a ring test proving Guest::set_design_token("color.primary", COLOR, 0xFF0000FF) on a fresh ring emits exactly vector 17's 16 bytes (path at arena offset 0).
pathland-core-transport (conformance.rs)
Add vector 19 (NETWORK:BATCH, frameCount=3, the vector-18 opcode, arena delta = [0D 00 00 00] + "color.primary") — encode via encode_batch(3, 0, &[op], &arena_delta) and assert byte-exact; add to the decode/round-trip test.
Java (EmitterTest or a new FrameCodecTest)
Golden-byte test that Opcode for vectors 17/18 produce the exact bytes; a FrameCodec round-trip carrying a DESIGN_TOKENSET_PROPERTY (path in the string section).
Item 2 — Complete Tier-1 default tokens in the HTML renderer
pathland-render-html/src/css.rs — extend the built-in :root (light) + @media (prefers-color-scheme: dark) blocks and add canonical names:
--pl-space-base (critical for generative space.<N>) + dark variant.
Canonical font tokens: --pl-font-body-size, --pl-font-body-weight, ; make the rule + block use (keep as an alias so app overrides retheme).
Assistant
Good — GTK native semantic colors confirmed. Let me verify what GTK4/gtk-rs 0.9.7 exposes for that (ThemeAdvisor/system colors), so the plan is concrete.
Assistant
All three decisions are settled and GTK4's StyleContext::lookup_color(&str) -> Option<gdk::RGBA> (gtk4 0.9.7, style_context.rs:165) gives us the GTK-native semantic-color path (@theme_* named colors). Here is the finalized plan.
Final Plan — finish feature/design-tokens-theming
Environment note: GTK4 4.22.4 + gtk4 0.9.7 are present and pathland-render-gtk builds, so item 6 is implemented and verified here.
1. Enforce token conformance vectors
pathland_core/src/conformance.rs: add vectors 17 (SET_DESIGN_TOKEN, path "color.primary" @ arenaRef 0, COLOR 0xFF0000FF) and 18 (SET_PROPERTY, prop COLOR=0x100A, valueType DESIGN_TOKEN, C=arenaRef 0) to VECTORS + decode-rebuild cases; add a ring test that a fresh Guest::set_design_token(...) emits vector 17 byte-exactly.
New pathland_core/src/tokens.rs (no_std+alloc, BTreeMap): TokenValue enum (Color/F32/U32/U8/I32/Str), resolve(path, scheme, overrides, defaults) implementing dark-layer → override → default → parent-fallback → fallback and the generative space.<N> family. Port the full "Design-Token Resolution Conformance" table as tests.
Now vector 20 in CONFORMANCE.md and conformance.rs:
Assistant
Now the HTML renderer. Let me check its imports first:
Assistant
Adding an HTML render test for STRING-valued tokens:
Assistant
Now the JS DOM renderer. Checking imports and test structure:
Assistant
TS green. Updating status.md files for Item 4:
Assistant
Now the TypeScript status.md:
Assistant
Item 4 done. Moving to Item 5 — theming demo. Let me examine the demo session setup:
Assistant
The SSR path renders sink.frame() (the mount frame), so theme overrides must ride inside the mount frame to appear in SSR HTML. I'll add an optional Theme to the Emitter that emits at the start of the mount/renderFull frames. Let me check SectionCard and AppearanceSection for the view style:
Assistant
Now implementing the demo. First, Theme.emitInto + Emitter theme hook:
Assistant
Now the ThemeSection view and DemoTheme in demo-views:
Assistant
Register ThemeSection in the kitchen sink:
Assistant
Now wire the theme into both demos:
Assistant
Adding the demo-views test:
Assistant
Now build both demos to confirm they compile:
Assistant
Demos compile. Updating demo-views status.md:
Assistant
Item 5 done. Now Item 6 — GTK renderer theme layer. Let me study the renderer lifecycle and host.rs fully:
Assistant
I have the full picture. Let me implement the GTK theme layer. First, add Default for Scheme in core, then rework host.rs:
Assistant
Now the host.rs changes — token refs on nodes, theme state on RenderTree, and resolution:
Assistant
Now update apply_frame for SET_DESIGN_TOKEN and DESIGN_TOKEN-typed SET_PROPERTY, and call resolve_tokens at the end:
Assistant
Adding the concrete default tables to host.rs:
Assistant
Let me add the function in smaller pieces. First view the insertion point:
Assistant
Now the GTK-native defaults module. Let me verify the gtk API surface first:
Assistant
No public StyleContext::new() in this binding — native colors must come from a widget's style context. I'll enrich lazily at first widget. Writing tokens.rs:
Assistant
No StyleContext constructor exists in this binding — only widget-provided contexts. Refactoring tokens.rs to take a resolver closure (testable headless):
Assistant
layout.rs test needs the new field. Let me check and fix:
Assistant
Now update lib.rs: register the module, add set_scheme + native-default enrichment, and wire scheme detection in run_with_pump:
Assistant
Duplicate module declarations. Fixing:
Assistant
Now the GtkRenderer changes — add native-ctx field, scheme handling, and first-widget enrichment:
Assistant
Now capture the style context at first widget build in get_or_create:
Assistant
Now wire scheme detection + notify in run_with_pump:
Assistant
Missing prelude import in tokens.rs:
Assistant
The method is is_gtk_application_prefer_dark_theme(). Fixing:
Assistant
Now adding GTK theme-layer tests:
Assistant
All GTK tests pass. Fixing the unused TokenValue import in tests:
Assistant
Updating the render-gtk status.md:
Assistant
Item 6 done. Running the full verification suite:
Assistant
All Rust green. Now the wasm no_std guard:
Assistant
All green. Let me run the whole Rust workspace to catch anything else (GTK demo, view-native):
Assistant
Entire workspace green. Let me review the change set:
Assistant
One first-paint subtlety: the root node is cloned before get_or_create captures the native context, so its first update uses pre-enrichment values. Fixing by re-reading the node after get_or_create:
Assistant
Let me add a describe line for SET_DESIGN_TOKEN for debug completeness:
Assistant
Final consolidated verification across all projects:
Assistant
All six items are implemented and verified. Summary:
1. Conformance vectors enforced
pathland-core/src/conformance.rs: vectors 17–18 (SET_DESIGN_TOKEN, DESIGN_TOKEN-typed SET_PROPERTY) + a ring test proving Guest::set_design_token emits vector 17 byte-exactly; new pathland_core::tokens module (no_std+alloc) with the reference resolution algorithm + the full CONFORMANCE resolution table tested.
Java: golden-byte opcode tests for 17/18 + FrameCodec DESIGN_TOKEN round-trip.
2. HTML renderer Tier-1 defaults — --pl-space-base (light+dark), canonical font.body.*, control.*/button.*/input.* catalog, radius scale, border.width.thin, elevation.* shadows; .pathland-* rules now reference canonical vars (focus ring → control.accent). Tests added.
3. DSL theme helpers — Rust pathland_engine::Theme + Engine::apply_theme (re-exported from pathland-view); Java Theme + OpcodeSink.setDesignToken in both sinks.
4. STRING-valued token overrides — Guest::set_design_token_string, spec vector 20, HTML renderer (quoted CSS), JS DOM applyDesignToken, and the Theme DSLs — all end-to-end.
5. Theming demo — ThemeSection + DemoTheme in demo-views; both Quarkus and Spring SessionApp pass the theme to the Emitter, which rides the overrides into the mount (SSR) + resync frames.
6. GTK renderer theme layer — host.rs stores overrides + token refs and resolves against pathland_core::tokens; Tier-1 defaults are concrete fallbacks enriched with GTK-native @theme_* colors from the first widget's style context; scheme detection via gtk::Settings (prefer-dark/-dark theme) with a notify handler that re-resolves + re-applies.
All status.md files updated. Verification green: full cargo test --workspace (no warnings), check-wasm.sh (no_std preserved), Java pathland-view+demo-views (44 tests), demos compile, TS 88 tests + typecheck. Wire version unchanged (all additive). Nothing committed.
User
Show me how it can be used from java
Assistant
Let me verify the exact Java API names so the example is accurate.
Assistant
Here's the full Java surface, end to end. All of this is already implemented on this branch and proven by tests.
1. Roll a theme (global SET_DESIGN_TOKEN overrides)
com.pathland.view.Theme — base values are light, dark* builders emit the dark. variant:
These emit the DESIGN_TOKEN value type (0x08) — the path rides the frame's string section/arena. Color.token also works with a dark. prefix, e.g. Color.token("dark.color.surface").
3a. SSR / WebSocket path — hand the theme to the Emitter
The theme's overrides ride the mount frame (so the SSR HTML document carries :root{--pl-color-primary:…} + the dark media query) and the resync frame. This is exactly what the Quarkus and Spring demos do:
java
User
For darkMode, could color() instead take 1 or 2 colors. And if a second color is specfied, then that is the dark color?
Assistant
Let me look at the current Theme API and all its usages to ground the plan.
Assistant
Good idea — that's a cleaner ergonomic. Here's what it looks like today and the plan.
Current API (Theme.java)
java
.color("color.primary", 0xFF2563EB) // base (light) only
.darkColor("color.primary", 0xFF60A5FA) // dark variant in a separate call
Proposed
Add a 3-arg overload — 1 color = light only, 2 colors = light + dark:
java
.color("color.primary", 0xFF2563EB) // light only
.color("color.primary", 0xFF2563EB, 0xFF60A5FA) // light + dark
Implementation is trivial — the 3-arg form pushes two overrides (base + dark.-prefixed), reusing the existing dark(path) helper:
java
public Theme color(String path, int argb, int darkArgb) {
return push(path, ValueTypes.COLOR, Color.of(argb))
.push(dark(path), ValueTypes.COLOR, Color.of(darkArgb));
}
Files touched:Theme.java (new overload + Javadoc example), EmitterTest.themeEmitsGlobalDesignTokenOverrides (switch to the 2-color form + assert it emits both base and dark), DemoTheme.java (rewrite with the 2-color form), and the Theme bullet in pathland-view/status.md.
/** Override a token with a light color and its dark variant in one call. */
public Theme color(String path, int argb, int darkArgb) {
return push(path, ValueTypes.COLOR, Color.of(argb))
.push(dark(path), ValueTypes.COLOR, Color.of(darkArgb));
}
(emits base override, then dark.<path> override)
RemovedarkColor, darkF32, darkString (no usages elsewhere — grep confirmed only darkColor in DemoTheme/EmitterTest, both updated below).
Keep color(path, argb), f32, u32, u8, string.
Update the Javadoc example to color("color.primary", 0xFF2563EB, 0xFF60A5FA).
2. Java usages
DemoTheme.java — rewrite each .color(...).darkColor(...) pair as one 2-color .color(path, light, dark) call (primary, surface, accent, control.background/foreground/accent).
EmitterTest.themeEmitsGlobalDesignTokenOverrides — use the 2-color form; add a focused test themeColorWithDarkEmitsBaseAndDarkOverrides asserting exactly two COLOR SET_DESIGN_TOKEN opcodes (color.primary + dark.color.primary) with the right argb values.
Update tests: dark_builder_prepends_dark_prefix and apply_theme_emits_set_design_token_opcodes to exercise color_pair (assert two COLOR overrides + paths).
4. Docs/status
Theme.java Javadoc; lib/java/pathland-view/status.md Theme bullet (drop darkColor, note the 2-color overload); lib/rust/crates/pathland-engine/status.md + pathland-view/status.md (Rust) if they mention the Theme builders.
Verification
cd lib/java && mvn -pl pathland-view -pl pathland-demo-views test
cd lib/rust && cargo test -p pathland-engine -p pathland-view && ./check-wasm.sh (view/engine still wasm-clean)
No wire/behavior change — overrides still emit the same SET_DESIGN_TOKEN opcodes; this is purely API ergonomics. Ready to implement on approval.
User
No.. Stop... I rather want it to be that all functions only define one value. But that we then built a theme for light and one for dark, and have an AdaptiveTheme class that can be contructed from the 2?
Assistant
Got it — that's a cleaner model. Every Theme holds only base (light) overrides; dark is a secondTheme; AdaptiveTheme composes them and does the dark. prefixing. Let me re-ground the plan against the current code.
Assistant
Clear. Here's the model I'll build:
java
Theme light = new Theme().color("color.primary", 0xFF2563EB).f32("space.base", 4f);
Theme dark = new Theme().color("color.primary", 0xFF60A5FA);
AdaptiveTheme theme = new AdaptiveTheme(light, dark);
Theme — builders define one value each (color(path, argb), f32, u32, u8, string). No dark variants.
AdaptiveTheme(Theme light, Theme dark) — emit/emitInto emits the light theme as-is and the dark theme with dark. prefixed onto every path (guarding against double-prefix).
Removed from Java: darkColor, darkF32, darkString, and the 2-color overload (never added).
Files touched
Java
Theme.java — remove the 3 dark* methods and the now-unneeded dark() helper (moves to AdaptiveTheme); make Override/an accessor package-private so AdaptiveTheme can read the dark theme's triples.
Emitter.java — theme hook becomes AdaptiveTheme (see question 1); still emitted at the start of mount + renderFull frames.
DemoTheme.java — split into light() / dark() / adaptive(); drop darkColor pairs.
EmitterTest.themeEmitsGlobalDesignTokenOverrides — build light+dark Themes + AdaptiveTheme; add a focused test that dark paths are emitted with the dark. prefix.
KitchenSinkViewTest + both SessionApps — new Emitter(sink, DemoTheme.adaptive()).
Both decisions locked in: the interface is ThemeData, and Rust gets mirrored. Final plan:
Java
ThemeData.java (new interface, com.pathland.view)
java
public interface ThemeData {
void emitInto(OpcodeSink sink); // into an open frame
default void emit(OpcodeSink sink) { // one frame
sink.beginFrame();
emitInto(sink);
sink.endFrame();
}
}
RemovedarkColor, darkF32, darkString and the dark() helper.
emitInto pushes each override; make Override + an overrides() accessor package-private so AdaptiveTheme can read the dark theme's triples.
AdaptiveTheme.java (new)
java
public final class AdaptiveTheme implements ThemeData {
private final Theme light, dark;
public AdaptiveTheme(Theme light, Theme dark) { ... }
public void emitInto(OpcodeSink sink) {
light.emitInto(sink);
for (Override o : dark.overrides())
sink.setDesignToken(dark(o.path()), o.valueType(), o.value()); // prefixes "dark."
}
}
(Double-prefix guarded by the existing startsWith("dark.") check.)
Emitter.java — field + constructor param become ThemeData; emitTheme() calls theme.emitInto(sink) (unchanged behavior).
Usages — DemoTheme becomes light() / / ; both s and use .
User
go
Assistant
Now update the Emitter to take ThemeData:
Assistant
Now DemoTheme:
Assistant
Update the two SessionApps:
Assistant
Now rework the EmitterTest theme test:
Assistant
The nested record name Override clashes with java.lang.Override. Renaming to TokenOverride:
Assistant
Java green. Now the Rust mirror. Let me view the full theme.rs:
Assistant
Now refactor engine.rs — shared override emitter + apply_adaptive_theme:
Assistant
Register AdaptiveTheme in the engine + view exports:
Assistant
ToString needs importing in the no_std engine.rs:
Assistant
Rust green. Now the status.md files:
Assistant
Now the Java and Rust view status.md Theme bullets:
Assistant
Final verification:
Assistant
Done. The model is now: Theme = one scheme, one value per builder; AdaptiveTheme(light, dark) composes them and does the dark. prefixing.
Java (lib/java/pathland-view/.../view/)
ThemeData (new interface) — emitInto(OpcodeSink) + default emit(...); implemented by both Theme and AdaptiveTheme.
Theme — single-value builders only (color/f32/u32/u8/string); darkColor/darkF32/darkString removed.
AdaptiveTheme(Theme light, Theme dark) (new) — emits light as-is, dark with dark. prefixed.
Emitter(OpcodeSink, ThemeData) — mounts either; rides overrides into mount + resync frames.
DemoTheme → light() / dark() / adaptive(); both SessionApps + KitchenSinkViewTest use new Emitter(sink, DemoTheme.adaptive()).
Tests: EmitterTest reworked to assert light unprefixed + dark dark.-prefixed, plus a bare-light-Theme case; KitchenSinkViewTest checks dark.color.primary etc. in the mount frame.
Rust (pathland_engine)
Theme — dark_color/dark_f32/dark_string removed; AdaptiveTheme { light, dark } added (re-exported from pathland_view).
Engine::apply_adaptive_theme — light as base, dark with dark. prefix, sharing a emit_token_override helper with apply_theme; tests updated.
Status — pathland-view (Java), pathland-engine, pathland-view (Rust) updated.
Verified: full cargo test workspace green, check-wasm.sh passes (no_std preserved), Java pathland-view (40) + demo-views (5) green, Quarkus + Spring demos compile. No wire change.
User
in the rendered html, the style tokend are rendered outside the style tags
Assistant
Let me investigate how the token CSS gets injected into the rendered document.
Assistant
Confirmed the bug. In render_document (lib.rs:782-792), the built-in css::STYLE is a complete <style>…</style> block, but tokens.css() returns raw CSS rules (:root{…}, @media …) that get concatenated right after </style> and before </head> — outside any <style> element. Let me check the tests and the Java shim for related assumptions.
The token rules sit between </style> and </head> as raw text — outside any <style> element — so the browser never applies them (the parser moves that text into <body>; overrides silently do nothing). Existing tests pass because they only assert substring presence (html.contains(":root{…}")), not placement.
The Java pathland-render-html shim delegates to this Rust renderer, so one fix covers both.
The fix (render_document)
Wrap the rules in their own <style data-pathland-tokens> element, emitted after the built-in block (so the override :root variables win the cascade — same specificity, later wins) and matching the JS DOM client's style[data-pathland-tokens] element for symmetry:
rust
let token_rules = tokens.css();
let token_style = if token_rules.is_empty() {
String::new() // no overrides → no empty element
} else {
format!("<style data-pathland-tokens>{token_rules}</style>\n")
};
// … {}{} → css::STYLE, token_style
Now the test. Let me place it near the existing set_design_token_emits_base_and_dark_override_css test:
Assistant
Let me verify the exact rendered string to make the test assertion robust:
Assistant
As expected, the whitespace-sensitive assertion failed. Fixing it to be robust:
Assistant
All green. Now update the render-html status.md and run the full workspace:
Assistant
Full workspace green. Quick sanity check on the Java side (its HTML shim delegates to the Rust renderer):
Assistant
Fixed and verified. Summary:
Bug: render_document appended tokens.css() — bare :root{…} / @media … rules — directly after the built-in </style>, so the token overrides sat outside any <style> element and were never applied by the browser.
Fix (pathland-render-html/src/lib.rs:render_document): the override rules now render inside their own <style data-pathland-tokens>…</style> element, placed after the built-in block so the override :root variables win the cascade — matching the JS DOM client's style[data-pathland-tokens] element. No overrides → no empty element (skipped via tokens.css().is_empty()).
Test added: design_token_css_renders_inside_a_style_element — asserts the base rule is inside the token style element, the element is closed after the dark media query, no bare rules appear after any </style>, and a document without overrides emits no data-pathland-tokens element.
Status: pathland-render-html/status.md updated.
Verified: cargo test full workspace green (36 render-html tests), Java pathland-render-html shim tests green (it delegates to the Rust renderer, so the fix flows through). No wire change.
User
commit
calc()
src/classes.ts
applyTokenRefProperty
src/apply.ts
Rust HTML renderer (pathland-render-html): consumes SET_DESIGN_TOKEN
per batch into the document head; resolves DESIGN_TOKEN refs at render;
canonicalized :root core-color tokens in src/css.rs.
Rust core/engine/DSL: pathland_core::Guest::set_design_token;
pathland_engine::Node::token_properties emitting DESIGN_TOKEN value type
(steady-state zero-alloc preserved — unchanged refs reuse arena offsets);
pathland_view::Color::token("…") in all color modifiers.
Java DSL (lib/java/pathland-view): Color.token("…"); emitter derives
the DESIGN_TOKEN value type; both FrameOpcodeSink and RingOpcodeSink
write the path into the string section/arena.
Outstanding work (do in this order unless told otherwise)
1. Enforce the token conformance vectors
spec/CONFORMANCE.md vectors 17–19 (ring SET_DESIGN_TOKEN, SET_PROPERTY
with a DESIGN_TOKEN ref, network batch) and the "Design-Token Resolution
Conformance" table are spec'd but NOT enforced by
lib/rust/crates/pathland-core/src/conformance.rs. Port them as golden-byte
vectors + resolution tests there (and in the Java transport codec test if
applicable). Verify with cargo test -p pathland-core.
2. Complete Tier-1 default-token coverage in the HTML renderer
lib/rust/crates/pathland-render-html/src/css.rs:root block lacks several
Tier-1 defaults — critically --pl-space-base (without it, generative
space.<N> refs resolve to an undefined CSS variable unless the app overrides
space.base). Add the missing Tier-1 defaults (space.base, font.body.*,
control.*, …) and map the still-internal component vars (--pl-input-*,
--pl-button-*, --pl-shadow-sm, --pl-color-focus-ring) onto the canonical
control.*/button.*/input.* catalog so app overrides retheme components.
Update status.md + add render tests.
3. DSL global theme/override helpers (Rust + Java)
Core plumbing exists (Engine::set_design_token, Guest::set_design_token)
but neither DSL exposes it. Add a high-level surface that emits a batch of
SET_DESIGN_TOKEN overrides at mount (base + dark.*) — e.g. a Theme/token
helper in lib/rust/crates/pathland-view and a setDesignToken/theme surface
in lib/java/pathland-view (both status.md files flag this gap). Keep it
emitter-friendly: overrides are global and renderer-global — they never
re-emit nodes.
The wire supports it (valueType STRING on SET_DESIGN_TOKEN, C = arenaRef)
but no renderer or DSL emits/resolves STRING token values yet. Implement
end-to-end (Rust HTML renderer + JS DOM renderer + DSLs), add spec-conformance
coverage, update status.md.
5. Theming demo
The plan's item 3d was not built: a small demo that rolls a full Theme
(base + dark.*), uses a token-referencing color (e.g. Color::token /
Color.token("color.primary")), and shows the HTML renderer + JS DOM client
re-theming under prefers-color-scheme. Prefer adding to the existing Java
demo views (lib/java/pathland-demo-views) or a small Rust demo.
6. GTK renderer theme layer — REQUIRES A GTK-CAPABLE MACHINE
pathland-render-gtk cannot build in this environment (no GTK4/pkg-config;
the full Rust workspace also pulls GTK via pathland-core-transport's dev-deps,
so run cargo test only on the non-GTK crates here). On a machine with GTK4,
implement the renderer contract from spec/TOKENS.md:
SET_DESIGN_TOKEN is currently dropped at host.rs:147. Add a theme layer:
light+dark default token table, scheme detection from the native GTK variant,
resolution (override → default → parent → fallback with the dark.* layer),
DESIGN_TOKEN property-ref resolution before applying widget styles, and
re-resolution on scheme change. Update status.md.
Verification & conventions
Rust (non-GTK): cd lib/rust && cargo test -p pathland-core -p pathland-view -p pathland-engine -p pathland-render-html.
Java: cd lib/java && mvn -pl pathland-view test (the JNA ring test skips without libpathland_core).
TS: cd lib/typescript && npm test && npm run typecheck.
pathland-core and pathland-view must stay #![no_std]+alloc and compile
for wasm32-unknown-unknown (lib/rust/check-wasm.sh).
Wire changes must stay additive — the wire version stays 1.
Update the affected project's status.md in the same change as the code.
Do NOT commit unless explicitly asked.
Reference implementations for the token contract: spec/TOKENS.md (resolution
algorithm), lib/typescript/src/tokens.ts, and pathland-render-html/src/lib.rs
--pl-font-body-family
html
@supports
var(--pl-font-body-family)
--pl-font-sans
Full radius scale --pl-radius-xs/lg/xl/full, --pl-border-width-thin.
Map the internal component vars onto the catalog: --pl-control-* (background/foreground/border/border-width/radius/height/accent), --pl-button-*, --pl-input-*; rewrite .pathland-* rules + style_css() to reference them; map --pl-color-focus-ring → control.accent; --pl-shadow-sm → elevation.low.* composite. Both light and dark defaults for everything.
Tests: assert --pl-space-base present (light+dark), the new canonical vars exist, component rules reference canonical vars, and a space.2 ref still resolves to calc(var(--pl-space-base) * 2).
Status: pathland-render-html/status.md (remove the gap lines; note canonical mapping).
Engine::apply_theme(&mut self, theme, guest) — emits one SET_DESIGN_TOKEN per override; string values alloc'd into the guest arena first. Overrides are renderer-global: no node re-emission.
pathland_view re-exports Theme (+ sugar) so pathland_view::Theme::new()… works.
Engine test: golden opcodes + arena bytes for a base+dark theme.
OpcodeSink.setDesignToken(path, valueType, value) (new method), implemented in FrameOpcodeSink (path + STRING value into the string section) and RingOpcodeSink (arenaAlloc).
Theme.emit(OpcodeSink) emits a single frame of overrides.
EmitterTest tests.
Status: pathland-view/status.md (Rust) + lib/java/pathland-view/status.md — drop the "no global override helper" gaps.
Core: add Guest::set_design_token_string(path, value) (alloc value → offset as C; additive). Ring round-trip test.
Spec: add vector 20 (STRING-valued SET_DESIGN_TOKEN) to CONFORMANCE.md; port to conformance.rs.
HTML renderer: Tokens stores value as Raw(u32) | Str(String); decode resolves STRING via the string section; css()/token_css_value quote+escape strings.
JS DOM (tokens.ts, apply.ts): applyDesignToken reads the value string when valueType===VAL_STRING; DesignTokenSink.setToken accepts number | string; quote in tokenCssOverride. Tests.
Status: core, render-html, typescript, both views.
Item 5 — Theming demo
Add a ThemeSection to lib/java/pathland-demo-views using Color.token("color.primary"), Color.token("dark.color.surface"), and token-referencing backgrounds/controls.
Roll a Theme (base + dark.*: color.primary, color.surface, space.base, font.body.family, control.*) and emit it per session in the Quarkus SessionApp (and Spring demo).
Test: demo-views test asserts SET_DESIGN_TOKEN opcodes + token refs in the mount frame; run mvn quarkus:dev to eyeball SSR HTML (:root{--pl-color-primary:…}, dark media query, var(--pl-color-primary)).
host.rs: RenderTree gains a theme store (base/dark overrides, effective scheme); HostNode gains token_refs: BTreeMap<u16, String>. SET_DESIGN_TOKEN (host.rs:147) now stores the override (resolve STRING value from arena); SET_PROPERTY with DESIGN_TOKEN value type records the path instead of a raw value.
Resolution: add pathland_core::tokens (if approved — see question 1) or a renderer-local module; Tier-1 light+dark default table; dark.* layer → override → default → parent → fallback; generative space.<N>.
Scheme detection: gtk::Settings::default() → gtk_application_prefer_dark_theme() (present in gtk4 0.9.7) + connect_gtk_application_prefer_dark_theme_notify; on change, re-resolve + full re-sync.
Apply-time resolution (GTK CSS has no var()): resolve token-backed props to concrete values in style_css, apply_text_style, apply_padding, and stack layout spacing — colors → rgba, font size/weight/family → Pango/CSS, radius/border → px.
Status: pathland-view (Rust), lib/java/pathland-view — drop the "no global override helper" gaps.
4. STRING-valued token overrides
Core: Guest::set_design_token_string(path, value) (additive). Spec: new vector 20 in CONFORMANCE.md + conformance.rs.
HTML renderer: Tokens stores Raw(u32) | Str(String); decode resolves STRING via the string section; css()/token_css_value quote+escape.
JS DOM (tokens.ts/apply.ts): applyDesignToken reads the value string for VAL_STRING; DesignTokenSink.setToken accepts number | string; quote in tokenCssOverride; tests.
Status: core, render-html, typescript, both views.
5. Theming demo
ThemeSection in pathland-demo-views using Color.token("color.primary") / "dark.color.surface" + token-referencing backgrounds/controls.
Roll a Theme (base + dark.*: primary, surface, space.base, font.body.family, control.*) and theme.emit(sink) per session in Quarkus SessionApp (+ Spring). Verify SSR HTML contains :root{--pl-color-primary:…}, the dark media query, and var(--pl-color-primary) usage.
Demo-views test asserts SET_DESIGN_TOKEN opcodes + token refs in the mount frame.
Status: pathland-demo-views.
6. GTK renderer theme layer
host.rs: RenderTree gains override/scheme storage; HostNode.token_refs: BTreeMap<u16, String>. SET_DESIGN_TOKEN (currently dropped at host.rs:147) stores overrides (STRING values resolved from the arena); DESIGN_TOKEN-typed SET_PROPERTY records the path instead of a raw value.
Defaults = GTK-native: resolve Tier-1 tokens at runtime via StyleContext::lookup_color of @theme_* names (color.background→@theme_bg_color, color.surface→@theme_base_color, color.text.primary→@theme_fg_color, color.accent/color.primary→@theme_selected_bg_color, color.border→@borders, color.success/warning/danger→@success_color/@warning_color/@error_color, …); fall back to concrete HTML-style defaults when no display/theme (keeps headless tests deterministic). Uses pathland_core::tokens resolution.
Scheme: gtk::Settings → gtk_application_prefer_dark_theme() + connect_gtk_application_prefer_dark_theme_notify; on change, re-resolve + full sync().
Apply-time resolution (GTK CSS has no var()): resolve token-backed props in style_css/apply_text_style/apply_padding/stack spacing → concrete rgba/px/Pango.
cd lib/java && mvn -pl pathland-view -pl pathland-demo-views test
cd lib/typescript && npm test && npm run typecheck
No wire version bump (additive only).
Ready to implement on approval. Items 1→6 in order; each lands with its status.md update.
FrameOpcodeSink sink = new FrameOpcodeSink(); // or a WebSocket-fed sink
Emitter emitter = new Emitter(sink, theme); // theme emitted at frame start
RenderResult result = emitter.mount(root, new Environment(state));
// SSR HTML now contains, e.g.:
// :root{--pl-color-primary:rgba(37,99,235,1);}
// @media (prefers-color-scheme: dark){:root{--pl-color-primary:rgba(96,165,250,1);}}
// ... <span style="color:var(--pl-color-primary)">Accent text</span>
The JS DOM client re-themes under prefers-color-scheme: dark; a native GTK renderer re-resolves under the GTK dark variant — no re-emission either way.
3b. Desktop / ring path (JNA into libpathland_core) — standalone
Overrides are renderer-global, so they can be one frame of their own:
java
RingOpcodeSink ring = new RingOpcodeSink();
theme.emit(ring); // one frame of SET_DESIGN_TOKEN
new Emitter(ring).mount(root, Environment.DEFAULT);
Live examples in the repo
lib/java/pathland-demo-views/.../DemoTheme.java — the rolled theme
.../ThemeSection.java — the token-referencing view (color.primary, control.accent, color.surface, dark.color.surface, control.background)
pathland-quarkus-demo + pathland-spring-boot-demoSessionApp — new Emitter(sink, DemoTheme.theme())
Run the SSR demo to see it live: cd lib/java/pathland-quarkus-demo && mvn quarkus:dev, then toggle the OS/browser dark mode.
dark()
adaptive()
SessionApp
KitchenSinkViewTest
new Emitter(sink, DemoTheme.adaptive())
Tests — rework themeEmitsGlobalDesignTokenOverrides to build light+dark Themes + AdaptiveTheme, asserting base overrides emit unprefixed and dark ones as dark.…; add a ThemeData/light-only emit case.
the @media dark rules are inside the same element (…rgba(96,165,250,1);}}@media … before </style>), and that </style>@media never appears (no bare rules after a style close)
a document with no overrides emits nodata-pathland-tokens element.
Existing set_design_token_* tests keep passing (substring assertions unaffected); document_head_loads_inter_from_the_rsms_cdn still finds the first <style>.
pathland-render-html/status.md — note overrides render inside <style data-pathland-tokens> after the built-in block.
Verification
cargo test -p pathland-render-html
Optional eyeball: cd lib/java/pathland-quarkus-demo && mvn quarkus:dev → SSR HTML has the token <style> in <head>; toggle prefers-color-scheme and confirm re-theme works.
No wire change; render_fragment untouched (it embeds into a document that already defines the token variables). Ready to implement on approval.