perf(frontend): drop redundant polling that duplicates SSE invalidation #724

Open
opened 2026-09-25 08:50:08 +02:00 by dries · 0 comments
Owner

Follow-up from the perf report (items 10, 11 + polling inventory).

  • `pages/Dashboard.tsx:68-71` and `pages/ProjectDetail.tsx:109-112`: `refetchInterval: 5000` on the session list while `App.tsx:405-411` already `invalidateQueries(['sessions'])` on every `ocman.session.changed`. On the session page the same event also triggers `useSidebarSessions.ts:198-204 refresh()` → `/api/sessions?since=72h&limit=0`, so there are two independent full-list pipelines (TanStack + apiStore). Fix: 30-60 s backstop; apply `patch` via `setQueryData` in the App handler instead of invalidating when a patch is present.
  • `pages/session-detail/SessionSidebar.tsx:125`: `useWorkEpics()` → `/api/factory/epics` every 10 s on every session page just to hide factory sessions. Fix: gate on a factory capability or 60 s.
  • `SessionDetail.tsx:393-398`, `SessionInfoSidebar.tsx:107`, `upstream/UpstreamPane.tsx:54`: three `useGitInfo` instances on one page (all sidebar dirs + 2x current dir), each a 30 s poll → server-side `git status` per dir. Fix: one hook in `SessionDetail`, pass down.
  • `lib/ClientActivityReporter.tsx:53-58`: POSTs `/api/client-activity` on every activity-scope change; scope changes whenever `recentSessions` changes. Fix: debounce.
  • `components/GitHubLinkPreview.tsx:71,103-106`: every visible card polls the forge-proxied preview every 5 s. Fix: 60 s + refresh on `visibilitychange`.
  • `pages/Routines.tsx:123-149`: 2 + 2N requests every 5 s (list + projects + per-routine history + webhook). Fix: 30 s; fetch history/webhook on row expand.
Follow-up from the perf report (items 10, 11 + polling inventory). - \`pages/Dashboard.tsx:68-71\` and \`pages/ProjectDetail.tsx:109-112\`: \`refetchInterval: 5000\` on the session list while \`App.tsx:405-411\` already \`invalidateQueries(['sessions'])\` on every \`ocman.session.changed\`. On the session page the same event also triggers \`useSidebarSessions.ts:198-204 refresh()\` → \`/api/sessions?since=72h&limit=0\`, so there are two independent full-list pipelines (TanStack + apiStore). Fix: 30-60 s backstop; apply \`patch\` via \`setQueryData\` in the App handler instead of invalidating when a patch is present. - \`pages/session-detail/SessionSidebar.tsx:125\`: \`useWorkEpics()\` → \`/api/factory/epics\` every 10 s on every session page just to hide factory sessions. Fix: gate on a factory capability or 60 s. - \`SessionDetail.tsx:393-398\`, \`SessionInfoSidebar.tsx:107\`, \`upstream/UpstreamPane.tsx:54\`: three \`useGitInfo\` instances on one page (all sidebar dirs + 2x current dir), each a 30 s poll → server-side \`git status\` per dir. Fix: one hook in \`SessionDetail\`, pass down. - \`lib/ClientActivityReporter.tsx:53-58\`: POSTs \`/api/client-activity\` on every activity-scope change; scope changes whenever \`recentSessions\` changes. Fix: debounce. - \`components/GitHubLinkPreview.tsx:71,103-106\`: every visible card polls the forge-proxied preview every 5 s. Fix: 60 s + refresh on \`visibilitychange\`. - \`pages/Routines.tsx:123-149\`: 2 + 2N requests every 5 s (list + projects + per-routine history + webhook). Fix: 30 s; fetch history/webhook on row expand.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dries/ocman#724
No description provided.