Fix stale persisted query data on post-save

Task 12519 · Done · Coder · created · updated

Found while running Task 12468's dev oracles (Projects edit, https://app.dev.jaah.ai/projects/57904). The bug: the react-query persister writes localStorage on a 1 s throttle (`apps/web/src/queryClient.ts`). Say a page is reloaded, or reached by a full navigation, within that second after a save that invalidated the record. The persisted copy from before the save is then restored. It is younger than `staleTime` (15 s), so the edit page's `fetchQuery` (`hooks/useEditRecord.ts`) answers from it and sends no GET. The form shows the old value, and the stale copy is persisted again. A Playwright run reproduced it twice: save, then `page.goto` to the same edit page about 0.5 s later. The old Notes value showed for 10 s, and again after a further reload. A fresh browser showed the saved value, so the server had the right data. Ask: - Flush the persister when a write succeeds, or persist a query's invalidated flag so a restored entry that was invalidated is refetched on mount. - After a successful save, a reload at any moment shows the saved value. Out of scope: the network choke point (`apps/web/src/net/`), the relay, idempotency, and React Query's global defaults other than persistence. Done means: - A vitest pins it: invalidate a persisted query, restore within the throttle window, and the record is refetched. - On dev, save a project's Notes, reload within 500 ms, and the new value shows at once.

Outcome

Already shipped by Task 12551 (pagehide/hidden flush in queryClient.ts). The vitest pins it (red without the flush). The dev oracle on project 57904 showed the new Notes value in 3/3 reloads 300 ms after a save. No PR. Memory: none applied.

Artifacts

Activity

  • Created
  • Run
  • Runner started
  • Runner ended (done)