diff --git a/src/apps/review/src/lib/hooks/useFetchAiWorkflowRuns.ts b/src/apps/review/src/lib/hooks/useFetchAiWorkflowRuns.ts index 739a7e0b6..2427efb55 100644 --- a/src/apps/review/src/lib/hooks/useFetchAiWorkflowRuns.ts +++ b/src/apps/review/src/lib/hooks/useFetchAiWorkflowRuns.ts @@ -1,4 +1,5 @@ import { useCallback, useEffect, useRef, useState } from 'react' +import { orderBy, uniqBy } from 'lodash' import useSWR, { SWRResponse } from 'swr' import { EnvironmentConfig } from '~/config' @@ -141,9 +142,12 @@ export function useFetchAiWorkflowsRuns( } }, [fetchError]) + const uniqueRuns = uniqBy(orderBy(runs, 'completedAt', 'desc'), 'workflow.id') + .reverse() + return { isLoading, - runs, + runs: uniqueRuns, } }