Repository navigation
Declarative title bar height option (WindowSpec.TitleBarHeight / TitleBar(...).Tall()) - #925
Conversation
📦 Build metricsArtifact sizes for Packages (compressed .nupkg)
Assemblies in Microsoft.UI.Reactor
Assemblies in Microsoft.UI.Reactor.Advanced
Assemblies in Microsoft.UI.Reactor.Devtools
✅ smaller / |
57130a9 to
354e3a9
Compare
There was a problem hiding this comment.
Pull request overview
Adds a declarative “tall title bar” option to Reactor’s windowing model, aligning WinUI’s system caption height and the WinUI TitleBar control height so common NavigationView/title-bar chrome layouts don’t require imperative workarounds.
Changes:
- Introduces
WindowTitleBarHeight { Standard, Tall, Collapsed }, exposed viaWindowSpec.TitleBarHeightandTitleBar(...).Tall()/.HeightOption(...). - Implements ordering/precedence logic in
ReactorWindowto apply caption height safely (after content-extension) and to keep the mountedTitleBarcontrol height in sync (including post-modifier fallback when.Height(...)is removed). - Adds headless unit tests and WinUI selftest fixtures; updates docs/skills and API reference indices; includes a related
ExtendsContentIntoTitleBarinference fix inReactorWindow.Update.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Reactor/Hosting/WindowSpec.cs |
Adds WindowTitleBarHeight enum and WindowSpec.TitleBarHeight API with validation/docs. |
src/Reactor/Hosting/ReactorWindow.cs |
Applies caption height option with spec-over-element precedence; syncs TitleBar control height; fixes ExtendsContentIntoTitleBar null-spec inference behavior. |
src/Reactor/Core/Element.cs |
Adds TitleBarElement.HeightOption and wires mount/update imperative hooks to push height state into ReactorWindow. |
src/Reactor/Elements/ElementExtensions.cs |
Adds DSL modifiers .HeightOption(WindowTitleBarHeight) and .Tall(bool). |
src/Reactor/Core/Reconciler.Mount.cs / src/Reactor/Core/Reconciler.Update.cs |
Re-applies caption-derived control height after modifiers to handle removed explicit .Height(...). |
tests/Reactor.Tests/TitleBarHeightTests.cs |
Headless tests covering data shape/precedence and reflection pins for key wiring points. |
tests/Reactor.AppTests.Host/SelfTest/Fixtures/TitleBarHeightFixtures.cs |
Selftest fixtures validating real caption/control geometry and ordering/guard behavior. |
tests/Reactor.AppTests.Host/SelfTest/SelfTestFixtureRegistry.cs |
Registers the new selftest fixtures in both required places. |
docs/_pipeline/templates/windows.md.dt / docs/guide/windows.md |
Documents .Tall() and migration away from the dispatcher-hop workaround. |
skills/windowing.md / plugins/reactor/skills/reactor-windowing/SKILL.md |
Updates windowing skill docs to describe tall title bar usage and rationale. |
skills/reactor.api.txt / plugins/reactor/skills/reactor-dsl/references/reactor.api.txt |
Updates public API snapshots. |
CHANGELOG.md |
Notes the added title-bar height feature and the ExtendsContentIntoTitleBar inference fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds a Reactor-owned WindowTitleBarHeight enum surfaced as WindowSpec.TitleBarHeight and TitleBarElement.HeightOption, with .Tall() / .HeightOption(...) fluent modifiers. A live-WinUI spike refuted the issue's stated cause: nothing in Reactor's mount clobbers AppWindow.TitleBar.PreferredHeightOption, and a naive UseEffect write produces the same geometry as the dispatcher-hop workaround. The real problems are (a) writing the property on a non-content-extended window throws COMException 0x8007139F, and (b) the WinUI TitleBar control does not follow the caption height, so Tall alone looks like a no-op. Reactor therefore applies the value after its own ExtendsContentIntoTitleBar flip and sizes both the caption and the control. Also fixes ReactorWindow.Update writing ExtendsContentIntoTitleBar = false when the spec value is null, which silently dropped a mounted TitleBar element's inference. Co-authored-by: Copilot App <[email protected]> Copilot-Session: a36817d0-2008-4d82-a37b-974628bf463b
Cross-model review of the previous commit found three real gaps: - A WindowSpec.TitleBarHeight change delivered through Update moved only the native caption; an already-mounted WinUI TitleBar control kept its old height, which is exactly the caption/control mismatch the feature exists to prevent. The window now holds a weak reference to the mounted control and sizes it whenever it writes the caption. - Removing an explicit .Height(...) from a still-tall TitleBar fell back to auto instead of the implied 48: the reconciler clears a removed Height modifier after the element's imperative entry runs. Added a post-modifier re-sync hook alongside the existing UpdateDefaultAutomationName one. - The not-extended selftest was satisfiable by a no-op implementation. It now also flips the window into content-extended mode and asserts the retained declaration is re-applied, which no gutted implementation can pass. Also tightened the headless assertions the review flagged as vacuous and added two selftest fixtures covering the two behaviours above. Co-authored-by: Copilot App <[email protected]> Copilot-Session: a36817d0-2008-4d82-a37b-974628bf463b
The Windows App SDK reactor-navview template ships the dispatcher-hop workaround. Whoever migrates it will read issue #917, which states an ordering theory the spike disproved -- so the docs now retire the workaround explicitly rather than only describing the new API, with a before/after for the migration. Co-authored-by: Copilot App <[email protected]> Copilot-Session: a36817d0-2008-4d82-a37b-974628bf463b
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
tests/Reactor.AppTests.Host/SelfTest/Fixtures/TitleBarHeightFixtures.cs:30
- These fixtures hard-code
AppWindow.TitleBar.Heightas 32/48, but that API reports physical pixels and will vary with display scaling (the file even calls out “at 100% scale”). This makes the selftests environment/DPI dependent and risks CI flakes if the runner DPI changes. Prefer making the oracle purely differential (compare Tall vs Standard measured in the same run) or deriving expected pixels from a measured baseline/scale factor instead of assuming 100%.
private const int StandardCaption = 32;
private const int TallCaption = 48;
src/Reactor/Hosting/ReactorWindow.cs:1543
- The warning text here can be misleading when
ExtendsContentIntoTitleBaris explicitly set tofalsewhile aTitleBar(...)element is present: it suggests “render a TitleBar(...) element” as a remedy even though the element may already be rendered and the real fix is to allow/enable content extension. Consider clarifying the message to point atExtendsContentIntoTitleBarneeding to betrue(or not forcedfalse) for the write to be legal.
DiagnosticLog.Warning(
LogCategory.Hosting,
"ReactorWindow.TitleBarHeight",
"TitleBarHeight requires a content-extended window; set WindowSpec.ExtendsContentIntoTitleBar = true "
+ "or render a TitleBar(...) element. The height option was not applied.");
354e3a9 to
aef31a0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/Reactor/Core/Element.cs:4720
- TitleBarElement's descriptor uses a ControlDescriptor.Imperative update lambda that runs on every render, but the new implementation always calls ApplyTitleBarHeightOption. That path can trigger COM property writes (PreferredHeightOption + control Height) even when neither HeightOption nor the explicit .Height(...) state changed, which is avoidable work and could cause unnecessary native churn on frequent re-renders.
Consider diffing old vs new and only calling ApplyTitleBarHeightOption when (a) HeightOption changed, or (b) the presence of an explicit Height modifier changed (since that affects ownership).
.Imperative(
mount: static (c, e) => RegisterWindowTitleBar(c, e),
update: static (c, _, e) => ApplyTitleBarHeightOption(c, e))
.HandCodedEvent<global::Microsoft.UI.Reactor.Core.V1Protocol.TitleBarEventPayload,
src/Reactor/Hosting/ReactorWindow.cs:568
- ApplyChrome now treats
_titleBarControlPresentas the inference source whenspec.ExtendsContentIntoTitleBaris null. But_titleBarControlPresentis only ever set totrue(via MarkTitleBarControlPresent) and is never cleared on TitleBar unmount, so a window that used to render a TitleBar may remain content-extended forever even after the TitleBar is removed and the spec stays null.
If the intended contract is “infer only while a TitleBar control is currently mounted”, you likely need an unmount hook to clear the flag (or a separate current-mounted flag) so inference can be withdrawn when the element disappears.
// A null spec value means "infer": a mounted TitleBar(...) element
// sets content-extension at mount. Re-applying chrome on Update must
// preserve that inference — writing the raw default here would
// silently drop the window out of content-extended mode behind a
// still-mounted TitleBar control. (issue #917; inference contract
// documented on WindowSpec.ExtendsContentIntoTitleBar)
try { _window.ExtendsContentIntoTitleBar = spec.ExtendsContentIntoTitleBar ?? _titleBarControlPresent; }
🧪 Merged coverageCoverage for
No coverage change beyond the noise floor. ✅ ✅ higher / |
…n (issue #917) Findings from the Copilot reviewer and the code-quality bot on PR #925. Accepted: - Selftest caption assertions hard-coded 32/48 as if AppWindowTitleBar.Height were DIPs. It reports physical pixels, so above 100% scaling they break -- and at 150% a Standard caption measures 48px, which would have false-passed the Tall check. Caption expectations now convert through the window's DipScale; control ActualHeight stays in DIPs, which needs no conversion. - _titleBarControlPresent is an ever-mounted latch that is never cleared, so the new ExtendsContentIntoTitleBar inference could not be withdrawn: a window that merely used to host a TitleBar stayed content-extended (and tall) for its lifetime. Split out _titleBarControlMounted for current mount state and added an unmount hook on both traversals (UnmountRecursive and the pooling UnmountAndCollect). The teardown latch is untouched -- issue #537 wants the conservative answer there. - The element's Imperative entry runs on every render, so the caption COM write and the control DP write fired even when nothing changed. Both are now dirty-checked. - The not-extended warning suggested rendering a TitleBar element even when one was already rendered and the spec was forcing the flag false. Message now branches on current mount state. - Dropped the GC.Collect/WaitForPendingFinalizers from fixture teardown; it was not part of the house CloseAndSettle pattern. Declined: the LINQ .Where() and generic/empty-catch findings target an idiom copied verbatim from Phase4WindowingFixtures.CloseAndSettle. Diverging in one file would fragment the pattern for no behavioural gain; added a comment explaining why the catch is intentionally best-effort. Co-authored-by: Copilot App <[email protected]> Copilot-Session: a36817d0-2008-4d82-a37b-974628bf463b
Review pass — all findings triagedWorking through the inline threads plus the four suppressed low-confidence comments (those have no thread to reply to, so covering them here). Three of the four were right, and one duplicated a gap my own pre-PR cross-check had flagged and I hadn't fixed. All fixes in 589136d.
#9 — the important oneFlagged as low confidence, but correct and the most consequential. Split into two flags rather than clearing the existing one — the latch also drives close-time teardown safety (issue #537), where the conservative "a control was mounted at some point" answer is the correct one and clearing it would risk reintroducing that heap corruption. A new Covered by a new fixture, #1 — worse than reportedThe reviewer said the hard-coded caption values would fail under scaling. They can also false-pass: at 150% a Standard caption measures 48px, exactly the hard-coded #8Confirmed real — the element's On #3 / #4 / #5These target Full unit suite (12,474) and the full selftest suite are green — the latter mattering more than usual, since the unmount hook now runs on every element teardown. |
Code-quality bot flagged the == comparison on FrameworkElement.Height, which is a double DP. Compare with a sub-pixel tolerance instead. NaN (the unset value) still falls through to the write, since every NaN comparison is false. Co-authored-by: Copilot App <[email protected]> Copilot-Session: a36817d0-2008-4d82-a37b-974628bf463b
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/Reactor/Core/Element.cs:4756
RegisterWindowTitleBarreturns early whenWindowSpec.ExtendsContentIntoTitleBaris explicitlyfalse, which also skips the newApplyTitleBarHeightOption(titleBar, element)call. That means aTitleBar(...).HeightOption(...)/.Tall()declaration (and even the control reference) never gets registered withReactorWindow, so if the window later becomes content-extended (e.g., the spec is updated tonull/true) the declarative height can’t be applied/resolved as described by the feature’s deferred-apply behavior.
Consider skipping only SetTitleBar(...) when the spec is explicitly false, but still letting the method continue so height option wiring and deferred application can work.
var explicitValue = owningWindow?.Spec.ExtendsContentIntoTitleBar;
if (explicitValue == false) return;
if (explicitValue is null)
host.Window.ExtendsContentIntoTitleBar = true;
host.Window.SetTitleBar(titleBar);
}
Two of the three findings I previously declined were declined on bad reasoning, so applying them: - .Where(): I claimed it would pull in a using System.Linq that no sibling fixture carries. Wrong on both counts -- ImplicitUsings is enabled for Reactor.AppTests.Host, so no directive is needed, and ten fixture files already use LINQ. - Empty catch: I argued logging would interleave with the TAP stream. True of Console.WriteLine, but DiagnosticLog.SwallowedError routes to the ETW EventSource (plus Debug.WriteLine in DEBUG), never Console -- and it is the product's own idiom for this exact swallowed-exception pattern, used by ReactorWindow throughout. The breadth of the catch itself is kept deliberately: this runs in a finally after the fixture's assertions, closing a window that may be mid-native teardown, and the WinUI TitleBar control throws teardown-reentry COMExceptions (issue #537). Enumerating specific types risks turning a passing fixture red for a reason unrelated to what it tests. Co-authored-by: Copilot App <[email protected]> Copilot-Session: a36817d0-2008-4d82-a37b-974628bf463b
…IP sizing Picks up two upstream window features and fixes two genuine bugs the empirical pass uncovered. Upstream parity: - WindowTitleBarHeight (microsoft#917/microsoft#925) lives in the Windows-only Hosting/WindowSpec.cs that this port replaces, but shared Element.cs/ElementExtensions.cs reference it, so the rebase broke the build. Declare the enum here and honour it for real: Uno implements AppWindowTitleBar.PreferredHeightOption (Standard 32 / Tall 48 / Collapsed 0). ReactorWindow gains the three members the shared TitleBar element and reconciler call -- SetElementTitleBarHeight, SyncTitleBarControlHeight, ClearTitleBarControl. - WindowSpec.Width/Height and the Run/RunAsync overloads become double? (microsoft#924), so a null axis defers to the OS instead of forcing 1024x768. Bug fixes: - AppWindow.Resize takes PHYSICAL PIXELS -- Uno's Win32 head hands the SizeInt32 straight to SetWindowPos -- but WindowSpec sizes are DIPs. Every window was undersized above 100% scale; a 480x360 request measured 320x240 DIP at 150%. Multiply by RasterizationScale, as Uno's own startup path does. Now measures 480x360. - OnContentAttached early-returned whenever the XamlRoot was null, and it always is on first call: Reactor assigns Window.Content from the dispatcher-queued render loop, while XamlRoot only appears once the element enters the live tree after Activate. `ReferenceEquals(null, null)` is true, so the window permanently skipped BOTH the initial resize and the XamlRoot.Changed subscription -- meaning live DPI tracking was silently dead. Re-arm on Loaded and apply once the root really exists. Also adds ReactorApp.CreateApplication<TRoot>() for native heads (Android Activity / iOS AppDelegate), which have no console Main and so cannot use Run. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017rs9N4ZH4ss5tDtBwBN1Go
Closes #917.
Adds
WindowTitleBarHeight { Standard, Tall, Collapsed }, surfaced asWindowSpec.TitleBarHeightandTitleBar(...).Tall()/.HeightOption(...).reactor-navviewtemplateThe diagnosis in #917 is wrong, and the fix here is not the fix the issue asked for. If you port the template by mechanically keeping the existing workaround and adding an API call, you will keep a line that never did anything.
#917 says the naive imperative write is clobbered by
TitleBar(...)'sExtendsContentIntoTitleBarinference running after the effect body, and that the dispatcher hop is what makes it stick. I measured this on a live window (100% scale,AppWindowTitleBar.Heightin px):TitleBarcontrolTitleBarelement, extended)PreferredHeightOption = TallUseEffect, no dispatcher hop.Height(48)only.Height(48)Rows 3 and 4 are identical. Nothing clobbers the value, and the dispatcher hop changes nothing. It is cargo cult — it "worked" because it was paired with the
.Height(48)the issue also mentions needing anyway, and that second line is what produced the visible change.The two real problems are:
TitleBarcontrol does not follow the caption. The caption grows to 48, the control stays 32. The property reads back asTalland the app looks near-identical — which is exactly the "succeeds but has no visual effect" symptom reported. Delaying the write never addressed this; pairing the two heights does, and that is what.Tall()applies.COMException 0x8007139F(ERROR_INVALID_STATE). So the write genuinely is order-sensitive, just not in the direction the issue describes: it must come after the extend flip, or it throws. Reactor now owns that ordering.Template migration
Delete the effect entirely.
.Tall()replaces both the hop and the.Height(48)— it sets the caption and the control together.Note the name differs from the issue's proposal: the enum is
WindowTitleBarHeight, notTitleBarHeightOption(that name is already taken byMicrosoft.UI.Windowing, and a Reactor-owned enum keeps the DSL from leaking a native type). Member names and ordering mirror the platform enum, pinned by a unit test.On the issue's secondary ask
Already true today; there was never a clobber to remove. The imperative escape hatch stays valid, with the one caveat that it throws if the window is not yet content-extended.
Behaviour
ExtendsContentIntoTitleBarflip — no ordering hazard for the app, and it can't hitERROR_INVALID_STATE.ExtendsContentIntoTitleBar— explicitWindowSpec.TitleBarHeightwins, the element's declaration is the fallback, neither means Reactor writes nothing (so an app settingPreferredHeightOptionimperatively keeps ownership). Removing a previously Reactor-applied value resets toStandard..Height(...)still wins over the implied 48, including when it is removed across renders.Standard.Drive-by fix
ReactorWindow.UpdatewroteExtendsContentIntoTitleBar = falsewhenever the spec value wasnull, silently dropping a mountedTitleBarelement's inference on any subsequent spec update. Nowspec.ExtendsContentIntoTitleBar ?? _titleBarControlPresent. Caught by a new fixture, not by inspection.Tests
tests/Reactor.Tests/TitleBarHeightTests.cs— headless: defaults, round-trips, differential isolation on.Tall(),.Tall(false) == Standard, enum-ordering parity with the platform enum, and reflection pins on the two control-height writers.tests/Reactor.AppTests.Host/SelfTest/Fixtures/TitleBarHeightFixtures.cs— 7 fixtures / 15 checks against real WinUI geometry. Every check is differential against a standard-caption baseline measured in the same run, so it fails if the apply path is removed. The not-extended fixture first proves the raw platform setter really does throw in that state, so it is testing the guard rather than a no-op.Full unit suite (12,469) and the full selftest suite both pass.
WindowLevel_RuntimeFlip_Topmostflaked once mid-run; reproduced with these changes reverted and green on re-run, so it is environmental.A multi-model cross-check on the first commit found three real gaps (spec-only
Updateleaving the mounted control stale, removing.Height(...)falling back to auto instead of 48, and one selftest that a no-op implementation could pass). All three are fixed in the second commit with fixtures covering them.Docs
docs/guide/windows.md(regenerated fromdocs/_pipeline/templates/windows.md.dt),skills/windowing.md, andplugins/reactor/skills/reactor-windowing/SKILL.mdall gained a "Tall title bar" section describing the new API.The migration note retiring the dispatcher hop lives only in the user guide, deliberately — the skills are per-session context budget, and a one-time migration for a preview API doesn't earn permanent tokens there. The correction is also posted as a comment on #917 itself, which is what a template port is most likely to be working from.