Skip to content

Document and test the edge-triggered contract for native-mutated declared bools (R7) - #940

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 6 commits into
mainfrom
azchohfi-fix-infobar-isopen-drift
Jul 30, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 6 commits into
mainfrom
azchohfi-fix-infobar-isopen-drift

Conversation

@azchohfi

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

Copy link
Copy Markdown
Collaborator

TL;DR

R7 as written is overstated — I could not reproduce it, so this PR ships no behaviour change.
A natively-dismissed InfoBar does recover: a declared false → true transition re-opens it. What
was actually missing is a stated rule and a test that pins it. This PR adds both, plus an
audit of a real inconsistency the investigation uncovered.

Rebased onto main after #930 merged. The diff is purely additive — 512 insertions, 0 deletions.
No existing assertion, allowlist or guard was touched, weakened, or relaxed.


Symptom as reported

R7 — InfoBar.IsOpen drifts after a native close and never recovers

The user closes an InfoBar with its built-in ✕. WinUI sets IsOpen = false on the control.
Reactor's declared IsOpen is still true, so on the next render old == new and the updater
skips the write — the bar can never be shown again without remounting.

The ask was to treat InfoBar.IsOpen as a controlled property: when the declared value is true
and the live control has drifted to false, re-assert it on the next render.

Root cause — accurate version

InfoBarElement.IsOpen is a generator-auto-mapped OneWay prop. OneWayPropEntry.Update
diffs old element vs new element, never the live control:

var nv = _get(newEl);
if (!_comparer.Equals(_get(oldEl), nv)) _set(ctrl, nv);

That much is true. But the conclusion drawn from it is not — with declared false → true the
comparison is unequal, so it does write. I confirmed the code path is unobstructed:

  • InfoBarElement has no arm in Element.ShallowEquals's switch (falls to _ => false), so
    Reconciler.Update's shallow-skip arm never fires for it.
  • DescriptorHandler.Update has no entry-level skip; props[i].Update(...) always runs.

Evidence — I ran this, against a real WinUI InfoBar

Throwaway selftest fixture, since deleted. Stable across 4 runs:

Step declared live after OnClosed count
A mount true True 0
B native ✕ (bar.IsOpen = false) true False 1
C re-render, same declared true False 1
D true → false false False 1
E false → true true True 1

Row E is the recovery R7 says is impossible. Row C — the only non-recovering case — is the
defined behaviour of an edge-triggered value, not a bug.

The rule this PR writes down

A declared bool that the native control can also mutate is edge-triggered: the element
declares a transition, not a mirror. Reactor writes the control only when the declared value
changes. Wire the control's change callback (OnClosed / OnPaneOpenChanged) to keep app state
in sync with a native dismissal.

Why I did not implement the requested fix

I planned it (a ReassertingOneWayPropEntry + a public ControlDescriptor.ReassertingOneWay(...)),
then withdrew it. InfoBarElement.IsOpen, SplitViewElement.IsPaneOpen and
NavigationViewElement.IsPaneOpen all default to true. Live re-assert would make every one of
them written without a change callback undismissable — the user dismisses, and the next unrelated
setState anywhere in that component brings it back. That is a worse, more visible regression than
the reported bug, and it would land on every existing caller.

"It's the React controlled-input contract" is a fair principle, but it does not survive a default of
true.

What changed

File Change
src/Reactor/Core/Element.cs XML doc on InfoBarElement.IsOpen, TeachingTipElement.IsOpen, SplitViewElement.IsPaneOpen, NavigationViewElement.IsPaneOpen (+ InfoBarElement.IsClosable). Doc comments only.
docs/_pipeline/templates/extending-reactor-controls.md.dt New "Values the native control mutates on its own" section
docs/guide/extending-reactor-controls.md Regenerated via mur docs compile --pages extending-reactor-controls
tests/Reactor.AppTests.Host/SelfTest/Fixtures/IsOpenEdgeTriggeredFixtures.cs New selftests against real InfoBar / TeachingTip
tests/Reactor.AppTests.Host/SelfTest/SelfTestFixtureRegistry.cs Registration (both AllFixtures and the Create() switch)
tests/Reactor.Tests/InfoBarIsOpenEdgeTriggeredTests.cs New headless descriptor-wiring guards

