From 96619a3570c6fcc1938fc3722fbdca684c66c939 Mon Sep 17 00:00:00 2001 From: Jamey Huffnagle Date: Thu, 7 Nov 2024 16:20:24 -0500 Subject: [PATCH] fix(app): add an exit button for failed moveToAddressable area commands during Error Recovery --- .../DropTipWizardFlows/DropTipWizardFlows.tsx | 6 +- .../DropTipWizardFlows/hooks/errors.tsx | 6 +- .../hooks/useDropTipCommands.ts | 84 +++++++++---------- 3 files changed, 50 insertions(+), 46 deletions(-) diff --git a/app/src/organisms/DropTipWizardFlows/DropTipWizardFlows.tsx b/app/src/organisms/DropTipWizardFlows/DropTipWizardFlows.tsx index b6b60315936..921e0fc04c3 100644 --- a/app/src/organisms/DropTipWizardFlows/DropTipWizardFlows.tsx +++ b/app/src/organisms/DropTipWizardFlows/DropTipWizardFlows.tsx @@ -68,9 +68,11 @@ export function DropTipWizardFlows( // after it closes. useEffect(() => { return () => { - dropTipWithTypeUtils.dropTipCommands.handleCleanUpAndClose() + if (issuedCommandsType === 'setup') { + void dropTipWithTypeUtils.dropTipCommands.handleCleanUpAndClose() + } } - }, []) + }, [issuedCommandsType]) return ( { - const error = commandData[0].data.error - if (error != null) { - setErrorDetails({ - runCommandError: error, - message: `Error moving to position: ${error.detail}`, - }) - } - }) - .then(resolve) - .catch(error => { - if ( - fixitCommandTypeUtils != null && - issuedCommandsType === 'fixit' - ) { - fixitCommandTypeUtils.errorOverrides.generalFailure() - } + if (addressableAreaFromConfig == null) { + throw new Error('invalid addressable area.') + } - reject( - new Error(`Error issuing move to addressable area: ${error}`) - ) - }) - } else { - setErrorDetails({ - message: `Error moving to position: invalid addressable area.`, + const moveToAACommand = buildMoveToAACommand( + addressableAreaFromConfig, + pipetteId, + isPredefinedLocation, + issuedCommandsType + ) + + return chainRunCommands( + isFlex + ? [ + ENGAGE_AXES, + UPDATE_ESTIMATORS_EXCEPT_PLUNGERS, + Z_HOME, + moveToAACommand, + ] + : [Z_HOME, moveToAACommand], + false + ) + .then((commandData: CommandData[]) => { + const error = commandData[0].data.error + if (error != null) { + // eslint-disable-next-line @typescript-eslint/no-throw-literal + throw error + } + resolve() + }) + .catch(error => { + if (fixitCommandTypeUtils != null && issuedCommandsType === 'fixit') { + fixitCommandTypeUtils.errorOverrides.generalFailure() + } else { + setErrorDetails({ + runCommandError: error, + message: error.detail + ? `Error moving to position: ${error.detail}` + : 'Error moving to position: invalid addressable area.', + }) + } + reject(error) }) - } }) }