Skip to content

Commit fe11f1b

Browse files
authored
Merge pull request #1346 from topcoder-platform/auto-refetch-run-items
Auto refetch run items when workflow run status has changed
2 parents b7801b6 + 24b01d1 commit fe11f1b

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/apps/review/src/lib/hooks/useFetchAiWorkflowRuns.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
22
import useSWR, { SWRResponse } from 'swr'
33

44
import { EnvironmentConfig } from '~/config'
5-
import { xhrGetBlobAsync } from '~/libs/core'
5+
import { xhrGetAsync, xhrGetBlobAsync } from '~/libs/core'
66
import { handleError } from '~/libs/shared/lib/utils/handle-error'
77

88
import { AiFeedbackItem, Scorecard } from '../models'
@@ -150,15 +150,17 @@ export function useFetchAiWorkflowsRuns(
150150
export function useFetchAiWorkflowsRunItems(
151151
workflowId: string | undefined,
152152
runId: string | undefined,
153+
runStatus: string = '',
153154
): AiWorkflowRunItemsResponse {
154155
// Use swr hooks for challenge info fetching
155156
const {
156157
data: runItems = [],
157158
error: fetchError,
158159
isValidating: isLoading,
159160
}: SWRResponse<AiWorkflowRunItem[], Error> = useSWR<AiWorkflowRunItem[], Error>(
160-
`${TC_API_BASE_URL}/workflows/${workflowId}/runs/${runId}/items`,
161+
`${TC_API_BASE_URL}/workflows/${workflowId}/runs/${runId}/items?[${runStatus}]`,
161162
{
163+
fetcher: url => xhrGetAsync(url.replace(`[${runStatus}]`, '')),
162164
isPaused: () => !workflowId || !runId,
163165
},
164166
)

src/apps/review/src/pages/reviews/components/AiModelModal/AiModelModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ const AiModelModal: FC<AiModelModalProps> = props => (
3535
</div>
3636
</div>
3737

38-
<p className={styles.modelDescription}>
38+
<div className={styles.modelDescription}>
3939
<MarkdownReview className={styles.mdContainer} value={props.model.description} />
40-
</p>
40+
</div>
4141
</div>
4242
</BaseModal>
4343
)

src/apps/review/src/pages/reviews/components/AiReviewViewer/AiReviewViewer.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import styles from './AiReviewViewer.module.scss'
2121
const AiReviewViewer: FC = () => {
2222
const { scorecard, workflowId, workflowRun, setActionButtons }: ReviewsContextModel = useReviewsContext()
2323
const [selectedTab, setSelectedTab] = useState('scorecard')
24-
const { runItems }: AiWorkflowRunItemsResponse = useFetchAiWorkflowsRunItems(workflowId, workflowRun?.id)
24+
const { runItems }: AiWorkflowRunItemsResponse = useFetchAiWorkflowsRunItems(
25+
workflowId,
26+
workflowRun?.id,
27+
workflowRun?.status,
28+
)
2529
const { totalCount }: AiWorkflowRunAttachmentsResponse
2630
= useFetchAiWorkflowsRunAttachments(workflowId, workflowRun?.id)
2731

src/apps/review/src/pages/reviews/components/ScorecardHeader/ScorecardHeader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ const ScorecardHeader: FC = () => {
105105
)}
106106
</div>
107107
</div>
108-
<p className={styles.workflowDescription}>
108+
<div className={styles.workflowDescription}>
109109
<MarkdownReview
110110
className={styles.mdContainer}
111111
value={workflow.description}
112112
/>
113-
</p>
113+
</div>
114114
{/* <div className={styles.workflowFileLink}>
115115
<a href={workflow.defUrl}>
116116
Workflow File

0 commit comments

Comments
 (0)