mur --regen-api reports reactor.api.txt unchanged for both skills/reactor.api.txt and its
plugins/reactor/... mirror — no public API surface change.

Tests

The two failure modes point in opposite directions, so both halves are pinned:

  • RisingEdgeReopens fails if the rising-edge write is ever lost — the recovery path.
  • SameDeclaredValueDoesNotReopen fails if the engine is ever changed to re-assert against the
    live control — a standing guard against exactly the regression described above.

Proof they are not vacuous — verbatim output

There is no product change here, so the usual "revert the fix, watch the test fail" does not apply.
I mutation-tested instead. All three mutations re-run after the rebase; all reverted afterwards
(git diff HEAD -- src/ is empty).

Baseline (unmutated): # Total failures: 0 — 9 InfoBar + 5 TeachingTip assertions pass.

MUTATION-1 — OneWayPropEntry.Update never writes:

not ok IsOpenEdge_InfoBar_RisingEdgeReopens - assertion failed
not ok IsOpenEdge_InfoBar_ProgrammaticCloseClosesOpenControl - assertion failed
not ok IsOpenEdge_TeachingTip_RisingEdgeOpens - assertion failed
not ok IsOpenEdge_TeachingTip_RisingEdgeReopensAfterDismiss - assertion failed
# Total failures: 4

MUTATION-2 — OneWayPropEntry.Update always writes (i.e. the re-assert "fix" R7 asked for):

not ok IsOpenEdge_InfoBar_SameDeclaredValueDoesNotReopen - assertion failed
not ok IsOpenEdge_InfoBar_FallingEdgeOnClosedControlRaisesNoCallback - assertion failed
not ok IsOpenEdge_InfoBar_RisingEdgeRaisesNoCallback - assertion failed
not ok IsOpenEdge_TeachingTip_SameDeclaredValueDoesNotReopen - assertion failed
# Total failures: 4

MUTATION-3 — InfoBarElement.IsOpen default flipped to false:

InfoBarIsOpenEdgeTriggeredTests.IsOpen_IsBoundThroughAPlainOneWayEntry [FAIL]
InfoBarIsOpenEdgeTriggeredTests.IsOpenEntry_CannotObserveTheLiveControl [FAIL]
InfoBarIsOpenEdgeTriggeredTests.IsOpen_DefaultsToTrue [FAIL]
Failed!  - Failed: 3, Passed: 0, Skipped: 0, Total: 3

The two mutations fail disjoint assertion sets, which is the point: neither direction of
regression can slip through.

The "always writes" mutation earned its keep: it caught a vacuity bug in my own first draft. I
had passed the same element instance as both old and new to rec.UpdateChild, and
Element.ShallowEquals opens with if (ReferenceEquals(a, b)) return true; — so the entire update
was skipped and the assertions passed for the wrong reason. Fixed by constructing a fresh element
per simulated render, which is what a real render loop does.

Audit — Reactor has three different rules here, not one

Found while verifying the above. Reported, not fixed.

Prop Element default Update rule Where
Expander.IsExpanded Optional<bool> unset live re-assert ExpanderHandler.cs:50
Popup.IsOpen false live re-assert OverlayLifecycle.cs:401
InfoBar.IsOpen true edge, both directions auto OneWay
TeachingTip.IsOpen false edge, both directions auto OneWay
SplitView.IsPaneOpen true edge, both directions auto OneWay
NavigationView.IsPaneOpen true edge, both directions auto OneWay
ContentDialog.IsOpen false rising edge only — no falling edge OverlayLifecycle.cs:48
Flyout.IsOpen false rising edge only — no falling edge OverlayLifecycle.cs:215

The two re-asserting rows are defensible and the docs now say why: Expander is Optional<bool> so
authority is opt-in, and Popup defaults to false, which is also where a light-dismissed popup
rests — so its re-assert is a no-op in the direction that would fight the user.

Two genuine defects fall out of this table, both left for separate PRs:

  1. ContentDialog.IsOpen / Flyout.IsOpen have no falling edge. Declaring IsOpen = false
    does not close them — the update only handles n.IsOpen && !o.IsOpen.
  2. A Reactor-mounted TeachingTip never actually presents. Declaring IsOpen: true on the
    first render leaves it closed, and even after a rising edge that flips the property, WinUI raises
    no Closed event on the way back down — while an identically-parented raw
    WinUI.TeachingTip does present and does raise Closed. This likely affects the gallery's
    TeachingTip page. This is also why TeachingTipEdgeTriggered has no OnClosed oracle: a callback
    count there would assert the absence of that presentation defect rather than the edge contract.
    The fixture's doc comment records this.

