Skip to content

Keep a conditional child's slot among unkeyed siblings; unmount ListView rows WinUI drops - #1424

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 10 commits into
mainfrom
azchohfi-reconciler-child-matching-investigation
Oct 27, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 10 commits into
mainfrom
azchohfi-reconciler-child-matching-investigation

Conversation

@azchohfi

@azchohfi Alexandre Zollinger Chohfi (azchohfi) commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Conditional children hold their slot. An unkeyed cond ? X : Empty(), cond ? X : null, or Group(...) that changes size (including nested groups) now keeps its argument slot, as React keeps a null child's place. Before, the container factories dropped the empty argument, so every later sibling shifted one index. The positional reconcile then either remounted the sibling (resetting its state) or gave it its neighbour's state.

  • Recording slots. The factories record each kept child's argument path in ChildSlots, a weak side table keyed by the filtered Children array.
    • The path is a long with 16 bits per level, so a group's own map nests under its parent's argument.
    • A path deeper than four levels, or an oversized index, is shortened or clamped. Only the children that end up sharing an id fall back to positional matching; their shallower siblings keep their exact identity.
    • A map is registered only on the slow path: when an argument was dropped or a group was flattened.
  • Matching. ChildReconciler matches unkeyed children by slot in one merge pass whenever a toggle shifted them. Otherwise the positional walk runs unchanged, including the PR-C structural-skip fast path.
  • Exit transitions. Both the walk and the panel post-pass that re-applies per-child attached props (for example a Grid cell's column) now step past controls that are still in the panel only to play an exit transition. On main, the following all paired later siblings with the wrong control or the wrong attached props:
    • a re-render during a fade;
    • a type swap whose exit re-inserts the old control;
    • a Grid/UniformGrid cell fading out.

ListView<T> / GridView<T> rows on containers WinUI drops are unmounted. Under fast churn, WinUI can park a container that is no longer linked to any item without raising the recycle ContainerContentChanging. The row's components then stayed mounted.

  • RefreshRealizedContainers now unmounts the view of such a container when its row has left the list or another container shows it. It keeps the visuals, so the delete transition still plays.
  • A re-realized container unmounts its previous row's view first.
  • ReactorDiagnostics.TrySetState therefore refuses those rows, instead of accepting a write that never renders.

.Children shape and public API are unchanged. Keyed containers keep keyed matching.

Linked issue / spec

Fixes #1423

Test plan

  • Headless unit tests: tests/Reactor.Tests/ChildSlotsTests.cs, 22 tests. They cover:
    • slot recording for Empty, null, Group, nested groups and deeply nested groups;
    • a trailing drop (no map is registered);
    • UniformGrid;
    • the sign-bit boundary, and ids that never decrease through 70k-wide groups;
    • Filter on hand-built arrays, and the AlignByIndex truth table.
  • Slot selftests: 15 ConditionalChildSlot_* fixtures.
    • Toggles: hide/show middle, same-type sibling, null, Empty→element→Empty, Group resize, nested group, a 5-level nested group.
    • Exit transitions: exit, re-toggle during an exit, replace-with-exit through the slot walk and through the positional walk, UniformGrid cell columns after an exit.
    • Other: Animate ambient, a self-triggered memoized sibling, and a callback skip arm.
  • ListView selftests: 2 TemplatedList_* fixtures. One is the tester's 16 ms churn: it ends on a structural op and includes a positive control. The other checks that a moved row stays live.
  • Mutation checks: disabling each fix makes its fixtures fail.
    • Slot matching off: a=a:5 instead of a:7, and y takes x's state.
    • Orphan sweep off: live=11 items=10 and accepted=1.
    • Exit skip off: order r1,r2,b,b.
    • Positional hand-off off: a lost, b duplicated.
    • Post-pass skip off: grid columns a=1 b=2 instead of 0/1.
  • dotnet test tests/Reactor.Tests -p:Platform=x64, after dotnet build tests/Reactor.Tests -p:Platform=x64 -p:SkipSignaturesGen=true: passed, 15,177 total, 0 failed.
  • dotnet run --project tests/Reactor.AppTests.Host --no-build -c Debug -p:Platform=x64 -- --self-test, full suite before the review rounds: passed, 1,737 fixtures, 0 failures, 3 environmental skips. Since then the ConditionalChildSlot_, TemplatedList_, Flex, Grid and Transition prefixes: passed, 0 failures.
  • dotnet restore Reactor.slnx, then dotnet build Reactor.slnx --no-restore -c Release: passed, 0 errors. Run locally with -p:NuGetAudit=false and a mirror NuGet config, because api.nuget.org TLS fails on this machine.
  • Local NativeAOT publish of the selftest host (-p:PublishAotInternal=true): the SlotReplace_* fixtures pass. One CI AOT run had failed SlotReplace_RegisteredHostReconcilesChild once. It did not reproduce locally, either isolated (3×) or in the full suite, and it passed on CI's next run.
  • pr-review skill: two passes plus a multi-model cross-check (GPT-6.1 Sol). Copilot review rounds have been addressed; latest: "No open issues".
  • Perf, tests/stress_perf/ci/Run-PerfBenchmark.ps1 -BaselineRoot <main worktree>, on a contended 4-core box:
    • Full compare (StocksGrid, skip-floor, keyed-list, flex, data-grid, micro): every metric within noise. Reconcile −5.5% [−15.0, +4.1]; alloc bytes/render −2.3%.

    • Headline re-measure with the PR side running first: reconcile −1.2% [−19.9, +17.5]; skip-floor reconcile −3.0% [−10.7, +4.6].

    • Microbenchmark, a raw Reconciler over 300 rows, warm median ms:

      Scenario main PR
      plain 1.36 / 1.31 1.37 / 1.48
      Empty present 1.39 / 1.30 1.40 / 1.45
      conditional toggling every render 45.4 / 39.7 11.4 / 11.4

      Building a tree whose rows drop an argument costs about +0.04 ms per 300 containers (the slot map plus its weak-table entry).

Risk / breaking changes

  • Behaviour change (intended): an unkeyed child is identified by its argument slot, not its filtered index.
    • Siblings after a toggled conditional keep their state instead of resetting or taking a neighbour's state.
    • As in React, a child whose argument slot changes is a different child: a ? X() : Empty(), a ? Empty() : X() now remounts X.
    • Containers with any keyed child keep keyed matching, and the docs say so.
    • CHANGELOG entries are under Fixed.
  • Hot path:
    • With no Empty/null/Group argument, the factories, Filter and the positional walk run as before, plus a volatile-flag read and a field check.
    • Once any slot map exists in the process, each container reconcile does two weak-table lookups.
    • Exit-aware routing applies only to a collection whose own count shows it holds exiting controls.
  • Templated lists: the orphan sweep only unmounts components, never visuals, and only for a row that has left the list or is shown by another container.
  • Pre-existing, not changed here:
    • A ListView<T> swap re-realizes the moved row's container, so that row's component state still resets.
    • An Animate-ambient fade-out's Composition batch does not always complete, so the faded control can linger; main shows the same.

…ned ListView rows

A container factory drops null/Empty() arguments and flattens Group(), so a
toggled conditional child shifted every later unkeyed sibling one index and the
positional reconcile compared each with the wrong child: a sibling of another
type remounted (state reset) and one of the same type inherited its neighbour's
state. The factories now record each kept child's argument slot (ChildSlots) and
ChildReconciler matches unkeyed children by slot when a toggle shifted them.

Under fast insert/remove churn a ListView<T>/GridView<T> could leave a container
parked and unlinked without raising the recycle ContainerContentChanging, so its
row's components stayed mounted (effects never cleaned up; diagnostics writes
were accepted but never rendered). RefreshRealizedContainers now unmounts the
view of an unlinked container whose row is gone, and a re-realized container
unmounts its previous row's view first.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1e3c8429-4945-4b4d-8d08-342c6b723f2d
…, narrower orphan sweep

