Skip to content

Commit

Permalink
fix(app): Fix persistent "run in progress" settings banner after run …
Browse files Browse the repository at this point in the history
…cancel (#17235)

Closes RQA-3838
  • Loading branch information
mjhuff authored Jan 10, 2025
1 parent 02b6a42 commit 3a46ebe
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 69 deletions.
1 change: 0 additions & 1 deletion app/src/local-resources/commands/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './getCommandTextData'
export * from './lastRunCommandPromptedErrorRecovery'

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -104,44 +99,25 @@ 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.
useEffect(() => {
if (
runStatus === RUN_STATUS_STOPPED &&
isRunCurrent &&
(initialPipettesWithTipsCount === 0 || robotType === OT2_ROBOT_TYPE) &&
!enteredER
(initialPipettesWithTipsCount === 0 || robotType === OT2_ROBOT_TYPE)
) {
closeCurrentRun()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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),
}
)

Expand Down
18 changes: 2 additions & 16 deletions app/src/pages/ODD/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit 3a46ebe

Please sign in to comment.