perf: MagicPerfHooks, zone-carried causes, AuthRestored.changed, change-only repository notifies - #210
Conversation
…r names MagicPerfHooks
A timer tick and a broadcast handler open a root cause scope that replaces the inherited one, and setState/repository queries inherit it, so a record names the site that started the work. Model.casts defaults to a const map and the model stub, docs and skills write const casts, so a cast map is no longer rebuilt on every attribute read.
The background user sync dispatched AuthRestored on every 200, including the cold-boot sync that only confirms the cached user, so a listener that remounts on it (magic_starter's reload) rebuilt the whole app on every boot and tore down whatever the user had just opened. AuthRestored gains changed, false when the synced user serializes the same as the one held before it; it defaults to true, so existing constructions keep their meaning.
patch, upsertFromShow and upsertFromList notified on every call, so a broadcast that restated a cached reading, or a refetch answering what was already held, rebuilt every screen listening to the repository; in uptizm one manual check rebuilt the hidden monitors list several times. Each write now compares the raw stored attributes before and after (deep, map keys in any order) and notifies only for a new, evicted or changed row. The deep comparison moves out of BaseGuard into an internal sameValue helper both use.
AuthRestored.changed compares toMap(), which drops hidden attributes, and Repository.patch compares against a shallow copy, so a nested value changed in place and patched back reads as unchanged. Both doc blocks now say so.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Note Kodizm (AI-generated). May contain mistakes; verify before acting. I found no defects in this change, and CI is green. I checked the areas most likely to go wrong:
With no sink installed, every instrumented site takes the old code path after one null check. The repo's post-change sync ( I read the diffs for all changed TestsThere are new tests in CI
|
What
MagicPerfHooks.sinkwith per-request ids replacesonRefreshUI; the notify cause is carried in the zone (root sitestimerTickandbroadcast, derived sites inherit).Model.castsdefaults to a const map; the stub, docs and skills write const casts.AuthRestored.changed: false when the background user sync only confirmed the cached user.Repository.patch,upsertFromShowandupsertFromListnotify only when the cache changed.Why
AuthRestored), tearing down any overlay or toast; one manual check rebuilt a hidden list several times through notifies that changed nothing.Testing
flutter testgreen (2262); magic_starter (1660), magic_devtools (135) and uptizm (bin/check flutter) green against this branch.Release before magic_starter, which needs
AuthRestored.changed.