- ChildReconciler: while any exit transition is in flight, take the slot walk and
  step past controls an earlier pass left fading, resolving dirty membership by
  the pre-pass collection index (re-toggling a faded child no longer pairs its
  siblings with the wrong control).
- FilterChildren: a group that flattened a nested group uses positions for all of
  its children (no duplicate slots); identity maps (a dropped trailing argument)
  are not registered; UniformGrid carries the cells' slots to its positioned copy.
- Orphan sweep only unmounts a row that left the list or another container now
  shows; one UnmountItemView helper owns the live-tag rule.
- Tests: re-toggle during exit, callback skip arm, nested group, trailing drop,
  UniformGrid, moved row stays live; churn fixture ends on a structural op and
  carries a positive control.
- Docs: the slot guarantee covers unkeyed containers; keyed-lists reference.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1e3c8429-4945-4b4d-8d08-342c6b723f2d
…xits, exiting-set hygiene

- Take the slot walk for exiting controls only when this collection holds some
  (its count exceeds the old children), so a fade elsewhere keeps the PR-C fast path.
- A replace whose exit transition re-inserts the old control mid-pass hands the
  rest of the positional walk to the slot walk (it shifted every later sibling).
- Drop a control from the exiting set when an ancestor unmounts it; mark an
  ambient-exit control compositor-tainted so it is never pooled mid-fade.
