Show the workspace credit balance in the topbar
Read from GET /organizations/me, refreshed after every action and every 30 seconds, since agents and schedules spend credits in the background. The date is dropped from the topbar, and its items wrap on phones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { ClerkProvider } from '@clerk/react'
|
||||
import { enUS, idID } from '@clerk/localizations'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { MutationCache, QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { BrowserRouter } from 'react-router-dom'
|
||||
import { EngineError } from './api/client'
|
||||
import App from './App'
|
||||
@@ -16,7 +16,9 @@ if (!clerkPubKey) {
|
||||
throw new Error('Missing VITE_CLERK_PUBLISHABLE_KEY (set it, or keep ../learning-lab/backend/.env available)')
|
||||
}
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
const queryClient: QueryClient = new QueryClient({
|
||||
// Any action may have spent workspace credits, so the topbar balance is read again after each one.
|
||||
mutationCache: new MutationCache({ onSettled: () => queryClient.invalidateQueries({ queryKey: ['credits'] }) }),
|
||||
defaultOptions: {
|
||||
// Retrying a 4xx (auth, credits, validation) only repeats the same answer.
|
||||
queries: { retry: (n, e) => n < 2 && !(e instanceof EngineError && e.status >= 400 && e.status < 500) },
|
||||
|
||||
Reference in New Issue
Block a user