Reload right after a save shows the pre-save record
Found on Projects edit while verifying this epic (originally drafted as task 12519, which was never dispatched; this replaces it — delete 12519 when this merges).
Reproduction (dev, by the network choke-point coder): on https://app.dev.jaah.ai/projects/<scratch id>, change Notes, Save, then `page.goto` the same edit page ~0.5 s later. The old Notes value shows for 10 s and again after a further reload; a fresh browser shows the saved value, so the server is right.
Cause: the react-query persister writes localStorage on a 1 s throttle (`apps/web/src/queryClient.ts`, persister setup; `shouldPersistQuery` at :114). A reload within that second restores the pre-save copy, which is younger than `staleTime` 15 s (`queryClient.ts:13`), so `useEditRecord`'s `fetchQuery` (`apps/web/src/hooks/useEditRecord.ts`) answers from it with no GET, and the stale copy is persisted again.
Fix (no new surface): after any successful write through `net/send` (or in `useSubmit` after its `run` resolves), flush the persister immediately — or persist the query's invalidated flag so a restored invalidated entry refetches on mount. Pick whichever is one place, not per page.
Acceptance:
- AC-1: a vitest invalidates a persisted query, restores within the throttle window, and asserts the record is refetched (fails on develop today).
- AC-2: on dev, save a scratch project's Notes, reload within 500 ms → the new value shows at once. Restore the value after.
Out of scope: `apps/web/src/net/` relay/race rules, server idempotency, React Query defaults other than persistence, any edit page's visible UI.
Done means:
- AC-1 vitest green and red-on-revert.
- AC-2 observed on https://app.dev.jaah.ai after the Jaah Deploy to dev succeeds (screenshot in report).
- `./dc check quick` green; PR merged via the merge lane; Jaah Deploy to dev green.
Outcome
A reload right after a save now shows the saved record: the throttled query-cache snapshot is written on pagehide or when the page goes hidden. AC-1 vitest passes, and fails on revert. Quick gate green. #7713 merged; dev deploy green; AC-2 checked on dev. Draft 12519 needs an operator to delete it (refused for this task). Memory: none applied.
Artifacts
Activity
- Ready
- Runner started
- Runner ended (done)