diff --git a/ui/litellm-dashboard/src/components/lens/investigations/live/useJobReviews.ts b/ui/litellm-dashboard/src/components/lens/investigations/live/useJobReviews.ts index 0800b6eb882..586ce92da0d 100644 --- a/ui/litellm-dashboard/src/components/lens/investigations/live/useJobReviews.ts +++ b/ui/litellm-dashboard/src/components/lens/investigations/live/useJobReviews.ts @@ -5,13 +5,16 @@ import { useState } from "react"; import { lensQueries } from "../../api/queries"; import type { LensApi } from "../../api/service"; -import { appendPage, EMPTY_FEED, type ReviewFeed } from "../../model/live"; +import { appendPage, EMPTY_FEED, polling, type ReviewFeed } from "../../model/live"; import type { Job, Review } from "../../model/types"; -export function useJobReviews(api: LensApi, lensId: string, job: Pick): readonly Review[] { +export function useJobReviews( + api: LensApi, + lensId: string, + job: Pick, +): readonly Review[] { const [feed, setFeed] = useState(EMPTY_FEED); - const live = job.status === "queued" || job.status === "running"; - const page = { lensId, jobId: job.id, after: feed.cursor, live }; + const page = { lensId, jobId: job.id, after: feed.cursor, live: polling(job, feed) }; const { data } = useQuery(lensQueries.reviews(api, page)); const next = data ? appendPage(feed, data) : feed; if (next !== feed) setFeed(next);