Skip to content

fix(react-ui): share single /api/operations poller across consumers#10029

Merged
mudler merged 1 commit into
masterfrom
worktree-fix-operations-polling
May 27, 2026
Merged

fix(react-ui): share single /api/operations poller across consumers#10029
mudler merged 1 commit into
masterfrom
worktree-fix-operations-polling

Conversation

@localai-bot
Copy link
Copy Markdown
Collaborator

@localai-bot localai-bot commented May 27, 2026

Summary

  • useOperations() ran its own setInterval per hook instance, so on /app/models (and /app/backends, /app/chat) both OperationsBar (mounted globally in App.jsx) and the page itself polled /api/operations at 1 Hz - 2 RPS sustained for the whole session, regardless of whether anything was actually installing.
  • Lift the poller into an OperationsProvider mounted under AuthProvider in main.jsx. All consumers now share a single timer.
  • hooks/useOperations.js becomes a thin re-export so the four call sites (OperationsBar, Models, Backends, Chat) keep working unchanged.

Test plan

  • vite build succeeds (verified locally)
  • Open DevTools Network panel on /app/models while idle - expect ~1 req/s to /api/operations, not 2-3
  • Same check on /app/backends and /app/chat
  • Trigger a model install - operations bar still appears, progress still updates, dismiss/cancel still work
  • Non-admin user - no /api/operations requests at all (poller gated on isAdmin)

useOperations() spun up its own setInterval per hook instance, so on
pages like /app/models the OperationsBar in App.jsx plus the page's
own useOperations() call each polled /api/operations at 1 Hz - 2 RPS
sustained for the whole session, repeated on Backends and Chat.

Lift the poller into an OperationsProvider mounted under AuthProvider
so all consumers (OperationsBar, Models, Backends, Chat) share one
timer. The hook file re-exports from the context to keep call sites
unchanged.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-7 [Claude Code]
@mudler mudler merged commit 893e69c into master May 27, 2026
57 checks passed
@mudler mudler deleted the worktree-fix-operations-polling branch May 27, 2026 14:39
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.

2 participants