diff --git a/api-client/src/runs/commands/types.ts b/api-client/src/runs/commands/types.ts index 8c5517a1fe3..215756ede66 100644 --- a/api-client/src/runs/commands/types.ts +++ b/api-client/src/runs/commands/types.ts @@ -1,8 +1,8 @@ import type { RunTimeCommand, RunCommandError } from '@opentrons/shared-data' export interface GetCommandsParams { - cursor: number | null // the index of the command at the center of the window pageLength: number // the number of items to include + cursor?: number } export interface GetRunCommandsParams extends GetCommandsParams { @@ -10,7 +10,7 @@ export interface GetRunCommandsParams extends GetCommandsParams { } export interface GetRunCommandsParamsRequest extends GetCommandsParams { - includeFixitCommands: boolean | null + includeFixitCommands?: boolean } export interface RunCommandErrors { diff --git a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/hooks/useActionButtonProperties.ts b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/hooks/useActionButtonProperties.ts index 4c5486eb6e7..f9ea87080ca 100644 --- a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/hooks/useActionButtonProperties.ts +++ b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderContent/ActionButton/hooks/useActionButtonProperties.ts @@ -132,6 +132,7 @@ export function useActionButtonProperties({ handleButtonClick = () => { isResetRunLoadingRef.current = true reset() + runHeaderModalContainerUtils.dropTipUtils.resetTipStatus() trackEvent({ name: ANALYTICS_PROTOCOL_PROCEED_TO_RUN, properties: { sourceLocation: 'RunRecordDetail', robotSerialNumber }, diff --git a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts index 48887d4ac17..2e1da26cd88 100644 --- a/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts +++ b/app/src/organisms/Desktop/Devices/ProtocolRun/ProtocolRunHeader/RunHeaderModalContainer/hooks/useRunHeaderDropTip.ts @@ -22,6 +22,7 @@ import type { Run, RunStatus } from '@opentrons/api-client' import type { DropTipWizardFlowsProps, PipetteWithTip, + TipAttachmentStatusResult, } from '/app/organisms/DropTipWizardFlows' import type { UseProtocolDropTipModalResult } from '../modals' import type { PipetteDetails } from '/app/resources/maintenance_runs' @@ -40,6 +41,7 @@ export interface UseRunHeaderDropTipParams { export interface UseRunHeaderDropTipResult { dropTipModalUtils: UseProtocolDropTipModalResult dropTipWizardUtils: RunHeaderDropTipWizProps + resetTipStatus: TipAttachmentStatusResult['resetTipStatus'] } // Handles all the tip related logic during a protocol run on the desktop app. @@ -111,11 +113,9 @@ export function useRunHeaderDropTip({ { includeFixitCommands: false, pageLength: 1, - cursor: null, }, { enabled: isTerminalRunStatus(runStatus) } ) - // Manage tip checking useEffect(() => { // If a user begins a new run without navigating away from the run page, reset tip status. @@ -127,7 +127,9 @@ export function useRunHeaderDropTip({ // have to do it here if done during Error Recovery. else if ( runSummaryNoFixit != null && - !lastRunCommandPromptedErrorRecovery(runSummaryNoFixit) + runSummaryNoFixit.length > 0 && + !lastRunCommandPromptedErrorRecovery(runSummaryNoFixit) && + isTerminalRunStatus(runStatus) ) { void determineTipStatus() } @@ -150,7 +152,11 @@ export function useRunHeaderDropTip({ } }, [runStatus, isRunCurrent, enteredER, initialPipettesWithTipsCount]) - return { dropTipModalUtils, dropTipWizardUtils: buildDTWizUtils() } + return { + dropTipModalUtils, + dropTipWizardUtils: buildDTWizUtils(), + resetTipStatus, + } } // TODO(jh, 09-12-24): Consolidate this with the same utility that exists elsewhere. diff --git a/app/src/organisms/Desktop/Devices/hooks/useDownloadRunLog.ts b/app/src/organisms/Desktop/Devices/hooks/useDownloadRunLog.ts index 61acbfb12c4..6e07d5bbfab 100644 --- a/app/src/organisms/Desktop/Devices/hooks/useDownloadRunLog.ts +++ b/app/src/organisms/Desktop/Devices/hooks/useDownloadRunLog.ts @@ -27,7 +27,6 @@ export function useDownloadRunLog( if (host == null) return // first getCommands to get total length of commands getCommands(host, runId, { - cursor: null, pageLength: 0, includeFixitCommands: true, }) diff --git a/app/src/organisms/Desktop/RunProgressMeter/__tests__/RunProgressMeter.test.tsx b/app/src/organisms/Desktop/RunProgressMeter/__tests__/RunProgressMeter.test.tsx index 3618b0ce586..928bd2572a9 100644 --- a/app/src/organisms/Desktop/RunProgressMeter/__tests__/RunProgressMeter.test.tsx +++ b/app/src/organisms/Desktop/RunProgressMeter/__tests__/RunProgressMeter.test.tsx @@ -77,7 +77,6 @@ describe('RunProgressMeter', () => { .thenReturn(null) when(useNotifyAllCommandsQuery) .calledWith(NON_DETERMINISTIC_RUN_ID, { - cursor: null, pageLength: 1, }) .thenReturn(mockUseAllCommandsResponseNonDeterministic) diff --git a/app/src/organisms/Desktop/RunProgressMeter/index.tsx b/app/src/organisms/Desktop/RunProgressMeter/index.tsx index 481947e1707..fb158f5d686 100644 --- a/app/src/organisms/Desktop/RunProgressMeter/index.tsx +++ b/app/src/organisms/Desktop/RunProgressMeter/index.tsx @@ -67,7 +67,6 @@ export function RunProgressMeter(props: RunProgressMeterProps): JSX.Element { const runData = runRecord?.data ?? null const { data: mostRecentCommandData } = useNotifyAllCommandsQuery(runId, { - cursor: null, pageLength: 1, }) // This lastRunCommand also includes "fixit" commands. diff --git a/app/src/organisms/DropTipWizardFlows/hooks/useTipAttachmentStatus/getPipettesWithTipAttached.ts b/app/src/organisms/DropTipWizardFlows/hooks/useTipAttachmentStatus/getPipettesWithTipAttached.ts index b710ba5a810..39d4c7dd94f 100644 --- a/app/src/organisms/DropTipWizardFlows/hooks/useTipAttachmentStatus/getPipettesWithTipAttached.ts +++ b/app/src/organisms/DropTipWizardFlows/hooks/useTipAttachmentStatus/getPipettesWithTipAttached.ts @@ -50,7 +50,6 @@ function getCommandsExecutedDuringRun( runId: string ): Promise { return getCommands(host, runId, { - cursor: null, pageLength: 0, includeFixitCommands: true, }).then(response => { @@ -58,7 +57,6 @@ function getCommandsExecutedDuringRun( return getCommands(host, runId, { cursor: 0, pageLength: totalLength, - includeFixitCommands: null, }).then(response => response.data) }) } diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useCurrentlyRecoveringFrom.test.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useCurrentlyRecoveringFrom.test.ts index dc3bb2dd2be..cc27994d671 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useCurrentlyRecoveringFrom.test.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useCurrentlyRecoveringFrom.test.ts @@ -55,7 +55,7 @@ describe('useCurrentlyRecoveringFrom', () => { expect(vi.mocked(useNotifyAllCommandsQuery)).toHaveBeenCalledWith( MOCK_RUN_ID, - { cursor: null, pageLength: 0 }, + { pageLength: 0 }, { enabled: false, refetchInterval: 5000 } ) expect(vi.mocked(useCommandQuery)).toHaveBeenCalledWith( diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useCurrentlyRecoveringFrom.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useCurrentlyRecoveringFrom.ts index 9ea9d468697..38f9e39165a 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useCurrentlyRecoveringFrom.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useCurrentlyRecoveringFrom.ts @@ -50,7 +50,7 @@ export function useCurrentlyRecoveringFrom( isFetching: isAllCommandsFetching, } = useNotifyAllCommandsQuery( runId, - { cursor: null, pageLength: 0 }, // pageLength 0 because we only care about the links. + { pageLength: 0 }, // pageLength 0 because we only care about the links. { enabled: isRunInRecoveryMode, refetchInterval: ALL_COMMANDS_POLL_MS, diff --git a/app/src/organisms/ODD/RunningProtocol/CurrentRunningProtocolCommand.tsx b/app/src/organisms/ODD/RunningProtocol/CurrentRunningProtocolCommand.tsx index 2866c3f95dd..92c1d1f5733 100644 --- a/app/src/organisms/ODD/RunningProtocol/CurrentRunningProtocolCommand.tsx +++ b/app/src/organisms/ODD/RunningProtocol/CurrentRunningProtocolCommand.tsx @@ -149,7 +149,6 @@ export function CurrentRunningProtocolCommand({ }: CurrentRunningProtocolCommandProps): JSX.Element | null { const { t } = useTranslation('run_details') const { data: mostRecentCommandData } = useNotifyAllCommandsQuery(runId, { - cursor: null, pageLength: 1, }) diff --git a/app/src/pages/ODD/RunSummary/index.tsx b/app/src/pages/ODD/RunSummary/index.tsx index ce7fd3c0ef6..dee57377d79 100644 --- a/app/src/pages/ODD/RunSummary/index.tsx +++ b/app/src/pages/ODD/RunSummary/index.tsx @@ -243,15 +243,14 @@ export function RunSummary(): JSX.Element { const runSummaryNoFixit = useCurrentRunCommands({ includeFixitCommands: false, pageLength: 1, - cursor: null, }) useEffect(() => { if ( isRunCurrent && runSummaryNoFixit != null && + runSummaryNoFixit.length > 0 && !lastRunCommandPromptedErrorRecovery(runSummaryNoFixit) ) { - console.log('HITTING THIS') void determineTipStatus() } }, [runSummaryNoFixit, isRunCurrent]) diff --git a/app/src/pages/ODD/RunningProtocol/__tests__/RunningProtocol.test.tsx b/app/src/pages/ODD/RunningProtocol/__tests__/RunningProtocol.test.tsx index f98666d3cbd..33d6f79e9a7 100644 --- a/app/src/pages/ODD/RunningProtocol/__tests__/RunningProtocol.test.tsx +++ b/app/src/pages/ODD/RunningProtocol/__tests__/RunningProtocol.test.tsx @@ -146,7 +146,6 @@ describe('RunningProtocol', () => { .thenReturn(mockRobotSideAnalysis) when(vi.mocked(useNotifyAllCommandsQuery)) .calledWith(RUN_ID, { - cursor: null, pageLength: 1, }) .thenReturn(mockUseAllCommandsResponseNonDeterministic) diff --git a/app/src/resources/runs/__tests__/useRunTimestamps.test.ts b/app/src/resources/runs/__tests__/useRunTimestamps.test.ts index 1417be1e96d..cbe714472e9 100644 --- a/app/src/resources/runs/__tests__/useRunTimestamps.test.ts +++ b/app/src/resources/runs/__tests__/useRunTimestamps.test.ts @@ -24,7 +24,7 @@ vi.mock('../useNotifyRunQuery') describe('useRunTimestamps hook', () => { beforeEach(() => { when(useRunCommands) - .calledWith(RUN_ID_2, { cursor: null, pageLength: 1 }, expect.any(Object)) + .calledWith(RUN_ID_2, { pageLength: 1 }, expect.any(Object)) .thenReturn([mockCommand.data as any]) }) diff --git a/app/src/resources/runs/useLastRunCommand.ts b/app/src/resources/runs/useLastRunCommand.ts index b061b46c7c8..a8ee6e249d3 100644 --- a/app/src/resources/runs/useLastRunCommand.ts +++ b/app/src/resources/runs/useLastRunCommand.ts @@ -18,7 +18,7 @@ export function useLastRunCommand( const runStatus = useRunStatus(runId) const { data: commandsData } = useNotifyAllCommandsQuery( runId, - { cursor: null, pageLength: 1 }, + { pageLength: 1 }, { ...options, refetchInterval: diff --git a/app/src/resources/runs/useNotifyAllCommandsQuery.ts b/app/src/resources/runs/useNotifyAllCommandsQuery.ts index 12bafb21ef3..e0082d26dd2 100644 --- a/app/src/resources/runs/useNotifyAllCommandsQuery.ts +++ b/app/src/resources/runs/useNotifyAllCommandsQuery.ts @@ -3,23 +3,12 @@ import { useAllCommandsQuery } from '@opentrons/react-api-client' import { useNotifyDataReady } from '../useNotifyDataReady' import type { UseQueryResult } from 'react-query' -import type { - CommandsData, - GetRunCommandsParams, - GetCommandsParams, -} from '@opentrons/api-client' +import type { CommandsData, GetRunCommandsParams } from '@opentrons/api-client' import type { QueryOptionsWithPolling } from '../useNotifyDataReady' -const DEFAULT_PAGE_LENGTH = 30 - -export const DEFAULT_PARAMS: GetCommandsParams = { - cursor: null, - pageLength: DEFAULT_PAGE_LENGTH, -} - export function useNotifyAllCommandsQuery( runId: string | null, - params?: GetRunCommandsParams | null, + params?: GetRunCommandsParams, options: QueryOptionsWithPolling = {} ): UseQueryResult { // Assume the useAllCommandsQuery() response can only change when the command links change. @@ -32,19 +21,8 @@ export function useNotifyAllCommandsQuery( topic: 'robot-server/runs/commands_links', options, }) - const nullCheckedParams = params ?? DEFAULT_PARAMS - - const nullCheckedFixitCommands = params?.includeFixitCommands ?? null - const finalizedNullCheckParams = { - ...nullCheckedParams, - includeFixitCommands: nullCheckedFixitCommands, - } - const httpQueryResult = useAllCommandsQuery( - runId, - finalizedNullCheckParams, - queryOptionsNotify - ) + const httpQueryResult = useAllCommandsQuery(runId, params, queryOptionsNotify) if (shouldRefetch) { void httpQueryResult.refetch() diff --git a/app/src/resources/runs/useRunTimestamps.ts b/app/src/resources/runs/useRunTimestamps.ts index f3ae3f1a803..b19cbe42193 100644 --- a/app/src/resources/runs/useRunTimestamps.ts +++ b/app/src/resources/runs/useRunTimestamps.ts @@ -30,7 +30,7 @@ export function useRunTimestamps(runId: string | null): RunTimestamps { const runCommands = useRunCommands( runId, - { cursor: null, pageLength: 1 }, + { pageLength: 1 }, { enabled: runStatus === RUN_STATUS_SUCCEEDED || diff --git a/react-api-client/src/runs/useAllCommandsAsPreSerializedList.ts b/react-api-client/src/runs/useAllCommandsAsPreSerializedList.ts index 4f7e2fdc0e0..c441fcc3553 100644 --- a/react-api-client/src/runs/useAllCommandsAsPreSerializedList.ts +++ b/react-api-client/src/runs/useAllCommandsAsPreSerializedList.ts @@ -14,10 +14,6 @@ import type { } from '@opentrons/api-client' const DEFAULT_PAGE_LENGTH = 30 -export const DEFAULT_PARAMS: GetRunCommandsParams = { - cursor: null, - pageLength: DEFAULT_PAGE_LENGTH, -} export function useAllCommandsAsPreSerializedList( runId: string | null, @@ -25,17 +21,15 @@ export function useAllCommandsAsPreSerializedList( options: UseQueryOptions = {} ): UseQueryResult { const host = useHost() - const nullCheckedParams = params ?? DEFAULT_PARAMS const allOptions: UseQueryOptions = { ...options, enabled: host !== null && runId != null && options.enabled !== false, } - const { cursor, pageLength } = nullCheckedParams - const nullCheckedFixitCommands = params?.includeFixitCommands ?? null - const finalizedNullCheckParams = { - ...nullCheckedParams, - includeFixitCommands: nullCheckedFixitCommands, + const { cursor, pageLength, includeFixitCommands } = params ?? {} + const finalizedParams = { + ...params, + pageLength: params?.pageLength ?? DEFAULT_PAGE_LENGTH, } // map undefined values to null to agree with react query caching @@ -50,13 +44,13 @@ export function useAllCommandsAsPreSerializedList( 'getCommandsAsPreSerializedList', cursor, pageLength, - nullCheckedFixitCommands, + includeFixitCommands, ], () => { return getCommandsAsPreSerializedList( host as HostConfig, runId as string, - finalizedNullCheckParams + finalizedParams ).then(response => { const responseData = response.data return { diff --git a/react-api-client/src/runs/useAllCommandsQuery.ts b/react-api-client/src/runs/useAllCommandsQuery.ts index 427e96b554f..a1fd6047fe0 100644 --- a/react-api-client/src/runs/useAllCommandsQuery.ts +++ b/react-api-client/src/runs/useAllCommandsQuery.ts @@ -9,45 +9,30 @@ import type { } from '@opentrons/api-client' const DEFAULT_PAGE_LENGTH = 30 -export const DEFAULT_PARAMS: GetRunCommandsParamsRequest = { - cursor: null, - pageLength: DEFAULT_PAGE_LENGTH, - includeFixitCommands: null, -} export function useAllCommandsQuery( runId: string | null, - params?: GetRunCommandsParamsRequest | null, + params?: GetRunCommandsParamsRequest, options: UseQueryOptions = {} ): UseQueryResult { const host = useHost() - const nullCheckedParams = params ?? DEFAULT_PARAMS - const allOptions: UseQueryOptions = { ...options, enabled: host !== null && runId != null && options.enabled !== false, } - const { cursor, pageLength } = nullCheckedParams - const nullCheckedFixitCommands = params?.includeFixitCommands ?? null - const finalizedNullCheckParams = { - ...nullCheckedParams, - includeFixitCommands: nullCheckedFixitCommands, + + const { cursor, pageLength, includeFixitCommands } = params ?? {} + const finalizedParams = { + ...params, + pageLength: params?.pageLength ?? DEFAULT_PAGE_LENGTH, } const query = useQuery( - [ - host, - 'runs', - runId, - 'commands', - cursor, - pageLength, - finalizedNullCheckParams, - ], + [host, 'runs', runId, 'commands', cursor, pageLength, includeFixitCommands], () => { return getCommands( host as HostConfig, runId as string, - finalizedNullCheckParams + finalizedParams ).then(response => response.data) }, allOptions diff --git a/react-api-client/src/runs/useRunCommandErrors.ts b/react-api-client/src/runs/useRunCommandErrors.ts index 63dd5875636..ef536d438e0 100644 --- a/react-api-client/src/runs/useRunCommandErrors.ts +++ b/react-api-client/src/runs/useRunCommandErrors.ts @@ -9,10 +9,6 @@ import type { } from '@opentrons/api-client' const DEFAULT_PAGE_LENGTH = 30 -export const DEFAULT_PARAMS: GetCommandsParams = { - cursor: null, - pageLength: DEFAULT_PAGE_LENGTH, -} export function useRunCommandErrors( runId: string | null, @@ -20,20 +16,23 @@ export function useRunCommandErrors( options: UseQueryOptions = {} ): UseQueryResult { const host = useHost() - const nullCheckedParams = params ?? DEFAULT_PARAMS - const allOptions: UseQueryOptions = { ...options, enabled: host !== null && runId != null && options.enabled !== false, } - const { cursor, pageLength } = nullCheckedParams + + const { cursor, pageLength } = params ?? {} + const finalizedParams = { + ...params, + pageLength: params?.pageLength ?? DEFAULT_PAGE_LENGTH, + } const query = useQuery( [host, 'runs', runId, 'commandErrors', cursor, pageLength], () => { return getRunCommandErrors( host as HostConfig, runId as string, - nullCheckedParams + finalizedParams ).then(response => response.data) }, allOptions