Repository navigation
fix(e2e): DevtoolsUx toggle tests — one-shot fixture reset - #85
Merged
Chris Anderson (codemonkeychris) merged 1 commit intoApr 24, 2026
Merged
Conversation
DevtoolsUxFixtures.DevtoolsUxTest was setting DebugUI.Value = false on every invocation. Reactor re-renders from the root on any reactive change, which re-runs the fixture factory — so the moment a toggle click notified subscribers, the factory clobbered the new value before the component could render it. The mirrored TextBlock stayed at "debug-off" and WaitForText timed out. Moved the reset inside DevtoolsUxTestComponent.Render, gated by a UseRef so it fires once per mount, synchronously before UseObservable reads the value. UseEffect isn't suitable here: effects flush after Render has already captured `debugUI`, so the initial remount would still reflect whatever state the previous test left behind. Both toggle tests now use NavigateToFixtureFresh — the plain form is a no-op when the fixture is already loaded (static _currentFixture check), which skips the Component remount and leaves prior-test state in place. Also keeps the WaitForText last-seen-text diagnostic in AppTestBase added during the broader E2E investigation — pure ergonomic improvement that was invaluable for diagnosing this. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Chris Anderson (codemonkeychris)
deleted the
fix/devtoolsux-e2e-toggle-reset
branch
May 28, 2026 19:11
This was referenced Jun 25, 2026
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Jun 25, 2026
H1 (#85): validate the per-element effective-theme-name cache against the element's own RequestedTheme/ActualTheme DPs, not only the global generation stamp, so a subtree-local RequestedTheme override the reconciler applies without a generation bump is no longer served a stale cached name. H2 (#86): drop the ThemeRef resolution caches on accent/system-palette changes that keep the same Light/Dark theme (which do not raise ActualThemeChanged). Both ReactorHost and ReactorHostControl now subscribe a dedicated always-on UISettings.ColorValuesChanged at root mount and unsubscribe it in Dispose; the handler calls ThemeRef.InvalidateCache() + RequestRender() (both thread-safe). Independent of the chart-gated UISettings so it works in apps that never activate charting. Tests: - ThemeRefCacheFixtures (selftest): resolve/cache-hit/invalidate, per-element RequestedTheme flip both directions (H1 guard), stale-until-invalidate then fresh-after-invalidate (#86 guard). - ListViewHandlerSelectionFixtures (selftest): typed multi-selection snapshot for ListView + GridView (#100), IsItemClickEnabled tracking across record cycles (partial H4 — full no-duplicate-fire needs real pointer input / E2E). - AnimationAmbientTests: two HasAny one-way-latch unit tests (#183 gate). Behaviour preserved: theme resolution returns identical brushes and still updates on theme/palette change; no new reflection (AOT/trim clean). Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Jun 25, 2026
Second pr-review round on PR #667. Addresses the theme-resolution findings: H1 (correctness): the #85 effective-theme-name cache was generation-validated plus the element's own RequestedTheme/ActualTheme DP reads, so a Default-themed descendant of an ancestor whose RequestedTheme flips could serve a stale theme inside the synchronous reconcile (before WinUI propagates the child's ActualTheme). Make the name cache reconcile-scoped instead: the host bumps a _reconcilePass once per Render() (ThemeRef.BeginReconcilePass), so every element re-walks its ancestors at most once per render -- collapsing the dozens of per-token walks (the #85 win) while matching the original always-walk result exactly. This is the brief's 'resolve once per reconcile at the container' option. M1 (correctness): ResolveForTheme now captures the theme generation before the uncached scan and only publishes the resolved brush when no InvalidateCache() (e.g. from UISettings.ColorValuesChanged on a pool thread) raced it -- closing a window where a pre-invalidation brush could be republished into the just-cleared cache. _themeGeneration is kept solely for this guard; the per-render bump uses the separate _reconcilePass. Tests (additive, in-scope): - ThemeRefCache_AncestorThemeFlipInheritedByDefaultChild selftest -- H1 regression guard (ancestor flip + new pass re-resolves a Default child). - ThemeRefCache_DefaultDictionaryFallback selftest -- #86 Default-dict fallback. - ListView/GridView MultiSelection fixtures -- assert the typed copy preserves SelectedItems order and surfaces an empty snapshot on clear (#100). - ObservableTreeTracker reentrancy test -- a side-effecting getter that fires PropertyChanged mid-walk exercises the _syncing fresh-scratch guard (#5). Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Jun 25, 2026
Copilot round-3 review: AttachThemeListener subscribed ActualThemeChanged on the rendered root and latched _themeListenerAttached, so after a root-element type swap (newControl != _currentControl) the listener stayed stranded on the detached old root. Theme flips then stopped firing InvalidateCache()+RequestRender(), leaving ThemeRef-resolved brushes stale (the #85/#86 caches were never dropped). ReactorHostControl is a ContentControl, so subscribe on the host instance itself (this.ActualThemeChanged) — stable across rendered-root swaps — instead of the swappable root. A single subscription suffices and the latch no longer needs to move it. ReactorHost (not a FrameworkElement) already re-binds correctly via _themeListenerElement, so it is unchanged. Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Jun 29, 2026
…change (#660 #86) ThemeRef.Resolve recursed Application.Resources.MergedDictionaries (XamlControlsResources and its nested dictionaries) on every resolve — per cell x per color token x per render on the data-grid workload. Cache the deterministic (resourceKey, themeName) -> Brush result in a process-wide ConcurrentDictionary and clear it from the hosts' theme-change handlers (ActualThemeChanged + UISettings.ColorValuesChanged). Transient-null Application.Resources (early startup) is not cached, so no poisoned null entry. Cached value mirrors the uncached return exactly (including null for unknown keys); ThemeDictionary brushes are shared instances, so returning the cached reference is identical behavior. Self-contained in Theme.cs (no BrushHelper/ThemeBinding/Reconciler coupling). The per-element theme-NAME cache (#85) is intentionally NOT here — it needs a generation bump where a localized RequestedTheme is applied (Reconciler.cs, sibling-owned), which is a cross-ownership change flagged to the coordinator. Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Jun 30, 2026
…omics (#660) Remove per-frame delegate/closure allocations and full-barrier atomics from the render-loop hosts (ReactorHost + ReactorHostControl), which run at render/data-tick frequency on the data-grid stress workload: #178 QueryCache.DispatcherPost: pass action.Invoke, drop the () => action() trampoline #179 cache _rerenderAction instead of () => RequestRender() every render #180 cache _renderLoopHandler (DispatcherQueueHandler) for TryEnqueue #181 cache _requestRenderAction (RequestRender method group) for BeginRender + Reconcile #182 HotReloadService.ConsumeUpdatePending: Volatile.Read fast-path, atomic only when pending #183 AnimationAmbient.HasAny sentinel gates the per-setState AsyncLocal walk #185 _lastRenderMs: Volatile.Write (single writer) instead of Interlocked.Exchange #186 report gate: integer ElapsedMilliseconds compare instead of Elapsed.TotalSeconds #187 remove unconditional [embed:trace] Console.Error writes at window open Behavior preserved: identical render cadence, delegate semantics, and re-render coalescing; HasAny is a one-way sentinel so any app that opens an Animations.Animate transaction keeps the full AsyncLocal path. New AnimationAmbient.HasAny tests. Deferred (flagged to coordinator): theme resolution cache (#85/#86) — #85's per-element theme-name cache needs generation invalidation on localized RequestedTheme application which lives in Reconciler.cs (sibling-owned), so it's a cross-boundary change; and theme resolution can't be measured headlessly. #184 charting dirty-gate (chart-specific, secondary). Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Jun 30, 2026
…change (#660 #86) ThemeRef.Resolve recursed Application.Resources.MergedDictionaries (XamlControlsResources and its nested dictionaries) on every resolve — per cell x per color token x per render on the data-grid workload. Cache the deterministic (resourceKey, themeName) -> Brush result in a process-wide ConcurrentDictionary and clear it from the hosts' theme-change handlers (ActualThemeChanged + UISettings.ColorValuesChanged). Transient-null Application.Resources (early startup) is not cached, so no poisoned null entry. Cached value mirrors the uncached return exactly (including null for unknown keys); ThemeDictionary brushes are shared instances, so returning the cached reference is identical behavior. Self-contained in Theme.cs (no BrushHelper/ThemeBinding/Reconciler coupling). The per-element theme-NAME cache (#85) is intentionally NOT here — it needs a generation bump where a localized RequestedTheme is applied (Reconciler.cs, sibling-owned), which is a cross-ownership change flagged to the coordinator. Co-authored-by: Copilot <[email protected]>
Alexandre Zollinger Chohfi (azchohfi)
added a commit
that referenced
this pull request
Jun 30, 2026
…rame atomics, cache theme-brush resolution (#660) (#751) * perf(render-loop): cache per-frame host delegates + drop per-frame atomics (#660) Remove per-frame delegate/closure allocations and full-barrier atomics from the render-loop hosts (ReactorHost + ReactorHostControl), which run at render/data-tick frequency on the data-grid stress workload: #178 QueryCache.DispatcherPost: pass action.Invoke, drop the () => action() trampoline #179 cache _rerenderAction instead of () => RequestRender() every render #180 cache _renderLoopHandler (DispatcherQueueHandler) for TryEnqueue #181 cache _requestRenderAction (RequestRender method group) for BeginRender + Reconcile #182 HotReloadService.ConsumeUpdatePending: Volatile.Read fast-path, atomic only when pending #183 AnimationAmbient.HasAny sentinel gates the per-setState AsyncLocal walk #185 _lastRenderMs: Volatile.Write (single writer) instead of Interlocked.Exchange #186 report gate: integer ElapsedMilliseconds compare instead of Elapsed.TotalSeconds #187 remove unconditional [embed:trace] Console.Error writes at window open Behavior preserved: identical render cadence, delegate semantics, and re-render coalescing; HasAny is a one-way sentinel so any app that opens an Animations.Animate transaction keeps the full AsyncLocal path. New AnimationAmbient.HasAny tests. Deferred (flagged to coordinator): theme resolution cache (#85/#86) — #85's per-element theme-name cache needs generation invalidation on localized RequestedTheme application which lives in Reconciler.cs (sibling-owned), so it's a cross-boundary change; and theme resolution can't be measured headlessly. #184 charting dirty-gate (chart-specific, secondary). Co-authored-by: Copilot <[email protected]> * perf(theme): cache (key,theme) -> Brush resolution, cleared on theme change (#660 #86) ThemeRef.Resolve recursed Application.Resources.MergedDictionaries (XamlControlsResources and its nested dictionaries) on every resolve — per cell x per color token x per render on the data-grid workload. Cache the deterministic (resourceKey, themeName) -> Brush result in a process-wide ConcurrentDictionary and clear it from the hosts' theme-change handlers (ActualThemeChanged + UISettings.ColorValuesChanged). Transient-null Application.Resources (early startup) is not cached, so no poisoned null entry. Cached value mirrors the uncached return exactly (including null for unknown keys); ThemeDictionary brushes are shared instances, so returning the cached reference is identical behavior. Self-contained in Theme.cs (no BrushHelper/ThemeBinding/Reconciler coupling). The per-element theme-NAME cache (#85) is intentionally NOT here — it needs a generation bump where a localized RequestedTheme is applied (Reconciler.cs, sibling-owned), which is a cross-ownership change flagged to the coordinator. Co-authored-by: Copilot <[email protected]> * fix(theme): complete #86 brush-cache invalidation per #751 review Two correctness hardenings on the (key,theme)->Brush cache: 1. Wire ReactorHostControl to UISettings.ColorValuesChanged (high-contrast / accent / palette) -> InvalidateResolutionCache, mirroring ReactorHost. Before, the embedded host only invalidated on ActualThemeChanged (Light/Dark), so an app using ReactorHostControl without a ReactorApp would keep stale brushes on a same-theme accent/high-contrast change. Subscribe on theme-listener attach, unsubscribe in Dispose. 2. Cache ONLY successful (non-null) resolutions. A cached null for an unknown key would go stale if a ResourceDictionary defining that key is merged in after the first resolve (a dictionary add raises no theme-change event). Unknown keys are rare; re-walking them is the same cost as pre-cache and always correct. Invalidation now covers: Light<->Dark (ActualThemeChanged, both hosts — AND the cache key includes the theme name so a toggle auto-misses) + accent/palette/ high-contrast (ColorValuesChanged, both hosts). Existing theme selftests pass with the cache active, incl. StructuralSkip_ThemeRangeParity (ThemeRange_ForegroundReresolvedOnToggle: resolve brush -> toggle theme -> assert re-resolved) and Issue522_CacheClear_StyleClearedDespiteCacheClear. Full headless suite 9915/0; build 0/0. Co-authored-by: Copilot <[email protected]> * test(theme): regression coverage for #86 brush-cache invalidation (H1/H2) Selftest fixtures pinning the two converged review findings (the code fixes landed in 3fd38c4): - Theme_BrushCacheNullMissNotCached (H2): resolve an unknown key → null (NOT cached) → merge a ResourceDictionary defining it → resolves to the brush. Guards against the cached-null poisoning a later-merged key (XamlIslandBootstrap / docking-embed late XamlControlsResources binding). - Theme_BrushCacheInvalidationReResolves (H1 mechanism): resolve key→brushA (cached) → swap to brushB for the same (key,theme) → still brushA (stale) → ThemeRef.InvalidateResolutionCache() (what the hosts call on ColorValuesChanged/ActualThemeChanged) → re-resolves to brushB. Both green. Validates the invalidation path the ReactorHostControl ColorValuesChanged wiring (3fd38c4) depends on. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DevtoolsUxFixtures.DevtoolsUxTestsetDebugUI.Value = falseon every call. Because Reactor re-renders from the root, each observable notification re-ran the factory and clobbered the toggle before the component could render the new value — soDevtools_Menu_Toggle_Flows_Through_To_SubscribersandDevtools_Menu_Toggle_Is_Reversibleboth timed out waiting fordebug-on/debug-off.DevtoolsUxTestComponent.Render, gated byUseRefso it fires once per mount, synchronously beforeUseObservablereads the value.UseEffectisn't sufficient here: effects flush afterRenderhas already captureddebugUI, so the initial remount would still reflect stale state from the previous test and the subsequent TextBlock update never propagates.NavigateToFixtureFresh—NavigateToFixtureis a no-op when_currentFixturealready matches, which skips the Component remount and leaves the prior test's toggle state in place.AppTestBase.WaitForTextthat includes the last-seen text in the timeout message. This was what made the root cause legible during investigation and is generally useful.Test plan
dotnet test tests/Reactor.AppTests -p:Platform=x64 --filter ClassName=Microsoft.UI.Reactor.AppTests.Tests.DevtoolsUxTests— 3/3 passdotnet test tests/Reactor.AppTests -p:Platform=x64— verified going from 53/57 → 54/57; unrelated failures remain (Interactive_DataGrid_ClickEditTabCommithas a known duplicate-handler bug in the reconciler, and a newly observed flake inGestureTests.Interactive_OnPan_Drag_ReportsTranslationAndPhaseis ordering-sensitive — both are separate investigations)🤖 Generated with Claude Code