Skip to content

Commit

Permalink
fix(app): add cursor and pageLength to GET /commandErrors (#16019)
Browse files Browse the repository at this point in the history
# Overview

closes [RQA-3031](https://opentrons.atlassian.net/browse/RQA-3031) and
[RQA-3047](https://opentrons.atlassian.net/browse/RQA-3047).
pass in cursor and page length to get run command errors. 

## Test Plan and Hands on Testing

- upload a protocol that will enter ER.
- make sure there are a few errors to show.
- at the end of the run make sure when you click 'view error details' is
showing the full error list.

## Changelog

added cursor and pageLength to GET request.

## Risk assessment

None.

[RQA-3031]:
https://opentrons.atlassian.net/browse/RQA-3031?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

[RQA-3047]:
https://opentrons.atlassian.net/browse/RQA-3047?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: Jamey Huffnagle <[email protected]>
  • Loading branch information
TamarZanzouri and mjhuff authored Aug 15, 2024
1 parent b8d74b9 commit 038abba
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
35 changes: 23 additions & 12 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,17 @@ export function ProtocolRunHeader({
const { closeCurrentRun, isClosingCurrentRun } = useCloseCurrentRun()
const { startedAt, stoppedAt, completedAt } = useRunTimestamps(runId)
const [showRunFailedModal, setShowRunFailedModal] = React.useState(false)
const { data: commandErrorList } = useRunCommandErrors(runId, null, {
enabled:
runStatus != null &&
// @ts-expect-error runStatus expected to possibly not be terminal
RUN_STATUSES_TERMINAL.includes(runStatus) &&
isMostRecentRun,
})
const { data: commandErrorList } = useRunCommandErrors(
runId,
{ cursor: 0, pageLength: 100 },
{
enabled:
runStatus != null &&
// @ts-expect-error runStatus expected to possibly not be terminal
RUN_STATUSES_TERMINAL.includes(runStatus) &&
isMostRecentRun,
}
)
const isResetRunLoadingRef = React.useRef(false)
const { data: runRecord } = useNotifyRunQuery(runId, { staleTime: Infinity })
const highestPriorityError =
Expand Down Expand Up @@ -288,13 +292,16 @@ export function ProtocolRunHeader({
},
})

// TODO(jh, 08-15-24): The enteredER condition is a hack, because errorCommands are only returned when a run is current.
// Ideally the run should not need to be current to view errorCommands.

// Close the run if no tips are attached after running tip check at least once.
// This marks the robot as "not busy" as soon as a run is cancelled if drop tip CTAs are unnecessary.
if (initialPipettesWithTipsCount === 0) {
if (initialPipettesWithTipsCount === 0 && !enteredER) {
closeCurrentRun()
}
}
}, [runStatus, isRunCurrent, runId])
}, [runStatus, isRunCurrent, runId, enteredER])

const startedAtTimestamp =
startedAt != null ? formatTimestamp(startedAt) : EMPTY_TIMESTAMP
Expand Down Expand Up @@ -935,12 +942,16 @@ function TerminalRunBanner(props: TerminalRunProps): JSX.Element | null {
const { t } = useTranslation('run_details')
const completedWithErrors =
commandErrorList?.data != null && commandErrorList.data.length > 0

const handleRunSuccessClick = (): void => {
handleClearClick()
}

const handleFailedRunClick = (): void => {
handleClearClick()
// TODO(jh, 08-15-24): See TODO related to commandErrorList above.
if (commandErrorList == null) {
handleClearClick()
}
setShowRunFailedModal(true)
}

Expand Down Expand Up @@ -1001,8 +1012,8 @@ function TerminalRunBanner(props: TerminalRunProps): JSX.Element | null {
// TODO(jh, 08-14-24): The backend never returns the "user cancelled a run" error and cancelledWithoutRecovery becomes unnecessary.
else if (
!cancelledWithoutRecovery &&
(highestPriorityError != null ||
(completedWithErrors && !isResetRunLoading))
!isResetRunLoading &&
(highestPriorityError != null || completedWithErrors)
) {
return buildErrorBanner()
} else {
Expand Down
7 changes: 5 additions & 2 deletions app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
SPACING,
LegacyStyledText,
TYPOGRAPHY,
DISPLAY_FLEX,
} from '@opentrons/components'

import { LegacyModal } from '../../../molecules/LegacyModal'
Expand Down Expand Up @@ -100,7 +101,7 @@ export function RunFailedModal({
isSingleError,
}: ErrorContentProps): JSX.Element => {
return (
<>
<Flex flexDirection={DIRECTION_COLUMN}>
<LegacyStyledText as="p" fontWeight={TYPOGRAPHY.fontWeightSemiBold}>
{isSingleError
? t('error_info', {
Expand Down Expand Up @@ -130,7 +131,7 @@ export function RunFailedModal({
</LegacyStyledText>
))}
</Flex>
</>
</Flex>
)
}

Expand Down Expand Up @@ -172,6 +173,8 @@ export function RunFailedModal({
}

const ERROR_MESSAGE_STYLE = css`
display: ${DISPLAY_FLEX};
flex-direction: ${DIRECTION_COLUMN};
max-height: 9.5rem;
overflow-y: ${OVERFLOW_AUTO};
margin-top: ${SPACING.spacing8};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,6 @@ describe('ProtocolRunHeader', () => {
render()

fireEvent.click(screen.getByText('View error'))
expect(mockCloseCurrentRun).toBeCalled()
screen.getByText('mock RunFailedModal')
})

Expand Down
18 changes: 11 additions & 7 deletions app/src/pages/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,17 @@ export function RunSummary(): JSX.Element {
localRobot?.serverHealth?.serialNumber ??
null

const { data: commandErrorList } = useRunCommandErrors(runId, null, {
enabled:
runStatus != null &&
// @ts-expect-error runStatus expected to possibly not be terminal
RUN_STATUSES_TERMINAL.includes(runStatus) &&
isRunCurrent,
})
const { data: commandErrorList } = useRunCommandErrors(
runId,
{ cursor: 0, pageLength: 100 },
{
enabled:
runStatus != null &&
// @ts-expect-error runStatus expected to possibly not be terminal
RUN_STATUSES_TERMINAL.includes(runStatus) &&
isRunCurrent,
}
)
// TODO(jh, 08-14-24): The backend never returns the "user cancelled a run" error and cancelledWithoutRecovery becomes unnecessary.
const cancelledWithoutRecovery =
!enteredER && runStatus === RUN_STATUS_STOPPED
Expand Down

0 comments on commit 038abba

Please sign in to comment.