-
Notifications
You must be signed in to change notification settings - Fork 21
Auto-refresh the AI reviews ui if run is in progress #1345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -279,10 +279,7 @@ export const SubmissionHistoryModal: FC<SubmissionHistoryModalProps> = (props: S | |
| <tr> | ||
| <td className={styles.aiReviewersTableRow} colSpan={4}> | ||
| <div className={styles.aiReviewersTable}> | ||
| <AiReviewsTable | ||
| reviewers={aiReviewers} | ||
| submission={submission} | ||
| /> | ||
| <AiReviewsTable submission={submission} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| </div> | ||
| </td> | ||
| </tr> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { useCallback, useEffect, useState } from 'react' | ||
| import { useCallback, useEffect, useRef, useState } from 'react' | ||
| import useSWR, { SWRResponse } from 'swr' | ||
|
|
||
| import { EnvironmentConfig } from '~/config' | ||
|
|
@@ -111,8 +111,8 @@ export const aiRunFailed = (aiRun: Pick<AiWorkflowRun, 'status'>): boolean => [ | |
|
|
||
| export function useFetchAiWorkflowsRuns( | ||
| submissionId: string, | ||
| workflowIds: string[], | ||
| ): AiWorkflowRunsResponse { | ||
| const hasInProgress = useRef(true) | ||
| // Use swr hooks for challenge info fetching | ||
| const { | ||
| data: runs = [], | ||
|
|
@@ -121,10 +121,19 @@ export function useFetchAiWorkflowsRuns( | |
| }: SWRResponse<AiWorkflowRun[], Error> = useSWR<AiWorkflowRun[], Error>( | ||
| `${TC_API_BASE_URL}/workflows/runs?submissionId=${submissionId}`, | ||
| { | ||
| isPaused: () => !workflowIds?.length || !submissionId, | ||
| isPaused: () => !submissionId, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| refreshInterval: hasInProgress.current ? 10 * 1000 : 0, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| }, | ||
| ) | ||
|
|
||
| hasInProgress.current = !!runs.find(r => ( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
| ![ | ||
| AiWorkflowRunStatusEnum.SUCCESS, | ||
| AiWorkflowRunStatusEnum.CANCELLED, | ||
| AiWorkflowRunStatusEnum.COMPLETED, | ||
| ].includes(r.status) | ||
| )) | ||
|
|
||
| // Show backend error when fetching challenge info | ||
| useEffect(() => { | ||
| if (fetchError) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ import { Context, createContext, FC, PropsWithChildren, ReactNode, useContext, u | |
| import { useParams, useSearchParams } from 'react-router-dom' | ||
|
|
||
| import { ChallengeDetailContext } from '../../../lib' | ||
| import { ChallengeDetailContextModel, ReviewCtxStatus, ReviewsContextModel } from '../../../lib/models' | ||
| import { ReviewCtxStatus, ReviewsContextModel } from '../../../lib/models' | ||
| import { AiWorkflowRunsResponse, useFetchAiWorkflowsRuns, useFetchSubmissionInfo } from '../../../lib/hooks' | ||
|
|
||
| export const ReviewsContext: Context<ReviewsContextModel> | ||
|
|
@@ -25,17 +25,10 @@ export const ReviewsContextProvider: FC<PropsWithChildren> = props => { | |
| const [actionButtons, setActionButtons] = useState<ReactNode>() | ||
|
|
||
| const challengeDetailsCtx = useContext(ChallengeDetailContext) | ||
| const { challengeInfo }: ChallengeDetailContextModel = challengeDetailsCtx | ||
|
|
||
| const [submissionInfo] = useFetchSubmissionInfo(submissionId) | ||
|
|
||
| const aiReviewers = useMemo(() => ( | ||
| (challengeInfo?.reviewers ?? []).filter(r => !!r.aiWorkflowId) | ||
| ), [challengeInfo?.reviewers]) | ||
| const aiWorkflowIds = useMemo(() => aiReviewers?.map(r => r.aiWorkflowId as string), [aiReviewers]) | ||
|
|
||
| const { runs: workflowRuns, isLoading: aiWorkflowRunsLoading }: AiWorkflowRunsResponse | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| = useFetchAiWorkflowsRuns(submissionId, aiWorkflowIds) | ||
| = useFetchAiWorkflowsRuns(submissionId) | ||
|
|
||
| const isLoadingCtxData | ||
| = challengeDetailsCtx.isLoadingChallengeInfo | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,12 +52,12 @@ const Tooltip: FC<TooltipProps> = (props: TooltipProps) => { | |
|
|
||
| function renderTrigger(): ReactElement[] { | ||
| return Children.toArray(props.children) | ||
| .map(child => cloneElement((wrapComponents(child, props.disableWrap) as ReactElement), { | ||
| .map((child, i) => cloneElement((wrapComponents(child, props.disableWrap) as ReactElement), { | ||
| 'data-tooltip-delay-show': triggerOnClick ? '0' : '300', | ||
| 'data-tooltip-id': tooltipId.current as string, | ||
| 'data-tooltip-place': props.place ?? 'bottom', | ||
| 'data-tooltip-strategy': props.strategy ?? 'absolute', | ||
| key: tooltipId.current as string, | ||
| key: `${tooltipId.current as string}-${i}`, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| } as any)) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗
correctness]The
AiReviewsTablecomponent no longer receives thereviewersprop. Ensure that this change is intentional and that theAiReviewsTablecomponent does not rely on thereviewersprop for its functionality.