Skip to content

Replace .Set escape hatches with real modifiers; drop legacy MDL2 icon font - #930

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 8 commits into
mainfrom
azchohfi-congenial-journey
Jul 29, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 8 commits into
mainfrom
azchohfi-congenial-journey

Conversation

@azchohfi

@azchohfi Alexandre Zollinger Chohfi (azchohfi) commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

.Set(x => x.Prop = ...) was being used in ~90 places across the samples and the shipped agent-kit docs for properties that already have first-class modifiers. That is the wrong tool for those properties, for three concrete reasons:

  • It bypasses the property diff and is never unwound. The modifier path calls ClearValue(<DP>Property) when a value is removed. WinUI.Button is poolable and ElementPool's reset clears neither FontFamily nor FontSize, so an imperative write can ride onto a recycled control.
  • It forces every element carrying setters onto the update path. Element.SettersEqual returns true only for the same array instance or both-empty, whereas modifiers are compared structurally, so an unchanged value costs nothing.
  • new FontFamily(...) crosses the managed to WinRT boundary on every render. WinRTCache.GetFontFamily exists precisely to avoid this.

While in here, the legacy "Segoe MDL2 Assets" (Windows 10) icon font is replaced with "Segoe Fluent Icons, Segoe MDL2 Assets", matching the fallback chain the reconciler already used for the TabView pin button.

Stacked: #932 builds on this branch. It wires the Reactor analyzers over the sample tree and adds a rule for this exact anti-pattern, so future .Set regressions are caught at build time instead of by hand. Review this PR first.

Approach

Core library is a small, surgical change: route the last raw new FontFamily(...) allocations through WinRTCache, and add an internal IconResolver.SymbolFontFallback constant. The FontIcon / FontIconSource fallbacks previously hardcoded a bare "Segoe Fluent Icons" with no Windows 10 tail, so they now share the same stack.

Samples migrate every .Set whose property has a modifier: FontFamily, FontSize, FontWeight, TextWrapping, TextTrimming, MaxLines, FontStyle, IsTextSelectionEnabled, AcceptsReturn, Padding, CornerRadius, MinWidth/MinHeight, Height, BorderThickness, Background, RequestedTheme, Scale, Translation, Style, Header, PlaceholderText, CharacterCasing, PasswordRevealMode, SelectionMode, Orientation, and the content-alignment pair. .Set is deliberately retained wherever no modifier exists (Shape geometry, IsHitTestVisible, Row/ColumnSpacing, HorizontalScrollBarVisibility, SplitView.DisplayMode, RadioButtons.Header).

The most important finding: a modifier can compile and still do nothing

ApplyModifiers gates several modifiers on the runtime control type — Padding reaches only Control/Border/StackPanel, and BorderBrush/BorderThickness/CornerRadius only Control/Border. A Grid is a Panel, not a Control, and a TextBlock is neither.

Two of my own conversions were therefore silently broken: ValueList.cs's header lost both its padding and its bottom divider, and the minesweeper glyph's .Padding(0) was dead. Both are reverted to .Set with the constraint documented at the call site. This is the general trap for the whole migration, and it is what #932's new rule encodes so the next person gets a build-time diagnostic instead of a silent visual regression.