Note for the gallery fix (sibling session)

The gallery's Reset button needs the OnClosed wiring and something more:
setShowClosable(true) when the value is already true never re-renders at all —
RenderContext.MakeStateSetter bails on an equal value. The framework change alone would not have
fixed that button.

Validation

Re-run after rebasing onto main (post-#930):

  • dotnet build Reactor.slnx — 0 errors
  • dotnet test tests/Reactor.Tests — Failed: 0, Passed: 12527, Skipped: 64, Total: 12591
  • targeted selftests — # Total failures: 0
  • dotnet test tests/Reactor.SelfTests — 2 failures, identical to the origin/main baseline
    measured on the same machine by reverting to a clean tree (BackdropTransparent_Apply + a fixture
    timeout); BackdropTransparent_Apply passes in isolation, so it is order/timing dependent and
    pre-existing, not from this branch
  • mur docs compile --validate-only — validation passed; unrelated drifted snippet churn in
    docs/guide/architecture-overview.md (regenerated from PR [Bug] Got error message when click expand item in Reactor.TestApp #919's source) was reverted so it is
    not in this diff
  • .github/skills/pr-review across all 8 dimensions on the final commit: 2 findings, both fixed
    (commits 2 and 3). Multi-model cross-check (GPT-5.4, high reasoning) returned 0 findings and
    independently confirmed the core judgement.

One red Selftests run in this PR's history — proven flake

Commit 273864e3 initially failed Selftests on Issue717_PinReleaseDoesNotClobberAuthorMinHeight.
That is not one of this PR's fixtures. Four independent pieces of evidence, rather than an assertion:

  1. Selftests was green on the immediately preceding head 4f1eee88.
  2. The only difference between those two commits is
    tests/Reactor.Tests/InfoBarIsOpenEdgeTriggeredTests.cs — a headless xUnit file that
    Reactor.AppTests.Host.csproj does not reference, so the selftest host never compiles it.
  3. The fixture passes 3/3 locally on the failing commit.
  4. Re-running the job unchanged on the identical commit went green.

Merge-ordering

No constraint. This PR adds no analyzer rule and changes no behaviour, so it cannot trip the
Release TreatWarningsAsErrors gate that #932 introduces.

Open question for the reviewer

If you'd rather have the behaviour change anyway, the safe version is not live re-assert — it is
migrating these four props to Optional<bool> so authority is opt-in, which is a breaking change to
their defaults and deserves its own spec.

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 clarifies Reactor’s intended contract for “native-mutated declared bool” properties (notably InfoBar.IsOpen): these are edge-triggered (writes occur only on declared value transitions), and callers must wire the native change callback back into state for recoverability. It adds documentation and test coverage to lock that behavior in, without changing runtime behavior.

Changes:

  • Added XML documentation on affected element properties (InfoBar.IsOpen, TeachingTip.IsOpen, SplitView.IsPaneOpen, NavigationView.IsPaneOpen) describing the edge-triggered contract and the required callback wiring.
  • Added a new “Values the native control mutates on its own” section to the extending-controls guide (template + regenerated guide output).
  • Added new selftest fixtures (InfoBar + TeachingTip) and a new headless unit test to pin descriptor wiring assumptions.

Reviewed changes

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

Show a summary per file
File Description
src/Reactor/Core/Element.cs Adds XML docs describing the edge-triggered contract and state-sync guidance for self-mutating bool props.
docs/_pipeline/templates/extending-reactor-controls.md.dt Adds the new guide section explaining edge-triggered vs re-asserting behavior and when each is appropriate.
docs/guide/extending-reactor-controls.md Regenerated guide output reflecting the new template section.
tests/Reactor.AppTests.Host/SelfTest/Fixtures/IsOpenEdgeTriggeredFixtures.cs Adds live-control selftests asserting both halves of the edge-triggered contract for InfoBar/TeachingTip.
tests/Reactor.AppTests.Host/SelfTest/SelfTestFixtureRegistry.cs Registers the new selftest fixtures in both the list and the factory switch.
tests/Reactor.Tests/InfoBarIsOpenEdgeTriggeredTests.cs Adds headless tests that verify InfoBar.IsOpen remains bound via a plain one-way descriptor entry and retains its default.

💡 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 184bf5c vs the base branch (3bd7dfa).

Packages (compressed .nupkg)

Artifact base PR Δ
Microsoft.UI.Reactor.nupkg 1.56 MB 1.56 MB +555 B (+0.03%) ≈
Microsoft.UI.Reactor.Advanced.nupkg 473.9 KB 473.9 KB +0 B (0.00%) ≈
Microsoft.UI.Reactor.Devtools.nupkg 278.2 KB 278.2 KB +0 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 1012.5 KB 1012.5 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 29, 2026 •

Copy link
Copy Markdown
Contributor

🧪 Merged coverage

Coverage for 184bf5c vs the base branch (2117320) — unit + selftest merged.

Metric base PR Δ
Line 85.64% 85.67% +0.03 pp ≈
Branch 77.10% (899/1166) 77.02% (898/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.

…ared bools

R7 reported that InfoBar.IsOpen `can never be shown again` after the user
dismisses the bar with its built-in close button. Empirically that is not
true: a declared false -> true transition re-opens it. What is missing is a
stated rule and a test that pins it.

Adds:
- XML doc on InfoBarElement.IsOpen, TeachingTipElement.IsOpen,
  SplitViewElement.IsPaneOpen and NavigationViewElement.IsPaneOpen recording
  that these are edge-triggered and that the change callback is the sync channel.
- A `values the native control mutates on its own` section in the
  extending-reactor-controls guide template (+ recompiled page).
- IsOpenEdgeTriggeredFixtures selftests pinning both halves of the contract.
- InfoBarIsOpenEdgeTriggeredTests headless guards on the descriptor wiring.

No behaviour change.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3a974fbd-1bad-4634-860f-3261f28a9ff9
…xture honestly

Two findings from the pr-review skill:

- alternative-solution (low): the guide told custom-control authors to always
  keep a self-mutating property on .OneWay, which contradicts Expander.IsExpanded
  and Popup.IsOpen (both re-assert against the live control). Narrowed the advice
  and spelled out the two conditions that make re-asserting safe: opt-in authority
  via Optional<T>, or an element default equal to the control's resting value.

- test-coverage (medium): TeachingTipEdgeTriggered had no OnClosed oracle. While
  adding one I found WinUI raises no Closed event for a Reactor-mounted
  TeachingTip at all, because it never actually presents (an identically parented
  raw WinUI.TeachingTip does). A callback count there would assert the absence of
  that presentation defect rather than the edge contract, so the fixture stays at
  the IsOpen property level and its doc comment records why. The presentation
  defect is reported separately.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3a974fbd-1bad-4634-860f-3261f28a9ff9
The multi-model cross-check flagged that TeachingTipEdgeTriggered unmounted
while the tip was still declared open. Harmless today because a Reactor-mounted
TeachingTip never actually presents, but it would leave a live overlay for the
next fixture in the shared selftest host once that defect is fixed.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3a974fbd-1bad-4634-860f-3261f28a9ff9
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

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

Comments suppressed due to low confidence (1)

tests/Reactor.Tests/InfoBarIsOpenEdgeTriggeredTests.cs:117

  • InstanceFieldNames() only inspects fields declared on the concrete entry type. If a future refactor moves _readBack/_dp into a non-public base type (or an intermediate helper), this test can start passing while the entry can still observe live control state, defeating the intended guard. Consider walking the base-type chain and collecting DeclaredOnly instance fields at each level.
    private static IReadOnlyCollection<string> InstanceFieldNames(Type type)
        => type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
               .Select(f => f.Name)
               .ToList();

Copilot flagged this as a low-confidence comment and it was right.
BindingFlags.NonPublic does not return private fields declared on BASE types,
so InstanceFieldNames only saw the concrete entry. If a refactor moved
_readBack into a base class, IsOpenEntry_CannotObserveTheLiveControl would
have started passing while the entry could still observe live control state —
the guard would have gone quiet exactly when it mattered.

Now walks Type.BaseType collecting DeclaredOnly fields at each level. Needed a
second UnconditionalSuppressMessage (IL2075) because the trim analyzer cannot
annotate Type.BaseType; same test-only pattern as RichTextBlockDescriptorTests.

Re-verified the guard still bites: with InfoBarElement.IsOpen flipped to false
all 3 facts fail; restored, all 3 pass.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3a974fbd-1bad-4634-860f-3261f28a9ff9
Copilot AI review requested due to automatic review settings July 30, 2026 00: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 6 out of 6 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

tests/Reactor.Tests/InfoBarIsOpenEdgeTriggeredTests.cs:142

  • GetPrivateField() only searches the concrete runtime type. If the descriptor entry implementation later moves a private field (like _get) into a base type, this helper returns null and the “locates by behaviour” test will start failing for a refactor that doesn’t change the contract. Walking the type hierarchy here would make the guard more resilient (and consistent with InstanceFieldNames()).
    [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Test-only: reflects a known non-public field on a concrete descriptor entry. JIT-only (this host is never trimmed) and behaviour-neutral.")]
    private static object? GetPrivateField(object owner, string name)
        => owner.GetType()
                .GetField(name, BindingFlags.Instance | BindingFlags.NonPublic)
                ?.GetValue(owner);

Second suppressed low-confidence comment from Copilot's review body, and it is
right for the same reason the first one was — but pointing the other way.

GetPrivateField used a single-level GetField(Instance | NonPublic), which does
not walk the hierarchy (and BindingFlags.FlattenHierarchy does not help: it is
documented not to apply to private fields). Moving _get into a base type would
have made FindIsOpenEntry match nothing and turned the test red for a refactor
that changed no contract. A guard that cries wolf on a behaviour-preserving
refactor is how guards get weakened, which is the opposite of this PR's point.

Now walks Type.BaseType with DeclaredOnly, consistent with InstanceFieldNames.
The widening cannot mask a real regression: the entry is still identified by
BEHAVIOUR (reads IsOpen, not IsClosable), a miss returns null and the
Assert.Single still fails loudly.

Adds ReflectionHelpers_FindPrivateFieldsDeclaredOnABaseType so the hierarchy
walk cannot be silently reverted. Mutation-checked: reverting GetPrivateField
to the single-level form fails exactly that test and nothing else; flipping
InfoBarElement.IsOpen to false still fails the 3 contract guards.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 3a974fbd-1bad-4634-860f-3261f28a9ff9
Copilot AI review requested due to automatic review settings July 30, 2026 01:12
@azchohfi

Copy link
Copy Markdown
Collaborator Author

Addressing the suppressed low-confidence review comment (InfoBarIsOpenEdgeTriggeredTests.cs:142)

Copilot's review body reported "generated no new comments" but carried a collapsed
Comments suppressed due to low confidence (1) block, which does not appear in the
pulls/940/comments API. Replying here since a suppressed block cannot be replied to inline.

GetPrivateField() only searches the concrete runtime type. If the descriptor entry
implementation later moves a private field (like _get) into a base type, this helper
returns null and the "locates by behaviour" test will start failing for a refactor that
doesn't change the contract.

Taken — it was right, and it matters more here than usual. This PR's whole argument is
that you pin semantics so a future refactor cannot silently break them. A guard that goes
red on a behaviour-preserving refactor is the opposite failure: it cries wolf, and
crying-wolf guards are how allowlists and assertions get weakened.

GetField(name, Instance | NonPublic) does not walk the hierarchy, and
BindingFlags.FlattenHierarchy does not help — it is documented not to apply to private
fields — so an explicit BaseType walk is the reliable form. Now consistent with
InstanceFieldNames(), which I fixed for the mirror-image reason in 273864e3 (that one
could have gone silently green; this one would have gone falsely red).

The widening cannot mask a real regression. The entry is still identified by
behaviour — it must read IsOpen and not IsClosable — and a miss returns null,
so ReadsIsOpen returns false and the Assert.Single in FindIsOpenEntry still fails
loudly. Fail-loud, not fail-silent.

Added ReflectionHelpers_FindPrivateFieldsDeclaredOnABaseType so the hierarchy walk cannot
be quietly reverted, using a local type whose private field is declared on the base — the
exact shape a future descriptor refactor would produce.

Mutation-checked, per the "make sure it still fails" bar:

Mutation Result
GetPrivateField reverted to single-level only ReflectionHelpers_FindPrivateFieldsDeclaredOnABaseType fails
InfoBarElement.IsOpen default flipped to false the 3 contract guards still fail; the helper test correctly still passes

Full unit suite green: Failed: 0, Passed: 12528.

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

@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit 113dd39 into main Jul 30, 2026
21 checks passed
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) deleted the azchohfi-fix-infobar-isopen-drift branch July 30, 2026 03:46
Ed-bb pushed a commit to Ed-bb/microsoft-ui-reactor.fork that referenced this pull request Aug 2, 2026
…icrosoft#949)

A `TeachingTip` whose first render declared `IsOpen: true` never presented.
The mount-time write *was* issued — `OneWayPropEntry.Mount` writes
unconditionally — and then silently lost.

Root cause: Reactor configures a control fully before its parent takes it.
On an UNPARENTED `TeachingTip`, WinUI discards a pending open as soon as
anything else is written to the control; parented, it is harmless. So the
declared open was always thrown away by a later write:

    DescriptorHandler.Mount   prop loop (IsOpen), EnsureSubscribed, ApplySetters
    V1HandlerAdapter.Mount    Content/HeroContent slots, AfterChildrenMount
    Reconciler.Mount          ApplyModifiers (Margin, ...)
       ...caller adds the control to its parent   <-- parenting is LAST

Ordering the entry last inside the descriptor is not enough: setters, the
content slots and common modifiers all run outside the descriptor's reach.
Measurement pinned `PreferredPlacement` as the write that discards it,
matching the descriptor bisect in the issue.

The fix takes `IsOpen` off the generator's auto-map (`[WrapManual]`) and
routes it through a bespoke `.Imperative` entry backed by a new
`MountOpenDeferral` helper. A declared `true` is deferred to the control's
`Loaded` event — the first moment the tip is parented into a live tree and
an open is guaranteed to stick. A declared `false` still writes directly and
disarms any pending open, so the app's latest word always wins.

Post-mount behaviour is unchanged: updates stay edge-triggered, so a
re-render carrying the same declared `true` still does not re-assert against
a natively dismissed tip (the contract locked in by microsoft#940).

Descriptor unmount hook
-----------------------
An arm could otherwise outlive the mount that created it: unmount before
`Loaded`, then re-parent, and the tip popped open on behalf of a mount that
no longer existed (proven — the new selftest fails without the hook). The
engine already dispatched unmount to hand-coded handlers, but
`DescriptorHandler` never forwarded it, so descriptors had no teardown seam
at all. Adds `ControlDescriptor.OnUnmount` / `.WithUnmount(...)` and the
forwarding implementation, and uses it to cancel a pending open.

Testing
-------
New `IsOpenEdge_TeachingTipMountOpen` selftest, registered in both required
places. Every assertion was mutation-checked so none can pass vacuously:

  A  bypass the deferral      -> DeclaredOpenOnFirstRenderOpens,
                                 PresentedTipRaisesClosedOnTeardown,
                                 RisingEdgeBeforeLoadOpensOnLoad
  B  Cancel becomes a no-op   -> FallingEdgeBeforeLoadCancelsPendingOpen
  C  mount always arms open   -> DeclaredClosedStaysClosed
  D  unmount hook disabled    -> UnmountBeforeLoadCancelsPendingOpen

`PresentedTipRaisesClosedOnTeardown` is the presentation oracle: WinUI raises
`Closed` only for a tip that genuinely presented, so a "set the DP and hope"
fix would not satisfy it.

Also refreshes the now-stale scope notes on `TeachingTipEdgeTriggered`, which
documented the mount path as broken, and adds a shared `CloseAndSettle`
teardown guard — these fixtures now really do present overlays, and
`WaitFor(() => !tip.IsOpen)` would have pumped the dispatcher zero times
because `IsOpen` flips synchronously.

Also fixed
----------
The gallery's "TeachingTip (Title Only)" card declared a tip with no `IsOpen`
and no trigger, so it could never appear. The issue warns that the obvious
one-line `IsOpen = true` fix lands straight on this bug; now that mount-open
works it would present once and, being edge-triggered with nothing wired to
`OnClosed`, never come back. Switched to the state-driven shape the sibling
"Basic TeachingTip" card already uses, and made it actually title-only.

12,933 unit tests pass; the full selftest suite matches the `main` baseline.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: ca0dab3f-2cff-4f78-a3b0-cb546975b515
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