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): Fix double drop tip prompting after Error Recovery cancel action #17316

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/local-resources/commands/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './getCommandTextData'
export * from './lastRunCommandPromptedErrorRecovery'
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { RunCommandSummary } from '@opentrons/api-client'
// Whether the last run protocol command prompted Error Recovery, if Error Recovery is enabled.
export function lastRunCommandPromptedErrorRecovery(
summary: RunCommandSummary[] | null,
isEREnabled: boolean
): boolean {
const lastProtocolCommand = summary?.findLast(
command => command.intent !== 'fixit' && command.error != null
)
// All recoverable protocol commands have defined errors.
return isEREnabled ? lastProtocolCommand?.error?.isDefined ?? false : false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import { useEffect } from 'react'

import { RUN_STATUS_IDLE, RUN_STATUS_STOPPED } from '@opentrons/api-client'
import { FLEX_ROBOT_TYPE, OT2_ROBOT_TYPE } from '@opentrons/shared-data'
import { useErrorRecoverySettings } from '@opentrons/react-api-client'

import { useDropTipWizardFlows } from '/app/organisms/DropTipWizardFlows'
import { useProtocolDropTipModal } from '../modals'
import { useCloseCurrentRun, useIsRunCurrent } from '/app/resources/runs'
import {
useCloseCurrentRun,
useCurrentRunCommands,
useIsRunCurrent,
} from '/app/resources/runs'
import { isTerminalRunStatus } from '../../utils'
import { useTipAttachmentStatus } from '/app/resources/instruments'
import { lastRunCommandPromptedErrorRecovery } from '/app/local-resources/commands'

import type { RobotType } from '@opentrons/shared-data'
import type { Run, RunStatus } from '@opentrons/api-client'
Expand Down Expand Up @@ -99,17 +105,33 @@ export function useRunHeaderDropTip({
: { showDTWiz: false, dtWizProps: null }
}

const { data } = useErrorRecoverySettings()
const isEREnabled = data?.data.enabled ?? true
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()
} else if (isRunCurrent && isTerminalRunStatus(runStatus)) {
}
// Only run tip checking if it wasn't *just* handled during Error Recovery.
else if (
!lastRunCommandPromptedErrorRecovery(runSummaryNoFixit, isEREnabled) &&
isRunCurrent &&
isTerminalRunStatus(runStatus)
) {
void determineTipStatus()
}
}
}, [runStatus, robotType, isRunCurrent])
}, [runStatus, robotType, isRunCurrent, runSummaryNoFixit, isEREnabled])

// 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.
Expand Down
16 changes: 14 additions & 2 deletions app/src/pages/ODD/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
useProtocolQuery,
useDeleteRunMutation,
useRunCommandErrors,
useErrorRecoverySettings,
} from '@opentrons/react-api-client'
import { useRunControls } from '/app/organisms/RunTimeControl/hooks'
import { onDeviceDisplayFormatTimestamp } from '/app/transformations/runs'
Expand All @@ -65,9 +66,11 @@ import {
useRunCreatedAtTimestamp,
useCloseCurrentRun,
EMPTY_TIMESTAMP,
useCurrentRunCommands,
} from '/app/resources/runs'
import { handleTipsAttachedModal } from '/app/organisms/DropTipWizardFlows'
import { useTipAttachmentStatus } from '/app/resources/instruments'
import { lastRunCommandPromptedErrorRecovery } from '/app/local-resources/commands'

import type { IconName } from '@opentrons/components'
import type { OnDeviceRouteParams } from '/app/App/types'
Expand Down Expand Up @@ -233,10 +236,19 @@ export function RunSummary(): JSX.Element {
runId,
runRecord: runRecord ?? null,
})
const { data } = useErrorRecoverySettings()
const isEREnabled = data?.data.enabled ?? true
const runSummaryNoFixit = useCurrentRunCommands({
includeFixitCommands: false,
pageLength: 1,
})

useEffect(() => {
void determineTipStatus()
}, [])
// Only run tip checking if it wasn't *just* handled during Error Recovery.
if (!lastRunCommandPromptedErrorRecovery(runSummaryNoFixit, isEREnabled)) {
void determineTipStatus()
}
}, [isRunCurrent, runSummaryNoFixit, isEREnabled])

const returnToQuickTransfer = (): void => {
closeCurrentRunIfValid(() => {
Expand Down
Loading