Skip to content

fix: share auto-refresh interval across consumers#37

Merged
ivanrdvc merged 1 commit into
mainfrom
fix/auto-refresh-shared-store
May 27, 2026
Merged

fix: share auto-refresh interval across consumers#37
ivanrdvc merged 1 commit into
mainfrom
fix/auto-refresh-shared-store

Conversation

@ivanrdvc
Copy link
Copy Markdown
Owner

Summary

  • useAutoRefresh consumers (sessions list, traces, tasks, session/trace detail) each held private React state seeded with the default '30s', hydrating from localStorage only via useEffect. Toggling on one page didn't propagate; every new mount briefly armed a 30s refetch before correcting.
  • Replaced with a useSyncExternalStore-backed module store, mirroring the existing pattern in src/hooks/use-user.ts. Synchronous read on mount, cross-consumer notify on change, cross-tab sync via storage events.

Test plan

  • Set auto-refresh to Off on /sessions, navigate into /sessions/:id — verify no 30s refetch and the inspector reflects Off.
  • Open two browser tabs, change interval in one — verify the other updates.
  • Toggle interval on /traces, navigate to /tasks — value persists across routes.

Each useAutoRefresh caller had its own React state seeded with the
default ('30s'); the persisted value only landed via useEffect on
mount. Toggling on one page didn't propagate to others, and every
new mount briefly armed a 30s refetch before hydrating.

Switch to a useSyncExternalStore-backed module store, mirroring
use-user.ts.
@ivanrdvc ivanrdvc merged commit c7e811e into main May 27, 2026
2 checks passed
@ivanrdvc ivanrdvc deleted the fix/auto-refresh-shared-store branch May 27, 2026 19:34
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