Repository navigation
fix(reconciler): resolve ThemeRef overrides against a host-inherited RequestedTheme - #1417
Conversation
…RequestedTheme A RequestedTheme set on a native ancestor of a ReactorHostControl (for example the window root) was invisible to ThemeRef-backed resource overrides: at mount the control is unparented, so resolution fell back to the app theme, and no theme change follows to correct it. ItemsView rows realized during layout had the same problem because they mount outside any root pass. - Seed the reconciler's ambient theme from the host's inherited RequestedTheme for each root pass. - Seed it from the repeater for layout-time row realization. - Force a resource refresh when a host loads under a different inherited theme than it rendered with. Adds Item1Mount_HostInheritedThemeResolvesAtMount (parented, detached-then- parented, and ItemsView row arms). Co-authored-by: Copilot App <[email protected]>
Refresh before arming each root pass when its inherited theme changed; cover detached parenting and live ancestor toggles for nested overrides and realized rows. Regenerate affected guide snippets. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Recycled rows can retain stale theme brushes after an ancestor theme change, and custom error fallbacks can mount with app-theme brushes instead of the inherited theme.
2 open issues
What changed in this PR
This PR extends ancestor-theme resolution across the native host boundary so ThemeRef resource overrides can follow a RequestedTheme set outside the Reactor tree.
Changes:
- Seeds root reconciliation and layout-time row realization with the inherited native theme.
- Requests a skip-bypassing resource refresh when the host’s inherited theme changes.
- Adds live regression coverage and updates generated guide snippets and the changelog.
| File | Description |
|---|---|
| tests/Reactor.AppTests.Host/SelfTest/SelfTestFixtureRegistry.cs | Registers the host-inherited theme fixture. |
| tests/Reactor.AppTests.Host/SelfTest/Fixtures/ResourceOverrideMountThemeFixtures.cs | Tests parented and detached hosts, realized rows, and theme transitions. |
| src/Reactor/Hosting/ReactorHostControl.cs | Seeds root-pass themes and requests refreshes on inherited-theme changes. |
| src/Reactor/Core/Reconciler.cs | Adds native ancestor lookup and scoped realization themes. |
| src/Reactor/Core/ElementFactory.cs | Applies inherited theme context during row realization. |
| docs/guide/reconciliation.md | Updates the generated reconciliation snippet. |
| docs/guide/architecture-overview.md | Updates generated reconciliation and row-realization snippets. |
| CHANGELOG.md | Documents the host-inherited theme fix. |
Review effort: Balanced
Preserve both changelog sections and integrate the latest conditional-slot and templated-container lifecycle changes. Co-authored-by: Copilot App <[email protected]>
Resolve themes from a native host anchor for normal and fallback reconciliation. Refresh stale pooled row subtrees and cover every list/grid/tree realization path. Add red-to-green and mutation-checked regressions. Co-authored-by: Copilot App <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
left a comment
There was a problem hiding this comment.
All four findings are addressed in 146068f. CI is green, and the Item1Mount_ selftests pass locally (50/50). I also broke the ListView and pooled-row fixes on purpose, and each time the matching new check failed. One optional cleanup: the OnLoaded refresh is now redundant, because BeginRootPass already re-arms on HostThemeChanged.
Resolve CHANGELOG.md conflict: keep both Fixed entries. Co-authored-by: Copilot App <[email protected]>
Resolve CHANGELOG.md conflict: keep both Fixed entries. Co-authored-by: Copilot App <[email protected]>
db02633
into
microsoft:main
Resolve conflicts with #1417 (realization theme scope) and #1424 (keyed item views): open the context RealizationFrame before EnterRealizationTheme at every row-realization site, and read the frame's live theme with the same InheritedRequestedTheme rule #1417 uses. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d6963d93-8fc8-4956-8c83-88b394debeee

Summary
ThemeRef-backed resource overrides now inherit a native ancestor's
RequestedThemeacross bothReactorHostControlandReactorHost.ContentTarget, including custom error fallbacks and virtualized rows. Previously, controls mounted before parenting could receive app-theme brushes, and unchanged pooled subtrees could retain brushes from their previous theme.Original repro: a Light app places a host under a native Dark ancestor. Cards using
.Resources(r => r.Set("ButtonBackground", Theme.Ref("CardBackgroundFillColorDefaultBrush")))receive light brushes on a dark page.Both hosts provide a native theme anchor to shared reconciliation. The reconciler seeds normal and fallback root passes from that anchor, bypasses structural skips when the inherited theme changes, and records the theme only after successful reconciliation. Layout-time realization uses its container's theme for ItemsView/ItemsRepeater, typed and untyped ListView/GridView, and typed TreeView. Pooled rows track the applied theme and refresh stale descendants on reuse without consuming a pending host refresh. Generated guide snippets and the changelog are synchronized.
Linked issue / spec
Follow-up to #771 (ancestor-themed resource overrides inside the Reactor tree); extends the fix across native host boundaries. No separate issue. Merged
mainat16062a12, preserving both changelog sections and the new container-lifecycle changes.Test plan
Realization_DoesNotConsumeAnArmedHostRefreshto protect root-refresh ownership.146068f6: 40 checks passed, 2 intentional path-filter skips. CI run 40630366226 passed full Release build, units, selftests, MSIX, E2E, both AOT shards, trim proofs, Docs build and snippet analyzer gate. Coverage, packaging, bootstrap, Node projects and build metrics also passed. Audit ledger and Docs tier-drift were intentionally skipped.Local ARM64 commands and results:
dotnet build tests\Reactor.AppTests.Host --no-restore -c Release -p:Platform=ARM64 -p:SkipSignaturesGen=true -p:UseSharedCompilation=false -m:1 -nodereuse:false -v:minimaldotnet test tests\Reactor.Tests -p:Platform=ARM64 -p:SkipSignaturesGen=true -p:UseSharedCompilation=falsedotnet run --project tests\Reactor.AppTests.Host --no-build -c Release -p:Platform=ARM64 -- --self-test --filter Item1Mountdotnet run --project tests\Reactor.AppTests.Host --no-build -c Release -p:Platform=ARM64 -- --self-test --filter ItemsViewdotnet run --project tests\Reactor.AppTests.Host --no-build -c Release -p:Platform=ARM64 -- --self-test --filter Lazydotnet run --project tests\Reactor.AppTests.Host --no-build -c Release -p:Platform=ARM64 -- --self-test --filter Themedotnet run --project tests\Reactor.AppTests.Host --no-build -c Release -p:Platform=ARM64 -- --self-test --filter EFR_dotnet run --project tests\Reactor.AppTests.Host --no-build -c Release -p:Platform=ARM64 -- --self-test --filter RenderErrorHandlerdotnet run --project tests\Reactor.AppTests.Host --no-build -c Release -p:Platform=ARM64 -- --self-test --filter TTV_dotnet run --project tests\Reactor.AppTests.Host --no-build -c Release -p:Platform=ARM64 -- --self-test --filter TemplatedListdotnet run --project tools\Reactor.DocPipeline --no-build -- compile --topic architecture-overview --no-screenshots --no-builddotnet run --project tools\Reactor.DocPipeline --no-build -- compile --topic reconciliation --no-screenshots --no-buildLocal caveats: the first grouped ItemsView run exceeded the parking fixture's 30-second budget, and the first TemplatedList run observed one unlinked row. Both failed fixtures passed in isolation and both complete grouped reruns passed; current-head CI's full suites also passed. No timeouts, assertions, warnings or CI gates were weakened. A stalled local build was stopped and retried without shared compilation. Full-solution Release was not repeated locally in this pass: the earlier local attempt encountered sample SDK extraction/MAX_PATH/apphost errors; the current-head full Release result is from CI. Packaged, E2E and AOT results are also CI runs, not local claims.
The original author reported verifying the initial fix in the downstream native dashboards app after a local
v0.1.0-preview.12port; that downstream check was not repeated for this revision.Risk / breaking changes
No new public API. Explicit element theme modifiers retain precedence over inherited themes. Returning an ancestor to
Defaultrefreshes affected overrides. Host-theme changes and stale pooled reuse intentionally bypass structural skips; normal same-theme reuse retains the skip path. Native ancestor walks occur at root reconciliation and out-of-pass realization. No broader performance benchmark was run.