Skip to content

Commit

Permalink
fix(app): simplify tip detection conditions post run
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed Jan 9, 2025
1 parent 40d08aa commit 9b10793
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 53 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 @@ -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,32 +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.
// Note that it's possible to cancel a run before executing any commands, and we still should check for tips in this case.
else if (
runSummaryNoFixit != null &&
!lastRunCommandPromptedErrorRecovery(runSummaryNoFixit) &&
isTerminalRunStatus(runStatus)
) {
} else if (isRunCurrent && isTerminalRunStatus(runStatus)) {
void determineTipStatus()
}
}
}, [runStatus, robotType, runSummaryNoFixit])
}, [runStatus, robotType, isRunCurrent])

// 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.
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 9b10793

Please sign in to comment.