Skip to content

Make hook-based paging the only DataGrid paging path - #1832

Open
Alexandre Zollinger Chohfi (azchohfi) wants to merge 15 commits into
mainfrom
azchohfi-datagrid-hook-paging-only
Open

Alexandre Zollinger Chohfi (azchohfi) wants to merge 15 commits into
mainfrom
azchohfi-datagrid-hook-paging-only

Conversation

@azchohfi

@azchohfi Alexandre Zollinger Chohfi (azchohfi) commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 50eb5fdf8e42ea506717ebc2d50d16cbaa960960

Dimension Assessment Rationale
Change confidence 9/10 ↑ All 50 CI checks pass on this head, coverage up (line +0.11 pp, branch +0.18 pp).
↑ Full Reactor.Tests suite (16,960) and all DataGrid and async-resource selftests pass locally.
↑ Every regression test added during review was mutation-checked: it fails with its fix reverted.
↑ Local /perf DataGrid leg within noise vs main (measured before the later review rounds).
↓ Shared UseInfiniteResource behavior changed for every caller, not only the grid.

Summary

The DataGrid now pages only through UseDataSource / UseInfiniteResource, and the old DataPageCache path is gone, along with ReactorFeatureFlags.UseHookBasedPaging. The hook path needed a few things the old default did before it could take over:

  • Client-side sort and filter for sources without ServerSort / ServerFilter. A new internal DataGridPagingSource<T> loads the rows in one request (still capped by MaxClientFallbackPageSize), sorts or filters them, and hands the whole result back as the first page, so every row is loaded at once like before.
  • Refetch on every query change. Pages used to come back from the QueryCache when you returned to an earlier sort, even after the data changed. The grid now drops its cached pages when the request changes and on unmount.
  • At most 20 pages kept, like the old block cache, rendered or headless. InfiniteResource.Items is now a view over the loaded pages instead of a TotalCount-sized array rebuilt on every page change. Evicted pages release their cache entry, in-flight pages don't count toward the cap, and the rows in view stay loaded when pages a fast scroll asked for land late.
  • Rows arriving after a scroll weren't refreshed once any earlier state change had rendered (the realized-row refresh treated the hook's render as older than the scroll). The grid now stamps those renders or leaves them to the settle timer.
  • A failed first page shows the error template instead of a page of placeholders, also after a refresh, and a page the source cancels on its own (an HTTP timeout, say) fails instead of staying in flight forever.
  • InfiniteResource.Refresh() keeps the known total while page 0 reloads, as it was documented to, so an observable source's DataChanged no longer resets the scroll position.
  • Headless DataGridState.LoadDataAsync keeps working. It drives the same hook state through a small core-internal DetachedDataSourceResource<T> (no QueryCache), completes when the first page is in, and throws if it fails.

Linked issue / spec

Relates to #1819. Finishes spec 020 §11.3 (docs/specs/020-async-resources-design.md).

Test plan

  • dotnet test tests/Reactor.Tests: 16,960 passed. tests/Reactor.DocPipeline.Tests: 593 passed
  • New unit tests: DataGridPagingSourceTests (fallback, headless loads, cancellation, superseded loads, value-type rows, page cap), plus InfiniteResourceTests and UseInfiniteResourceTests cases for the view, eviction, refresh and source-side cancellation
  • dotnet run --project tests/Reactor.AppTests.Host -- --self-test --filter "DataGrid": 0 failures, including new DataGridParityFixtures for client sort/filter on screen, refetch on returning to a sort, rows landing after a scroll, observable sources (incl. worker thread and keeping the scroll position), search, the page cap, late pages, failed pages and failed refreshes
  • --filter "Async" selftests: 0 failures
  • dotnet build Reactor.slnx --no-restore -c Release: clean except the VS extension projects, which couldn't restore from nuget.org on my machine. CI's Build solution passes.
  • Local /perf DataGrid leg vs main: all metrics within noise
  • Regenerated both reactor.api.txt copies, the reference docs and the edited guide pages

Risk / breaking changes

Removed public API: DataPageCache<T>, CacheBlock<T>, BlockStatus, ReactorFeatureFlags.UseHookBasedPaging, DataGridState<T>.PageCache and RowKeyCache. DataGridState<T>.HookResource is renamed RowsResource and SetHookResource is now internal. The CHANGELOG has a member-by-member migration.

