Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
df43a44
Fix TeachingTip declared IsOpen: true on first render never opening (…
azchohfi Jul 31, 2026
0e1814e
Address pr-review findings on the TeachingTip mount-open fix
azchohfi Jul 31, 2026
5a16f79
Merge remote-tracking branch 'origin/main' into azchohfi-congenial-go…
azchohfi Jul 31, 2026
02c3270
Drop the reload-after-native-dismiss selftest as flaky and redundant
azchohfi Jul 31, 2026
0e147ae
Trim the TeachingTip selftest's wall-clock cost to fit the process cap
azchohfi Jul 31, 2026
2d953e8
Make the Title Only gallery snippet name the state it actually uses
azchohfi Jul 31, 2026
adc4e71
Cover the two gaps a re-review found in the final branch state
azchohfi Jul 31, 2026
1820dc8
Prove the barren-probe precondition instead of mirroring NeedsTag
azchohfi Jul 31, 2026
09d5585
Fix CS0108 in the new selftest fixture (Release-only build break)
azchohfi Jul 31, 2026
b6d2243
Merge remote-tracking branch 'origin/main' into azchohfi-congenial-go…
azchohfi Jul 31, 2026
bd9065f
Merge remote-tracking branch 'origin/main' into azchohfi-congenial-go…
azchohfi Jul 31, 2026
276b58b
Merge remote-tracking branch 'origin/main' into azchohfi-congenial-go…
azchohfi Jul 31, 2026
3c497a2
Make an unmeasurable popup count fail loudly instead of reading as zero
azchohfi Jul 31, 2026
3c0623a
Merge remote-tracking branch 'origin/main' into azchohfi-congenial-go…
azchohfi Jul 31, 2026
6bd81a7
Merge remote-tracking branch 'origin/main' into azchohfi-congenial-go…
azchohfi Aug 1, 2026
1771c37
Name every mount guard after the sub-fixture it guards
azchohfi Aug 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ Conventions for contributors:
owners the pool does not clear (`Canvas`, `ScrollViewer`, `Grid`) are
unaffected.

- **`ControlDescriptor.OnUnmount` / `.WithUnmount(...)` — descriptor teardown hook
(spec 047 §6, issue #949).** The engine already dispatched unmount to hand-coded
`IElementHandler` implementations, but `DescriptorHandler` never forwarded it, so
descriptor authors had no teardown seam at all. A descriptor can now declare
`.WithUnmount((in UnmountContext ctx, TControl c) => ...)` to invalidate
control-scoped state the pool reset contract cannot see — a pending deferred
write, a one-shot lifecycle subscription, a disposable. It is not for event
trampolines, which anchor to the control's lifetime by design. Declaring the hook
makes the handler force the control's `ReactorState` into existence at mount,
because the engine's unmount dispatch is tag-gated; without that the hook would
fire for callback-bearing elements of a type and silently not for callback-free
ones.

### Changed

- **`WithNavigation` gained an optional `settingsRoute` argument (binary-breaking,
Expand All @@ -125,6 +138,23 @@ Conventions for contributors:

### Fixed

- **`TeachingTip` declared `IsOpen: true` on its first render now actually opens
(issue #949).** The mount-time write was issued and then silently dropped: WinUI
only holds a pending open on an *unparented* `TeachingTip` while nothing else is
written to it, and Reactor — like XAML — fully configures a control before handing
it to its parent, so the later prop entries, setters, content slots and common
modifiers all discarded it. Ordering the entry last was not enough, because most of
those writes happen outside the descriptor. `IsOpen` is now a bespoke descriptor
entry that defers a mount-time `true` to the control's `Loaded` event, the first
moment the tip is parented into a live tree. Post-mount edges are unchanged and
stay edge-triggered, so a re-render carrying the same declared `true` still does
not re-assert against a natively dismissed tip. One consequence worth knowing: a
`.Set(t => t.IsOpen = false)` can no longer override a declared mount-time `true`,
because the deferred write lands after the setter pass — declare the value instead.
The gallery's "TeachingTip (Title Only)" card, which declared a tip with no
`IsOpen` and no trigger and so could never appear, now uses the state-driven shape
its sibling card already used.

- **Unsetting a common modifier no longer permanently overrides the control's
style (issue #952).** `Reconciler.ApplyModifiers` reset a dropped modifier by
*assigning* the dependency property's default value (`fe.Margin =
Expand Down
38 changes: 36 additions & 2 deletions docs/_pipeline/templates/extending-reactor-controls.md.dt
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,37 @@ So, when wrapping a control of your own with a self-mutating property:
equals the value the control rests at after the user acts. A plain
`bool` defaulting to the "showing" state fails both tests.

#### Mount is not an edge — and a few controls need parenting first

Edge semantics describe the *steady state*. At mount there is no previous
element, so the declared value is always written. What can still go wrong
is *when*: Reactor configures a control fully before its parent takes it,
and a handful of WinUI controls quietly discard a state change made while
they are unparented.

`TeachingTip` is the built-in that does. An unparented tip holds a pending
open only while nothing else is written to it, and a mount always writes
something afterwards — later prop entries, setters, content slots, common
modifiers. Ordering the entry last does not help, because most of those
writes happen outside the descriptor. So its `IsOpen` entry defers a
mount-time `true` to the control's `Loaded` event, the first moment the
tip is parented into a live tree and an open is guaranteed to stick (issue
949). Post-mount edges are unaffected: by then the control is loaded and
the write goes straight through.

If a control you are wrapping only presents once it is in a live tree, use
the same shape — an `.Imperative` entry that defers to `Loaded`, paired
with `.WithUnmount(...)` so the pending write is dropped if the control
leaves the tree first, and a falling edge that arrives meanwhile disarms
it — rather than trusting mount ordering.

`.WithUnmount(...)` is the descriptor's teardown seam in general: the
engine already dispatched unmount to hand-coded handlers, and this
surfaces the same hook to descriptor authors. Reach for it only for state
the pool reset contract cannot see — a pending deferred write, a one-shot
lifecycle subscription, a disposable. It is explicitly *not* for event
trampolines, which anchor to the control's lifetime by design.

### Reference properties

Use reference entries when a native control property points at another
Expand Down Expand Up @@ -339,8 +370,11 @@ trampoline slot on the typed event-payload box, and the next Mount
finds an empty slot and re-subscribes. Writing a real unsubscribe
into the lambda double-frees the subscription when the control pools
and is the most common source of "the event stops firing after a
re-render" bugs. If your control genuinely needs explicit unsubscribe
on unmount, override `IElementHandler.Unmount` and tear down there.
re-render" bugs. If your control genuinely needs explicit teardown on
unmount — a pending deferred write, a one-shot lifecycle subscription,
a disposable — declare `.WithUnmount(...)` on the descriptor. Reach for
a hand-coded `IElementHandler.Unmount` only when you also need to
control the unmount disposition or to see the element.
<!-- /ai:caveat -->

## Step 4 — Wire events (the non-DP case)
Expand Down
38 changes: 36 additions & 2 deletions docs/guide/extending-reactor-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,37 @@ So, when wrapping a control of your own with a self-mutating property:
equals the value the control rests at after the user acts. A plain
`bool` defaulting to the "showing" state fails both tests.

#### Mount is not an edge — and a few controls need parenting first

Edge semantics describe the *steady state*. At mount there is no previous
element, so the declared value is always written. What can still go wrong
is *when*: Reactor configures a control fully before its parent takes it,
and a handful of WinUI controls quietly discard a state change made while
they are unparented.

`TeachingTip` is the built-in that does. An unparented tip holds a pending
open only while nothing else is written to it, and a mount always writes
something afterwards — later prop entries, setters, content slots, common
modifiers. Ordering the entry last does not help, because most of those
writes happen outside the descriptor. So its `IsOpen` entry defers a
mount-time `true` to the control's `Loaded` event, the first moment the
tip is parented into a live tree and an open is guaranteed to stick (issue
949). Post-mount edges are unaffected: by then the control is loaded and
the write goes straight through.

If a control you are wrapping only presents once it is in a live tree, use
the same shape — an `.Imperative` entry that defers to `Loaded`, paired
with `.WithUnmount(...)` so the pending write is dropped if the control
leaves the tree first, and a falling edge that arrives meanwhile disarms
it — rather than trusting mount ordering.

`.WithUnmount(...)` is the descriptor's teardown seam in general: the
engine already dispatched unmount to hand-coded handlers, and this
surfaces the same hook to descriptor authors. Reach for it only for state
the pool reset contract cannot see — a pending deferred write, a one-shot
lifecycle subscription, a disposable. It is explicitly *not* for event
trampolines, which anchor to the control's lifetime by design.

### Reference properties

Use reference entries when a native control property points at another
Expand Down Expand Up @@ -391,8 +422,11 @@ dispatch cost for that prop stays at zero.
> finds an empty slot and re-subscribes. Writing a real unsubscribe
> into the lambda double-frees the subscription when the control pools
> and is the most common source of "the event stops firing after a
> re-render" bugs. If your control genuinely needs explicit unsubscribe
> on unmount, override `IElementHandler.Unmount` and tear down there.
> re-render" bugs. If your control genuinely needs explicit teardown on
> unmount — a pending deferred write, a one-shot lifecycle subscription,
> a disposable — declare `.WithUnmount(...)` on the descriptor. Reach for
> a hand-coded `IElementHandler.Unmount` only when you also need to
> control the unmount disposition or to see the element.

## Step 4 — Wire events (the non-DP case)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,7 @@ T DefaultValue { get; }
new()
AfterChildrenMountCallback<TElement, TControl> AfterChildrenMount { get; init; }
ChildrenStrategy<TElement, TControl> Children { get; set; }
DescriptorUnmountCallback<TControl> OnUnmount { get; init; }
Func<TControl> Factory { get; init; }
Func<TElement, Action<TControl>[]> GetSetters { get; init; }
IReadOnlyList<PropEntry<TElement, TControl>> Properties { get; }
Expand All @@ -1798,6 +1799,7 @@ Reference(Func<TElement, ElementRef> get, Action<TControl, FrameworkElement> set
Reference<TTarget>(Func<TElement, ElementRef<TTarget>> get, Action<TControl, TTarget> set) → ControlDescriptor<TElement, TControl>
ReferenceList<TTarget>(Func<TElement, IReadOnlyList<ElementRef<TTarget>>> get, Action<TControl, IReadOnlyList<TTarget>> apply) → ControlDescriptor<TElement, TControl>
WithAfterChildrenMount(AfterChildrenMountCallback<TElement, TControl> callback) → ControlDescriptor<TElement, TControl>
WithUnmount(DescriptorUnmountCallback<TControl> callback) → ControlDescriptor<TElement, TControl>

### static class ControlRegistry
Register<TElement, TControl>(Func<IElementHandler<TElement, TControl>> handlerFactory) → void
Expand Down Expand Up @@ -1905,6 +1907,7 @@ ChildrenStrategy<TElement, TControl> ChildrenForUnmount { get; }
ControlDescriptor<TElement, TControl> Descriptor { get; }
AfterChildrenMount(MountContext ctx, TElement element, TControl control) → void
Mount(MountContext ctx, TElement el) → TControl
Unmount(UnmountContext ctx, TControl control) → void
Update(UpdateContext ctx, TElement oldEl, TElement newEl, TControl ctrl) → void

### record DevtoolsCliOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TeachingTipPage : Component
public override Element Render()
{
var (showTip, setShowTip) = UseState(false);
var (showTitleOnlyTip, setShowTitleOnlyTip) = UseState(false);
var (showTargetedTip, setShowTargetedTip) = UseState(false);
var crossContainerTarget = this.UseElementRef<FrameworkElement>();

Expand All @@ -37,8 +38,19 @@ public override Element Render()
}"),

SampleCard("TeachingTip (Title Only)",
TeachingTip("Did you know?", "You can customize the title bar!"),
@"TeachingTip(""Did you know?"", ""You can customize the title bar!"")"),
VStack(8,
Button("Show title-only tip", () => setShowTitleOnlyTip(true)),
(TeachingTip("Did you know you can customize the title bar?") with
{
IsOpen = showTitleOnlyTip,
OnClosed = () => setShowTitleOnlyTip(false),
})
),
@"Button(""Show title-only tip"", () => setShowTitleOnlyTip(true)),
TeachingTip(""Did you know you can customize the title bar?"") with {
IsOpen = showTitleOnlyTip,
OnClosed = () => setShowTitleOnlyTip(false),
}"),

SampleCard("TeachingTip targeting another subtree",
HStack(16,
Expand Down
3 changes: 3 additions & 0 deletions skills/reactor.api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,7 @@ T DefaultValue { get; }
new()
AfterChildrenMountCallback<TElement, TControl> AfterChildrenMount { get; init; }
ChildrenStrategy<TElement, TControl> Children { get; set; }
DescriptorUnmountCallback<TControl> OnUnmount { get; init; }
Func<TControl> Factory { get; init; }
Func<TElement, Action<TControl>[]> GetSetters { get; init; }
IReadOnlyList<PropEntry<TElement, TControl>> Properties { get; }
Expand All @@ -1798,6 +1799,7 @@ Reference(Func<TElement, ElementRef> get, Action<TControl, FrameworkElement> set
Reference<TTarget>(Func<TElement, ElementRef<TTarget>> get, Action<TControl, TTarget> set) → ControlDescriptor<TElement, TControl>
ReferenceList<TTarget>(Func<TElement, IReadOnlyList<ElementRef<TTarget>>> get, Action<TControl, IReadOnlyList<TTarget>> apply) → ControlDescriptor<TElement, TControl>
WithAfterChildrenMount(AfterChildrenMountCallback<TElement, TControl> callback) → ControlDescriptor<TElement, TControl>
WithUnmount(DescriptorUnmountCallback<TControl> callback) → ControlDescriptor<TElement, TControl>

### static class ControlRegistry
Register<TElement, TControl>(Func<IElementHandler<TElement, TControl>> handlerFactory) → void
Expand Down Expand Up @@ -1905,6 +1907,7 @@ ChildrenStrategy<TElement, TControl> ChildrenForUnmount { get; }
ControlDescriptor<TElement, TControl> Descriptor { get; }
AfterChildrenMount(MountContext ctx, TElement element, TControl control) → void
Mount(MountContext ctx, TElement el) → TControl
Unmount(UnmountContext ctx, TControl control) → void
Update(UpdateContext ctx, TElement oldEl, TElement newEl, TControl ctrl) → void

### record DevtoolsCliOptions
Expand Down
Loading