Repository navigation
Complete the #1090 selection-write guard; drop the unreproducible hardening - #1097
Conversation
…dening Follow-up to #1091 (merged), addressing findings from a multi-dimensional review of that branch. Every finding below was independently confirmed by a second model. 1. The fix was incomplete: three more unguarded paths (HIGH) #1091 guarded only ListViewHandler and GridViewHandler. The same suppress-then-write shape exists in the templated (typed) list path, which #1091 never touched: - TemplatedListLifecycle: 6 sites (Mount/Update x ListView/GridView/FlipView) - TemplatedListViewDescriptor (spec-047 Phase 3 descriptor variant) - TemplatedGridViewDescriptor The descriptor pair is worse than a swallowed event: with an unreachable index the WinUI setter throws ArgumentException. A new typed selftest crashed on it, which is how the path was found. 2. Removed the BeginSuppressCancelable / EchoSuppressArm hardening That primitive was written for a hypothesis that measurement disproved (an ItemsSource swap preserving a still-valid selection). It also carried a real defect: CancelIfUnconsumed is watermark-guarded, not identity-guarded, so with two overlapping arms on one control a delayed retraction cancels the wrong token -- unsuppressing a genuine engine echo. Its own XML doc claimed the opposite. Keeping buggy speculative code for an unobservable branch is not a good trade, so the arm-then-observe blocks revert to the plain drift-gated BeginSuppress that main used before, and the 12 headless tests that modelled the hypothetical branch are deleted. 3. Centralized the rule IsReachable was duplicated per handler. It is now SelectionWriteGuard.CanLand, used by all 10 write sites, so the typed and untyped families cannot drift. 4. Corrected an unsupported claim in shipped docs The threading guide asserted that ItemsSource reassignment "preserves the selection silently on some WinUI versions". No in-repo source establishes that -- the only support was this PR's own test comments, which is circular, and every runtime measured (WASDK 2.1 and 2.3.1) resets and fires. Replaced with the rule that is actually established: gate on reachability as well as drift, and skip the write entirely when it cannot land. 5. Closed the coverage gaps #1090's mutation check removed both guards at once, so it could not tell Mount from Update. Each guard is now pinned independently: ListView Mount guard removed -> Issue1090_ListView_IndexPastEndOfShortSource ListView Update guard removed -> Issue1090_ListView_ControlledIndexUnreachableAfterShrink GridView guards removed -> Issue1090_GVEmptyMount + GridView_IndexPastEndOfShortSource Templated guards removed -> Issue1090_TypedListView_ControlledIndexUnreachableAfterShrink New fixtures also cover multi-select empty mount via the OnSelectionChanged snapshot callback, and the GridView past-end case. Verified: 1443 selftest fixtures pass (up from 1440); 13276 unit tests pass; Release builds of src/Reactor and the selftest host are clean; docs recompiled via `mur docs compile --topic threading-and-dispatch`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 32bf22fb-ba60-47d3-a0c6-8f5c0079f10e
📦 Build metricsArtifact sizes for Packages (compressed .nupkg)
Assemblies in Microsoft.UI.Reactor
Assemblies in Microsoft.UI.Reactor.Advanced
Assemblies in Microsoft.UI.Reactor.Devtools
No size change beyond the noise floor. ✅ ✅ smaller / |
🧪 Merged coverageCoverage for
No coverage change beyond the noise floor. ✅ ✅ higher / |
There was a problem hiding this comment.
Pull request overview
This PR completes the Issue #1090 “selection-write reachability” guard across the remaining typed/templated list paths, removes the previously added retractable echo-suppression arm (and its unit tests), and updates the threading guide text to reflect the reachability-based rule rather than a version-dependent ItemsSource-swap claim.
Changes:
- Introduces
SelectionWriteGuard.CanLand()and applies it to all suppressedSelectedIndexwrite sites across untyped handlers and typed/templated lifecycle + descriptors. - Removes
BeginSuppressCancelable/EchoSuppressArmfromChangeEchoSuppressorand deletes the associated headless tests. - Adds multiple new selftest fixtures to cover the newly-guarded write sites and updates the doc/template wording to match the new guidance.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Reactor.Tests/EchoSuppressArmTests.cs | Deletes tests for the removed retractable suppression-arm primitive. |
| tests/Reactor.AppTests.Host/SelfTest/SelfTestFixtureRegistry.cs | Registers new Issue1090 selftest fixtures. |
| tests/Reactor.AppTests.Host/SelfTest/Fixtures/Issue1090SelectionStrandFixtures.cs | Adds new fixtures covering GridView past-end, update-side shrink, multi-select callback path, and typed list shrink scenarios; updates probe commentary. |
| src/Reactor/Core/V1Protocol/TemplatedListLifecycle.cs | Adds reachability gating (SelectionWriteGuard.CanLand) to templated Mount/Update selection writes. |
| src/Reactor/Core/V1Protocol/SelectionWriteGuard.cs | Adds centralized reachability rule helper for selection writes. |
| src/Reactor/Core/V1Protocol/Handlers/ListViewHandler.cs | Switches to centralized reachability guard and drops retractable-suppression arm/observe logic for ItemsSource swaps. |
| src/Reactor/Core/V1Protocol/Handlers/GridViewHandler.cs | Same as ListViewHandler: centralized reachability guard + removal of retractable-suppression logic. |
| src/Reactor/Core/V1Protocol/Descriptor/Descriptors/TemplatedListViewDescriptor.cs | Adds reachability gating to descriptor-based templated ListView/GridView selection writes. |
| src/Reactor/Core/ChangeEchoSuppressor.cs | Removes the retractable suppression-arm primitive. |
| docs/guide/threading-and-dispatch.md | Updates shipped guide text to describe reachability gating rather than version-dependent ItemsSource swap behavior. |
| docs/_pipeline/templates/threading-and-dispatch.md.dt | Updates the source template for the same guide section to match the new guidance. |
Suppressed comments (1)
src/Reactor/Core/V1Protocol/Descriptor/Descriptors/TemplatedListViewDescriptor.cs:104
- Same as the ListView descriptor:
shouldWritecallsel.GetSelectedIndex()multiple times. Store it in a local once and reuse for the reachability + sign checks.
.OneWayConditional(
get: static el => el.GetSelectedIndex(),
set: static (ctrl, v) => { if (v >= 0) ctrl.SelectedIndex = v; },
shouldWrite: static el => el.GetSelectedIndex() >= 0
&& SelectionWriteGuard.CanLand(el.GetSelectedIndex(), el.ItemCount));
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…rationale Review comment: `shouldWrite` called `el.GetSelectedIndex()` twice, which is redundant and could disagree with itself if that ever normalizes. Capture it once in a block-bodied lambda. Both descriptor sites. Also corrects the comment on those two sites, which overstated what I had established. TemplatedListViewDescriptor / TemplatedGridViewDescriptor are "retained for isolated selftests" (TemplatedListHandler.cs) and are NOT registered on the production path -- the TemplatedListHandler decorator replaced the per-kind descriptor registrations. A probe injected into shouldWrite confirms it is never invoked for ListView<T>. I had claimed a new selftest crashed on this path. That was wrong: the crash came from a stale binary left by an earlier mutation experiment that had removed the TemplatedListLifecycle guards, and I attributed it to the descriptor change that happened to land next. The guard stays for consistency across the family -- the write shape is identical and would be a live defect if those ports were ever re-registered -- but it is defensive, not a fix for anything a fixture reaches. The TemplatedListLifecycle finding is unaffected and remains proven: removing just those 6 guards still reddens Issue1090_TypedListView_ControlledIndexUnreachableAfterShrink with the ArgumentException, re-verified after this change. Selftests 1443/1443. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 32bf22fb-ba60-47d3-a0c6-8f5c0079f10e
Audits every PR merged since v0.1.0-preview.13 (56 commits) for changelog
coverage, then cuts the release section per docs/contributing/release-runbook.md.
Only 9 of those PRs updated CHANGELOG.md. Nine user-facing changes were missing
an entry and are added here:
Added - declarative window icon: icon: on ReactorApp.Run plus
Run(WindowSpec, ...) overloads (#1145, issue #1143)
Changed - dotnet new reactorapp resolves the latest Windows App SDK (#1096)
Fixed - connected animations never played across a replaced subtree (#1124)
- a controlled SelectedIndex WinUI cannot honor stranded an echo
token and ate the next real selection (issue #1090, #1091, #1097)
- legacy text-node TreeView rendered empty under NativeAOT (#1108)
- devtools DP lookups found nothing, since CsWinRT projects
DependencyProperty statics as properties (issue #1109)
- the exe-icon fallback was dead code, and WindowIcon.FromResource
silently applied a default icon in packaged apps (issue #1143)
- an installed mur was frozen at first bootstrap, and mur check
shipped without Roslyn (#1130)
- mur loc/docs help printed the non-existent "duct" command (#1129)
- a scaffolded project would not launch in Visual Studio 26 (#1084)
The three behaviour fixes were checked against v0.1.0-preview.13 rather than
assumed: the AOT skip for ControlUpdate_Collections, the
_pendingConnectedAnimationStarts list, and the drift-only SelectedIndex gates
all exist at the tag, so each shipped broken and none qualifies for the
introduced-and-fixed-in-window exemption.
Deliberately omitted: dependency bumps, docs-only and CI/test-infra work, and
#1099/#1102, whose product code was already correct (the defect was in a test
classifier and a text matcher respectively).
Bumps ReactorPublicVersion to 0.1.0-preview.14 and recompiles the guide, which
substitutes {{reactorVersion}} across 8 pages, satisfying the docs freshness gate.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Follow-up to #1091 (merged), addressing findings from a multi-dimensional review of that branch.
1. The fix was incomplete — the typed path was unguarded (high)
#1091 guarded only
ListViewHandlerandGridViewHandler. The identical suppress-then-write shape lives in the typed/templated list path, which #1091 never touched:TemplatedListLifecycleTemplatedListViewDescriptor/TemplatedGridViewDescriptorThe lifecycle defect is real and pinned. Removing just those 6 guards reddens
Issue1090_TypedListView_ControlledIndexUnreachableAfterShrinkwithArgumentException: Value does not fall within the expected range— so on the typed path an unreachable index doesn't merely swallow an event, it throws.The descriptor ports are defensive, not a fix. They are "retained for isolated selftests" (
TemplatedListHandler.cs:24) and are not registered on the production path — theTemplatedListHandlerdecorator replaced the per-kind descriptor registrations. A probe injected intoshouldWriteconfirms it is never invoked forListView<T>. The guard stays because the write shape is identical and would be a live defect if those ports were re-registered, but no fixture reaches it. Reviewers who prefer to drop those two lines have a fair case.2. Removed the
BeginSuppressCancelable/EchoSuppressArmhardeningWritten for a hypothesis that measurement disproved (an
ItemsSourceswap preserving a still-valid selection), and it carried a real defect:Its own XML doc claimed the opposite. The arm-then-observe blocks revert to the plain drift-gated
BeginSuppressmain used before, and the 12 headless tests modelling the hypothetical branch are deleted.3. Centralized the rule
IsReachablewas duplicated per handler. It is nowSelectionWriteGuard.CanLand, used by all write sites, so the typed and untyped families cannot drift.4. Corrected an unsupported claim in shipped docs
The threading guide asserted that
ItemsSourcereassignment "preserves the selection silently on some WinUI versions". No in-repo source establishes that — the only support was #1091's own test comments (circular), and every runtime measured (WASDK 2.1 and 2.3.1) resets and fires. Replaced with the rule that is established.5. Closed the coverage gaps
#1091's mutation check removed both guards at once, so it could not distinguish Mount from Update. Each guard group is now pinned independently:
Issue1090_ListView_IndexPastEndOfShortSourceIssue1090_ListView_ControlledIndexUnreachableAfterShrinkIssue1090_GVEmptyMount+GridView_IndexPastEndOfShortSourceTemplatedListLifecycleguardsIssue1090_TypedListView_ControlledIndexUnreachableAfterShrinkNew fixtures also cover multi-select empty mount through the
OnSelectionChangedsnapshot callback, and the GridView past-end case.Verification
src/Reactorand the selftest host cleanmur docs compile --topic threading-and-dispatchUnrelated flake spotted, not fixed here
WindowLevel_RuntimeFlip_Topmostfailed in 2 of ~5 full-suite runs, including one where nothing of mine was in play. It is order-dependent and unrelated to this diff (nothing here touches windowing), so I left it alone rather than widen scope — worth its own issue.