Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): add cursor and pageLength to GET /commandErrors #16019

Merged
merged 10 commits into from
Aug 15, 2024
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
18 changes: 11 additions & 7 deletions app/src/pages/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,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
Loading