diff --git a/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx b/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx index 8490bbd3871..c19f5d39b01 100644 --- a/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx +++ b/app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx @@ -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 = @@ -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 @@ -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) } @@ -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 { diff --git a/app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx b/app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx index 37d624fedc4..6c0c41d99ba 100644 --- a/app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx +++ b/app/src/organisms/Devices/ProtocolRun/RunFailedModal.tsx @@ -18,6 +18,7 @@ import { SPACING, LegacyStyledText, TYPOGRAPHY, + DISPLAY_FLEX, } from '@opentrons/components' import { LegacyModal } from '../../../molecules/LegacyModal' @@ -100,7 +101,7 @@ export function RunFailedModal({ isSingleError, }: ErrorContentProps): JSX.Element => { return ( - <> + {isSingleError ? t('error_info', { @@ -130,7 +131,7 @@ export function RunFailedModal({ ))} - + ) } @@ -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}; diff --git a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx index b30505837a6..daa105277f4 100644 --- a/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx +++ b/app/src/organisms/Devices/ProtocolRun/__tests__/ProtocolRunHeader.test.tsx @@ -800,7 +800,6 @@ describe('ProtocolRunHeader', () => { render() fireEvent.click(screen.getByText('View error')) - expect(mockCloseCurrentRun).toBeCalled() screen.getByText('mock RunFailedModal') }) diff --git a/app/src/pages/RunSummary/index.tsx b/app/src/pages/RunSummary/index.tsx index 3f8a9099737..0bdc68a4c4e 100644 --- a/app/src/pages/RunSummary/index.tsx +++ b/app/src/pages/RunSummary/index.tsx @@ -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