Repository navigation
feat(themes): resolve built-in palettes from the connected Gateway - #2264
paulcam206 wants to merge 11 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
c4f7cf6 to
6cdd173
Compare
|
Codex review: ready, awaiting a maintainer decision. What this changesThis PR adds Gateway themes to Companion and resolves built-in palettes from the connected Gateway, retaining bundled palettes as fallback. Example: Manuscript light against Gateway 2026.11.5-beta.4.
Review scores
ProductKind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⏳ Ready, awaiting maintainer decision Keep this PR open: it adds distinct functionality absent from main, but adopting internal Gateway CSS as a runtime dependency still needs an owner decision. Priority: P3 Decision needed
Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe operator client reads Gateway stylesheets, an isolated WebView2 resolves their tokens, and the existing appearance path applies validated palettes to native windows with a persistent cache and bundled fallback. flowchart LR
Gateway[Connected Gateway] --> Reader[Bounded stylesheet reader]
Reader --> Probe[Isolated WebView2 probe]
Probe --> Resolver[Validated theme resolver]
Cache[Palette cache] --> Resolver
Bundle[Bundled palettes] --> Resolver
Resolver --> UI[Native Companion appearance]
Technical reviewBest possible solution: Use an owner-approved palette source through the existing appearance resolver while preserving bundled fallback and saved preferences. Do we have a high-confidence way to reproduce the issue? This is new functionality; supplied current-head screenshots and logs demonstrate the bundled-versus-connected palette difference without a reviewer-run reproduction. Is this the best way to solve the issue? The shared probe, validated source seam, cache, and retained fallback form a coherent implementation; the remaining question is whether internal CSS is an acceptable product dependency. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a0a2a24ec1dd. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed November 17, 2026, 6:25 AM ET / 11:25 UTC (Revision 4). |
Add the shared theme model the Companion's appearance will build on: CSS Color 4 parsing, resolved light and dark palettes in the Control UI's vocabulary (including the surfaces it derives in CSS: sidebar mix, shell, 78% composer fill and accent-subtle user bubble), the Gateway's themes.list/themes.get wire shapes and definition limits, plugin palette expansion, a 3:1 legibility floor, and a persisted, tolerant appearance setting. Built-in palettes come from a table generated by scripts/Update-GatewayThemeTable.ps1, which resolves the Control UI cascade in headless Edge at a pinned openclaw/openclaw ref (here the packaged Gateway 2026.11.1, 4ffdd204). Nothing applies a theme yet.
General settings gains a Gateway theme picker with the built-in OpenClaw dashboard themes. AppThemeApplicator recolors the bound Fluent, App and chat brushes in the light and dark dictionaries from the theme's palette, including the surfaces the dashboard derives in CSS (sidebar mix, opaque shell, 78% composer, accent-subtle user bubble), and moves accent-driven visuals (navigation indicator, working claw, voice) onto the theme's accent ramp. The theme's typefaces are bundled (OFL, google/fonts) and reach all text through ContentControlThemeFontFamily and a re-declared type ramp. A themed window paints the theme's opaque canvas over its own backdrop, as the dashboard does, and clearing the theme restores every recolored brush. High Contrast dictionaries are never touched, so High Contrast always wins. A caught layout cycle now logs the active theme, focus and open popups.
General settings gains a "Mica backdrop" toggle. It governs the Windows default look only: on shows the window's own Mica, off paints the opaque Fluent canvas over it. Gateway themes stay opaque either way, as the dashboard is, and High Contrast keeps the system backdrop. The change applies to every open window and dialog live by painting the window root, never by swapping backdrops (which faults inside WinUI across a theme refresh), and each window logs its backdrop mode.
While connected, the theme picker also offers the Gateway's plugin and imported themes (themes.list and themes.get, operator.read, Gateway 2026.9+), re-read on plugins.changed and users.prefs.changed. A chosen Gateway theme is saved as a validated definition snapshot, so it still renders offline; themes below a 3:1 text contrast are neither offered nor applied. A new "Follow Gateway theme" setting (off by default) shows the theme selected in the dashboard and updates live; a theme the Companion can't render keeps the last followed one, then the manual choice. The Companion never calls themes.set or writes preferences. The fixture Gateway gains a themes scenario for tests and proof.
6cdd173 to
381a401
Compare
381a401 to
35129ec
Compare
The generator now resolves each built-in's radius-sm, radius-md and corner scale, reading the circular geometry WinUI draws (Edge's 1.25 squircle compensation is neutralized; CRT's own 0.25 still wins). Controls take the small and medium radii (ControlCornerRadius, OverlayCornerRadius) from the theme in effect at startup and keep them for the session. WinUI resolves a control style's radius when the first control of that type is created, so a later change would reshape some control types and not others. Chat surfaces scale their radii by the theme's corner scale and follow every switch, including mounted messages that do not render again. Windows default and High Contrast keep Fluent's geometry.
While following the Gateway theme, the Companion reads the person's saved dashboard accent (users.prefs.get ui.accent, operator.read) with themes.list and re-reads it on users.prefs.changed. A hex accent is drawn over the theme's accent tokens exactly as the Control UI's applyControlUiAccent does, so the user bubble takes the same 16% wash. "theme" or unset uses the theme's own accent; an unknown read (no durable profile, older Gateway, failure) keeps the last followed accent, which is persisted for offline starts. Nothing is written back.
Bundle the Control UI's light and dark artwork for each built-in theme (and its neutral pair for plugin and imported themes), re-encoded as PNG from the pinned release's lossless WebP by scripts/Update-ThemeBackgrounds.ps1. Chat draws it behind the new-chat surface and conversations with the dashboard's ui.background model: faded or full-bleed, visibility and the two placement toggles. While following, the person's dashboard choice is read with users.prefs.get and followed live; otherwise Settings offers the Companion's own style and strength. Windows default, High Contrast and transparency effects off show no artwork. A custom dashboard image is not fetched yet.
35129ec to
89e67bf
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
89e67bf to
a870f2a
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The desktop lobster's notification and quick-chat bubble lives in a windowed popup that neither AppThemeApplicator nor BackdropPolicy reached. Its translucent Fluent fill, which the theme projection skips, stayed grey under every theme. PopoverSurfacePolicy chooses the bubble's backdrop, fill and stroke through ThemeBackdropPolicy, like Mica windows: a Gateway theme paints the dashboard toast's opaque --popover and --border with the acrylic removed, Windows default keeps Fluent's acrylic with the Mica setting on and its opaque flyout fill with it off, and High Contrast keeps Fluent's resources. DesktopCompanionWindow re-applies it on BackdropPolicy.Configured and when the bubble's light/dark mode changes, without replaying the entrance. The stock DesktopAcrylicBackdrop on a popup follows the application theme (the Windows app mode), so a dark Companion on light Windows drew white text on white acrylic. PopoverAcrylicBackdrop drives a DesktopAcrylicController with the bubble's own theme. A source-text test that grepped for the stock backdrop is replaced by behavioral UI tests.
The Hub follows the applied theme's working indicator and brand icon, resolved like upstream resolveThemeBranding: the snappy claw, a dots indicator in the theme accent, a pulsing brand mark, or no glyph (the run status words stay visible). In-app brand spots (dialog headers, the tray menu header) show the claw or the theme's mark; plugin artwork brand icons fall back to the mark. The generator carries the built-in branding fields, failing on unknown values. Windows default keeps the claw everywhere; window, taskbar, tray and package icons stay the OpenClaw identity. High Contrast only changes colors.
…ateway release A daily workflow reads the openclaw commit that the latest stable openclaw-windows-packaging release ships from its verified payload, regenerates BuiltinGatewayThemes.g.cs when it moved, runs the theme tests (including the bundled-font check) and opens or updates one pull request from automation/gateway-theme-sync with a GitHub App token. Resolution lives in scripts/GatewayThemeUpstream.psm1 with offline tests in CI; the built-in table test now checks invariants instead of a pinned theme list so new upstream themes can sync.
The Companion's built-in Gateway themes came only from the bundled table, so a Gateway older or newer than the pinned release showed palettes its own dashboard does not. The Companion now reads the stylesheets the connected Gateway's Control UI serves, resolves them with the same probe the table generator uses (ThemeProbe.js) in an offscreen WebView2, and applies them, with names and branding from the Gateway's themes.list descriptors. The bundled table stays the fallback: a disabled Control UI, a missing WebView2 runtime, a timeout or an invalid result keeps it, and ids neither source styles keep the Windows default look. Results are cached per Gateway build, so reconnecting and starting offline need no probe. Tests compare the probe with what real 2026.9.7, 2026.11.4 and 2026.11.5-beta.4 dashboards computed, recorded by scripts/Record-ControlUiThemeFixture.ps1.
a870f2a to
2e98953
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Superseded by # in native stack #2302. |
Related: the Companion themes stack, layers 1 to 10: #2255, #2256, #2257, #2258, #2266, #2267, #2268, #2270, #2271, #2272 (it supersedes the closed #2218, #2219 and #2220).
This is the runtime-resolution layer on top of the 10-part Companion themes stack. Like the stack's other drafts it targets
mainand carries the commits below it; review only this PR's own commit,2e98953a feat(themes): resolve built-in palettes from the connected Gateway. It depends on thepaulcam206-themes-10-synclayer, #2272 (783b9ed7, the built-in table sync).What Problem This Solves
Fixes: built-in Gateway themes show the Companion's bundled palettes instead of the connected Gateway's when that Gateway is older or newer than the release the bundled table was generated from.
User Impact
User impact: with a built-in theme selected (or followed), the Companion now paints the same colors, fonts and radii as the connected Gateway's own dashboard, including Gateways released after this Companion build. When the Gateway's palettes cannot be read, it keeps the bundled table exactly as before. Existing settings, pairing and device identity carry over from the released Companion unchanged.
Why This Change Was Made
Built-in palettes are a
color-mix()cascade in the Control UI's CSS, so only a CSS engine can resolve them. The table generator already resolves them with a probe in headless Edge; that probe is now one shared file (ThemeProbe.js) that both the generator and the Companion run.On each operator connection the Companion reads the Control UI's
index.html, the stylesheets it links andthemes/<id>.cssover the existing Gateway HTTP base (no credentials, no redirects, mount-confined, size and time bounded), runs the probe in an offscreen in-private WebView2 that answers every other request with 404, validates the result, and caches it per Gateway build id. Names and branding come from the Gateway'sthemes.listbuilt-in descriptors when it sends them, and the Settings picker lists the Gateway's built-ins by those names.Fallback order: Gateway palettes, then the bundled table, then the Windows default for an id neither styles. A disabled Control UI, missing WebView2, timeout or invalid result keeps the table; a theme whose own stylesheet did not load keeps the table and is retried on the next connection; only the newest connection publishes; reconnecting to the same build or starting offline reuses the cache without a probe, and the startup theme (which fixes control geometry for the session) already comes from it. The cache is optional: malformed or stale content only costs a fresh probe. The table and the daily sync workflow stay as the fallback; the fonts stay bundled.
Evidence
Before/after on a Crabbox Hyper-V guest against a real npm Gateway
[email protected](whose built-in surfaces were retuned after the table's pinned release), Manuscript, light mode, chat home:Left:
783b9ed7(the layer below), bundled table. Right:2e98953a(this PR), the Gateway's palettes.Window canvas pixel: before
#f6f1e5(table), after#edece7(the beta.4 dashboard paints#edece6). App log after:[Themes] Built-in palettes from the Gateway (11 themes, resolved, build 2026.11.5-beta.4-release-2c173a37a48f-…).Upgrade from the latest stable release: a profile created and paired by the released Companion v2026.11.3 (portable zip, SHA-256 verified against the release digest, the same artifact CI's released-profile check uses) was opened by this PR's build. Settings, gateway record, device id and device token were preserved with no new pairing request. A Gateway theme was then chosen in Settings and kept across a restart. The App theme was Dark on a light-mode Windows guest:
settings.jsonwritten by v2026.11.3, compared with the same file after the upgrade, theme choice and restart. The only change is the added appearance block:Recorded-dashboard tests:
scripts/Record-ControlUiThemeFixture.ps1recorded what real 2026.9.7, 2026.11.4 and 2026.11.5-beta.4 Gateways served and what their own dashboards computed (headless Edge, each theme selected through the dashboard's saved settings, probed in place). The real WebView2 probe reproduces every token of 2026.11.4 and 2026.9.7 exactly (11 themes × 2 modes × 33 tokens, plus painted canvas). For beta.4 one token differs by one step (dashlight inline code): the dashboard's page-load link order lets an equal-specificity core rule beatdash.css, while a live theme switch letsdash.csswin; the probe, like the generator, follows the theme file. The test names that single known difference.Change Type
Scope
winnodeRequired proof pools
windows-winui-interactive: built-in theme colors applied to WinUI windows now come from the connected Gateway.Validation
All on
2e98953a:./build.ps1: all builds succeeded (Shared, Cli, WinNodeCli, SetupEngine, WinUI); documentation validation passed.dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 6004 passed, 29 skipped, 0 faileddotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 6801 passed, 0 faileddotnet test ./tests/OpenClaw.Tray.UITests -c Debug -r win-x64 --filter FullyQualifiedName~GatewayBuiltinThemeProbeTests: 4 passed (real WebView2 probe vs the three recorded dashboards, plus a newly added built-in and an unstyled id).scripts/Update-GatewayThemeTable.ps1 -UpstreamRef 4ffdd2047d192dd65554de3c8c46c0e0197c6e2awith the shared probe: output byte-identical to the committedBuiltinGatewayThemes.g.cs.New focused coverage:
ServedGatewayThemeTests: index parsing of real served shapes; stylesheet reading; build-id and content-hash keys; probe validation that rejects path/URL font stacks, translucent window surfaces and out-of-range radii; descriptor branding; cache LRU, invalidation, corruption, malformed entries and repeated ids; and the Control UI HTTP read with no credentials, no redirects, type and size limits, and mount-confined paths.GatewayBuiltinThemeResolverTests:GatewayFixtureProtocolTests.ControlUiReads_AreRefusedLikeADisabledControlUi_WithoutCountingAsUnexpected: the fixture Gateway answers the client's real Control UI reads with 404, like a Gateway with its Control UI disabled, while any other plain HTTP stays a rejected upgrade.GatewayThemeSettingsTests: the picker lists the Gateway's built-ins by its names and reselects a saved Gateway-only built-in once its palettes arrive.Real Behavior Proof
cbx_7bab69bddc8d, Windows 11 Insider 29683 primed template with the VC++ x64 14.52 redistributable (DiskIdentifier5D83D17D), Windows in light mode. Isolated Companion profiles connected to real npm Gateways on loopback with token auth ([email protected],[email protected], and beta.4 withgateway.controlUi.enabled=false); each Companion device was approved with the Gateway's ownopenclaw devices approve. Earlier rounds on leasescbx_29742a00d1cf,cbx_9b585c653bdb,cbx_76a02555eb44andcbx_bf1de6ac7b38(same template) andcbx_4dc657ba6dc6(clean template) showed the same results on previous heads.2e98953a(after, this PR's head),783b9ed7(before, the layer below) and released Companion v2026.11.3 (upgrade source).Appearance.Theme = {Id: manuscript|tide, Source: builtin}andUseMica: false; launched each build; navigated with local MCPapp.navigateto Settings and chat; captured the window and sampled pixels. For the upgrade, v2026.11.3 paired and changed settings through MCPapp.settings.set, then this build opened the same profile, Manuscript was chosen through the Settings picker (UI Automation), and the app was restarted.#f6f1e5, after#edece7; logBuilt-in palettes from the Gateway (11 themes, resolved, build 2026.11.5-beta.4-…); cache written.Backdrop WorkspaceWindow: Opaque ... root #FFEDECE7), so the startup theme and its control geometry come from the cache.#f6f1e5), so nothing changes where the Gateway matches the table.#14191fand content#10151b(beta.4) instead of the table's#10161c.Built-in palettes from the bundled table: the Gateway does not serve its Control UI here.; table pixels.#211e18.Yes/No/N/A): Yes. Both images are attached to this description and were read back after upload.Security Impact
Yes/No): NoYes/No): NoYes/No): YesYes/No): NoYes/No): NoYes, explain the risk and mitigation: the Companion now GETs the connected Gateway's own unauthenticated Control UI files (index.html, linkedassets/*.css,themes/<id>.css) over the HTTP base it already uses for media. Requests carry no credentials, never follow redirects, stay under the Gateway's mount (no..,//, scheme, query or off-origin paths), require the expected media type and are size and time bounded. The CSS is only evaluated in an offscreen in-private WebView2 whose every other request returns 404, so it cannot reach the network or run Gateway script. Resolved values are validated: colors must be hex and window surfaces opaque, font stacks must be plain family names (paths and URLs are rejected so a Gateway cannot make WinUI load a UNC font), radii are bounded.Compatibility and Migration
Yes/No): YesYes/No): YesYes/No): NoAppearanceblock shown above. The palette cache is a new, versioned, disposable file under the local data directory. OptionalOPENCLAW_CONTROL_UI_ASSET_TIMEOUT_MS(per file, default 15000) andOPENCLAW_THEME_RESOLVE_TIMEOUT_MS(whole resolution, default 30000). Gateways with the Control UI disabled or serving an unexpected layout keep the bundled table.Review Conversations