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 persistent "run in progress" settings banner after run cancel #17235

Merged
merged 3 commits into from
Jan 10, 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: 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 @@ -118,14 +118,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
Loading