- CHANGELOG entries; docs wording; relink-guard comment; replace-with-exit fixtures.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1e3c8429-4945-4b4d-8d08-342c6b723f2d
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1e3c8429-4945-4b4d-8d08-342c6b723f2d
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1e3c8429-4945-4b4d-8d08-342c6b723f2d
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build metrics

Artifact sizes for 67a2261 vs the base branch (f92623b).

Packages (compressed .nupkg)

Artifact base PR Δ
Microsoft.UI.Reactor.nupkg 1.90 MB 1.91 MB +3.51 KB (+0.18%) ⚠️
Microsoft.UI.Reactor.Advanced.nupkg 493.4 KB 493.4 KB +5 B (0.00%) ≈
Microsoft.UI.Reactor.Devtools.nupkg 287.9 KB 287.9 KB +9 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor

Artifact base PR Δ
Reactor.Analyzers.dll 411.5 KB 411.5 KB +0 B (0.00%) ≈
Reactor.dll 2.65 MB 2.65 MB +3.00 KB (+0.11%) ⚠️
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 1.00 MB 1.00 MB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Devtools

Artifact base PR Δ
Microsoft.UI.Reactor.Devtools.dll 787.0 KB 787.0 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.

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.

🟡 Changes recommended

Nested-group slot fallback can still transfer component state between siblings or remount unchanged siblings.

1 open issue
What changed in this PR

Addresses #1423 by preserving unkeyed sibling identity around conditional children and cleaning up templated rows whose containers WinUI drops.

Changes:

  • Records child argument slots and adds slot-aware reconciliation, including handling for lingering exit transitions.
  • Unmounts orphaned or replaced templated row views while preserving delete-transition visuals.
  • Adds regression tests and updates documentation and release notes.
File Description
tests/​Reactor.Tests/​ReconcilerCorrectnessTests.cs Updates tests to call the revised filter directly.
tests/​Reactor.Tests/​PanelChildReconciliationTests.cs Replaces reflection-based filter calls.
tests/​Reactor.Tests/​ChildSlotsTests.cs Tests slot recording, propagation, and alignment.
tests/​Reactor.AppTests.Host/​SelfTest/​SelfTestFixtureRegistry.cs Registers the new selftest fixtures.
tests/​Reactor.AppTests.Host/​SelfTest/​Fixtures/​TemplatedListOrphanContainerFixtures.cs Tests row cleanup and responsiveness after churn.
tests/​Reactor.AppTests.Host/​SelfTest/​Fixtures/​ConditionalChildSlotFixtures.cs Tests sibling identity across toggles and exits.
src/​Reactor/​Elements/​Dsl.cs Records slots during filtering and preserves UniformGrid metadata.
src/​Reactor/​Core/​Reconciler.Update.cs Cleans up orphaned templated containers.
src/​Reactor/​Core/​Reconciler.Mount.cs Centralizes row-view teardown before recycling or realization.
src/​Reactor/​Core/​Reconciler.cs Tracks exiting controls and replacement transitions.
src/​Reactor/​Core/​ChildSlots.cs Adds weakly stored child-slot metadata.
src/​Reactor/​Core/​ChildReconciler.cs Adds slot matching and exit-aware traversal.
plugins/​reactor/​skills/​reactor-dsl/​references/​keyed-lists.md Clarifies conditional behavior with mixed keys.
docs/​guide/​reconciliation.md Updates generated reconciliation guidance and snippets.
docs/​guide/​cheat-sheet.md Explains conditional slot preservation.
docs/​_pipeline/​templates/​reconciliation.md.dt Documents argument-slot identity and keyed exceptions.
docs/​_pipeline/​templates/​cheat-sheet.md.dt Updates conditional-render guidance at its source.
CHANGELOG.md Records both fixes under issue #1423.

Review effort: Balanced

Comment thread src/Reactor/Elements/Dsl.cs Resolved
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🧪 Merged coverage

Coverage for 67a2261 vs the base branch (f92623b) — unit + selftest merged.

Metric base PR Δ
Line 87.34% 87.42% +0.08 pp ≈
Branch 76.69% (977/1274) 76.77% (978/1274) +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.

