Repository navigation
In read mode a local strategy opens from the store when the store is known to equal Hive for it, and every open and page switch says where it came from - #737
Open
SunkenInTime wants to merge 2 commits into
Conversation
…known to equal Hive for it, and every open and page switch records where it was served from and why
… each page load logs, and how to time an open and a switch
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 44 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch has not been deployed
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.
This is step 3 of reading the local library from the store: in
--library-store=read, a local strategy now opens from the store's rows instead of Hive. Hive stays the truth. Saves still go to Hive throughLocalLibrary, so the editor's state comes from rows while the saved data stays Hive's. This is the first step where the flag can change saved data, so most of this PR is proof that it doesn't.What the editor takes from the store, and what goes back
A local open takes three things from storage: the page list in sort order, the shown page, and the theme. In read mode, each page load either comes wholly from the store or wholly from Hive, never a mix. "Wholly" covers the page data, the page list the pages bar shows, and the theme.
A save writes back only these, starting from Hive's own record:
Page names and order, the other pages, the folder and the strategy name always come from Hive. So do migration, the cleanup of unused images, and every page operation (add, delete, reorder, duplicate, apply to all pages).
When the store is used
The open comes from the store only when all of these hold:
That last one is checked before and after the reads, with a per-strategy count of Hive writes begun.
If any of these fails, the load comes from Hive. Nothing is ever refused, and nothing waits for the mirror. Each page switch runs the same test.
Every open and switch has an outcome
StorePageReads(lib/library_store/store_page_reads.dart) records one outcome per page load. It is either served from the store, or served from Hive with a reason:migrationRanmirrorNotFollowingmayDiffernotInStoretiedPositionsnoPagesdamagedRowshiveWriteDuringReadreadFailedThe driver prints every load (
STORE page ...). The new{"logPageReads": tag, "expect": {...}}step checks counts. Every run in read mode ends with the counts by reason.A page switch practically always comes from Hive (
mayDiffer). On main, every local switch first writes the page it leaves back to Hive, even with no edit. That write isn't copied by the mirror yet when the next page is read. My design note missed this. The rule is still safe; it just means only opens are served from the store at this step.What a build without the flag runs
localPageReadsProviderisnullunless--library-store=readoverrides it. That flag only takes effect in drive and debug builds (shadowReachable), so a shipped build never sets it. At each hook, a build without the flag runs:LocalStrategyPageSource.loadPage: one provider read that returnsnull, then main's Hive code unchanged._applyLoadedPageData: one provider read that returnsnull, then the samelistPageIdswait and the same two theme lookups, in the same order.loadFromHive: a null-aware call onnull. Dart doesn't evaluate its arguments, somigratedStrategy != newStratisn't evaluated either.test/local_open_from_hive_test.dartpins today's local open and switch behaviour. Its 4 tests pass on main at 9d955e0 unchanged. They cover:Proof
Outcome tests (
test/library_store/store_page_reads_test.dart, 11). They go through the real editor open in a container wired as read mode wires it.mayDiffer.hiveWriteDuringRead, and the canvas shows Hive's page rather than the planted one.mayDiffer. That's because the mirror hasn't copied the write when the read ends.The corpus (
test/library_store/open_from_store_corpus_test.dart). It skips withoutICARUS_LIBRARY_CORPUS, and copies each store to scratch, never opening it in place.agentDatadiffering for that strategy.Running app: I ran six local editor scripts once in mirror mode and once in read mode, on Windows (release driver build) and on Linux. The scripts were quick-page-switch-local, lineup-order-local, autosave-after-side-on-all-pages-local, transition-marker-sizes, transition-drawings-local and marker-size-undo.
SUMMARY ... CLEAN, in both modes, on both platforms.mayDiffer: 17 in all, for examplemayDiffer 9, openFromStore 1, switchFromHive 9in quick-page-switch-local.close-with-unsaved-local ends by closing the window, so it has no summary in either mode. Both modes reach the same last logged page.
Speed
Time from the tap's release to the first frame showing the page, on Windows, in a release driver build, three runs each. These come from the new
open-timed-largest.jsonandopen-timed-typical.json, started with--hive-storeon copies of the real stores:canvas-compatibility-v97, 20 pages, 549 items)Lotus replay · Oct 31, 2026, 2 pages, 27 items)Reading a whole strategy from the store costs 0.44 s at 100 pages, and the cost grows faster than the page count. The open never does that; it reads page by page. Filed as #734.
Not in this PR
ci: analyze test