From 3a46ebe7dd219dff386f980255283d2db0ecb59c Mon Sep 17 00:00:00 2001 From: Jamey Huffnagle Date: Fri, 10 Jan 2025 10:15:52 -0700 Subject: [PATCH] fix(app): Fix persistent "run in progress" settings banner after run cancel (#17235) Closes RQA-3838 --- .../local-resources/commands/utils/index.ts | 1 - .../lastRunCommandPromptedErrorRecovery.ts | 13 -------- .../TerminalRunBannerContainer.tsx | 8 ++--- .../hooks/useRunHeaderDropTip.ts | 32 +++---------------- .../ProtocolRunHeader/hooks/useRunErrors.ts | 6 +--- app/src/pages/ODD/RunSummary/index.tsx | 18 ++--------- 6 files changed, 9 insertions(+), 69 deletions(-) delete mode 100644 app/src/local-resources/commands/utils/lastRunCommandPromptedErrorRecovery.ts diff --git a/app/src/local-resources/commands/utils/index.ts b/app/src/local-resources/commands/utils/index.ts index cc4e9c2579a..7aa84d14de5 100644 --- a/app/src/local-resources/commands/utils/index.ts +++ b/app/src/local-resources/commands/utils/index.ts @@ -1,2 +1 @@ export * from './getCommandTextData' -export * from './lastRunCommandPromptedErrorRecovery' diff --git a/app/src/local-resources/commands/utils/lastRunCommandPromptedErrorRecovery.ts b/app/src/local-resources/commands/utils/lastRunCommandPromptedErrorRecovery.ts deleted file mode 100644 index dd07756ef43..00000000000 --- a/app/src/local-resources/commands/utils/lastRunCommandPromptedErrorRecovery.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { RunCommandSummary } from '@opentrons/api-client' - -// Whether the last run protocol command prompted Error Recovery. -export function lastRunCommandPromptedErrorRecovery( - summary: RunCommandSummary[] -): boolean { - const lastProtocolCommand = summary.findLast( - command => command.intent !== 'fixit' && command.error != null - ) - - // All recoverable protocol commands have defined errors. - return lastProtocolCommand?.error?.isDefined ?? false -} diff --git a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderBannerContainer/TerminalRunBannerContainer.tsx b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderBannerContainer/TerminalRunBannerContainer.tsx index ec70dcdf189..4148a791611 100644 --- a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderBannerContainer/TerminalRunBannerContainer.tsx +++ b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderBannerContainer/TerminalRunBannerContainer.tsx @@ -121,14 +121,10 @@ function ProtocolRunErrorBanner({ const { closeCurrentRun } = useCloseCurrentRun() - const { highestPriorityError, commandErrorList } = runErrors + const { highestPriorityError } = runErrors const handleFailedRunClick = (): void => { - // TODO(jh, 08-15-24): Revisit the control flow here here after - // commandErrorList may be fetched for a non-current run. - if (commandErrorList == null) { - closeCurrentRun() - } + closeCurrentRun() runHeaderModalContainerUtils.runFailedModalUtils.toggleModal() } diff --git a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts index 82d9c30c84b..0ff96a562df 100644 --- a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts +++ b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts @@ -5,13 +5,8 @@ import { FLEX_ROBOT_TYPE, OT2_ROBOT_TYPE } from '@opentrons/shared-data' import { useDropTipWizardFlows } from '/app/organisms/DropTipWizardFlows' import { useProtocolDropTipModal } from '../modals' -import { - useCloseCurrentRun, - useCurrentRunCommands, - useIsRunCurrent, -} from '/app/resources/runs' +import { useCloseCurrentRun, useIsRunCurrent } from '/app/resources/runs' import { isTerminalRunStatus } from '../../utils' -import { lastRunCommandPromptedErrorRecovery } from '/app/local-resources/commands' import { useTipAttachmentStatus } from '/app/resources/instruments' import type { RobotType } from '@opentrons/shared-data' @@ -104,35 +99,17 @@ export function useRunHeaderDropTip({ : { showDTWiz: false, dtWizProps: null } } - const runSummaryNoFixit = useCurrentRunCommands( - { - includeFixitCommands: false, - pageLength: 1, - }, - { enabled: isTerminalRunStatus(runStatus) } - ) // Manage tip checking useEffect(() => { // If a user begins a new run without navigating away from the run page, reset tip status. if (robotType === FLEX_ROBOT_TYPE) { if (runStatus === RUN_STATUS_IDLE) { resetTipStatus() - } - // Only determine tip status when necessary as this can be an expensive operation. Error Recovery handles tips, so don't - // have to do it here if done during Error Recovery. - else if ( - runSummaryNoFixit != null && - runSummaryNoFixit.length > 0 && - !lastRunCommandPromptedErrorRecovery(runSummaryNoFixit) && - isTerminalRunStatus(runStatus) - ) { + } else if (isRunCurrent && isTerminalRunStatus(runStatus)) { void determineTipStatus() } } - }, [runStatus, robotType, runSummaryNoFixit]) - - // 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. + }, [runStatus, robotType, isRunCurrent]) // If the run terminates with a "stopped" status, close the run if no tips are attached after running tip check at least once. // This marks the robot as "not busy" if drop tip CTAs are unnecessary. @@ -140,8 +117,7 @@ export function useRunHeaderDropTip({ if ( runStatus === RUN_STATUS_STOPPED && isRunCurrent && - (initialPipettesWithTipsCount === 0 || robotType === OT2_ROBOT_TYPE) && - !enteredER + (initialPipettesWithTipsCount === 0 || robotType === OT2_ROBOT_TYPE) ) { closeCurrentRun() } diff --git a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/hooks/useRunErrors.ts b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/hooks/useRunErrors.ts index 4d66b367a0e..593c435029b 100644 --- a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/hooks/useRunErrors.ts +++ b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/hooks/useRunErrors.ts @@ -1,7 +1,6 @@ import { useRunCommandErrors } from '@opentrons/react-api-client' import { isTerminalRunStatus } from '../utils' -import { useMostRecentRunId } from '/app/resources/runs' import { getHighestPriorityError } from '/app/transformations/runs' import type { RunStatus, Run } from '@opentrons/api-client' @@ -27,14 +26,11 @@ export function useRunErrors({ runRecord, runStatus, }: UseRunErrorsProps): UseRunErrorsResult { - const mostRecentRunId = useMostRecentRunId() - const isMostRecentRun = mostRecentRunId === runId - const { data: commandErrorList } = useRunCommandErrors( runId, { cursor: 0, pageLength: ALL_COMMANDS_PAGE_LENGTH }, { - enabled: isTerminalRunStatus(runStatus) && isMostRecentRun, + enabled: isTerminalRunStatus(runStatus), } ) diff --git a/app/src/pages/ODD/RunSummary/index.tsx b/app/src/pages/ODD/RunSummary/index.tsx index 86aec6aaf87..9d1f73d7e3b 100644 --- a/app/src/pages/ODD/RunSummary/index.tsx +++ b/app/src/pages/ODD/RunSummary/index.tsx @@ -65,10 +65,8 @@ import { useRunCreatedAtTimestamp, useCloseCurrentRun, EMPTY_TIMESTAMP, - useCurrentRunCommands, } from '/app/resources/runs' import { handleTipsAttachedModal } from '/app/organisms/DropTipWizardFlows' -import { lastRunCommandPromptedErrorRecovery } from '/app/local-resources/commands' import { useTipAttachmentStatus } from '/app/resources/instruments' import type { IconName } from '@opentrons/components' @@ -236,21 +234,9 @@ export function RunSummary(): JSX.Element { runRecord: runRecord ?? null, }) - // Determine tip status on initial render only. Error Recovery always handles tip status, so don't show it twice. - const runSummaryNoFixit = useCurrentRunCommands({ - includeFixitCommands: false, - pageLength: 1, - }) useEffect(() => { - if ( - isRunCurrent && - runSummaryNoFixit != null && - runSummaryNoFixit.length > 0 && - !lastRunCommandPromptedErrorRecovery(runSummaryNoFixit) - ) { - void determineTipStatus() - } - }, [runSummaryNoFixit, isRunCurrent]) + void determineTipStatus() + }, []) const returnToQuickTransfer = (): void => { closeCurrentRunIfValid(() => {