Slot ids are now long paths (16 bits per level): a group's own slot map nests
under the argument the group occupies, so a nested group no longer falls back to
positions and hands a later sibling another's slot (state transfer / remount).
Adds the nested-group unit and selftest regressions; test LINQ cleanups.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1e3c8429-4945-4b4d-8d08-342c6b723f2d

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.

🟡 Changes recommended

Confirmed slot-encoding boundary defects can transfer component state between unrelated siblings, and native lifecycle changes still warrant human validation.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/Reactor/Core/ChildSlots.cs Resolved
Comment thread src/Reactor/Elements/Dsl.cs Resolved
- Nest uses a logical shift, so group-child indices past 32767 no longer
  sign-extend into the argument above them.
- No group map is discarded any more: nesting a four-level path drops only its
  deepest level and oversized indices are clamped, keeping ids non-decreasing;
  only the children sharing a shortened id match positionally, never their
  shallower siblings.
- Tests: sign-bit boundary, deep nested toggle (unit + 5-level selftest),
  non-decreasing ids through deep and 70k-wide groups.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1e3c8429-4945-4b4d-8d08-342c6b723f2d

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.

🔵 Needs a closer look

The attached-property post-pass still includes exiting controls, leaving surviving Grid cells incorrectly positioned after a fade.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Exclude exiting controls from post-pass column assignment

src/​Reactor/​Core/​ChildReconciler.cs:125

The attached-property post-pass in V1HandlerAdapter.cs:390–404 still pairs new elements with physical collection indices, including exiting controls. Hiding the first fading cell of a three-cell UniformGrid leaves [exiting, a, b], so the post-pass applies column 0 to the exiting cell and column 1 to a, while b retains column 2; the survivors remain incorrectly positioned after the fade. Skip IsExiting controls in both the per-child assignments and after-all pair construction, and add a live regression checking the surviving cells' columns after the exit.

2 resolved since last review

Review effort: Balanced

…ntrols

The panel post-pass that re-applies per-child attached props (a Grid cell's
column) paired new children with physical indices, so a control still fading out
shifted every later child onto its neighbour's props, kept after the fade. It now
steps past controls the reconciler tracks as exiting. Adds a UniformGrid fade
regression; the ambient-animate fixture no longer asserts the fade's completion
(its Composition batch completing is run-dependent and predates this change) but
checks the fading child holds its slot.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1e3c8429-4945-4b4d-8d08-342c6b723f2d

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.

🔵 Needs a closer look

Core component-identity changes and asynchronous WinUI exit and container lifecycles warrant final maintainer review despite the reported regression coverage.

No open issues 🎉

Review effort: Balanced

@azchohfi Alexandre Zollinger Chohfi (azchohfi) added ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Oct 27, 2026
…hild-matching-investigation

# Conflicts:
#	CHANGELOG.md
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit 16062a1 into main Oct 27, 2026
45 checks passed
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) deleted the azchohfi-reconciler-child-matching-investigation branch October 27, 2026 22:17
@azchohfi Alexandre Zollinger Chohfi (azchohfi) removed the ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge label Oct 27, 2026
Alexandre Zollinger Chohfi (azchohfi) added a commit to azchohfi/microsoft-ui-reactor that referenced this pull request Oct 27, 2026
Resolve CHANGELOG.md (keep both Fixed entries) and Reconciler.Mount.cs
(keep microsoft#1424's UnmountItemView before re-realizing a container and this
branch's keyed BuildKeyedItemView). Adds round-6 wrapped-row mount checks.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 1a2fe041-2181-4ae4-b7a4-389eb72edde9
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Oct 28, 2026
Resolve conflicts with #1417 (realization theme scope) and #1424 (keyed
item views): open the context RealizationFrame before EnterRealizationTheme
at every row-realization site, and read the frame's live theme with the same
InheritedRequestedTheme rule #1417 uses.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: d6963d93-8fc8-4956-8c83-88b394debeee
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Oct 30, 2026
)

* Unmount ListView rows WinUI parks in the layout pass after a move

#1424's orphan sweep found a container's row through ListViewItem.Content,
which WinUI leaves null for these lists, so it never unmounted anything; and
it ran during the update, before the layout pass in which WinUI parks the
container of a row moved twice or moved out of the realized range without
raising the recycle ContainerContentChanging. Those rows kept a live
component: effects never cleaned up, and diagnostics writes were accepted
but never rendered.

The list state now flags structural changes, and after one the reconciler
unmounts, once the next layout pass completes, the view of every container
that pass left unlinked from any item. Visuals stay for delete transitions.

Fixes #1440

Co-authored-by: Copilot App <[email protected]>

* Wait for a pass that lays the list out; test the sweep gate and unsubscribe

LayoutUpdated fires for every layout pass in the window, so the one-shot sweep
could spend itself while the list was collapsed and miss the container WinUI
parks once the list is shown. The sweep now waits while the list has a
collapsed ancestor, and an unloaded list re-arms StructureChanged instead.

Tests: a fixture that collapses the list with the last move; every linked
container keeps a live view; the sweep unsubscribes (test-only run counter);
headless StructureChanged gate tests.

Co-authored-by: Copilot App <[email protected]>

* Sweep a reinserted list; test the moved row once scrolled back into view

A list inserted into the tree is laid out (and its container parked) before
its Loaded is raised, so the sweep no longer gives up on an unloaded list; it
only waits while the list or an ancestor is collapsed.

Tests: a fixture that reinserts the list (keyed reorder) with the last move,
which fails with the unloaded give-up; the out-of-range row is scrolled back
into view and must respond.

Co-authored-by: Copilot App <[email protected]>

* Wait for a collapsed list on its own EffectiveViewportChanged; drop the sweep on unmount

A sweep that found the list collapsed stayed on the window-wide LayoutUpdated,
walking the ancestors on every layout pass for as long as the list stayed
collapsed, and outlived a list unmounted meanwhile. It now waits on the list's
own EffectiveViewportChanged, which the pass that lays the list out raises,
and unmounting a list drops either pending handler.

Tests: a fixture unmounts the list while the sweep waits; mutants that skip
the cancel, the collapsed wait, or the reschedule are caught.

Co-authored-by: Copilot App <[email protected]>

* Wait for an out-of-tree list to load before sweeping it

A list in a TabView tab that is not selected stays mounted but leaves the
tree; WinUI parks the container only when the tab is selected again, after a
sweep scheduled meanwhile had already run. The sweep now waits on the list's
Loaded (then sweeps after the next layout pass) when the list is not loaded.

Test: the list's tab is switched away in the render of the last move; fails
without the wait.

Co-authored-by: Copilot App <[email protected]>

* Fixture: use IsVisible (Visible is obsolete)

Co-authored-by: Copilot App <[email protected]>

* Address review round 1: isolate parked-row cleanup failures

The sweep runs from LayoutUpdated after unsubscribing, so a throwing effect
cleanup stopped it mid-way, left rows mounted and bypassed the
RenderErrorHandler. It now drains every cleanup under
IsolateUnmountCleanupFailures and routes failures through
ReportCleanupFailures (Cleanup source; with no handler the first is rethrown
after the sweep), as host teardown does.

Test: a parked row's cleanup throws once; the failure is reported and the
parked view still unmounts (the host crashes without the isolation).

Co-authored-by: Copilot App <[email protected]>

* Address review round 2: keep a declined propagation through the sweep

- Open the render-error propagation scope before the parked-row unmounts, not
  just around reporting: a cleanup's nested Reactor work that the app already
  declined now keeps going out instead of being handed to the list's handler
  (which could swallow it). Regression: a parked row's cleanup mounts a host
  whose failing render is declined.
- Subscribe the Loaded / EffectiveViewportChanged waits through non-null locals.
- Count sweeps from a static helper; LINQ in the fixture's linked-row check.

Co-authored-by: Copilot App <[email protected]>

* Address review round 3: isolate descriptor unmount hooks; AOT-safe list lookup

- A control descriptor's OnUnmount hook now runs under the active
  IsolateUnmountCleanupFailures scope like component cleanups: a throw is
  collected (and reported) and the control's children are still torn down.
  Regression: a parked row holds a control whose descriptor teardown throws.
- Fixtures: skip the parked-teardown checks when WinUI parked nothing (the
  teardown never ran); check every parked container's view is released; find
  the fixture's ListView by its ReactorRow source (under NativeAOT the TabView's
  tab strip matched an exact-type check).
- Wait locals are non-nullable.

Co-authored-by: Copilot App <[email protected]>

* Address review round 4: isolate RegisterType unmount callbacks

A per-host RegisterType unmount callback that throws during an isolated
teardown (the parked-row sweep, a released tree) is now collected and
reported like component cleanups and descriptor hooks, instead of escaping.
Regression: a parked row holds a registered control whose unmount throws.

