Skip to content

perf: switch refetchOnWindowFocus to staleTime-gated#102

Merged
FrkAk merged 1 commit into
mainfrom
perf/mymr-222-staletime-gated-refetch-on-focus
May 25, 2026
Merged

perf: switch refetchOnWindowFocus to staleTime-gated#102
FrkAk merged 1 commit into
mainfrom
perf/mymr-222-staletime-gated-refetch-on-focus

Conversation

@FrkAk
Copy link
Copy Markdown
Owner

@FrkAk FrkAk commented May 25, 2026

Summary

Task Reference: [MYMR-222]

Switch lib/query/client.ts:17 from refetchOnWindowFocus: "always" to refetchOnWindowFocus: true so focus refetches respect the existing 30-second staleTime. The "always" value bypasses staleTime and triggers a full refetch on every tab-focus event regardless of whether the query is fresh; the regular true value gates focus refetches on staleTime. Combined with the conditional-GET path at lib/api/conditional.ts:42 (which emits ETags on slim project / task responses), refocus events inside the stale window become no-ops, and refocus events outside it still revalidate but collapse to ~50-byte 304s when the data has not changed.

This is the bridge stop-gap before MYMR-215 (Durable Object WebSocket push) lets us flip refetchOnWindowFocus: false entirely. Once push exists the client gets explicit invalidation messages and no longer needs focus-driven polling for liveness.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation

Testing

  • Tested locally with bun run dev
  • Linting passes (bun run lint)
  • Typecheck passes (bun run typecheck)

Notes for reviewer

  • One-line change. No tests, no types, no API surface.
  • Manual verification after deploy: open the workspace view, switch tab focus 10x over 5 minutes without making any data changes, observe 304 responses for /api/projects/* GETs in the DevTools network panel instead of 200 with full bodies.
  • Data freshness invariants still hold: staleTime gates focus refetch, ETag revalidation runs on stale-window expiry.

@FrkAk FrkAk requested review from ZeyNor and ulascanzorer as code owners May 25, 2026 11:46
@FrkAk FrkAk changed the title perf: switch refetchOnWindowFocus to staleTime-gated [MYMR-222] perf: switch refetchOnWindowFocus to staleTime-gated May 25, 2026
@FrkAk FrkAk self-assigned this May 25, 2026
@FrkAk FrkAk merged commit 2f9cf9e into main May 25, 2026
4 checks passed
@FrkAk FrkAk deleted the perf/mymr-222-staletime-gated-refetch-on-focus branch May 25, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant