Skip to content

Commit 0da7b99

Browse files
authored
fix(app): Fix double drop tip prompting after Error Recovery cancel action (#17316)
This commit brings the `lastRunCommandPromptedErrorRecovery` util back and adds the new and improved behavior to also check if Error Recovery is enabled (in settings). If it's not enabled, we need to run tip detection even if the last run command was recoverable.
1 parent 9c70751 commit 0da7b99

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './getCommandTextData'
2+
export * from './lastRunCommandPromptedErrorRecovery'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { RunCommandSummary } from '@opentrons/api-client'
2+
// Whether the last run protocol command prompted Error Recovery, if Error Recovery is enabled.
3+
export function lastRunCommandPromptedErrorRecovery(
4+
summary: RunCommandSummary[] | null,
5+
isEREnabled: boolean
6+
): boolean {
7+
const lastProtocolCommand = summary?.findLast(
8+
command => command.intent !== 'fixit' && command.error != null
9+
)
10+
// All recoverable protocol commands have defined errors.
11+
return isEREnabled ? lastProtocolCommand?.error?.isDefined ?? false : false
12+
}

app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ import { useEffect } from 'react'
22

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

67
import { useDropTipWizardFlows } from '/app/organisms/DropTipWizardFlows'
78
import { useProtocolDropTipModal } from '../modals'
8-
import { useCloseCurrentRun, useIsRunCurrent } from '/app/resources/runs'
9+
import {
10+
useCloseCurrentRun,
11+
useCurrentRunCommands,
12+
useIsRunCurrent,
13+
} from '/app/resources/runs'
914
import { isTerminalRunStatus } from '../../utils'
1015
import { useTipAttachmentStatus } from '/app/resources/instruments'
16+
import { lastRunCommandPromptedErrorRecovery } from '/app/local-resources/commands'
1117

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

108+
const { data } = useErrorRecoverySettings()
109+
const isEREnabled = data?.data.enabled ?? true
110+
const runSummaryNoFixit = useCurrentRunCommands(
111+
{
112+
includeFixitCommands: false,
113+
pageLength: 1,
114+
},
115+
{ enabled: isTerminalRunStatus(runStatus) }
116+
)
117+
102118
// Manage tip checking
103119
useEffect(() => {
104120
// If a user begins a new run without navigating away from the run page, reset tip status.
105121
if (robotType === FLEX_ROBOT_TYPE) {
106122
if (runStatus === RUN_STATUS_IDLE) {
107123
resetTipStatus()
108-
} else if (isRunCurrent && isTerminalRunStatus(runStatus)) {
124+
}
125+
// Only run tip checking if it wasn't *just* handled during Error Recovery.
126+
else if (
127+
!lastRunCommandPromptedErrorRecovery(runSummaryNoFixit, isEREnabled) &&
128+
isRunCurrent &&
129+
isTerminalRunStatus(runStatus)
130+
) {
109131
void determineTipStatus()
110132
}
111133
}
112-
}, [runStatus, robotType, isRunCurrent])
134+
}, [runStatus, robotType, isRunCurrent, runSummaryNoFixit, isEREnabled])
113135

114136
// If the run terminates with a "stopped" status, close the run if no tips are attached after running tip check at least once.
115137
// This marks the robot as "not busy" if drop tip CTAs are unnecessary.

app/src/pages/ODD/RunSummary/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
useProtocolQuery,
4040
useDeleteRunMutation,
4141
useRunCommandErrors,
42+
useErrorRecoverySettings,
4243
} from '@opentrons/react-api-client'
4344
import { useRunControls } from '/app/organisms/RunTimeControl/hooks'
4445
import { onDeviceDisplayFormatTimestamp } from '/app/transformations/runs'
@@ -65,9 +66,11 @@ import {
6566
useRunCreatedAtTimestamp,
6667
useCloseCurrentRun,
6768
EMPTY_TIMESTAMP,
69+
useCurrentRunCommands,
6870
} from '/app/resources/runs'
6971
import { handleTipsAttachedModal } from '/app/organisms/DropTipWizardFlows'
7072
import { useTipAttachmentStatus } from '/app/resources/instruments'
73+
import { lastRunCommandPromptedErrorRecovery } from '/app/local-resources/commands'
7174

7275
import type { IconName } from '@opentrons/components'
7376
import type { OnDeviceRouteParams } from '/app/App/types'
@@ -233,10 +236,19 @@ export function RunSummary(): JSX.Element {
233236
runId,
234237
runRecord: runRecord ?? null,
235238
})
239+
const { data } = useErrorRecoverySettings()
240+
const isEREnabled = data?.data.enabled ?? true
241+
const runSummaryNoFixit = useCurrentRunCommands({
242+
includeFixitCommands: false,
243+
pageLength: 1,
244+
})
236245

237246
useEffect(() => {
238-
void determineTipStatus()
239-
}, [])
247+
// Only run tip checking if it wasn't *just* handled during Error Recovery.
248+
if (!lastRunCommandPromptedErrorRecovery(runSummaryNoFixit, isEREnabled)) {
249+
void determineTipStatus()
250+
}
251+
}, [isRunCurrent, runSummaryNoFixit, isEREnabled])
240252

241253
const returnToQuickTransfer = (): void => {
242254
closeCurrentRunIfValid(() => {

0 commit comments

Comments
 (0)