Repository navigation
feat(themes): resolve built-in palettes from the connected Gateway - #2301
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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR resolves built-in theme palettes from the connected Gateway, caches them, and retains the bundled palettes as fallback. Example: Manuscript light theme with Gateway 2026.11.5-beta.4.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR adds useful behavior absent from current main, with sufficient live proof and no actionable introduced defects found. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe theme resolver reads CSS through the existing operator client's HTTP transport and supplies validated palettes to appearance selection, Settings, and the WinUI theme applicator. flowchart LR
Gateway[Connected Gateway] --> Reader[Bounded CSS reader]
Reader --> Probe[Offscreen WebView2 probe]
Probe --> Resolver[Validated palette resolver]
Cache[Build palette cache] <--> Resolver
Table[Bundled fallback table] --> Resolver
Resolver --> Appearance[Appearance selection]
Appearance --> WinUI[WinUI theme application]
Technical reviewBest possible solution: Retain one runtime palette resolver using the existing operator transport and shared probe, with validated caching and the bundled table as fallback. Do we have a high-confidence way to reproduce the issue? The contributor's live before/after evidence demonstrates palette drift on the preceding theme-stack layer; current main does not yet offer this feature, and this review executed no target code. Is this the best way to solve the issue? Palette drift is the problem, preserving fallback and saved selections is the invariant, and extending the existing theme source with a shared CSS probe is a coherent complete solution whose added owners serve distinct boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c38dbcc53e7d. 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. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel 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 18, 2026, 6:46 PM ET / 23:46 UTC (Revision 4). |
ac1ad87 to
539aa55
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
539aa55 to
3c4caca
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
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.
3c4caca to
601932d
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…06-themes-11-runtime # Conflicts: # src/OpenClaw.Tray.WinUI/Presentation/SettingsPageViewModel.cs # src/OpenClaw.Tray.WinUI/Theming/GatewayThemeCatalog.cs
…reads cookie-free A WebView2 call that ignores cancellation, or a UI thread that never runs the probe, no longer holds a connection's resolution open: the resolver and probe both bound their waits to the resolution deadline, a controller created after the deadline is closed with its window, and the connection falls back to the bundled table and retries on the next connection. The shared Gateway media HttpClient now sets UseCookies=false so Control UI reads carry no cookie state. The recordings README states that the zips are frozen captures of real builds, not live Gateway proof. Co-authored-by: Copilot App <[email protected]>
…andoned probe calls Review follow-ups for the probe deadline: the controller creation call is no longer cancelled by the token, so a controller the runtime still creates after the deadline reaches the closer; abandoned ExecuteScriptAsync calls have their faults observed; the hung-probe test uses a larger budget and also asserts the reconnect publishes exactly once. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…palettes Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Related: the Companion themes stack, layers 1 to 10: #2291, #2292, #2293, #2294, #2295, #2296, #2297, #2298, #2299, #2300.
This is part 11 of 11 in the Companion themes stack, opened as a native GitHub stack: each PR is based on the layer below it, so this diff is only this layer's commit,
601932d6 feat(themes): resolve built-in palettes from the connected Gateway. It depends on the table-sync layer #2300 (paulcam206-themes-10-sync).This commit is
2e98953arebased onto main1af25869, andgit range-diffshows the same patch. Evidence and validation below name the heads they ran on; in this stack2e98953ais now3c4cacaeand783b9ed7is now3f14cc1f.Rebased again onto main
30cfe593, which includes #2307 and #2308: this commit is now601932d6(was3c4cacae), andgit range-diffshows the same patch. Evidence below that names3c4cacaeor an earlier head ran on this same patch.Themes architecture
Layer 11 of 11 in the Companion themes stack. This layer resolves built-in palettes from the connected Gateway's own stylesheets in an offscreen WebView2 probe, caches the result per Gateway build, and falls back to the bundled table. The nodes this pull request adds are highlighted below. For the full write-up, with code links, see OpenClaw Windows Companion: theme architecture.
flowchart TD subgraph src["Sources"] GW["Gateway"] UI["Settings page"] WIN["Windows settings"] SYNC["Daily table sync"] TBL["Built-in table"] FNT["Bundled fonts"] ARTA["Artwork images"] end subgraph proc["Processing"] CAT["Theme catalog"] FOL["Follower"] RES["Palette resolver"] PRB["WebView2 probe"] CCH["Palette cache"] MOD["Theme model"] SET["Appearance setting"] SEL["Theme selection"] ACC["Accent overlay"] end subgraph app["Application"] APL["Theme applicator"] PRJ["WinUI brushes"] RAD["Corner radii"] BKP["Mica backdrop"] ART["Chat artwork"] BUB["Lobster bubble"] BRD["Branding"] end GW -->|catalog and prefs| CAT GW -->|Control UI CSS| RES SYNC -->|regenerates| TBL TBL -->|fallback| RES RES --> PRB PRB --> CCH CCH -->|reuse| RES CAT -->|built-in names| RES CAT -->|plugin themes| MOD CAT -->|dashboard choice| FOL FOL -->|followed values| SET UI -->|manual choice| SET MOD --> SEL RES -->|built-in palettes| SEL SET --> SEL SEL --> ACC ACC --> APL WIN --> APL WIN --> BKP FNT --> PRJ APL --> PRJ APL --> RAD APL --> BKP APL --> BRD APL --> ART ARTA --> ART BKP --> BUB classDef layer fill:#ffd866,stroke:#7a5200,stroke-width:3px,color:#000000 class RES,PRB,CCH layerWhat 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
30cfe593(fix: match inline code chips to the chat theme #2307), on this commit, the new stack top601932d6:./build.ps1succeeded;dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 6016 passed, 0 failed, 29 skipped (existing opt-in integration skips);dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 6807 passed, 0 failed;dotnet test ./tests/OpenClaw.Tray.UITests/OpenClaw.Tray.UITests.csproj -r win-x64 --filter "FullyQualifiedName~GatewayTheme|FullyQualifiedName~GatewayBuiltinThemeProbe|FullyQualifiedName~DesktopCompanionWindowTests.OpenBubble|FullyQualifiedName~ReactorMarkdownWebParity|FullyQualifiedName~ReactorToolActivityProofTests|FullyQualifiedName~WorkAlignment": 63 passed, 0 failed.1af25869, on the new stack top3c4cacae, which contains this commit:./build.ps1succeeded;dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 6012 passed, 0 failed, 29 skipped (existing opt-in integration skips);dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 6801 passed, 0 failed;dotnet test ./tests/OpenClaw.Tray.UITests -r win-x64 --filter "FullyQualifiedName~GatewayTheme|FullyQualifiedName~GatewayBuiltinThemeProbe|FullyQualifiedName~DesktopCompanionWindowTests.OpenBubble|FullyQualifiedName~ReactorMarkdownWebParity"(developer machine, Windows dark mode): 33 passed, 0 failed.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