Skip to content

Fix TokenizingTextBox counter colors on local theme changes - #895

Open
azchohfi wants to merge 4 commits into
CommunityToolkit:mainfrom
azchohfi:azchohfi-token-counter-theme
Open

azchohfi wants to merge 4 commits into
CommunityToolkit:mainfrom
azchohfi:azchohfi-token-counter-theme

Conversation

@azchohfi

@azchohfi azchohfi commented Nov 24, 2026 •

Copy link
Copy Markdown

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 8d1a56150c135da04315181a9deeeeafb23d9959

Dimension Assessment Rationale
Change confidence 9/10 ↑ Both unchanged native regression rows pass on this head, with 381 native tests passed and 3 skipped.
↑ All 14 build and both package jobs passed after the main merge.
↓ UWP component tests are not discovered, and other Uno targets have no runtime counter test evidence.
Diagnosis confidence 9.5/10 ↑ Test-only native baseline failed both counter-color assertions after distinct Light/Dark probes and effective-theme checks passed.
↑ Preserving the existing template ThemeResource expressions fixes both failures and limit recovery.
Evidence fit 8/10 ↑ Bare native WinUI 1.8 reproduces the same local-Dark counter symptom without Reactor.
↓ The original wrapped 2.2 matrix was not rerun, and its captures do not establish a contrast ratio or app-wide Dark failure.

Fixes

No linked issue. The counter theme failure was reproduced with a bare native control in the existing component-test CI before adding the correction.

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

The counter template declares a ThemeResource foreground, but its loaded/count-update code replaces that reference with a brush from Application.Current.Resources. Changing the control's local RequestedTheme can leave the counter using the previous theme's color.

The test-only baseline reproduced this on native WinUI 1.8.260204000. In local Dark, the empty counter stayed #9E000000 instead of the element-local probe's #C5FFFFFF. At the limit, it stayed #FFC42B1C instead of #FFFF99A4.

What is the new behavior?

Count updates select the existing inner TextBox MaxReachedState or Default visual state rather than assigning the foreground directly. Both colors stay owned by the template's existing ThemeResource expressions. The shared path handles initial loading, token additions and token removals.

The bare native regression applies Light, Dark, and Light again directly to the control and its element-local secondary/critical probes, leaving the window root and application theme untouched. It first asserts that each probe has different Light and Dark colors, so matching an unchanged brush cannot pass the oracle.

The two cases cover the empty below-limit counter and the full counter followed by recovery through the existing ClearAsync API. They use the suite's existing loaded/render helpers, without arbitrary delays, app-wide theme changes, resource overrides, or wrappers.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • Tested code with current supported SDKs
  • New component
    • Documentation has been added
    • Sample in sample app has been added
    • Analyzers are passing for documentation and samples
    • Icon has been created (if new sample) following the Thumbnail Style Guide and templates
  • Tests for the changes have been added (if applicable)
  • Header has been added to all new source files
  • Contains NO breaking changes

Other information

git diff --check passed before the test and product commits. git diff --check origin/main HEAD also passed after merging main. No new source file or component was added, so their checklist items do not apply.

The standard CI workflow runs the Windows App SDK component suite with this command.

vstest.console.exe ./tooling/**/CommunityToolkit.Tests.wasdk.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=wasdk.trx" /Blame:"CollectDump;DumpType=Full;CollectHangDump;TestTimeout=30m;HangDumpType=Full" /Diag:"${{ github.workspace }}/vstest-diagnostic-log.txt"

Before the fix, commit f8800615cc053cec1a6c251f34b284a0292bda0d compiled successfully and both regression rows failed at the counter-color assertion. Their differing-color oracle and effective-theme assertions passed first. Native baseline job.

The overall baseline suite later aborted after losing communication with its test host while a Sizers test was active. It reported 25 passed and 2 failed, with an unknown total. This is evidence of the two specific native failures, not a cleanly completed full-suite run.

After the fix, the same command passed on commit 87b9bfbee112122d79d84adb71b5768bdb0637bf. Both unchanged regression rows passed, including limit recovery. The full native suite completed with 384 total, 381 passed and 3 skipped. After-fix native job, original attempt.

The same native job also passed all 39 source-generator tests with this command.

vstest.console.exe ./tooling/CommunityToolkit.Tooling.SampleGen.Tests/bin/Release/net8.0/CommunityToolkit.Tooling.SampleGen.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx"

Those before/after runs restored Microsoft.WindowsAppSDK.WinUI 1.8.260204000, Foundation 1.8.260203002, Base 1.8.251216001, and InteractiveExperiences 1.8.260125001. These native CI results are not a rerun of the separate wrapped 2.2 compatibility matrix.

The first after-fix UWP attempt failed in the gallery's .NET Native compiler with MSB6006 (ilc.exe exit -1073741819). A single unchanged UWP retry built successfully and passed the 39 source-generator tests. Both the test-only UWP baseline and this retry reported No test is available in entrypoint\CommunityToolkit.Tests.Uwp.exe for the component-test command below. Their green job status is therefore build evidence, not a UWP regression-test pass. That lane restored Microsoft.UI.Xaml 2.8.7.

vstest.console.exe ./tooling/**/CommunityToolkit.Tests.uwp.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=uwp.trx" /Blame:"CollectDump;DumpType=Full;CollectHangDump;TestTimeout=30m;HangDumpType=Full" /Diag:"${{ github.workspace }}/vstest-diagnostic-log.txt"

The final two-file diff was reviewed directly with no actionable finding. The first hosted review was explicitly incomplete after a runtime budget stop and is not treated as completed review. The hosted retry completed at the original after-fix head 87b9bfbee112122d79d84adb71b5768bdb0637bf with no open issues or inline findings. Its state is COMMENTED, not a human approval.

Current head after the main merge

Main commit af067edcc29e92cb28376aaf54f4cd99c8ac523f from #893 was integrated with a normal, non-rewriting merge. The new head is 8d1a56150c135da04315181a9deeeeafb23d9959, pushed only to the fork feature branch. The native component tree is identical to the original after-fix head, and the net diff against main remains the same two native files. No branch-specific CI workaround was added.

Current-head CI completed successfully. All 14 build jobs and both package jobs passed, along with XAML styling, sample-index and wasm-linux checks. Signing and release were skipped as expected for this PR. CLA passed. No fork workflow approval was needed or performed.

All eight formerly failing Uno lanes now passed their Uno Check step, MSBuild step and whole job on this head.

Target WinUI 2 WinUI 3
wasm All three passed All three passed
android All three passed All three passed
ios All three passed All three passed
macos All three passed All three passed

The new-head WASDK job reran both commands above successfully. Both counter regression rows passed, the component suite again reported 381 passed and 3 skipped out of 384, and all 39 generator tests passed. It restored the same 1.8 package versions listed above. This is additional new-head evidence, not a relabeling of the original before/after runs.

The new-head UWP job built successfully and passed 39 generator tests with Microsoft.UI.Xaml 2.8.7. Its component-test command again reported no tests available. No UWP runtime counter validation is claimed.

Copilot was requested exactly once for this new head. Its completed review has no open issues or inline threads, but calls for human assessment of cross-target runtime coverage. Its reference to Uno pre-build failures describes the earlier run, now superseded by the eight successful jobs above. The UWP discovery and broader runtime-coverage limits remain valid. The review is COMMENTED, not human approval.

All current-head automated gates have passed. Human review is still required. No merge or auto-merge is requested or enabled. No local GUI, Appx, or OS operations were used.

azchohfi and others added 3 commits November 23, 2026 17:03
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>
@azchohfi azchohfi changed the title Test TokenizingTextBox counter foreground across local themes Fix TokenizingTextBox counter colors on local theme changes Nov 24, 2026
@azchohfi
azchohfi requested a balanced review from Copilot November 24, 2026 01:40

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 review remained incomplete because one or more reviewers received a runtime budget-stop instruction.

No open issues 🎉

What changed in this PR

Fixes TokenizingTextBox counter colors when the control’s local theme changes, preserving the template’s theme-aware resource references.

Changes:

  • Replaces direct foreground assignments with the inner TextBox’s existing visual states.
  • Adds Light → Dark → Light regression coverage for empty and full counters, including recovery after ClearAsync.
File Description
components/​TokenizingTextBox/​tests/​Test_TokenizingTextBox_General.cs Tests counter colors against element-local theme probes and verifies limit recovery.
components/​TokenizingTextBox/​src/​TokenizingTextBoxItem.AutoSuggestBox.cs Selects counter visual states without replacing template ThemeResource expressions.

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.

🟢 Approval recommended

No active review issues remain for the change preserving theme-aware TokenizingTextBox counter colors.

No open issues 🎉

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

Although native WinUI CI passed, no UWP component tests were discovered and Uno jobs failed before build, leaving cross-target runtime validation of the shared XAML visual-state change incomplete and requiring human assessment.

No open issues 🎉

Review effort: Balanced

@azchohfi
azchohfi marked this pull request as ready for review November 25, 2026 22:57

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants