- Notifications
You must be signed in to change notification settings - Fork21
[PROD] - AI Workflows MVP#1343
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…annerPM-2133 dismissable banner
…to feat/ai-workflows
…nges-pagePM-1904 active challenges page
…s-pagePM-1905 - ai reviews
| } | ||
| constAiReviewsTable:FC<AiReviewsTableProps>=props=>{ | ||
| const{ runs, isLoading}:AiWorkflowRunsResponse=useFetchAiWorkflowsRuns(props.submission.id) |
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]
TheuseFetchAiWorkflowsRuns function call no longer includesaiWorkflowIds as a parameter. Ensure that this change is intentional and that the function can operate correctly without this argument. IfaiWorkflowIds is required for filtering or other logic withinuseFetchAiWorkflowsRuns, this could lead to incorrect behavior.
| </span> | ||
| {isOpen&&( | ||
| <divclassName={classNames(styles.table,'reviews-table')}> | ||
| <AiReviewsTablesubmission={props.submission}/> |
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]
TheAiReviewsTable component no longer receives thereviewers prop. Ensure that this change is intentional and thatAiReviewsTable does not requirereviewers for its functionality.
| <tr> | ||
| <tdclassName={styles.aiReviewersTableRow}colSpan={4}> | ||
| <divclassName={styles.aiReviewersTable}> | ||
| <AiReviewsTablesubmission={submission}/> |
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]
TheAiReviewsTable component no longer receives thereviewers prop. If this prop is necessary for the component's functionality, ensure it is handled appropriately withinAiReviewsTable. Otherwise, confirm that this change does not affect the component's behavior.
| exportfunctionuseFetchAiWorkflowsRuns( | ||
| submissionId:string, | ||
| ):AiWorkflowRunsResponse{ |
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]
TheworkflowIds parameter has been removed, but it is still referenced in theisPaused function. Ensure that this change is intentional and that the logic does not rely onworkflowIds being present.
| `${TC_API_BASE_URL}/workflows/runs?submissionId=${submissionId}`, | ||
| { | ||
| isPaused:()=>!submissionId, | ||
| refreshInterval:hasInProgress.current ?10*1000 :0, |
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.
[performance]
TherefreshInterval is set to 10 seconds whenhasInProgress.current is true. Consider whether this interval is appropriate for your use case, as frequent polling can lead to performance issues.
| const[actionButtons,setActionButtons]=useState<ReactNode>() | ||
| constchallengeDetailsCtx=useContext(ChallengeDetailContext) | ||
| const[submissionInfo]=useFetchSubmissionInfo(submissionId) |
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]
ThechallengeInfo destructuring has been removed, butaiReviewers andaiWorkflowIds calculations that depend onchallengeInfo have also been removed. Ensure that this is intentional and that the logic is not needed elsewhere.
| constchallengeDetailsCtx=useContext(ChallengeDetailContext) | ||
| const[submissionInfo]=useFetchSubmissionInfo(submissionId) | ||
| const{runs:workflowRuns,isLoading:aiWorkflowRunsLoading}:AiWorkflowRunsResponse |
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]
TheuseFetchAiWorkflowsRuns hook is now called withoutaiWorkflowIds. If this hook relies on these IDs to fetch data correctly, this change might lead to incorrect data fetching. Verify that the hook can function correctly withoutaiWorkflowIds.
| 'data-tooltip-place':props.place??'bottom', | ||
| 'data-tooltip-strategy':props.strategy??'absolute', | ||
| key:tooltipId.currentasstring, | ||
| key:`${tooltipId.currentasstring}-${i}`, |
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.
[performance]
UsingtooltipId.current as part of the key is potentially problematic iftooltipId.current changes over time, as it could lead to unnecessary re-renders. Ensure thattooltipId.current remains constant or consider using a more stable identifier.
Auto refetch run items when workflow run status has changed
| error:fetchError, | ||
| isValidating:isLoading, | ||
| }:SWRResponse<AiWorkflowRunItem[],Error>=useSWR<AiWorkflowRunItem[],Error>( | ||
| `${TC_API_BASE_URL}/workflows/${workflowId}/runs/${runId}/items?[${runStatus}]`, |
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 URL construction withrunStatus in the query string seems incorrect. Using[${runStatus}] in the URL and then replacing it in the fetcher function is error-prone and could lead to unexpected behavior ifrunStatus contains special characters. Consider directly appendingrunStatus to the URL if needed, or ensure proper encoding and validation.
| }:SWRResponse<AiWorkflowRunItem[],Error>=useSWR<AiWorkflowRunItem[],Error>( | ||
| `${TC_API_BASE_URL}/workflows/${workflowId}/runs/${runId}/items?[${runStatus}]`, | ||
| { | ||
| fetcher:url=>xhrGetAsync(url.replace(`[${runStatus}]`,'')), |
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.
[maintainability]
The use ofurl.replace([${runStatus}], '') in the fetcher function is not ideal. This approach relies on a specific pattern in the URL that could be fragile and lead to bugs if the URL structure changes. Consider constructing the URL correctly from the start or using a more robust method to handle optional query parameters.
| </div> | ||
| </div> | ||
| <divclassName={styles.modelDescription}> |
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]
Changing the<p> tag to a<div> tag formodelDescription may affect the semantics and styling of the content. Ensure that the change does not impact the accessibility or intended styling, as<p> tags are typically used for paragraphs of text, which may have default styling and semantic meaning that<div> tags do not provide.
| )} | ||
| </div> | ||
| </div> | ||
| <divclassName={styles.workflowDescription}> |
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]
Changing the<p> element to a<div> may affect the semantics and styling of the content. Ensure that this change does not negatively impact accessibility or the intended styling, as<p> elements have default margins that<div> elements do not.
fix(PM-3065, PM-3074, PM-3076): added back button, ui issues
| try{ | ||
| if(challengeInfo?.id){ | ||
| // Ensure the challenge details reflect the latest data (e.g., active phase) | ||
| awaitmutate(`challengeBaseUrl/challenges/${challengeInfo?.id}`) |
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.
[maintainability]
Themutate function is called with a hardcoded URL string. Consider defining a constant or using a configuration file to manage URLs, which can improve maintainability and reduce the risk of errors if the URL changes.
| constpastPrefix='/past-challenges/' | ||
| // eslint-disable-next-line no-restricted-globals | ||
| constidx=location.pathname.indexOf(pastPrefix) |
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]
Usinglocation.pathname directly can lead to issues if the code is executed in a non-browser environment or if the pathname changes. Consider using a more robust method to determine the current path, such as a routing library's API.
| ?`${rootRoute}/past-challenges/${challengeInfo?.id}/challenge-details` | ||
| :`${rootRoute}/active-challenges/${challengeInfo?.id}/challenge-details` | ||
| navigate(url,{ | ||
| fallback:'./../../../../challenge-details', |
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 fallback URL./../../../../challenge-details seems relative and could lead to navigation errors if the directory structure changes. Consider using an absolute path or a named route to ensure reliability.
…-rendererMake sure the AI feedback md renderer is not yelling headings
Add ai reviewers on all tables
| :global(.reviews-table) { | ||
| margin-left:auto; | ||
| width:75%; | ||
| margin-bottom:-9px; |
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.
[maintainability]
Using a negative margin (margin-bottom: -9px;) can lead to layout issues, especially if the surrounding elements are not designed to accommodate this. Consider revisiting this approach to ensure it doesn't cause unintended overlap or spacing issues.
| @includeltelg { | ||
| width:auto; | ||
| margin-left:-1*$sp-4; |
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.
[maintainability]
The use ofmargin-left: -1*$sp-4; with a negative multiplier can be error-prone and may lead to unexpected layout shifts. Ensure this is intentional and tested across different screen sizes.
| className={styles.aiReviews} | ||
| aiReviewers={props.aiReviewers!} | ||
| submission={submissionPayload} | ||
| defaultOpen={allRows ?!allRows.indexOf(data) :false} |
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 use of! to assert thatprops.aiReviewers is notundefined ornull can lead to runtime errors if the assumption is incorrect. Consider using optional chaining or a conditional check to ensure safety.
| aiReviewers={props.aiReviewers!} | ||
| submission={submissionPayload} | ||
| defaultOpen={allRows ?!allRows.indexOf(data) :false} | ||
| /> |
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 expression!allRows.indexOf(data) will always evaluate tofalse becauseindexOf returns-1 for not found and0 or higher for found indices. Consider usingallRows.indexOf(data) === 0 to check ifdata is the first element.
| @includeltelg { | ||
| width:auto; | ||
| margin-left:-1*$sp-4; |
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 use of-1*$sp-4 formargin-left could be problematic if$sp-4 is not a simple numeric value. Consider usingcalc() for better clarity and to ensure proper CSS calculation.
| <CollapsibleAiReviewsRow | ||
| className={styles.aiReviews} | ||
| aiReviewers={props.aiReviewers} | ||
| submission={submissionasany} |
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.
[maintainability]
Thesubmission prop is being cast toany. This can lead to runtime errors if the expected structure ofsubmission changes. Consider defining a more specific type forsubmission to ensure type safety.
| className={styles.aiReviews} | ||
| aiReviewers={props.aiReviewers} | ||
| submission={submissionasany} | ||
| defaultOpen={allRows ?!allRows.indexOf(submission) :false} |
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.
[💡readability]
The expressionallRows ? !allRows.indexOf(submission) : false is used to determine thedefaultOpen state. This logic could be clearer. Consider usingallRows.indexOf(submission) === 0 to explicitly check if the submission is the first element, which would be more readable.
| :global(.reviews-table) { | ||
| margin-left:auto; | ||
| width:75%; | ||
| margin-bottom:-9px; |
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.
[maintainability]
Using a negative margin (margin-bottom: -9px;) can lead to unexpected layout issues, especially if the surrounding elements have dynamic content or styles. Consider revisiting this approach to ensure consistent layout behavior.
| @includeltelg { | ||
| width:auto; | ||
| margin-left:-1*$sp-4; |
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.
[maintainability]
The use ofmargin-left: -1*$sp-4; with a negative multiplier can be error-prone and may lead to layout issues if$sp-4 changes. Consider using a more explicit approach to manage spacing.
| className={styles.aiReviews} | ||
| aiReviewers={props.aiReviewers!} | ||
| submission={submissionPayloadasPick<BackendSubmission,'id'|'virusScan'>} | ||
| defaultOpen={allRows ?!allRows.indexOf(data) :false} |
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]
Using the non-null assertion operator (!) onprops.aiReviewers could lead to runtime errors ifaiReviewers isundefined. Consider adding a check or default value to ensure safety.
| className={styles.aiReviews} | ||
| aiReviewers={props.aiReviewers!} | ||
| submission={submissionPayloadasPick<BackendSubmission,'id'|'virusScan'>} | ||
| defaultOpen={allRows ?!allRows.indexOf(data) :false} |
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]
CastingsubmissionPayload toPick<BackendSubmission, 'id'|'virusScan'> without verifying all required properties are present could lead to runtime errors. Ensure thatsubmissionPayload contains the necessary properties before casting.
| data={props.screenings} | ||
| data={filteredScreenings} | ||
| showExpand | ||
| expandMode='always' |
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.
[performance]
TheexpandMode='always' prop on theTable component may lead to performance issues if the dataset is large, as all rows will be expanded by default. Consider whether this is necessary or if a different approach could be more efficient.
…ablesupdate rendering for ai reviewers
| return( | ||
| <CollapsibleAiReviewsRow | ||
| className={styles.aiReviews} | ||
| aiReviewers={props.aiReviewers??[]} |
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.
[performance]
Usingprops.aiReviewers ?? [] ensures thataiReviewers is always an array, but it might be more efficient to handle the case whereaiReviewers is undefined outside of theuseMemo to avoid unnecessary re-renders.
| }, | ||
| { | ||
| ...column, | ||
| colSpan:column.label ?1 :2, |
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.
[💡readability]
The use ofcolSpan: column.label ? 1 : 2 is correct, but it might be clearer to explicitly state the logic or extract it into a named constant to improve readability.
| renderer:(submission:SubmissionInfo,allRows:SubmissionInfo[])=>( | ||
| <CollapsibleAiReviewsRow | ||
| className={styles.aiReviews} | ||
| aiReviewers={props.aiReviewers??[]} |
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.
[💡maintainability]
Usingprops.aiReviewers ?? [] ensures thataiReviewers is always an array, which is good for preventing runtime errors. However, ifaiReviewers is expected to be an array, consider validating this at the prop type level to catch potential issues earlier in the development process.
| constcolumnsMobile=useMemo<MobileTableColumn<SubmissionInfo>[][]>(()=>( | ||
| (actionColumn ?[...columns,actionColumn] :columns).map(column=>([ | ||
| { | ||
| column.label&&{ |
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.
[💡readability]
The conditionalcolumn.label && { ... } could lead to a situation whereundefined is pushed into the array, which is why.filter(Boolean) is used later. Consider restructuring this logic to avoid pushingundefined in the first place, which would make the code cleaner and more efficient.
| constaiReviewersColumn=useMemo<TableColumn<Screening>|undefined>( | ||
| ()=>({ | ||
| columnId:'ai-reviews-table', |
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 check forprops.aiReviewers?.length has been removed. Ifprops.aiReviewers is undefined or an empty array, this could lead to unexpected behavior or errors when accessingprops.aiReviewers!. Consider reintroducing the check to ensureprops.aiReviewers is defined and not empty before proceeding.
| ()=>columns.map( | ||
| column=>[ | ||
| { | ||
| column.label&&{ |
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 use ofcolumn.label && as a condition could lead to unexpected behavior ifcolumn.label is an empty string or a falsy value. Consider explicitly checking forcolumn.label !== undefined to ensure clarity and correctness.
Related JIRA Ticket:
https://topcoder.atlassian.net/browse/PM-1428
What's in this PR?
AI Workflows MVP