Skip to content

Commit 94c32a7

Browse files
authored
fix(app): fix labware offset text alignment, fix historical run log missing timestamps (#11114)
Ensure that labware names are left aligned in the LabwareInfoOverlay, even if an offset is present. Ensure that historical runs which involved more than 60 LPC (or otherwise pre-play) run commands are able to correctly glean the first post play run command in the absence of a current command key. Remove unnecessary polling of the protocol record from the run detail page. Closes #11109, Closes #11108
1 parent ea09265 commit 94c32a7

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

app/src/organisms/Devices/ProtocolRun/LabwareInfoOverlay.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Icon,
1818
DIRECTION_ROW,
1919
ALIGN_FLEX_START,
20+
JUSTIFY_SPACE_BETWEEN,
2021
} from '@opentrons/components'
2122
import { StyledText } from '../../../atoms/text'
2223

@@ -56,7 +57,7 @@ const LabwareInfo = (props: LabwareInfoProps): JSX.Element | null => {
5657
>
5758
<Flex
5859
flexDirection={DIRECTION_ROW}
59-
justifyContent={JUSTIFY_FLEX_END}
60+
justifyContent={JUSTIFY_SPACE_BETWEEN}
6061
alignItems={ALIGN_FLEX_START}
6162
gridGap={SPACING.spacing2}
6263
>

app/src/organisms/Devices/ProtocolRun/RunLog.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export function RunLog({ robotName, runId }: RunLogProps): JSX.Element | null {
7878
const listInnerRef = React.useRef<HTMLDivElement>(null)
7979
const currentItemRef = React.useRef<HTMLDivElement>(null)
8080
const firstPostInitialPlayRunCommandIndex = React.useRef<number | null>(null)
81+
const lastKnownPrePlayRunCommandIndex = React.useRef<number>(-1)
8182
const [isDeterministic, setIsDeterministic] = React.useState<boolean>(true)
8283
const [windowIndex, setWindowIndex] = React.useState<number>(0)
8384
const [
@@ -90,7 +91,8 @@ export function RunLog({ robotName, runId }: RunLogProps): JSX.Element | null {
9091
const prePlayCommandCount =
9192
firstPostInitialPlayRunCommandIndex.current != null
9293
? firstPostInitialPlayRunCommandIndex.current
93-
: 0
94+
: lastKnownPrePlayRunCommandIndex.current + 1
95+
9496
const isCurrentRun =
9597
useRunQuery(runId, { staleTime: Infinity }).data?.data.current ?? false
9698
const { data: commandsData } = useAllCommandsQuery(
@@ -141,6 +143,32 @@ export function RunLog({ robotName, runId }: RunLogProps): JSX.Element | null {
141143
)
142144

143145
const runStartDateTime = runStartTime != null ? new Date(runStartTime) : null
146+
React.useEffect(() => {
147+
// if viewing an historical run log, because there is no current command
148+
// we may get stuck with no run commands as the default first window may
149+
// contain only "pre-play" commands (e.g. more LPC commands than the window size)
150+
// in this case, we'll walk the pointer to the first "post-play" command
151+
if (
152+
(runStatus === RUN_STATUS_FAILED ||
153+
runStatus === RUN_STATUS_STOPPED ||
154+
runStatus === RUN_STATUS_SUCCEEDED) &&
155+
runStartDateTime != null &&
156+
firstPostInitialPlayRunCommandIndex.current === null
157+
) {
158+
const foundPostPlayRunCommandIndex = runCommands.findIndex(
159+
command => new Date(command?.createdAt) > runStartDateTime
160+
)
161+
if (foundPostPlayRunCommandIndex >= 0) {
162+
firstPostInitialPlayRunCommandIndex.current =
163+
lastKnownPrePlayRunCommandIndex.current +
164+
foundPostPlayRunCommandIndex +
165+
1
166+
} else {
167+
lastKnownPrePlayRunCommandIndex.current =
168+
lastKnownPrePlayRunCommandIndex.current + runCommands.length
169+
}
170+
}
171+
}, [runId, runStatus, runCommands, runStartDateTime])
144172
const postInitialPlayRunCommands =
145173
runStartDateTime != null
146174
? dropWhile(
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react'
21
import { useProtocolQuery } from '@opentrons/react-api-client'
32
import { useCurrentRun } from './useCurrentRun'
43

@@ -7,12 +6,9 @@ import type { Protocol } from '@opentrons/api-client'
76
export function useCurrentProtocol(): Protocol | null {
87
const currentProtocolId = useCurrentRun()?.data?.protocolId ?? null
98

10-
const enableProtocolPolling = React.useRef<boolean>(true)
11-
const { data: protocolRecord } = useProtocolQuery(
12-
currentProtocolId,
13-
{ staleTime: Infinity },
14-
enableProtocolPolling.current
15-
)
9+
const { data: protocolRecord } = useProtocolQuery(currentProtocolId, {
10+
staleTime: Infinity,
11+
})
1612

1713
return protocolRecord ?? null
1814
}

0 commit comments

Comments
 (0)