Three real bugs fixed along the way

  • reactor-ide terminal double-subscribe. Two tool windows had tb.KeyDown += ... inside a .Set lambda. Since setters re-run on update, Enter fired the command once per elapsed render. Replaced with .OnKeyDown(...), which the reconciler subscribes once.
  • Agent-kit pack gaps. skills/design-docs/*.md was never in the pack list — the skills\*.md glob is non-recursive — so the guidance files this PR edits would not have shipped in the NuGet at all. The same audit found plugins/reactor/skills/reactor-advanced and reactor-docking have never shipped. Both pre-existing; this PR is the first change to depend on the former.
  • Stale context menu on a pooled control. SessionListItem attached its ContextFlyout through .Set, which is never unwound, and ElementPool.CleanElement resets Flyout but not ContextFlyout — so a recycled Button could inherit it. Now uses the existing .WithContextFlyout(MenuItems(...)).

Worth a careful look

  • ApplyStyle is mount-only. ModalOverlay originally converted .Set(btn => btn.Style = ...) to .ApplyStyle(...), which is not semantics-preserving: Reconciler gates OnMountAction on oldM is null, so it applies once instead of every update. It now uses the existing .AccentButton() fluent, and the caveat is documented on ApplyStyle/AccentButton/SubtleButton/TextLink themselves, since IntelliSense never shows a sample comment.
  • Glyph coverage was the highest-risk claim here and was independently verified: every converted codepoint exists in Segoe Fluent Icons, and the comma-separated FontFamily value is a genuine fallback sequence.
  • Generated docs. advanced, context and modifier-system were teaching .Set for properties that now have modifiers. I edited the pipeline sources and ran mur docs compile on those three topics, then reverted the unrelated screenshot churn the compile produced.

Linked issue / spec

N/A

Test plan

  • dotnet build Reactor.slnx — 0 warnings, 0 errors
  • dotnet test tests/Reactor.Tests — 12468 passed, 0 failed
  • Full selftest suite — 1316 checks, 0 failures
  • Added 2 selftest checks in ReconcilerBigCoverageFixtures.PrivateMountHotPaths covering the changed fallback font stack, which previously had no oracle at all
  • Mutation-verified those assertions: reverting SymbolFontFallback to "Segoe Fluent Icons" fails PrivMount_SymbolFontFallbackStack
  • Regenerated samples/ReactorGallery/reactor-search-index.json (SearchIndexGeneratorTests.Index_IsUpToDate gate passes)
  • Ran the repo's pr-review skill across all 8 dimensions twice, including the multi-model cross-check, and addressed every finding
  • Four rounds of GitHub Copilot review to convergence (zero comments, zero low-confidence suppressed)

Risk / breaking changes

No public API change — the only new symbol is an internal const. The user-visible behavior changes are:

  1. The icon-font fallback for unrecognized symbol strings now carries a Windows 10 tail it previously lacked.
  2. Samples that hardcoded the legacy MDL2 font now prefer Segoe Fluent Icons.

Note one deliberate tension: code-review-checklist.md previously forbade hardcoding icon fonts outright. Since the samples now use an explicit fallback stack, that rule was reworded to prefer SymbolThemeFontFamily where a live Application.Current exists while allowing the explicit stack as a static fallback — and the same wording was propagated to design.md, figma.md and reactor-design/SKILL.md so the shipped guidance agrees with the shipped samples. Happy to go the other way and route the samples through the theme resource instead if reviewers prefer.

…n font

`.Set(x => x.Prop = ...)` was used in ~90 places across samples and the
skills docs for properties that already have first-class modifiers. It is
the wrong tool for those:

- `.Set` bypasses the property diff and is never unwound. The modifier
  path calls `ClearValue(<DP>Property)` on removal. `WinUI.Button` is
  poolable and its pool reset does not clear FontFamily/FontSize, so an
  imperative write can ride onto a recycled control.
- `Element.SettersEqual` only returns true for the same array instance or
  both-empty, so any element carrying setters is forced onto the Update
  path every render. Modifiers are compared structurally, so an unchanged
  value is free.
- `new FontFamily(...)` crosses the managed->WinRT boundary on every
  render; `WinRTCache.GetFontFamily` exists to avoid exactly this.

Also drop the legacy "Segoe MDL2 Assets" (Windows 10) icon font in favour
of "Segoe Fluent Icons, Segoe MDL2 Assets", matching the fallback chain
the reconciler already used for the TabView pin button.

Core library:
- Route the remaining raw `new FontFamily(...)` allocations in
  Element.Icon.cs, ErrorFallback.cs and Reconciler.Mount.cs through
  WinRTCache.
- Add `IconResolver.SymbolFontFallback` and use it for the FontIcon /
  FontIconSource fallbacks, which previously hardcoded a bare
  "Segoe Fluent Icons" with no Windows 10 tail.
- Retarget the `.Set` doc example on ElementExtensions to a property that
  genuinely has no modifier, so it stops teaching the anti-pattern.

Samples: migrate every `.Set` whose property has a modifier — FontFamily,
FontSize, FontWeight, TextWrapping, TextTrimming, MaxLines, FontStyle,
IsTextSelectionEnabled, AcceptsReturn, Padding, CornerRadius, MinWidth,
MinHeight, Height, BorderThickness, Background, RequestedTheme, Scale,
Translation, Style, Header, PlaceholderText, CharacterCasing,
PasswordRevealMode, SelectionMode, Orientation, HorizontalContentAlignment
and VerticalContentAlignment. `.Set` is kept only where no modifier
exists (Shape geometry, IsHitTestVisible, RowSpacing/ColumnSpacing,
HorizontalScrollBarVisibility, SplitView.DisplayMode, RadioButtons.Header,
InfoBar.IsOpen, MediaPlayer.AutoPlay).

Fix two latent bugs in reactor-ide's tool windows: `tb.KeyDown +=` inside
a `.Set` lambda re-subscribed on every update, so Enter ran the command
once per elapsed render. Replaced with `.OnKeyDown(...)`, which the
reconciler subscribes once and dispatches with fresh state.

Docs: update the skills guidance to teach the modifier instead of `.Set`,
and add a review-checklist item for it. Regenerate the gallery search
index for the one ThemePage snippet that changed.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 84892418-ea0e-4cb9-8718-af610162d90b
…ites

Follow-up to the .Set -> modifier migration, from a multi-dimension review of
the branch.

Packaging (the one finding with real user impact):
- `skills/design-docs/*.md` was never in the agent-kit pack list. The
  `skills\*.md` glob is non-recursive, so the two guidance files edited by the
  previous commit would not have shipped in the NuGet at all. Added an explicit
  entry, mirroring how `skills/recipes/` is already handled.

Correctness:
- ModalOverlay converted `.Set(btn => btn.Style = ...)` to `.ApplyStyle(...)`,
  which is not semantics-preserving: `ApplyStyle` is `OnMount`-based and
  `Reconciler` gates `OnMountAction` on `oldM is null`, so it applies once at
  mount while the `.Set` re-ran on every update. Switched to the existing
  `.AccentButton()` fluent (the idiomatic spelling for `AccentButtonStyle`) and
  documented the mount-only constraint. Verified latent in this sample:
  `IsPrimary` is fixed per call site and the overlay remounts its subtree when
  `isOpen` flips.

Completeness:
- The previous commit matched only single-line `.Set` lambdas, so multi-line
  `.Set(x => { ... })` bodies were skipped -- including in files it otherwise
  converted, leaving both idioms in one file. Converted the remaining
  modifier-backed writes across the chat, minesweeper, regedit, TestApp,
  charting and gallery samples. `.Set` is deliberately retained where no
  modifier exists (ContextFlyout, BorderBrush, Content, LineHeight,
  LineStackingStrategy, TextAlignment, HorizontalScrollBarVisibility).

Docs:
- `code-review-checklist.md` forbade hardcoded icon fonts while the samples now
  hardcode a fallback stack. Reworded to prefer `SymbolThemeFontFamily` where a
  live `Application.Current` exists and to allow the explicit
  "Segoe Fluent Icons, Segoe MDL2 Assets" stack as a static fallback, while
  still rejecting a bare legacy or Windows-11-only family.
- `typography-and-colors.md` and `dsl-reference.md` still taught
  `.Set(tb => tb.TextWrapping = ...)`; moved to the modifier and retargeted the
  escape-hatch example to a property that genuinely has none.

Tests:
- The symbol-glyph fallback stack had no oracle -- reverting it passed every
  test. Added two selftest checks: one asserting the exact stack, one asserting
  both glyph resolvers consume it. Mutation-verified: reverting
  `SymbolFontFallback` to "Segoe Fluent Icons" fails
  `PrivMount_SymbolFontFallbackStack`.

Also uses the `Icon(...)` path for the gallery theme toggle so `IconResolver`
owns font resolution instead of repeating the literal.

Validation: solution builds with 0 warnings / 0 errors; 12468 unit tests pass;
1316 selftests run with only the 2 pre-existing `Issue487_SV2*` failures, which
reproduce unchanged on pristine origin/main.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 84892418-ea0e-4cb9-8718-af610162d90b

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces reliance on .Set(...) setter escape hatches in samples/docs by switching to existing first-class modifiers (improving diffing/unwind behavior and avoiding unnecessary updates), and standardizes icon font fallback behavior by introducing a shared "Segoe Fluent Icons, Segoe MDL2 Assets" stack that routes through WinRTCache.

Changes:

  • Core: route remaining new FontFamily(...) allocations through WinRTCache, and centralize the symbol fallback font stack in IconResolver.SymbolFontFallback.
  • Tests: add selftest oracles that assert the exact fallback stack and that both glyph resolvers consume it.
  • Samples/docs/agent-kit: migrate many usages of .Set(...) to modifiers (FontFamily, TextWrapping/Trimming, MaxLines, padding/alignment/theme/etc.), and ensure skills/design-docs/*.md is actually packed into the NuGet agent kit.

Reviewed changes

Copilot reviewed 59 out of 59 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Reactor.AppTests.Host/SelfTest/Fixtures/ReconcilerBigCoverageFixtures.cs Adds selftest checks asserting the exact fallback font stack and its consumption by icon resolvers.
src/Reactor/Reactor.csproj Packs skills/design-docs/*.md into the agent-kit NuGet payload (non-recursive glob gap fix).
src/Reactor/Elements/ElementExtensions.cs Updates .Set(...) doc example; relies on modifiers elsewhere in the PR.
src/Reactor/Core/V1Protocol/IconResolver.cs Introduces SymbolFontFallback constant; uses WinRTCache.GetFontFamily(...) for glyph fallback.
src/Reactor/Core/Reconciler.Mount.cs Routes TabView pin-button font family through WinRTCache using the shared fallback constant.
src/Reactor/Core/ErrorFallback.cs Routes monospace FontFamily creation through WinRTCache.
src/Reactor/Core/Element.Icon.cs Routes FontIcon patch FontFamily creation through WinRTCache.
skills/figma.md Updates agent-kit guidance to use .FontFamily(...) modifier instead of .Set(...).
skills/dsl-reference.md Updates .Set(...) example and adds guidance to prefer modifiers when available.
skills/design.md Updates design guidance to use .FontFamily(...) modifier for icon glyphs.
skills/design-docs/typography-and-colors.md Updates design doc examples to use modifiers for FontFamily/TextWrapping.
skills/design-docs/code-review-checklist.md Updates checklist to allow the explicit fallback stack as static fallback and prefer .FontFamily(...) over .Set(...).
samples/TodoApp/Program.cs Converts icon TextBlocks from .Set(FontFamily=...) to .FontFamily(...).
samples/ReactorGallery/UserControls/GalleryControls.cs Replaces .Set(...) for wrapping/trimming with .TextWrapping(...) / .TextTrimming(...).
samples/ReactorGallery/SamplePageHost.cs Replaces .Set(FontFamily=...) with .FontFamily(...) for code blocks.
samples/ReactorGallery/reactor-search-index.json Regenerates a snippet to reflect .RequestedTheme(...) modifier usage.
samples/ReactorGallery/Pages/SettingsPage.cs Switches MDL2-only font usage to explicit Fluent+MDL2 fallback; replaces .Set(TextWrapping) with modifier.
samples/ReactorGallery/Pages/HomePage.cs Replaces .Set(TextWrapping) with .TextWrapping(...).
samples/ReactorGallery/GalleryShell.cs Replaces MDL2-hardcoded theme toggle button with Icon(...) usage.
samples/ReactorGallery/ControlPages/Navigation/FrameNavigationPage.cs Replaces .Set(FontFamily=...) with .FontFamily(...).
samples/ReactorGallery/ControlPages/Layout/DockingPage.cs Replaces .Set(TextWrapping) with .TextWrapping(...).
samples/ReactorGallery/ControlPages/Layout/CardPage.cs Switches Fluent-only font to Fluent+MDL2 fallback stack.
samples/ReactorGallery/ControlPages/DesignGuidance/TypographyPage.cs Replaces .Set(...) blocks with first-class modifiers for wrapping/trimming/max lines/font family.
samples/ReactorGallery/ControlPages/DesignGuidance/ThemePage.cs Replaces .Set(RequestedTheme=...) with .RequestedTheme(...) in both live sample and snippet.
samples/ReactorGallery/ControlPages/DesignGuidance/SpacingPage.cs Replaces .Set(...) for wrapping/font family with modifiers.
samples/ReactorGallery/ControlPages/DesignGuidance/GeometryPage.cs Replaces MDL2-only font usage and .Set(...) wrapping/font-family blocks with modifiers where available.
samples/ReactorGallery/ControlPages/DesignGuidance/ColorPage.cs Replaces MDL2-only font usage and .Set(TextWrapping/FontFamily) with modifiers.
samples/ReactorGallery/ControlPages/BasicInput/TextBoxPage.cs Replaces .Set(AcceptsReturn/TextWrapping) with .AcceptsReturn() / .TextWrapping(...).
samples/ReactorGallery/ControlPages/BasicInput/SliderPage.cs Replaces .Set(Orientation=...) with .Orientation(...).
samples/ReactorGallery/ControlPages/BasicInput/PasswordBoxPage.cs Replaces .Set(PasswordRevealMode=...) with .PasswordRevealMode(...).
samples/ReactorGallery/ControlPages/BasicInput/ColorPickerPage.cs Replaces .Set(Background=...) with .Background(...).
samples/ReactorCharting.Gallery/Samples/WorkflowPipeline.cs Switches MDL2-only font usage to Fluent+MDL2 fallback and replaces .Set(FontFamily) with modifier.
samples/ReactorCharting.Gallery/Samples/ComponentHierarchy.cs Replaces multi-property .Set(...) blocks with modifiers for padding/font/min sizes.
samples/ReactorCharting.Gallery/Program.cs Replaces .Set(...) blocks with modifiers (font family, padding/min sizes, wrapping, code font setup).
samples/Reactor.TestApp/Demos/VirtualizationDemo.cs Replaces .Set(Height/SelectionMode) with .Height(...) / .SelectionMode(...).
samples/Reactor.TestApp/Demos/TransitionsDemo.cs Replaces .Set(Scale/Translation/Background) with modifiers where available.
samples/Reactor.TestApp/Demos/SlotsDemo.cs Replaces .Set(FontFamily=...) with .FontFamily(...) for glyph TextBlocks.
samples/Reactor.TestApp/Demos/RichTextDemo.cs Moves HorizontalContentAlignment out of .Set(...) into modifier and removes duplicate set.
samples/Reactor.TestApp/Demos/NavigationDemo.cs Replaces .Set(PlaceholderText=...) with .PlaceholderText(...).
samples/Reactor.TestApp/Demos/FlyoutDemo.cs Replaces .Set(Padding/Min*) with modifiers; retains .Set where needed for imperative content mutation.
samples/NavigationDemo/App.cs Replaces .Set(BorderThickness=...) with .BorderThickness(...).
samples/CommandingDemo/App.cs Replaces .Set(FontWeight=SemiBold) with .SemiBold().
samples/apps/validation-showcase/App.cs Replaces .Set(CharacterCasing/FontWeight) with .CharacterCasing(...) / .SemiBold().
samples/apps/regedit/Components/ValueList.cs Replaces .Set(...) for padding/border thickness/trimming/wrapping/font family with modifiers where available; keeps .Set for BorderBrush.
samples/apps/regedit/Components/Dialogs/EditMultiStringDialog.cs Replaces .Set(AcceptsReturn/TextWrapping) with modifiers.
samples/apps/regedit/Components/Dialogs/EditBinaryDialog.cs Replaces .Set(...) block with .FontFamily(...) / .AcceptsReturn() / .TextWrapping(...).
samples/apps/regedit/App.cs Replaces .Set(PlaceholderText/TextTrimming/TextWrapping) with modifiers.
samples/apps/reactor-ide/App.cs Fixes terminal double-subscribe by moving KeyDown wiring from .Set to .OnKeyDown(...); replaces other .Set(...) blocks with modifiers.
samples/apps/minesweeper/Components/SmileyButton.cs Replaces .Set(...) for content alignment/padding with modifiers.
samples/apps/minesweeper/Components/ModalOverlay.cs Uses .AccentButton() with a caution comment about mount-only styling semantics.
samples/apps/minesweeper/Components/CellComponent.cs Replaces .Set(Padding/BorderThickness) pieces with modifiers and narrows .Set usage to what lacks modifiers.
samples/apps/chat/Chat.UI/StatusBar.cs Replaces .Set(...) blocks with .MinWidth(...) / .CornerRadius(...) modifiers.
samples/apps/chat/Chat.UI/Sidebar.cs Replaces .Set(...) blocks with alignment/corner radius modifiers; updates glyph font stack.
samples/apps/chat/Chat.UI/SessionListItem.cs Replaces .Set(...) blocks with modifiers; retains .Set for ContextFlyout assignment.
samples/apps/chat/Chat.UI/SessionHeader.cs Replaces .Set(TextTrimming/MaxLines) with modifiers.
samples/apps/chat/Chat.UI/LandingPage.cs Replaces .Set(...) blocks with modifiers for layout/enablement/background and text box settings.
samples/apps/chat/Chat.UI/InputBar.cs Replaces .Set(...) blocks with modifiers (button styling, textbox enablement, banner wrapping/trimming, etc.).
samples/apps/chat/Chat.UI/ChatTimeline.cs Replaces .Set(...) blocks with modifiers for font/wrapping/selection and sizing; moves HorizontalContentAlignment out of .Set.
plugins/reactor/skills/reactor-design/SKILL.md Keeps plugin-format skill guidance consistent with .FontFamily(...) modifier usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build metrics

Artifact sizes for b753e5e vs the base branch (c9e878b).

Packages (compressed .nupkg)

Artifact base PR Δ
Microsoft.UI.Reactor.nupkg 1.54 MB 1.56 MB +22.9 KB (+1.45%) ⚠️
Microsoft.UI.Reactor.Advanced.nupkg 473.9 KB 473.9 KB -2 B (0.00%) ≈
Microsoft.UI.Reactor.Devtools.nupkg 278.1 KB 278.1 KB -4 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor

Artifact base PR Δ
Reactor.Analyzers.dll 301.0 KB 301.0 KB +0 B (0.00%) ≈
Reactor.dll 2.37 MB 2.37 MB +0 B (0.00%) ≈
Reactor.Localization.Generator.dll 16.0 KB 16.0 KB +0 B (0.00%) ≈
Reactor.Wrappers.Abstractions.dll 10.5 KB 10.5 KB +0 B (0.00%) ≈
Reactor.Wrappers.Generator.dll 99.5 KB 99.5 KB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Advanced

Artifact base PR Δ
Reactor.Advanced.dll 1013.0 KB 1013.0 KB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Devtools

Artifact base PR Δ
Microsoft.UI.Reactor.Devtools.dll 777.5 KB 777.5 KB +0 B (0.00%) ≈

✅ smaller / ⚠️ larger / ≈ within noise. Sizes come from a Release dotnet pack on the CI runner: packages are the compressed .nupkg download size, assemblies the uncompressed DLL inside it.
workflow run.

@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

🧪 Merged coverage

Coverage for b753e5e vs the base branch (fba0b2b) — unit + selftest merged.

Metric base PR Δ
Line 85.67% 85.67% 0.00 pp ≈
Branch 77.02% (898/1166) 77.02% (898/1166) 0.00 pp ≈

No coverage change beyond the noise floor. ✅

✅ higher / ⚠️ lower / ≈ within noise. Δ is in percentage points; coverage is unit + selftest merged (Debug x64) on the CI runner. Cobertura reports attached to the workflow run as artifacts.

Second review round. The important finding is that two of the previous
commit's conversions were silently broken.

Modifier applicability (real regressions, now reverted):
- `ApplyModifiers` in Reconciler.cs applies `Padding` only to `Control`,
  `Border` and `StackPanel`, and `BorderThickness`/`BorderBrush`/`CornerRadius`
  only to `Control` and `Border`. A `Grid` is none of those, so
  `ValueList`'s header lost its padding AND its bottom divider when those
  writes moved from `.Set` to modifiers. Reverted to `.Set` with a comment
  naming the constraint. `TextBlock` is likewise not a `Control`, so
  `.Padding(0)` on the minesweeper glyph was also a no-op -- reverted.
  This is a general trap for the whole `.Set` -> modifier migration: a
  modifier can compile and still do nothing for a given control type.

Packaging:
- `plugins/reactor/skills/reactor-advanced` and `reactor-docking` have never
  been in the agent-kit pack list, so both skills are missing from the shipped
  NuGet. Added entries. Pre-existing, same class as the `skills/design-docs`
  gap fixed in the previous commit.

API docs:
- `ApplyStyle` and `AccentButton` are `OnMount`-based, so conditionally
  chaining them does not apply or remove the style when the condition flips
  on an in-place update. That was documented only in a sample comment, which
  IntelliSense never shows. Documented on both methods, with the
  `.WithKey(...)`-to-force-remount workaround.

Generated docs (edited the pipeline sources, then `mur docs compile`d the
three affected topics; reverted the unrelated screenshot churn):
- `advanced` taught `.Set` for `TextWrapping`/`CharacterSpacing`/
  `IsTextSelectionEnabled` and `Padding`, all of which have modifiers. The
  escape-hatch demo now shows genuinely modifier-less properties
  (`ToolTipService` attached property, `LineStackingStrategy`,
  `IsTextScaleFactorEnabled`).
- `context` used `.Set(b => b.RequestedTheme = ...)`; `modifier-system` used
  `TextWrapping` in its `.Set` example.

Agent-kit consistency:
- `design.md`, `figma.md`, `reactor-design/SKILL.md` and
  `typography-and-colors.md` all said "use SymbolThemeFontFamily" with no
  mention of the static fallback the samples actually use. They now carry the
  same live-resource-vs-static-fallback rule as the review checklist.
- `figma.md` still showed the accent button as
  `.Set(b => b.Style = ...["AccentButtonStyle"])`; now `.AccentButton()`.

Also switched the minesweeper bevel to the `.BorderBrush(...)` modifier
(Border supports it) and the glyph to `.TextAlignment(...)` / `.LineHeight(...)`.

Validation: 0 warnings / 0 errors; 12468 unit tests pass; 1316 selftests with
0 failures (the two Issue487_SV2 failures seen earlier are flaky and pass here).

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 84892418-ea0e-4cb9-8718-af610162d90b
Copilot AI review requested due to automatic review settings July 29, 2026 01:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 66 out of 66 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/Reactor/Elements/ElementExtensions.cs:556

  • The ApplyStyle XML doc says it applies the style at "mount/update time", but the implementation uses OnMount (and the doc immediately below says "Applied at mount only"). This is internally inconsistent and can mislead callers about update semantics.
    src/Reactor/Elements/ElementExtensions.NamedStyles.cs:19
  • The AccentButton XML doc claims the style "re-resolves on light/dark/contrast switches via the underlying static-resource lookup", but AccentButton/ApplyStyle only do a one-time Application.Current.Resources lookup at mount. Consider rephrasing to avoid implying the style is re-looked-up on theme changes.

Addresses the two low-confidence notes from the Copilot review, both of
which are accurate:

- The ApplyStyle summary still opened with 'at mount/update time' while the
  <para> I added immediately below says 'Applied at mount only'. Removed the
  contradictory phrase.
- AccentButton claimed the style 're-resolves on light/dark/contrast switches
  via the underlying static-resource lookup'. The resource lookup happens once
  at mount; theme-awareness actually comes from the {ThemeResource} setters
  inside the Style, which WinUI re-resolves. Rephrased to say that accurately.

Also pointed SubtleButton and TextLink at ApplyStyle for the same mount-only
caveat, since they share the trap.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 84892418-ea0e-4cb9-8718-af610162d90b
Copilot AI review requested due to automatic review settings July 29, 2026 01:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 66 out of 66 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

samples/apps/chat/Chat.UI/SessionListItem.cs:63

  • This still uses .Set(b => b.ContextFlyout = ...) even though .Set writes are never unwound and pooled Button controls are not reset for ContextFlyout (ElementPool.CleanElement clears button.Flyout but not button.ContextFlyout). A button rented later from the pool by an element that doesn't set ContextFlyout can inherit this stale context menu.

Consider expressing the menu via Reactor flyout elements and attaching it through the modifier path (.WithContextFlyout(...) + MenuItems(...) / MenuItem(...)), so the reconciler can update/clear it structurally.

Copilot review flagged that .Set(b => b.ContextFlyout = ...) is never
unwound and ElementPool.CleanElement resets button.Flyout but NOT
button.ContextFlyout, so a pooled Button later rented by an element that
does not set a context menu can inherit this stale one. Verified: Button is
in ElementPool's poolable list and the reset switch clears Content,
IsEnabled and Flyout only.

Replaced the hand-built MenuFlyout with the existing declarative path,
.WithContextFlyout(MenuItems(MenuItem(...), MenuItem(...))), which routes
through ElementModifiers so the reconciler updates and clears it
structurally. Drops BuildContextMenu() and its imperative Click wiring.

The bug predates this branch, but the surrounding chain was already being
converted here and the fix uses an API the repo already ships.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 84892418-ea0e-4cb9-8718-af610162d90b
Copilot AI review requested due to automatic review settings July 29, 2026 01:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 66 out of 66 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 29, 2026 02:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 69 out of 69 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 29, 2026 03:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 74 out of 74 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (3)

src/Reactor/Core/V1Protocol/IconResolver.cs:76

  • Same as ResolveIconString: using Resources["SymbolThemeFontFamily"] risks throwing when the resource key is missing, preventing the intended fallback. Prefer TryGetValue so the fallback stack is actually used when the theme resource can’t be resolved.
    samples/apps/regedit/Components/ValueList.cs:82
  • .Padding(...) is currently ignored for Grid in Reconciler.ApplyModifiers (only Control/Border/StackPanel are handled). As a result this row padding is a silent no-op. Either keep it imperative (as done for the header) or wrap the row in a Border and pad that.
    src/Reactor/Hooks/UseFocus.cs:190
  • The Loaded += handler added in OnMountAdd is never removed. With element pooling / control reuse, a TextBox that was once mounted with autoFocus=true can keep focusing itself on subsequent loads even if later mounted with autoFocus=false (or in a different FocusManager). Make the handler one-shot (unsubscribe on first fire) to avoid leaking the behavior across reuse.

Copilot AI review requested due to automatic review settings July 29, 2026 03:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 77 out of 77 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/Reactor/Hooks/UseFocus.cs:207

  • Same issue as the TextBox overload: the autoFocus Loaded subscription is never removed. Loaded can fire multiple times for a control during its lifetime, so this can re-focus unexpectedly on later loads. A self-unsubscribing handler keeps the behavior to “focus once per mount”.
    src/Reactor/Hooks/UseFocus.cs:190
  • The Loaded handler added for autoFocus is never removed. Since TextBox is pooled (ElementPool pools TextBox), the same native control can be re-mounted later and this will accumulate Loaded subscriptions across pool reuse, causing repeated Focus calls and retaining extra delegates. Consider using a self-unsubscribing handler (or pairing with OnUnmount) so autoFocus runs once per mount and doesn't persist on the control.

This issue also appears on line 203 of the same file.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 80 out of 80 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/Reactor/Hooks/UseFocus.cs:207

  • Same pattern as the TextBox overload: Loaded is subscribed with an anonymous lambda and never removed. Even if NumberBox isn't currently pooled, using a self-unsubscribing handler avoids surprises if pooling is enabled later or if the element is reloaded multiple times.
    src/Reactor/Hooks/UseFocus.cs:190
  • The Loaded handler is added with an anonymous lambda and never removed. Since TextBox is a poolable control (ElementPool includes TextBox), a pooled instance can be re-mounted and accumulate multiple Loaded handlers across rent/return cycles, causing repeated Focus calls and unnecessary handler growth.

This issue also appears on line 203 of the same file.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 66 out of 66 changed files in this pull request and generated no new comments.

Copilot review on #930 (comment 3670677639), and it is correct.

ResourceDictionary implements IDictionary, so Resources[key] THROWS on a
missing key rather than returning null. The '?? SymbolFontFallback' form could
therefore never run: a host that had not merged XamlControlsResources would get
a KeyNotFoundException instead of the fallback stack. That made the fallback
constant this branch introduced effectively dead code on the one code path it
exists to serve.

The lookup pattern was pre-existing, but the fallback it feeds is new here, so
the bug is squarely in scope. Extracted ResolveSymbolFontFamily() using
TryGetValue -- the idiom Theme.cs:155 already uses for exactly this -- and
pointed both the FontIcon and FontIconSource paths at it.

Selftest additions:
- PrivMount_SymbolFontLookupUsesTryGetValue asserts both halves of the claim:
  the indexer throws on a missing key, and TryGetValue returns false. That pins
  the API contract that makes the indexer wrong.
- PrivMount_SymbolFontResolverDoesNotThrow covers the resolver surviving that
  path.
- The existing check also moved off the indexer, so the fixture no longer
  demonstrates the pattern it warns about.

Scope noted in the comment rather than overstated: neither check fails if the
resolver is reverted to the indexer, because under a live app the resource is
present and the throwing path is never taken. Proving the revert would require
removing the key from the shared Application dictionary mid-run, which is not
safely reversible when it comes from a merged XamlControlsResources. The tests
document the hazard instead of trapping it.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 84892418-ea0e-4cb9-8718-af610162d90b
Copilot AI review requested due to automatic review settings July 29, 2026 07:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 66 out of 66 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

tests/Reactor.AppTests.Host/SelfTest/Fixtures/ReconcilerBigCoverageFixtures.cs:1798

  • In this contract-pinning check, appResources?["..."] won’t throw if Application.Current?.Resources is unexpectedly null, and catching System.Exception can mask unrelated failures. Since the intent is specifically to prove the ResourceDictionary indexer throws on a missing key, use the non-null indexer and catch KeyNotFoundException only so the test fails on other unexpected exceptions.

CodeQL 'generic catch clause' on the check added in 0902749, and the finding
is right: catching System.Exception meant an unrelated failure would have been
silently recorded as 'the indexer threw', so the check could pass for the wrong
reason -- the exact vacuousness it was written to avoid.

The suggested fix was to narrow to KeyNotFoundException. Probed it rather than
applying it, and the actual type is COMException: ResourceDictionary is a
projected WinRT type, so a missing-key lookup surfaces the underlying
IMap.Lookup HRESULT rather than the managed dictionary exception. Narrowing to
KeyNotFoundException would not have matched, and the exception would have
propagated and failed the fixture.

Narrowed to COMException and recorded why, since it also means guarding the
indexer with a managed KeyNotFoundException catch would not work either.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 84892418-ea0e-4cb9-8718-af610162d90b
Copilot AI review requested due to automatic review settings July 29, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 66 out of 66 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

src/Reactor/Core/V1Protocol/IconResolver.cs:30

  • The XML doc comment claims the ResourceDictionary indexer would throw a KeyNotFoundException. For WinUI’s projected ResourceDictionary, a missing key typically surfaces as a COMException (see the selftest rationale in ReconcilerBigCoverageFixtures). This comment should avoid naming the wrong exception type, or it may lead readers to catch/guard the wrong exception.
    tests/Reactor.AppTests.Host/SelfTest/Fixtures/ReconcilerBigCoverageFixtures.cs:1781
  • These comments say the Resources[key] indexer would yield a KeyNotFoundException on a missing key, but the code immediately below demonstrates it surfaces as a COMException for WinUI’s projected ResourceDictionary. To keep the rationale consistent (and avoid suggesting the wrong catch type), update this block to mention COMException (or just “throws”).

Copilot AI review requested due to automatic review settings July 29, 2026 22:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 66 out of 66 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (6)

tests/Reactor.AppTests.Host/SelfTest/Fixtures/ReconcilerBigCoverageFixtures.cs:2225

  • This comment says the Resources[key] missing-key path would throw KeyNotFoundException, but the catch block below (and WinRT projection behavior) shows it surfaces as COMException. Updating the comment avoids conflicting guidance in the same block.
    src/Reactor/Core/V1Protocol/IconResolver.cs:30
  • The XML doc says the ResourceDictionary indexer would throw KeyNotFoundException on a missing key, but for projected WinRT ResourceDictionary lookups the missing-key case surfaces as a COMException (IMap.Lookup). This is also what the new selftest pins, so the doc should match the actual exception behavior.
    skills/design.md:461
  • This example uses Application.Current.Resources["SymbolThemeFontFamily"], which can throw (COMException) if the app hasn't merged XamlControlsResources (the same missing-key scenario this PR highlights). Consider using a TryGetValue-based lookup (e.g., ThemeResource.Get(...)) with a fallback stack so the snippet is safe to copy/paste.
    plugins/reactor/skills/reactor-design/SKILL.md:307
  • This snippet uses Application.Current.Resources["SymbolThemeFontFamily"], which can throw if the host didn't merge XamlControlsResources. Since this PR explicitly calls out that missing-key hazard, it would be more consistent to model a TryGetValue-based lookup with a fallback stack in the guidance.
  ```csharp
  TextBlock("\uE710")
      .FontFamily((FontFamily)Application.Current.Resources["SymbolThemeFontFamily"])
**skills/design-docs/typography-and-colors.md:82**
* The example uses the ResourceDictionary indexer for `SymbolThemeFontFamily`, which can throw when the key is missing. Since this doc now discusses fallback behavior, consider switching to a TryGetValue-style lookup (ThemeResource.Get<FontFamily>) so the snippet doesn't crash in hosts that haven't merged XamlControlsResources.
**skills/figma.md:157**
* This inline example uses `Application.Current.Resources["SymbolThemeFontFamily"]`, which can throw if the app hasn't merged XamlControlsResources. Since this PR establishes a safe fallback stack, consider using a non-throwing lookup (ThemeResource.Get<FontFamily>(...) ?? new FontFamily("Segoe Fluent Icons, Segoe MDL2 Assets")) so copy/paste usage is resilient.
</details>

@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit 3bd7dfa into main Jul 29, 2026
22 checks passed
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jul 30, 2026
Post-#930 the repo prefers fluent modifiers, so the guide now names
.Closed(...) alongside the with-expression form, and names the equivalent
hook on the other three props (OnPaneOpenChanged / OnClosed).

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3a974fbd-1bad-4634-860f-3261f28a9ff9
Alexandre Zollinger Chohfi (azchohfi) pushed a commit that referenced this pull request Jul 30, 2026
Both conflicts are in files #932 owns and kept evolving after this branch forked:

- samples/.editorconfig: #932 removed the REACTOR_NAV_001 downgrade and fixed that rule at
  its single source instead. Kept their version and re-applied only the REACTOR_MOD_003
  rows on top.
- ModifierTableIntegrityTests.ReadApplyModifierControlGates: #932 made the same CodeQL
  cs/linq/missed-where refactor independently. Kept this branch's version, which is a
  superset - it routes the type-name mapping through the shared SimpleTypeName helper and
  attributes a multi-name guard to every modifier it gates rather than only the first.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 856c61fb-75c8-4cbb-b33a-f77d9e23621b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants