Repository navigation
Description
Current behavior
Start with a model that has a state and a command, bound in XAML:
public partial record MainModel
{
public IState<int> Count => State.Value(this, () => 0);
public async ValueTask Increment(CancellationToken ct) => await Count.UpdateAsync(c => c + 1, ct);
}<TextBlock Text="{Binding Count}" AutomationProperties.AutomationId="CountText" />
<Button Content="+1" Command="{Binding Increment}" AutomationProperties.AutomationId="IncrementButton" />While the app runs, add a feed through Hot Reload:
public IFeed<bool> IsGoalReached => Count.Select(c => c >= 10);Hot Reload reports success on both sides: server op Success, and the app's op Success with types MainModel, MainModelMock, MainViewModel (+1 more). The page is recreated with Count = 0. From then on, clicking +1 does nothing. The command runs and completes (IsExecuting False, no error), but Count stays 0.
The view model's DataContext after two clicks (from the App MCP):
MainViewModel
Model: Preflight.Presentation.MainModel#1
Count: 0
IsGoalReached: False
Increment: AsyncCommand (IsExecuting False)
Likely cause
The generated __Reactive_BindableInitializeForUpdatedModel(object updatedModel, ...) handles the two kinds of member differently:
- Commands: rebuilt on every call, against the updated model (
dynamic model = updatedModel; ... model.Increment(...)). - Feeds and states: created only once,
if (_count == null) _count = new Bindable<int>(Property<int>("Count", model.Count)).
So after the update, Increment updates MainModel#1's Count, while CountText stays bound to the Count of the model instance the view model was created with.
Expected behavior
After the edit, clicking +1 increments the displayed count, as it does after an edit that changes only a method body. That case works on desktop: the page is recreated and the new code runs.
How to reproduce
On an app created from the recommended preset (MVUX, Navigation), with the model and XAML above:
- Run the desktop target under the DevServer and click +1 once (0 → 1).
- Add the
IsGoalReachedfeed and save; Hot Reload reports it applied. - Click +1 twice: the count stays 0.
Seen in an AI-agent run too: after adding IsGoalReached (plus XAML edits), the agent clicked Increment twice with no change, suspected a stale binding, read the DataContext (Model: MainModel#1), and restarted the app.
Environment
- Uno.WinUI 7.0.0-dev.2270, Uno.Extensions.Reactive / Navigation 8.0.0-dev.76, Uno.Sdk 7.0.0-dev.73
- DevServer host 7.0.0-dev.2270; .NET SDK 10.0.400
- Skia desktop (Windows 11)
Related
Possibly a regression of #2906, which #2830 fixed.
Scripted run (driven through the App MCP), including the DataContext dump
mode=addfeed host ready; logs X:\skill-ab\repro\hr-repro10-addfeed-155918-*
[start net10.0-desktop] exit=0 21s | Hot Reload: Ready. Edit XAML/C# files and confirm each edit with uno_app_hot_reload_status(file); do NOT restart the app to pick up edits.
tap before any edit (+1): CountText 0 -> 1 (delta 1) invoke exit=0
[E1 add feed IsGoalReached] exit=0 | edit to 'Preflight\Presentation\MainModel.cs': applied (server op #1 Success in 2.8s, local op #2 Success in 0.4s, types: MainModel, MainModelMock, MainViewModel (+1 more))
tap after E1, 1st (+1 if the UI follows the model): CountText 0 -> 0 (delta 0) invoke exit=0
tap after E1, 2nd: CountText 0 -> 0 (delta 0) invoke exit=0
[datacontext of CountText] exit=0
<Object type="Preflight.Presentation.MainViewModel"><Model><Object type="Preflight.Presentation.MainModel#1"><Title>Main - Preflight-en - Development</Title><Count><Object type="Uno.Extensions.Reactive.Core.StateImpl`1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]"><Context><Object type="Uno.Extensions.Reactive.Core.SourceContext"><Token><Object type="System.Threading.CancellationToken"><IsCancellationRequested type="Boolean">False</IsCancellationRequested><CanBeCanceled type="Boolean">True</CanBeCanceled><WaitHandle><Object type="System.Threading.ManualResetEvent"><Handle type="IntPtr">1776</Handle><SafeWaitHandle><Object type="Microsoft.Win32.SafeHandles.SafeWaitHandle"><IsInvalid type="Boolean">False</IsInvalid><IsClosed type="Boolean">False</IsClosed></Object></SafeWaitHandle></Object></WaitHandle></Object></Token></Object></Context><Requests><Object type="Uno.Extensions.Reactive.Core.CompositeRequestSource" /></Requests></Object></Count><IsGoalReached><Object type="Uno.Extensions.Reactive.Operators.SelectFeed`2[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Boolean, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]" /></IsGoalReached></Object></Model><Title>Main - Preflight-en - Development</Title><Count type="Int32">0</Count><Increment><Object type="Uno.Extensions.Reactive.Commands.AsyncCommand"><IsExecuting type="Boolean">False</IsExecuting></Object></Increment><IsGoalReached type="Boolean">False</IsGoalReached></Object>
sources reset, host stopped
Activity
fix(mvux): hot-patch the feed a bindable was created from on view mod…
fix(mvux): keep bindables on the updated model when an HR delta adds …