feat(recipe): refresh stale data when returning to a long-open page #117
+150
−14
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.
Changes
Defines when a mounted page refreshes its data: when the user comes back to it and the data is stale.
useRecipeQuerylistens towindowfocusanddocumentvisibilitychange. If the shown data is older thanRECIPE_FRESHNESS_MS(30 s, the same as the read cache), it drops that cache entry and refetches.refreshWhenStale: false), so typed input is never replaced.Validation
npm run checkpasses (215 unit tests), incl. new tests: no refetch on focus after 10 s; background refetch after 31 s with the old data kept until the new arrives; no refetch whenrefreshWhenStaleis off.AI usage
Written with Claude Code (Anthropic) to address a teammate's review of the final-delivery findings. Please review the diff as you would any other contribution.
Closes #107