Skip to content

Commit 6b294b9

Browse files
authored
Merge pull request #1312 from topcoder-platform/qa-ai-workflows
Various QA issues re AI workflows
2 parents 1bcb555 + cc781f3 commit 6b294b9

File tree

12 files changed

+77
-38
lines changed

12 files changed

+77
-38
lines changed

src/apps/review/src/lib/assets/icons/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ReactComponent as IconClock } from './icon-clock.svg'
1414
import { ReactComponent as IconPremium } from './icon-premium.svg'
1515
import { ReactComponent as IconComment } from './icon-comment.svg'
1616
import { ReactComponent as IconEdit } from './icon-edit.svg'
17+
import { ReactComponent as IconFile } from './icon-file.svg'
1718

1819
export * from './editor/bold'
1920
export * from './editor/code'
@@ -47,6 +48,7 @@ export {
4748
IconPremium,
4849
IconComment,
4950
IconEdit,
51+
IconFile,
5052
}
5153

5254
export const phasesIcons = {

src/apps/review/src/lib/components/AiReviewsTable/AiReviewsTable.module.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
width: 100%;
1111
border-collapse: collapse;
1212

13-
th {
13+
14+
&.reviewsTable thead tr th {
1415
border-top: 1px solid #A8A8A8;
1516
font-weight: bold;
16-
background: #E0E4E8;
17+
background: none;
1718
}
1819

1920
th, td {
@@ -60,7 +61,8 @@
6061
padding-left: $sp-4;
6162
padding-right: $sp-4;
6263
> * {
63-
flex: 1 1 50%;
64+
flex: 0 0 50%;
65+
white-space: normal;
6466
}
6567
}
6668
.label {

src/apps/review/src/lib/components/AiReviewsTable/AiReviewsTable.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ const AiReviewsTable: FC<AiReviewsTableProps> = props => {
4646
workflow: {
4747
description: '',
4848
name: 'Virus Scan',
49+
scorecard: {
50+
minimumPassingScore: 1,
51+
},
4952
},
5053
} as AiWorkflowRun,
5154
], [runs, props.submission])
@@ -112,7 +115,7 @@ const AiReviewsTable: FC<AiReviewsTableProps> = props => {
112115
<tr>
113116
<th>AI Reviewer</th>
114117
<th>Review Date</th>
115-
<th>Score</th>
118+
<th className={styles.scoreCol}>Score</th>
116119
<th>Result</th>
117120
</tr>
118121
</thead>
@@ -147,7 +150,7 @@ const AiReviewsTable: FC<AiReviewsTableProps> = props => {
147150
</td>
148151
<td className={styles.scoreCol}>
149152
{run.status === 'SUCCESS' ? (
150-
run.workflow.scorecard ? (
153+
run.workflow.id ? (
151154
<a
152155
href={`./reviews/${props.submission.id}?workflowId=${run.workflow.id}`}
153156
>

src/apps/review/src/lib/components/AiReviewsTable/AiWorkflowRunStatus.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export const AiWorkflowRunStatus: FC<AiWorkflowRunStatusProps> = props => {
7373
{status === 'failed' && (
7474
<StatusLabel
7575
icon={<IconOutline.XCircleIcon className='icon-xl' />}
76+
hideLabel={props.hideLabel}
7677
status={status}
78+
label='Failure'
7779
score={score}
7880
/>
7981
)}

src/apps/review/src/lib/components/Scorecard/ScorecardViewer/ScorecardViewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ const ScorecardViewerContent: FC<ScorecardViewerProps> = props => {
184184
</div>
185185
)}
186186

187-
{totalScore && !!props.aiFeedback && (
187+
{!!totalScore && !!props.aiFeedback && (
188188
<div className={styles.conclusion}>
189189
<strong>Conclusion</strong>
190190
<p>

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { handleError } from '~/libs/shared/lib/utils/handle-error'
77

88
import { AiFeedbackItem, Scorecard } from '../models'
99

10-
import { useRolePermissions, UseRolePermissionsResult } from './useRolePermissions'
11-
1210
export enum AiWorkflowRunStatusEnum {
1311
INIT = 'INIT',
1412
QUEUED = 'QUEUED',
@@ -42,6 +40,8 @@ export interface AiWorkflowRun {
4240
startedAt: string;
4341
completedAt: string;
4442
status: AiWorkflowRunStatusEnum;
43+
gitRunId?: string;
44+
gitRunUrl?: string;
4545
score: number;
4646
workflow: AiWorkflow
4747
}
@@ -76,7 +76,6 @@ export function useFetchAiWorkflowsRuns(
7676
submissionId: string,
7777
workflowIds: string[],
7878
): AiWorkflowRunsResponse {
79-
const { isAdmin }: UseRolePermissionsResult = useRolePermissions()
8079
// Use swr hooks for challenge info fetching
8180
const {
8281
data: runs = [],
@@ -106,7 +105,7 @@ export function useFetchAiWorkflowsRuns(
106105

107106
return {
108107
isLoading,
109-
runs: runs.filter(r => isAdmin || !aiRunFailed(r)),
108+
runs,
110109
}
111110
}
112111

src/apps/review/src/pages/reviews/ReviewsViewer/ReviewsViewer.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { FC, useEffect, useMemo } from 'react'
1+
import { FC, useMemo } from 'react'
22
import { useLocation } from 'react-router-dom'
33

4-
import { NotificationContextType, useNotification } from '~/libs/shared'
5-
6-
import { IconAiReview } from '../../../lib/assets/icons'
74
import { PageWrapper } from '../../../lib'
85
import { BreadCrumbData, ReviewsContextModel } from '../../../lib/models'
96
import { ReviewsSidebar } from '../components/ReviewsSidebar'
@@ -15,7 +12,6 @@ import { ReviewViewer } from '../components/ReviewViewer'
1512
import styles from './ReviewsViewer.module.scss'
1613

1714
const ReviewsViewer: FC = () => {
18-
const { showBannerNotification, removeNotification }: NotificationContextType = useNotification()
1915
const { challengeInfo, submissionId, workflowRun }: ReviewsContextModel = useReviewsContext()
2016

2117
const location = useLocation()
@@ -41,16 +37,6 @@ const ReviewsViewer: FC = () => {
4137
},
4238
], [challengeInfo?.name, challengeInfo?.id, submissionId, containsPastChallenges])
4339

44-
useEffect(() => {
45-
const notification = showBannerNotification({
46-
icon: <IconAiReview />,
47-
id: 'ai-review-icon-notification',
48-
message: `Challenges with this icon indicate that
49-
one or more AI reviews will be conducted for each member submission.`,
50-
})
51-
return () => notification && removeNotification(notification.id)
52-
}, [showBannerNotification, removeNotification])
53-
5440
return (
5541
<PageWrapper
5642
pageTitle={challengeInfo?.name ?? ''}

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

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import { FC, useState } from 'react'
1+
import { FC, useMemo, useState } from 'react'
22

33
import { Tabs } from '~/apps/review/src/lib'
44
import { ScorecardViewer } from '~/apps/review/src/lib/components/Scorecard'
55
import { ScorecardAttachments } from '~/apps/review/src/lib/components/Scorecard/ScorecardAttachments'
6-
import { AiWorkflowRunItemsResponse, useFetchAiWorkflowsRunItems } from '~/apps/review/src/lib/hooks'
6+
import {
7+
AiWorkflowRunItemsResponse,
8+
AiWorkflowRunStatusEnum,
9+
useFetchAiWorkflowsRunItems,
10+
} from '~/apps/review/src/lib/hooks'
711
import { ReviewsContextModel, SelectOption } from '~/apps/review/src/lib/models'
812

913
import { ScorecardHeader } from '../ScorecardHeader'
@@ -20,6 +24,12 @@ const AiReviewViewer: FC = () => {
2024
const { scorecard, workflowId, workflowRun }: ReviewsContextModel = useReviewsContext()
2125
const [selectedTab, setSelectedTab] = useState('scorecard')
2226
const { runItems }: AiWorkflowRunItemsResponse = useFetchAiWorkflowsRunItems(workflowId, workflowRun?.id)
27+
const isFailedRun = useMemo(() => (
28+
workflowRun && [
29+
AiWorkflowRunStatusEnum.CANCELLED,
30+
AiWorkflowRunStatusEnum.FAILURE,
31+
].includes(workflowRun.status)
32+
), [workflowRun])
2333

2434
return (
2535
<div className={styles.wrap}>
@@ -31,15 +41,24 @@ const AiReviewViewer: FC = () => {
3141
selected={selectedTab}
3242
onChange={setSelectedTab}
3343
/>
34-
{!!scorecard && selectedTab === 'scorecard' && (
35-
<ScorecardViewer
36-
scorecard={scorecard}
37-
aiFeedback={runItems}
38-
/>
39-
)}
4044

41-
{selectedTab === 'attachments' && (
42-
<ScorecardAttachments />
45+
{isFailedRun ? (
46+
<div>
47+
AI run failed - no scorecard results are available
48+
</div>
49+
) : (
50+
<>
51+
{!!scorecard && selectedTab === 'scorecard' && (
52+
<ScorecardViewer
53+
scorecard={scorecard}
54+
aiFeedback={runItems}
55+
/>
56+
)}
57+
58+
{selectedTab === 'attachments' && (
59+
<ScorecardAttachments />
60+
)}
61+
</>
4362
)}
4463
</div>
4564
)

src/apps/review/src/pages/reviews/components/ScorecardHeader/ScorecardHeader.module.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@
9797
color: var(--FontColor);
9898
}
9999

100+
svg {
101+
&.sm {
102+
height: 16px;
103+
}
104+
path {
105+
fill: #0A0A0A;
106+
}
107+
}
108+
100109
@include ltemd {
101110
margin-left: 0;
102111
}

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { FC, useCallback, useMemo, useState } from 'react'
22
import moment, { Duration } from 'moment'
33

44
import { ReviewsContextModel } from '~/apps/review/src/lib/models'
5+
import { useRolePermissions, UseRolePermissionsResult } from '~/apps/review/src/lib/hooks'
56

6-
import { IconClock, IconPremium } from '../../../../lib/assets/icons'
7+
import { IconClock, IconFile, IconPremium } from '../../../../lib/assets/icons'
78
import { AiModelModal } from '../AiModelModal'
89
import { useReviewsContext } from '../../ReviewsContext'
910
import AiModelIcon from '../AiModelIcon'
@@ -19,6 +20,7 @@ const formatDuration = (duration: Duration): string => [
1920

2021
const ScorecardHeader: FC = () => {
2122
const { workflow, workflowRun }: ReviewsContextModel = useReviewsContext()
23+
const { isAdmin }: UseRolePermissionsResult = useRolePermissions()
2224
const runDuration = useMemo(() => (
2325
workflowRun && workflowRun.completedAt && workflowRun.startedAt && moment.duration(
2426
+new Date(workflowRun.completedAt) - +new Date(workflowRun.startedAt),
@@ -64,6 +66,21 @@ const ScorecardHeader: FC = () => {
6466
{!!runDuration && formatDuration(runDuration)}
6567
</span>
6668
</span>
69+
{isAdmin && (
70+
<span>
71+
<IconFile className={styles.sm} />
72+
<span>
73+
<strong>Git log:</strong>
74+
{' '}
75+
{workflowRun.gitRunUrl && (
76+
<a href={workflowRun.gitRunUrl} target='_blank' rel='noreferrer noopener'>
77+
#
78+
{workflowRun.gitRunId}
79+
</a>
80+
)}
81+
</span>
82+
</span>
83+
)}
6784
</div>
6885
</div>
6986
<p className={styles.workflowDescription}>

0 commit comments

Comments
 (0)