Skip to content

fix(gallery): stop the title bar's right-header glyphs from clipping - #968

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 4 commits into
mainfrom
azchohfi-fix-gallery-titlebar-icons-trimmed
Jul 31, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 4 commits into
mainfrom
azchohfi-fix-gallery-titlebar-icons-trimmed

Conversation

@azchohfi

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

Copy link
Copy Markdown
Collaborator

The bug

The gallery title bar's two right-header buttons rendered clipped glyphs — the link icon lost its trailing half, the moon lost its right edge.

before and after

Root cause

Both buttons are 40×36. WinUI's default Button padding is 11,5,11,6, leaving 18 DIP of content width. Icon("\uE71B") resolves (via IconResolver.ResolveIconString) to a FontIcon at its default 20 DIP size, so the glyph overflowed the content box and was clipped on the right.

Measured on the live window: glyph ink spanned x:1654..1669, terminating exactly on the 1653..1670 content boundary — while the title bar's own back / pane-toggle glyphs render at 16 DIP.

Fix

Size both glyphs to 16 DIP (what the WinUI TitleBar template already uses for its own chrome) and zero the button padding so the icon centres in the full 40×36 box.

before after
link ink 16×11, cut on right 16×9, complete + centred
moon ink 14×20, cut on right 15×16, complete + centred

Also verified in dark theme (the \uE706 sun arm) and for the transient "copied" checkmark state:

dark theme

Test

The fix moves both buttons onto the standalone Icon(FontIcon(glyph, fontSize:)) path, which had no coverage. Two distinct code paths carry it:

  • mount — IconResolver.CreateFontIcon, which assigns FontFamily only when the author supplied one, unlike ResolveIconString which assigns ResolveSymbolFontFamily() by hand. If those two ever land on different families, typed glyph icons render tofu.
  • update — IconElement.PatchIcon's same-subtype patch, which rewrites Glyph and FontSize in place.

RBC_IconElementFontIconSizing mounts the gallery's exact shape, swaps the glyph at a constant size, then changes the size, and also pins the zero padding the fix depends on.

Every check was mutation-verified against product code — one oracle each. Each mutation failed exactly its own check and no others:

check mutated product code
GlyphAndSizeProjected CreateFontIcon FontSize write
ExplicitFamilyWins CreateFontIcon FontFamily write
DefaultFamilyMatchesGlyphResolver ResolveSymbolFontFamily theme-resource arm
ZeroPaddingApplied ApplyModifiers padding write
GlyphSwapKeepsSize PatchIcon Glyph write
SizeChangePatched PatchIcon FontSize write

Commits

b5a2f09 the gallery fix
4a930b3 the selftest fixture
31f19cb code-quality review: tolerance-based FontSize comparison + hoisted null guards
d4d5468 second review pass: scope the default-family check's claim honestly

Review trail

Two full passes of the repo's pr-review skill (8 dimensions each, multi-model cross-check on a different model family), plus three Copilot review rounds.

  • Pass 1 (over b5a2f09) — 0 critical, 0 high, 1 medium: the Icon(FontIcon(..., fontSize:)) path had no coverage. Closed by the fixture.
  • Pass 2 (over the full branch, since the fixture landed after pass 1) — 1 medium: the comment on DefaultFamilyMatchesGlyphResolver overclaimed. Under a live app ResolveSymbolFontFamily returns from its theme-resource arm, so the check traps a retarget of that arm — what the mutation run exercised — but not the ?? SymbolFontFallback tail, which never executes in this host. Comment rewritten to say so, in the style of the existing "Scope, honestly:" note in PrivateMountHotPaths.
  • Declined: pass 2 also raised two high findings alleging Button("\uE713") renders tofu in ControlPages/Navigation/TitleBarPage.cs and docs/_pipeline/templates/windows.md.dt. Both files are outside this diff, and the claim rests on Windows PUA font fallback, which is unverified — the multi-model cross-check disputed both and also found the paired ⚙ is U+2699, which is in normal text fonts. Filed as Verify whether Button("\uE713") renders tofu in the TitleBar sample and the windows guide #979 instead of expanding this PR.
  • Copilot rounds: round 1 → no comments from Copilot; github-code-quality[bot] raised 4 (one float-equality, three constant-condition), all fixed in 31f19cb, each replied to and resolved. Rounds 2 and 3 → no new comments.

