Polling tiers

Polling tiers for `refetchInterval`. Pick a tier that matches how fresh the data needs to feel — pages can mix tiers across queries. - {@link POLL_CRITICAL} (2s) — pages where stale data is misleading (run details while a run is in progress, live status indicators). - {@link POLL_ACTIVE} (5s) — list views the user is actively watching (runs list, recent events, dashboards). - {@link POLL_AMBIENT} (30s) — background freshness for detail views that don't need second-by-second updates (settings, overviews). - {@link POLL_FALLBACK} (60s) — safety-net interval used when a real-time event stream is connected; see {@link getRefetchInterval}. - {@link POLL_IDLE} (5m) — cold data that only changes on explicit user action (database table browser, static reference lists). Events and mutations still invalidate the cache normally; this is just the ambient safety-net rate.

Hooks

getRefetchInterval composite

Returns the appropriate refetch interval based on whether the WebSocket event stream is connected. When connected, polling drops to a 60s safety net. When disconnected, uses the original tier-based intervals.

TypeScript
getRefetchInterval(tier: PollingTier, wsConnected: boolean): number
TypeScript
const { connected } = useEventStream({ workspaceId });
useListRuns(
  { workspace_id: workspaceId },
  { refetchInterval: getRefetchInterval("active", connected) },
);

POLL_ACTIVE composite

TypeScript
POLL_ACTIVE = 5_000;

POLL_AMBIENT composite

TypeScript
POLL_AMBIENT = 30_000;

POLL_CRITICAL composite

Polling tiers for refetchInterval. Pick a tier that matches how fresh the data needs to feel — pages can mix tiers across queries.

  • (2s) — pages where stale data is misleading (run details while a run is in progress, live status indicators).
  • (5s) — list views the user is actively watching (runs list, recent events, dashboards).
  • (30s) — background freshness for detail views that don't need second-by-second updates (settings, overviews).
  • (60s) — safety-net interval used when a real-time event stream is connected; see .
  • (5m) — cold data that only changes on explicit user action (database table browser, static reference lists). Events and mutations still invalidate the cache normally; this is just the ambient safety-net rate.
TypeScript
POLL_CRITICAL = 2_000;

POLL_FALLBACK composite

Safety-net interval used when a WebSocket event stream is connected.

TypeScript
POLL_FALLBACK = 60_000;

POLL_IDLE composite

Cold-data tier — 5 minutes. Use for queries where ambient refresh is unwanted (database table browse, schema viewers, static reference lists). Data still refreshes via cache invalidation on mutations and event-stream updates; POLL_IDLE is only the slow-drip safety net for cases where no event will ever fire.

TypeScript
POLL_IDLE = 5 * 60_000;