Repository navigation
fix(mvux): keep bindables on the updated model when an HR delta adds a derived feed (backport #3230) - #3232
Merged
Conversation
…a derived feed - Patch bindable properties before initializing members from the updated model, so the shared subscription is re-keyed onto the new feed before a newly added derived feed subscribes to it - Hot-swap the shared subscription before re-keying it, and log a key conflict instead of aborting the property, so the bindable follows the updated model in every case - Add a unit repro (red on main) covering the added feed and a second delta, a runtime HR test mirroring the issue, spec 015, and a lesson on running the HR lane on Windows Closes #3226 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bnp4Xi4RAU2pnfN9PNRUph (cherry picked from commit 06868ef)
…els recreated after HR - Record the feed each bindable property is created from (state hot reload only), and have the patcher swap that feed's subscription instead of re-reading the property from the previous model - After a delta, the EnC-updated view-model ctor and reflection on the original model type can run different getters, each with its own cached lambda, so `State.Value`/`Feed.Async` returned another state and the bindable of a recreated page never followed the updated model - On a re-key conflict, keep tracking the previous feed, which still resolves to the shared subscription - Cover the recreated view model in the runtime HR test (red on main, green locally) and add a unit repro of the getter divergence; document how to run the HR lane on Windows Refs #3226 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bnp4Xi4RAU2pnfN9PNRUph (cherry picked from commit 9c85e9d)
…n_StateForEach - `SetAsync` completes once the state applied the update, not once ForEach callbacks ran, so asserting right after it was flaky (`When_Mixed_Multiple_UpdateState_...` failed CI on this PR, and fails ~20% of local runs on main too) - Replace the immediate assertions and the fixed 100 ms delay with a bounded wait for the expected callback count, so a dropped callback still fails the test Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Bnp4Xi4RAU2pnfN9PNRUph (cherry picked from commit ab3b517)
5 of 7 tasks
Closed
1 task done
kazo0
approved these changes
Oct 26, 2026
Merged
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue (If applicable): closes #3226
PR Type
What is the current behavior?
After a Hot Reload delta that adds a feed derived from an existing state (e.g.
IsGoalReached => Count.Select(c => c >= 10)), commands keep running but the UI no longer reflects them:Countstays at 0.A bindable property follows a hot-patch only if the patcher swaps the shared subscription the bindable enumerates (keyed by the feed the bindable was created from). Two causes broke that:
__Reactive_UpdateModelinitialized members from the updated model before patching. The new derived feed subscribed to the updatedCountstate, soSetSubscription(updated, shared)threw on the key conflict and the swap after it never ran.model.Countand the patcher's reflection read ofCounton the original model type run different getters, each with its own() => 0lambda.State.Value(likeFeed.Async) caches per lambda, so the same model instance yields two states. The patcher swapped the subscription of a state no bindable used.What is the new behavior?
ViewModelGenTool_3,_2): patch first, then initialize.BindableViewModelBase):Property(name, feed)records the feed each bindable is created from (only when state hot reload is enabled), and the patcher swaps that tracked feed rather than a fresh read of the previous model.SetSubscription. A key conflict is logged and the previous feed stays tracked, so the next delta still finds the shared subscription.ObjectDisposedExceptionstill propagates.PR Checklist
HotReload.Spec.md§4.13,specs/lessons.md)Other information
Tests:
Reactive.Tests/IntegrationTests/Given_HotReload.cs:When_AddDerivedFeedInModel_Then_StateBindableFollowsUpdatedModel(cause 1, plus a second delta). Red onmain.When_ViewModelCreatedAfterDelta_Then_CommandsUpdateBoundState(cause 2, emulates the getter divergence). Red without feed tracking.Reactive.UI.Tests/Given_HotReload.cs:When_AddDerivedFeedToModelWithStateAndCommand_Then_CommandUpdatesBoundStatecovers both the live view model and one created after the delta.Verification (Windows, desktop head, real HR deltas):
mainexpected "2", actual "0"Given_HotReloadruntime tests with the full fixFlaky tests:
Given_StateForEach.When_Mixed_Multiple_UpdateState_Then_CallbackInvokedIgnoringInitialValuefailed the Packages job on this PR. It is a pre-existing race:SetAsynccompletes beforeForEachcallbacks run, and the test asserted immediately (it fails ~20% of local runs onmaintoo). A separate test-only commit replaces the immediate assertions, and an older fixed 100 ms delay, with a bounded wait for the expected callbacks in the five tests sharing that race.Given_PaginatedListFeed.When_Async_Then_FlagIsLoadingfails intermittently under full-suite load, onmaintoo (2 of 5 runs). It passes alone and is not touched here.The "Build and Deploy Job" (Azure Static Web Apps docs preview) fails because the Static Web App has reached its maximum number of staging environments. Someone with Azure access needs to delete old preview environments; nothing in this PR affects it.
Running the HR lane on Windows needs a specific build: both head target frameworks, with hard links off. The recipe is in
specs/lessons.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01Bnp4Xi4RAU2pnfN9PNRUph
This is an automatic backport of pull request #3230 done by [Mergify](https://mergify.com).