Validation

  • --self-test --filter "RBC_" green locally; CI 18 pass / 2 skipped / 0 fail, including Selftests, AOT Selftests, AOT Trim Proof, E2E, and Docs build
  • samples/ReactorGallery builds clean (0 errors, no REACTOR_* diagnostics)
  • dotnet run --project tools/Reactor.SearchIndex — no drift; the generator reads only ControlRegistry.cs, PageRouter.cs and ControlPages/**, none of which this touches
  • No public API change, so skills/reactor.api.txt needs no regeneration

The copy-link and theme-toggle buttons in the gallery title bar are 40x36,
but WinUI's default Button padding (11,5,11,6) leaves only 18 DIP of content
width. Icon("\uE71B") resolves to a FontIcon at its default 20 DIP size, so
the glyph overflowed and was clipped on the right - the link icon lost its
trailing half and the moon/sun lost its right edge.

Size both glyphs to 16 DIP (what the WinUI TitleBar template already uses for
its own back and pane-toggle glyphs) and zero the button padding so the icon
is centred in the full 40x36 box with no clipping.

Verified against the live window: glyph ink is now 16x9 (link) and 15x16
(moon), centred in the button, matching the 16x10 pane-toggle glyph - versus
the previous ink that terminated exactly on the 18 DIP content boundary.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c
PR review flagged that the gallery fix now leans on the standalone
Icon(FontIcon(glyph, fontSize:)) path with nothing covering it. Two
distinct code paths carry it and neither had a live fixture:

  mount  - IconResolver.CreateFontIcon, which assigns FontFamily only when
           the author supplied one (unlike ResolveIconString, which assigns
           ResolveSymbolFontFamily() by hand). If those two ever land on
           different families, typed glyph icons render tofu.
  update - IconElement.PatchIcon's same-subtype patch, which rewrites Glyph
           and FontSize in place.

RBC_IconElementFontIconSizing mounts the gallery's exact shape, swaps the
glyph at a constant size, then changes the size, and pins the zero padding
the fix also depends on.

Every check was mutation-verified against product code, one oracle each:

  GlyphAndSizeProjected            CreateFontIcon FontSize write
  ExplicitFamilyWins               CreateFontIcon FontFamily write
  DefaultFamilyMatchesGlyphResolver  ResolveSymbolFontFamily target
  ZeroPaddingApplied               ApplyModifiers padding write
  GlyphSwapKeepsSize               PatchIcon Glyph write
  SizeChangePatched                PatchIcon FontSize write

Each mutation failed exactly its own check and no others; src/ is reverted.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c

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

Fixes clipped glyph rendering in the ReactorGallery title bar right-header buttons by ensuring the icons fit within the 40×36 button content box (matching the WinUI TitleBar chrome sizing), and adds a selftest fixture to cover the typed FontIcon projection and same-subtype update patching paths.

Changes:

  • Switch gallery title-bar buttons from Icon(stringGlyph) to Icon(FontIcon(glyph, fontSize: 16)) and apply .Padding(0) to avoid clipping.
  • Introduce GalleryControls.TitleBarGlyphSize constant to centralize the chosen glyph size.
  • Add RBC_IconElementFontIconSizing selftest fixture and register it in the selftest registry.

Reviewed changes

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

File Description
tests/Reactor.AppTests.Host/SelfTest/SelfTestFixtureRegistry.cs Registers the new RBC fixture in the list and factory switch.
tests/Reactor.AppTests.Host/SelfTest/Fixtures/ReconcilerBigCoverageFixtures.cs Adds IconElementFontIconSizing fixture covering mount/update paths for FontIcon sizing and padding.
samples/ReactorGallery/UserControls/GalleryControls.cs Updates the deep-link copy button to use sized FontIcon + zero padding; adds TitleBarGlyphSize constant.
samples/ReactorGallery/GalleryShell.cs Updates the theme toggle button to use sized FontIcon + zero padding.

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

@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build metrics

Artifact sizes for d4d5468 vs the base branch (17c5b5d).

Packages (compressed .nupkg)

Artifact base PR Δ
Microsoft.UI.Reactor.nupkg 1.60 MB 1.60 MB -36 B (0.00%) ≈
Microsoft.UI.Reactor.Advanced.nupkg 475.5 KB 475.5 KB -13 B (0.00%) ≈
Microsoft.UI.Reactor.Devtools.nupkg 278.2 KB 278.2 KB -6 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor

Artifact base PR Δ
Reactor.Analyzers.dll 354.5 KB 354.5 KB +0 B (0.00%) ≈
Reactor.dll 2.38 MB 2.38 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 1014.0 KB 1014.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%) ≈

No size change beyond the noise floor. ✅

✅ 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 31, 2026 •

Copy link
Copy Markdown
Contributor

🧪 Merged coverage

Coverage for d4d5468 vs the base branch (9ef0e6d) — unit + selftest merged.

Metric base PR Δ
Line 85.73% 85.76% +0.03 pp ≈
Branch 77.19% (900/1166) 77.27% (901/1166) +0.08 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.

- Replace exact double ==/!= on FontSize with a tolerance helper. A WinUI
  control default can be theme-resource derived rather than a literal; the
  0.0001 tolerance is far tighter than any DIP gap under test (16/20/28),
  so it cannot mask a real mismatch.
- Hoist the null guards out of the ?. chains. Once the leading conjunct
  proves non-null the later ?. reads were constant-true conditions, which
  obscured intent and tripped the constant-condition analyzer.

Behaviour is unchanged and the oracles still trap: re-mutating both
FontSize writes (IconResolver.CreateFontIcon and IconElement.PatchIcon)
fails GlyphAndSizeProjected, GlyphSwapKeepsSize and SizeChangePatched;
reverted, the whole RBC_ group is green.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c
Copilot AI review requested due to automatic review settings July 31, 2026 06:31

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 4 out of 4 changed files in this pull request and generated no new comments.

Second pr-review pass flagged that the comment on
IconFontSize_DefaultFamilyMatchesGlyphResolver overclaimed. Under a live
app SymbolThemeFontFamily is present, so ResolveSymbolFontFamily returns
from its theme-resource arm; the check traps a retarget of that arm (which
is what the mutation run actually exercised) but not the
`?? SymbolFontFallback` tail, which never executes in this host.

Rewrite the comment in the style of the existing "Scope, honestly:" note in
PrivateMountHotPaths: say which arm is trapped, point at
PrivMount_SymbolFontFallbackStack as the check that pins the fallback
constant, and state what this check uniquely adds - cross-path agreement
between Reactor's hand-assigned family and the WinUI FontIcon default
style, whose divergence would render typed glyph icons as tofu while the
string form kept working.

Comment-only; the six checks are unchanged and still green.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c

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 4 out of 4 changed files in this pull request and generated no new comments.

@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit d1a89e2 into main Jul 31, 2026
21 checks passed
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) deleted the azchohfi-fix-gallery-titlebar-icons-trimmed branch July 31, 2026 17:15
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jul 31, 2026
Refreshes the base past #968/#970/#971/#972 so CI validates this fix against
current main rather than a stale base. Only DataGridEditFixtures.cs is touched
by both sides; main's change there is the #971 fixed-delay -> WaitFor sweep in
neighbouring fixtures and auto-merges clean.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 40080795-41cb-4886-bfa4-219bf8567dcc
Ed-bb pushed a commit to Ed-bb/microsoft-ui-reactor.fork that referenced this pull request Aug 2, 2026
Verified in the running gallery: Navigation -> TitleBar -> "TitleBar with
Content" renders its 36x36 settings button as tofu (the .notdef empty
rectangle). Windows font fallback does NOT substitute a symbol font for
U+E713 in default-font text.

Button(string) assigns the raw string to Button.Content, so it renders
through a ContentPresenter/TextBlock in the inherited FontFamily. That is a
different path from Icon(...), which goes through IconResolver and assigns
SymbolThemeFontFamily. On the very same page the two title-bar buttons
(copy-link, theme toggle) render their glyphs correctly because they take
the Icon(...) path - a clean same-window differential.

It is also an accessibility defect: the button's UIA Name was EMPTY, since
a PUA codepoint as string content yields no usable accessible name.

Fixed every site that used the broken shape:

  samples/ReactorGallery/ControlPages/Navigation/TitleBarPage.cs  (+ the
      displayed snippet, which showed a third variant again)
  docs/_pipeline/templates/windows.md.dt  -> recompiled docs/guide/windows.md
  docs/specs/059-titlebar-drag-regions.md
  plugins/reactor/skills/reactor-windowing/SKILL.md   (ships in the NuGet
      agent kit, so it was teaching this to end users)
  src/Reactor/Elements/ElementExtensions.cs  (IsDragRegion XML doc example,
      ships in IntelliSense)

All now use Icon(FontIcon("\uE713", fontSize: 16)) - the idiom microsoft#968
established - and the gallery button gains AutomationName("Settings"),
confirmed live: its UIA Name is now "Settings" instead of empty.

Deliberately NOT changed, because they are already correct:
  NavItem(..., icon: "\uE713", ...) in samples/NavigationDemo, skills/figma.md
      and spec 001 - the icon parameter routes through IconResolver.
  Caption("\uE713") in samples/apps/chat - sets .FontFamily explicitly.
  The old snippet's Button("<gear>") - U+2699 is present in normal text
      fonts, so that half of the original report was wrong.

reactor-search-index.json needs no regeneration: the generator takes each
page's FIRST complete SampleCard, which for TitleBarPage is "Basic TitleBar",
not the card edited here. Verified by regenerating - no diff.

Closes microsoft#979

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c2d77c16-04ec-408f-9d60-d30680e7cf2c
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