Co-authored-by: Copilot App <[email protected]>

* Address review round 5: isolate decorator handler unmounts

A decorator handler whose Unmount throws during an isolated teardown is now
collected and reported, and the default traversal still tears down what it
wraps. With the V1 handler, descriptor and RegisterType paths, every unmount
callback kind now honours IsolateUnmountCleanupFailures. Regression: a parked
row holds a decorator-handled control whose unmount throws.

Co-authored-by: Copilot App <[email protected]>

* Address review round 6: drain a failed RegisterType unmount, never pool it

When a RegisterType unmount callback throws during an isolated teardown, the
Reactor children it had not reached yet are now torn down, and the
half-torn-down control is not pooled. Regression: a parked row's registered
control hosts a component its throwing callback never reaches; it is still
unmounted.

Co-authored-by: Copilot App <[email protected]>

* Address review round 7: no second teardown of a child the failed callback reached

While a RegisterType unmount callback runs inside an isolated teardown, the
controls it tears down are recorded; if it throws, the recovery walk over its
children skips them, so a child's handler and descriptor hooks run exactly
once. Self-reentrant calls are unaffected (the record is only consulted during
recovery). Shared by the plain and pooling unmount walks.

Regression: a registered control tears down its first child and throws; on
both walks each child's descriptor hook runs once.

Co-authored-by: Copilot App <[email protected]>

* Address review round 8: keep ancestor skips in nested recovery; fixture init

- A nested registered control's recovery now inherits the enclosing
  recovery's skip set, so a grandchild the outer callback already tore down is
  not torn down again. Regression (both walks): the outer callback tears down
  a leaf inside the inner control and throws; the inner throws at once.
- The isolated-teardown fixtures call Reset() first, which runs the enclosing
  class's static constructor (CountedLeaf registration), so each passes alone.

Co-authored-by: Copilot App <[email protected]>

* Address review round 9: one isolated-teardown path for every handler kind

V1 handlers (standard, descriptor, decorator) and RegisterType callbacks now
share one engine helper for isolated teardowns: a throw is collected, the
children the handler did not reach are torn down once each (inherited skips
included), and the half-torn-down control is never pooled. The adapter-level
catches are gone (a decorator's continued traversal could repeat a child's
teardown; a failed descriptor control could be pooled).

Regressions: a decorator tears down one child and throws (both walks); the
pooling walk never pools a control whose teardown failed.

Co-authored-by: Copilot App <[email protected]>

* Address review round 10: run the children strategy when a descriptor hook throws

Inside an isolated teardown, a throwing descriptor OnUnmount no longer skips
the strategy-driven child teardown (named slots such as TeachingTip.HeroContent
are outside the engine's generic child walk). The adapter tears the children
down, then rethrows so the engine reports the failure once, recovers with its
skip set and keeps the control out of the pool.

Regression (both walks): a descriptor whose hook throws, with a leaf in a
named slot; the leaf is torn down exactly once.

Co-authored-by: Copilot App <[email protected]>

* Address review round 11: skip children a failed hook already tore down

When a handler's unmount hook throws inside an isolated teardown, the
adapter's strategy teardown now runs with the reconciler's skip set covering
what the hook already tore down, so a slot child it reached is not torn down
twice. Regression (both walks): the hook unmounts the named slot's child,
then throws; the child is torn down exactly once.

Co-authored-by: Copilot App <[email protected]>

* Address review round 12: run each descriptor unmount callback independently

Inside an isolated teardown, every ImperativeBridged property unmount callback
and the descriptor's OnUnmount hook now run even when an earlier one throws
(each may own a secondary slot no other walk reaches). The first failure is
rethrown for the adapter and engine (strategy teardown, recovery, no pooling);
later ones are reported directly, so each is reported once.

Regression (both walks): the first of two property callbacks throws; the
second still tears its child down and the hook still runs.

Co-authored-by: Copilot App <[email protected]>

* Address review round 13: report descriptor unmount failures in encounter order

Each property unmount callback and hook failure is now reported to the
isolation sink as it happens; the handler then throws an already-reported
marker so the adapter and engine still run the strategy teardown and recovery
and keep the control out of the pool, without reporting again. With no
handler, the first failure is the one that escapes.

Regression (both walks): a property callback fails, then the hook; the sink
sees first,second and the first escapes.

Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: Copilot App <[email protected]>
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.

[Bug] A conditional Empty()/null child remounts its unkeyed siblings; ListView<T> rows stay mounted on containers WinUI drops

2 participants