Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/apps/review/src/lib/hooks/useFetchAiWorkflowRuns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import useSWR, { SWRResponse } from 'swr'

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

import { AiFeedbackItem, Scorecard } from '../models'
Expand Down Expand Up @@ -150,15 +150,17 @@ export function useFetchAiWorkflowsRuns(
export function useFetchAiWorkflowsRunItems(
workflowId: string | undefined,
runId: string | undefined,
runStatus: string = '',
): AiWorkflowRunItemsResponse {
// Use swr hooks for challenge info fetching
const {
data: runItems = [],
error: fetchError,
isValidating: isLoading,
}: SWRResponse<AiWorkflowRunItem[], Error> = useSWR<AiWorkflowRunItem[], Error>(
`${TC_API_BASE_URL}/workflows/${workflowId}/runs/${runId}/items`,
`${TC_API_BASE_URL}/workflows/${workflowId}/runs/${runId}/items?[${runStatus}]`,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The query parameter [${runStatus}] in the URL is unconventional and may lead to unexpected behavior if not handled correctly. Consider using a standard query parameter format like runStatus=${runStatus}.

{
fetcher: url => xhrGetAsync(url.replace(`[${runStatus}]`, '')),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The use of url.replace([${runStatus}], '') to remove the run status from the URL is error-prone. If runStatus contains special characters, it might not be replaced correctly. Consider using a more robust method to construct the URL without the need for replacement.

isPaused: () => !workflowId || !runId,
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ const AiModelModal: FC<AiModelModalProps> = props => (
</div>
</div>

<p className={styles.modelDescription}>
<div className={styles.modelDescription}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Changing the <p> tag to a <div> tag for modelDescription might affect the semantics of the HTML. If the content is still a paragraph, consider using a <p> tag to maintain semantic correctness.

<MarkdownReview className={styles.mdContainer} value={props.model.description} />
</p>
</div>
</div>
</BaseModal>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import styles from './AiReviewViewer.module.scss'
const AiReviewViewer: FC = () => {
const { scorecard, workflowId, workflowRun, setActionButtons }: ReviewsContextModel = useReviewsContext()
const [selectedTab, setSelectedTab] = useState('scorecard')
const { runItems }: AiWorkflowRunItemsResponse = useFetchAiWorkflowsRunItems(workflowId, workflowRun?.id)
const { runItems }: AiWorkflowRunItemsResponse = useFetchAiWorkflowsRunItems(
workflowId,
workflowRun?.id,
workflowRun?.status,
)
const { totalCount }: AiWorkflowRunAttachmentsResponse
= useFetchAiWorkflowsRunAttachments(workflowId, workflowRun?.id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ const ScorecardHeader: FC = () => {
)}
</div>
</div>
<p className={styles.workflowDescription}>
<div className={styles.workflowDescription}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Changing the <p> tag to a <div> tag may affect the styling and semantics of the content. Ensure that the CSS styles and the semantic meaning of the content are preserved with this change.

<MarkdownReview
className={styles.mdContainer}
value={workflow.description}
/>
</p>
</div>
{/* <div className={styles.workflowFileLink}>
<a href={workflow.defUrl}>
Workflow File
Expand Down
Loading