Repository navigation
fix(ui): define each cached read once, so the developer report runs its own full check - #1060
Merged
Merged
Conversation
…ng check The check made as an instance is opened (checkInstance) and the developer report's check of every document (validateInstance) were cached under one key, ["validation", url], both kept fresh for good. The workspace keeps its data check mounted while it shows the report, so the report showed the opening check from the cache, without the answer log, which validation.md says the developer report always checks. And "Validate again" put the full report where the data check reads, so an answer log month that doesn't conform could hold the instance back under "block the instance", though the opening check leaves the answer log out on purpose. Each check now has a key of its own under ["validation", url] (instanceCheck, fullValidation), so refreshing the instance's checks still makes both again, with the Studio's deck health under it too. Refs: #1059
Each screen wrote out the pod reads it caches: the query key, the use case that fills it, and how long the result stays fresh. check:keys made the key a single definition, but the read and its freshness were still written at every site, and nothing kept the sites of one key alike. That is how ["validation", url] came to be filled by two different checks. Each read is now defined once as TanStack Query's queryOptions, in packages/ui/src/ui/queries.ts (Solid Memo's reads, and the ones the Studio shares) and apps/studio/src/ui/queries.ts (the Studio's own, built on the first, as the keys modules are). A screen spreads a definition into useQuery, useQueries or a prefetch and adds only what is its own: enabled, select, placeholderData, or a prefetch's or fetch's own staleTime. A definition given no argument to read with reads nothing (skipToken), so an enabled that only guarded a missing argument goes, with its non-null assertions. The factories that were already there (studyCountsQuery, courseStripQuery, libraryIndexQuery, libraryUpgradeQuery, statisticsQuery, todayFiguresQuery, libraryUpdatesQuery, releaseDraftQuery, deckHealthQuery) move into the modules. Cache-only observers get definitions of their own (foundDeckHealth, foundInstanceGraph) on the same keys. The release check's draft versions and Markdown check move to draftVersions.ts, so the Studio's queries module can use them without an import cycle. Where the sites of one key differed in freshness, one choice is made: - deckTree is never read again on focus: the arrangement is edited on the screen before it is written, and a read begun then could bring back the list as it was. The Studio's drafts and transfer screens no longer read the arrangement again when the window takes the focus. - preferences: SchedulerInvitation's refetchOnWindowFocus: false goes. It had no effect: the workspace's own reads of the preferences, mounted beside it, read them again on focus. - preferencesMisfit is read again on focus wherever it is shown, as the preferences it tells of are. The deck list's invitation now reads it again when the window takes the focus. - cardAnswers is kept for STATISTICS_STALE_MS everywhere, as the statistics are: every change made clears it (keepStudyFiguresFresh), in the Studio too. The Studio's card inspector now shows answers read in the last half minute instead of reading them again. - instanceCheck is read again on focus when it failed or left a document unread, on the Studio's instance health screen too, which before kept a check with data until asked. - course: CourseStrip's 30 s is its prefetch's own staleTime (a course read in the last half minute isn't read again), so it stays at the prefetch; the read itself has one freshness. - studyCounts: every site already used one factory. The deck health screen's read afresh (forgetDeckCheck first) is the definition's afresh option now, not a queryFn written at the screen. Refs: #1059
Each cached read is now defined once in a queries module, with its key, the use case that fills it and its freshness. Nothing kept a screen from writing a read of its own again, with another use case or freshness on the same key, which is how ["validation", url] came to hold two different checks. check:keys now also fails on a queryKey property of an object literal outside packages/ui/src/ui/queries.ts and apps/studio/src/ui/queries.ts, in code that is not a test. A QueryClient's filter of queries (an invalidation, a removal, cancelQueries, matchQuery and the like) still names its key by a function of queryKeys, so a queryKey given to one is accepted. The rules on keys written out as arrays are unchanged, and apply in the queries modules too. Closes: #1059
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.
What and why
The check made as an instance is opened (
checkInstance) and the developer report's check of every document (validateInstance) were cached under one key,["validation", url], and both stayed fresh until asked again. The workspace keeps its data check mounted while it shows the report. So the report showed the opening check from the cache, without the answer log, thoughvalidation.mdsays the developer report always checks it. "Validate again" then put the full report where the data check reads. An answer log month that didn't conform could then hold the instance back under "block the instance", though the opening check leaves the answer log out on purpose.The cause was that each screen wrote out its own cached reads (key, use case and freshness), and nothing kept the sites of one key alike. This pull request has three commits:
["validation", url](instanceCheck,fullValidation), so refreshing the instance's checks still makes both again, with the Studio's deck health. A regression test mounts both checks together. It fails on the shared key.queryOptions, inpackages/ui/src/ui/queries.ts(the app's reads and the Studio's shared ones) andapps/studio/src/ui/queries.ts(the Studio's own, built on the first, as the keys modules are).enabled,select, or a prefetch's ownstaleTime.skipToken), so the guards and non-null assertions that only covered a missing argument are gone.draftVersions.ts, so the Studio's queries module andreleaseCheck.tsdon't import each other.check:keysnow also fails on aqueryKey:property outside the two queries modules, in code that isn't a test. A QueryClient's filter of queries (an invalidation or a removal) still takes a key fromqueryKeys.Where the sites of one key differed in freshness, one choice is made, with its reason in the definition's comment. Four of these choices change behavior:
preferencesMisfitagain on focus, as the preferences it describes are.docs/validation.md,docs/architecture.md(query keys),docs/testing.md(check:keys) and the pages that named the moved factories are updated.npm run checkpasses on each commit, andnpm run lint:reusepasses.Closes: #1059