Behavior to know about: in client-side sort/filter mode TotalCount is the number of rows shown, and shift-click now selects a range whenever every row is loaded (it used to only in that mode). The UseInfiniteResource changes (items view, eviction, cancellation, refresh) apply to every user of the hook, not just the grid.

Port the client-side sort/filter fallback to the UseDataSource path, drive
headless DataGridState.LoadDataAsync through the same InfiniteResource
machinery, and remove DataPageCache, CacheBlock, BlockStatus,
ReactorFeatureFlags.UseHookBasedPaging, DataGridState.PageCache and
RowKeyCache (spec 020 section 11.3, #1819).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- InfiniteResource.Items is a view over loaded pages instead of a
  TotalCount-sized array per page change; evicted pages release their
  cache entry; a failed page no longer extends the view.
- A page the source cancels on its own fails instead of staying in flight.
- InfiniteHookState serializes its bookkeeping for headless loads.
- DataGrid keeps 20 pages like the old block cache, drops its cached pages
  on unmount, and reloads observable changes on the UI thread.
- LoadDataAsync faults on a failed first page and completes when replaced;
  HookResource is renamed RowsResource and SetHookResource is internal.
- Row occupancy works for value-type rows.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build metrics

Artifact sizes for 50eb5fd vs the base branch (7020f0c).

Packages (compressed .nupkg)

Artifact base PR Δ
Microsoft.UI.Reactor.nupkg 2.19 MB 2.19 MB -1003 B (-0.04%) ≈
Microsoft.UI.Reactor.Advanced.nupkg 531.4 KB 535.0 KB +3.65 KB (+0.69%) ⚠️
Microsoft.UI.Reactor.Devtools.nupkg 290.6 KB 290.6 KB -17 B (-0.01%) ≈

Assemblies in Microsoft.UI.Reactor

Artifact base PR Δ
Microsoft.UI.Reactor.dll 2.93 MB 2.92 MB -512 B (-0.02%) ≈
Reactor.Analyzers.dll 469.5 KB 469.5 KB +0 B (0.00%) ≈
Reactor.Localization.Generator.dll 16.0 KB 16.0 KB +0 B (0.00%) ≈
Reactor.Wrappers.Abstractions.dll 12.0 KB 12.0 KB +0 B (0.00%) ≈
Reactor.Wrappers.Generator.dll 229.5 KB 229.5 KB +0 B (0.00%) ≈

Assemblies in Microsoft.UI.Reactor.Advanced

Artifact base PR Δ
Microsoft.UI.Reactor.Advanced.dll 1.08 MB 1.09 MB +8.00 KB (+0.72%) ⚠️

Assemblies in Microsoft.UI.Reactor.Devtools

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

Unresolved paging defects cause excessive data retention, stale results after refresh, incorrect LRU eviction, and inconsistent values for overlapping pages.

5 open issues
What changed in this PR

Makes hook-based paging the sole DataGrid loading path, completing the migration in spec 020 §11.3 and supporting the compatibility cleanup in #1819.

Changes:

  • Removes the legacy page cache and feature flag, with documented API migrations.
  • Adds client-side sort/filter fallback and headless loading through shared paging machinery.
  • Updates resource storage, cancellation handling, regression tests, samples, and documentation.
File Description
tests/​stress_perf/​StressPerf.DataGrid/​Program.cs Updates paging-flow comments.
tests/​stress_perf/​ci/​PerfLib.ps1 Updates benchmark explanatory text.
tests/​Reactor.Tests/​InfiniteResourceTests.cs Tests page views, errors, and eviction.
tests/​Reactor.Tests/​DataPageCacheTests.cs Removes legacy cache tests.
tests/​Reactor.Tests/​DataGridStateAdditionalTests.cs Updates resource assertions.
tests/​Reactor.Tests/​DataGridPagingSourceTests.cs Adds fallback and headless-loading tests.
tests/​Reactor.Tests/​Data/​DataPageCacheParityTests.cs Removes dual-path parity tests.
tests/​Reactor.Tests/​Core/​UseInfiniteResourceTests.cs Tests cancellation and cache release.
tests/​Reactor.Tests/​Architecture/​AdvancedInternalSurfaceTests.cs Records new internal dependencies.
tests/​Reactor.AppTests.Host/​SelfTest/​SelfTestFixtureRegistry.cs Registers paging regression fixtures.
tests/​Reactor.AppTests.Host/​SelfTest/​Fixtures/​DataGridParityFixtures.cs Expands hook-only UI regression coverage.
tests/​Reactor.AppTests.Host/​SelfTest/​Fixtures/​DataGridPagingFixtures.cs Updates paging comments.
src/​Reactor/​Hooks/​UseInfiniteResource.cs Revises synchronization, cancellation, and subscriptions.
src/​Reactor/​Data/​DetachedDataSourceResource.cs Adds renderer-independent paging driver.
src/​Reactor/​Data/​DataSourceResourceExtensions.cs Extracts shared paging helpers.
src/​Reactor/​Data/​DataPageCache.cs Deletes legacy cache types.
src/​Reactor/​Core/​ReactorFeatureFlags.cs Removes paging rollout flag.
src/​Reactor/​Core/​InfiniteResource.cs Introduces page-backed item views.
src/​Reactor.Advanced/​Controls/​DataGrid/​DataGridState.cs Unifies row access and headless loading.
src/​Reactor.Advanced/​Controls/​DataGrid/​DataGridPagingSource.cs Adds client-side sort/filter adapter.
src/​Reactor.Advanced/​Controls/​DataGrid/​DataGridComponent.cs Uses hooks exclusively for paging.
skills/​reactor.api.txt Updates public API index.
samples/​apps/​headtrax/​HeadTrax/​Program.cs Removes legacy paging switch.
samples/​apps/​headtrax/​HeadTrax/​App.cs Removes paging-mode indicator.
samples/​apps/​headtrax/​docs/​missing-features.md Describes hook-based loading.
plugins/​reactor/​skills/​reactor-dsl/​references/​reactor.api.txt Synchronizes mirrored API index.
docs/​specs/​tasks/​async-resources-implementation.md Updates migration completion status.
docs/​specs/​020-async-resources-design.md Records legacy cache removal.
docs/​reference/​async-system.md Removes obsolete flag references.
docs/​guide/​reference/​extensibility/​ReactorFeatureFlags.md Updates generated flag reference.
docs/​guide/​reference/​data/​paging.md Removes retired cache API documentation.
docs/​guide/​reference/​controls/​data-grid.md Updates state API reference.
docs/​guide/​data-system.md Documents hook-only paging behavior.
docs/​guide/​controls.md Removes legacy cache listing.
docs/​guide/​async-resources.md Updates paging migration guidance.
docs/​_pipeline/​templates/​data-system.md.dt Updates paging guide source.
docs/​_pipeline/​templates/​controls.md.dt Removes obsolete control-guide entry.
docs/​_pipeline/​templates/​async-resources.md.dt Updates migration guide source.
docs/​_pipeline/​reference-map.yaml Removes retired type mappings.
docs/​_pipeline/​apps/​data-system/​App.cs Updates paging sample comment.
docs/​_pipeline/​ai-author-skill.md Updates paging authoring guidance.
CHANGELOG.md Documents behavior changes and API migrations.

Review effort: Balanced

Comment thread src/Reactor/Core/InfiniteResource.cs Resolved
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

🧪 Merged coverage

Coverage for 50eb5fd vs the base branch (7020f0c) — unit + selftest merged.

Metric base PR Δ
Line 89.22% 89.33% +0.11 pp ✅
Branch 43.99% (18780/42687) 44.17% (18881/42749) +0.18 pp ✅

✅ 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.

- Release the client-side result when paging from the source again.
- Keep rows in view recent for MaxLoadedPages, without refetching rows an
  oversized fallback page already holds.
- LoadedRows takes the indexer's value where pages overlap.
- Cap headless DataGridState loads at the grid's 20 pages.
- Refresh invalidates every page of the query, evicted ones included.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

Active pagination defects can prematurely evict loaded pages, skip fetching unloaded rows, and return placeholders for data already available.

1 open issue
2 previously missed issues

In code that hasn't changed since last review

Medium severity ItemAt returns placeholders when overlapping pages contain the row

src/​Reactor/​Core/​InfiniteResource.cs:165

This covering-page lookup is bypassed when an overlapping page already has an in-flight slot. For example, request pages 0 and 1 with PageSize 10, then let page 0 return 25 rows while page 1 remains pending: Items[15] contains row 15, but ItemAt(15) returns default from the earlier slot branch. Consumers using ItemAt therefore show placeholders for loaded data. Apply the covering-page fallback to existing slots that cannot supply the requested row, matching ItemsView.

Medium severity In-flight pages incorrectly count toward the loaded-page cap

src/​Reactor/​Core/​InfiniteResource.cs:493

The eviction loop counts in-flight slots toward MaxLoadedPages: with 21 requests outstanding and a cap of 20, the first completed page is immediately evicted even though it is the only loaded page. Rapid scrolling against a slow source can therefore discard arriving rows and trigger redundant fetches. Count only completed pages toward the cap, and add a regression test with overlapping asynchronous requests.

5 resolved since last review

Review effort: Balanced

Comment thread src/Reactor/Core/InfiniteResource.cs Resolved
- EnsureRange only treats rows as covered by an oversized page within the
  requested range, so rows past it are still requested without a total.
- ItemAt reads a row an oversized page holds when its own page is in flight.
- Only loaded pages count toward MaxLoadedPages.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

Asynchronous data refreshes lose the known row count and replace the virtual list with a loading template, destroying its scroll state and returning users to the top.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve virtual list scroll position when refreshing observable data

src/​Reactor.Advanced/​Controls/​DataGrid/​DataGridComponent.cs:361

When an asynchronous observable source raises DataChanged after scrolling, Refresh() replaces the resource without retaining TotalCount; the pending render then reports zero rows and replaces the VirtualList with the loading template. This destroys its ScrollViewer, so the grid returns at the top when page 0 arrives. Preserve the known extent and viewport across refresh, reload the visible pages, and add a regression test with a delayed observable source.

1 resolved since last review

Review effort: Balanced

InfiniteResource.Refresh keeps the known TotalCount while page 0 reloads,
as documented, and the grid reloads the rows in view, so an observable
source's DataChanged no longer resets the scroll position.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

A failed refresh after a successful load can hide the error behind placeholders because the retained total count remains nonzero, requiring a corrected error-template condition and regression coverage.

1 open issue

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

Human assessment is needed because refreshes can retain misleading totals that hide rows or leave stale placeholders, while failed pages can accumulate LRU metadata despite cache limits.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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

Human assessment is needed to evaluate failed-page subscriptions that can accumulate pinned cache entries despite the page cap.

No open issues 🎉

Review effort: Balanced

Follow-up from Copilot's round 6 summary.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

Human assessment is needed because out-of-order refresh completions can erase a newer item total and truncate the grid’s scroll extent.

No open issues 🎉

Review effort: Balanced

Follow-up from Copilot's round 7 summary.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

Human assessment is needed because evicting cached continuation cursors can make revisiting older pages trigger increasingly expensive refetches.

No open issues 🎉

Review effort: Balanced

Follow-up from Copilot's round 8 summary: an evicted page releases its
cache entry, so its next cursor is kept separately and a cursor-paged
source doesn't refetch the chain to revisit a page.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

Eviction cursor history grows without bound for DataGrid/UseDataSource requests despite the 20-page cap, even though CursorFromPageIndex makes that history unnecessary.

1 open issue

Review effort: Balanced

Comment thread src/Reactor/Core/InfiniteResource.cs Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

Human assessment is needed because late offscreen page completions can evict the visible page after scrolling stops, leaving placeholders visible until another scroll.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Follow-up from Copilot's round 10 summary: each page that lands outside a
scroll marks the rows in view as recently used again (and reloads any a
late page evicted).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

A persistent page failure can trigger an unbounded request/render loop without further scrolling; the queued load needs an error-state guard and regression coverage.

1 open issue

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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 changes span shared paging lifecycle, cancellation, eviction, and WinUI refresh behavior, but independent cross-model review and Windows runtime validation were unavailable.

No open issues 🎉

1 resolved since last review

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 Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Agent work and technical checks complete; awaiting review, not approval or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants