Skip to content

fix(analyzers): skip REACTOR_DSL_001 on Select projecting non-elements - #1428

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 2 commits into
microsoft:mainfrom
bkudiess:bkudiess-fix-dsl001-non-element-select
Oct 27, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 2 commits into
microsoft:mainfrom
bkudiess:bkudiess-fix-dsl001-non-element-select

Conversation

@bkudiess

@bkudiess Barbara Kudiess (bkudiess) commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

REACTOR_DSL_001 (MissingWithKeyAnalyzer) asked for .WithKey() on any Select passed into a layout factory, even when the projection produces values rather than elements. Real repro from openclaw-windows-node (Usage page charts):

Grid(days.Select(_ => GridSize.Star()).ToArray(), new[] { GridSize.Star() }, TextBlock("x"))

The Select builds GridSize[] column definitions, so there is nothing to key, but the analyzer reported DSL_001 on it.

Fix: after the existing cheap syntactic gates, the rule resolves the projection's type and skips it unless it is a Microsoft.UI.Reactor.Core.Element. A projection still counts as an element when:

  • its own type derives from Element;
  • the type it converts to is Element, as with ForEach's Func<T, Element> or an explicit Select<T, Element>. That keeps bodies that become elements through an implicit operator (string, ChartElement<T>) reporting;
  • it is a type parameter constrained to Element, directly or through another type parameter.

An unresolved, error or dynamic type keeps the old verdict, so broken code still reports. The semantic lookup only runs for candidates that already passed every syntactic gate. docs/guide/analyzer-architecture.md is updated to describe this step.

Linked issue / spec

Related to spec 042 (keys). No issue filed.

Test plan

  • Added unit tests in tests/Reactor.Tests/AnalyzerTests/MissingWithKeyAnalyzerTests.cs:
    • No diagnostic: Select projecting GridSize Grid definitions; Select projecting strings into a string[] layout argument.
    • Still fires: an element Select next to the Grid definitions (exactly once); a ForEach body that converts to Element implicitly; an explicit Select<Row, Element> of a convertible body; Select of an Element-constrained type parameter, direct and transitive.
  • Mutation checks: without the type check, the two GridSize tests fail. Without the converted-type and constraint handling, the three "still fires" conversion/generic tests fail.
  • dotnet build src/Reactor.Analyzers -c Release: succeeded, 0 warnings, 0 errors.
  • dotnet test tests/Reactor.Tests --no-build -p:Platform=x64 --filter-class "*MissingWithKeyAnalyzerTests*": 54/54 passed.
  • dotnet test tests/Reactor.Tests --no-build -p:Platform=x64 --filter-namespace "*AnalyzerTests*": 3151/3151 passed.
  • dotnet test tests/Reactor.Tests --no-build -p:Platform=x64 --filter-namespace "*CheckCommandTests*" --filter-namespace "*Tooling*": 643/643 passed.
  • dotnet run --project tools/Reactor.DocPipeline -- compile --topic analyzer-architecture --no-screenshots --no-ai --no-build --skip-diagrams, then dotnet test tests/Reactor.DocPipeline.Tests: 493/493 passed.
  • CI on the current head: 40 checks passed, 2 skipped (path-filtered), 0 failed, including Build solution (Release) and Unit Tests.
  • Caveat: the full local dotnet test tests/Reactor.Tests run and the local Release solution build were not clean on the author's machine, for reasons unrelated to this change. The test host crashed partway through one run. The solution build hit MSB3030 copy errors in two sample apps' copilot-cli payloads under a deep worktree path. CI's Unit Tests and Build solution jobs are green on this head.

Risk / breaking changes

Low. This is a diagnostic-only change. It only removes DSL_001 reports, and only for projections whose resolved, converted and constrained types are all non-Element values. No public API change. There is no mur check mirror of DSL_001 (CheckCommand only maps it to a doc hint), so the CLI needs no matching change. CHANGELOG entry added under Unreleased → Fixed.

Known pre-existing limitation, unchanged by this PR: when the body only converts to Element (for example a chart builder), the DSL_001 code fix's .WithKey(...) suggestion doesn't compile without a cast.

A Select passed into a layout factory was flagged whatever it produced, so
Grid(days.Select(_ => GridSize.Star()).ToArray(), rows, ...) asked for a key
on column definitions. After the syntactic gates, skip projections whose type
does not derive from Microsoft.UI.Reactor.Core.Element; an unresolved type
keeps the old verdict.

Co-authored-by: Copilot App <[email protected]>
Count the converted type and Element-constrained type parameters as element
projections so ForEach bodies that convert implicitly (string, chart builders),
explicit Select<T, Element>, and generic row helpers still report DSL_001.
Treat dynamic as unresolved. Refresh analyzer-architecture docs.

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

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.

🟢 Approval recommended

No active review issues are reported for the fix to false-positive missing-key warnings on non-element projections.

No open issues 🎉

What changed in this PR

This PR fixes false-positive REACTOR_DSL_001 warnings when layout arguments use Select to produce values, such as Grid definitions, rather than Reactor elements.

Changes:

  • Adds a projection-type check after the existing syntactic filters, preserving diagnostics for element conversions and element-constrained type parameters.
  • Adds regression tests for non-element projections and cases that must still report.
  • Updates the analyzer documentation and changelog.
File Description
tests/​Reactor.Tests/​AnalyzerTests/​MissingWithKeyAnalyzerTests.cs Adds coverage for value projections, conversions, and generic constraints.
src/​Reactor.Analyzers/​MissingWithKeyAnalyzer.cs Filters out resolved non-element projections before reporting missing keys.
docs/​guide/​analyzer-architecture.md Updates the generated guide to explain semantic filtering.
docs/​_pipeline/​templates/​analyzer-architecture.md.dt Updates the source template for the analyzer guide.
CHANGELOG.md Records the diagnostic fix under Unreleased.

Review effort: Balanced

@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit 0b20c84 into microsoft:main Oct 27, 2026
42 checks passed
Barbara Kudiess (bkudiess) added a commit to openclaw/openclaw-windows-node that referenced this pull request Nov 10, 2026
…rts and filters (#1895)

* feat(usage): rebuild the Usage page with the web page's sessions, charts and filters

Replace the classic XAML Usage page with a Reactor page that gives Windows
users the same usage information as the web Control UI: reporting range with
presets, time zone and scope, totals, daily token and cost charts, started-by
attribution, overview stats and top lists, cost windows, heatmap, activity by
time, a sessions list with per-session details, provider plans, and CSV/JSON
export.

Gateway JSON is parsed in OpenClaw.Shared (sessions.usage, .timeseries, .logs,
usage.status, usage.cost) and projected by WinUI-free presentation code with
unit tests. Released Gateways that reject the newer sessions.usage overview
parameters get a basic view; Gateways without sessions.usage fall back to
usage.cost totals.

Depends on Reactor analyzer fixes microsoft/microsoft-ui-reactor#1427 and
microsoft/microsoft-ui-reactor#1428; with stock 0.1.0-preview.12 the build
reports 7 REACTOR_DSL_001/REACTOR_A11Y_001 false positives.

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

* fix(usage): keep chart marks visible in high contrast

Use the existing Usage data palette for marks and selection indicators instead of the native button fill, which can equal the plot background in high contrast. Cover clickable and nonclickable native charts with contrasting theme inputs.

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

* fix(usage): preserve filtered and incomplete report states

Keep filtered details scoped to matching usage, preserve model lower bounds, clear unsupported legacy selection and show legacy refresh failures. Pair high-contrast weekday text and fill, and strengthen callback and production-theme regression coverage.

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

* feat(usage): compact native Usage page on official Reactor preview.17

Replace the classic XAML Usage page with a compact Reactor page backed by
read-only Gateway reads.

- Cost, token and session totals; Today, 7-day, 30-day and custom ranges with a
  visible reporting zone; a daily trend with an accessible table; agent, model
  and provider contributors; capability-gated session browsing; lightweight
  detail; native conversation access; a web Usage handoff and a secondary CSV
  export.
- Provider allowance stays distinct from session-derived estimates. Partial,
  stale, failed, unsupported, forbidden and disconnected states are explicit.
- Released Gateways that reject the server overview parameters get a bounded
  basic view (at most 1000 rows). Older Gateways report Unsupported.
- Compact header: short custom-range label and inline date pickers on wide
  hosts, using the shared PageResponsiveLayout helper.
- Adopt official Reactor 0.1.0-preview.17 with a hash-verified, repository-local
  package bootstrap wired into build, CI, CodeQL and Store packaging.
- Update the six locales, DESIGN.md palette resources, the architecture ledger
  and the fixture documentation.

Known open items: the mounted UsagePageRenderingTests 937.14 DIP compact
transition case still fails, and cached Usage state is not yet reset when the
operator Gateway client changes.

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

* fix(usage): reset Usage on Gateway switch and stabilize layout waits

- Drop reports, plans, details and export state from the previous Gateway
  when the operator client is replaced; keep range, zone, scope, search,
  sort and metric. In-flight reads are cancelled and generation-fenced.
- Read the operator client once per operation so a replacement between
  reads cannot split one load across two Gateways or send the previous
  Gateway's session key to the new one.
- UI tests: wait on physical-pixel width for the 937.14 DIP transition
  and on model/topology convergence for the Custom range reflow.

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

* fix(usage): preserve native analysis and shared inset geometry

Keep reported-day charts, native expanders and shared provider reads. Integrate the authorized adaptive Settings and embedded inset/toggle ownership ports, and add pinned Usage hit, keyboard and feedback proof coverage.

Current source-only shell/test additions remain unvalidated pending the exclusive native lane. Historical proof does not establish acceptance of this candidate.

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

* fix(usage): refine native hero, facts and rendering diagnostics

Keep compact usage facts responsive, localize the allowance warning, and add owned-window paired capture diagnostics. Native pixel proof remains pending.

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

* fix(usage): simplify native controls and polish session layout

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

* fix(usage): address analysis correctness and review regressions

Preserve query provenance, disclose bounded selected-session details, keep pricing completeness separate from token counts, and coordinate provider refresh after authenticated binding. Bootstrap published Reactor packages before local builds while preserving NoBuild; adopt shared capped-field alignment and focused regressions.

Validated source content in an isolated headless snapshot: full build passed; Shared 4909 passed with 25 permitted skips; unfiltered Tray 5557 passed; Debug ARM64 UI tests compiled with no warnings or errors; documentation and 20 offline bootstrap controls passed.

Native/UI and Debug/non-Dev Release real-app proof remain blocked. The earlier failed run and retained safety lease are unchanged. No native readiness claim is made.

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

* fix(usage): fence deferred exports and stale analysis warnings

Check Gateway and page ownership after native file selection, withhold exact session shares for incomplete reports, and share expiry-aware provider attention. Preserve later reset notifications and retained-snapshot render invalidation.

Add deferred-file, completeness, provider lifetime and rendered regressions. Repair deterministic Usage fixture coverage and native geometry proof boundaries without removing keyboard, hit-testing, inset or ink assertions. Retain the unassigned mounted testhost crash as a validation blocker.

Validation: diff checks and static fixture reproduction passed. Independent source/proof-plan review completed; both follow-up test findings were corrected and independently checked. Windows build, .NET tests, negative controls and native proof remain unrun here because pwsh, dotnet and winapp are unavailable.

Co-authored-by: bkudiess <[email protected]>

* fix(usage): distinguish quota-window projection from WinUI types

Rename only the private LINQ tuple member so the unchanged pure-presentation architecture guard does not mistake it for a WinUI Window. Filtering and ordering are byte-identical after normalizing that identifier.

Validation: baseline/candidate token check and git diff --check passed. Full build, Shared/Tray and focused xUnit execution remain blocked locally by missing PowerShell and dotnet; fresh CI and native validation are required.

Co-authored-by: bkudiess <[email protected]>

* fix(usage): wait for committed warnings and unobstructed proof

Keep the failure-detail assertion behind actual native warning layout rather than unchanged fallback text. Prepare each responsive capture through the known host-warning presentation control, retain its Inbox fact, and reject late or unknown notification obstruction without weakening ink or hit-test guards.

Validation: diff checks and independent source/rubber-duck review completed, including corrections for capture-window ownership and asynchronous warning admission. Windows build and Shared/Tray tests remain unrun locally because pwsh and dotnet are unavailable. Preserve the original failed UI run, shared pane-toggle failure and whole-fixture timeout as outstanding validation work.

Co-authored-by: bkudiess <[email protected]>

* fix(usage): await measurable peers during responsive proof

Treat temporarily missing UI Automation measurements as not ready while retaining consecutive stable widths, exact geometry, all five captures and foreground ink checks. Keep this repair based on the published head, separate from private native height diagnostics.

Co-authored-by: bkudiess <[email protected]>

* test(chat): await composer visibility commits around questions

Observe the root visibility commit as well as the independently rendered question controls. Preserve native control identity, view-model draft and visibility assertions, and verify native draft text while hidden.

Co-authored-by: bkudiess <[email protected]>

* test(usage): verify native filter alignment rather than equal heights

Respect content-sized native controls while checking row containment, desired-height allocation, wide center alignment and wrapped query separation. Preserve the six theme/width cases and native session action guards.

Co-authored-by: bkudiess <[email protected]>

* test(chat): retain bounded redirect probe diagnostics

Record content-free monotonic phases and responder outcomes without changing the production request, security assertions or timeout budgets. Preserve primary failures and observe responder faults across cleanup races. This collects evidence, not a fix for the retained timeout.

Co-authored-by: bkudiess <[email protected]>

* fix(usage): retain query recovery and prove physical pane input

Keep overview-capable search mounted while a new query loads or fails, without restoring stale figures. Cover retained native focus and recovery through a bounded committed-state wait.

Replace the PR-added UIA point-leaf assumption with exact-center native mouse input and required pane transitions. Record the original UIA bridge result, require exact root HWND and foreground ownership, and reject a real test-owned opaque occluder. Preserve geometry and Tab assertions with no Invoke fallback.

Full isolated build, Shared (5347 passed, 28 permitted skips), Tray (5797 passed), native compilation and docs/bootstrap checks passed on the repair candidate. Final Release query regression passed. Debug and Release pinned fixtures proved physical transitions and occluder rejection, then failed the retained Tab-to-content assertion; attribution remains inconclusive and that gate is not waived. Earlier failed attempts remain recorded.

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

* refactor(usage): trim unrelated and unused page machinery

Preserve the approved daily analysis, connection and generation fencing, capability fallback, query recovery, export safeguards and distinct native regressions. Remove unrelated chat/Inbox changes, unused count state and forwarding, web-only fixture analytics, orphan resources and duplicate cases.

Validated exact tree aa2374d: full build; Shared 5347 passed with 28 permitted skips; unfiltered Tray 5828 passed; focused suites 175 and 246 passed; ARM64 UI compilation and docs/skills/bootstrap checks passed. Native runtime proof remains separate.

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

* test(usage): follow native title-bar tab order in pinned proof

Preserve physical hit and occlusion checks, then assert exact native title-bar stops before visible page focus. Verify Shift+Tab leaves content and Tab returns to the same control. The prior direct history-to-content assertion contradicted unchanged main XAML order.

Validated final source with full build, Shared 5445 passed/28 permitted skips, unfiltered Tray 5993 passed, focused 177/246, UI/integration compilation and workflow/docs checks. The exact pinned fixture passed 1/1 across Light and Dark with 20 physical transitions, two occluder negatives and explicit forward/reverse focus receipts; owned kernel job drained before release.

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

---------

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

3 participants