Skip to content

Commit

Permalink
fix(app): update legacy run type (#15965)
Browse files Browse the repository at this point in the history
This PR fixes an error where a whitescreen occurs when opening device
details for a robot with robot server <7.3. Move `runTimeParameters`
property from `LegacyGoodRunData` to `KnownGoodRunData` since robot
server does not return RTP for server versions <7.3. Check for
`runTimeParameters` property explicitly when needed.
  • Loading branch information
ncdiehl11 authored Aug 12, 2024
1 parent 0cb4832 commit 1201666
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api-client/src/runs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export interface LegacyGoodRunData {
modules: LoadedModule[]
protocolId?: string
labwareOffsets?: LabwareOffset[]
runTimeParameters: RunTimeParameter[]
}

export interface KnownGoodRunData extends LegacyGoodRunData {
ok: true
runTimeParameters: RunTimeParameter[]
}

export interface KnownInvalidRunData extends LegacyGoodRunData {
Expand Down
9 changes: 6 additions & 3 deletions app/src/organisms/Devices/HistoricalProtocolRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ export function HistoricalProtocolRun(
const { t } = useTranslation('run_details')
const { run, protocolName, robotIsBusy, robotName, protocolKey } = props
const [drawerOpen, setDrawerOpen] = React.useState(false)
const countRunDataFiles = run.runTimeParameters.filter(
parameter => parameter.type === 'csv_file'
).length
const countRunDataFiles =
'runTimeParameters' in run
? run?.runTimeParameters.filter(
parameter => parameter.type === 'csv_file'
).length
: 0
const runStatus = run.status
const runDisplayName = formatTimestamp(run.createdAt)
let duration = EMPTY_TIMESTAMP
Expand Down
20 changes: 11 additions & 9 deletions app/src/organisms/Devices/HistoricalProtocolRunDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ export function HistoricalProtocolRunDrawer(
const allLabwareOffsets = run.labwareOffsets?.sort(
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
)
const runDataFileIds = run.runTimeParameters.reduce<string[]>(
(acc, parameter) => {
if (parameter.type === 'csv_file') {
return parameter.file?.id != null ? [...acc, parameter.file?.id] : acc
}
return acc
},
[]
)
const runDataFileIds =
'runTimeParameters' in run
? run.runTimeParameters.reduce<string[]>((acc, parameter) => {
if (parameter.type === 'csv_file') {
return parameter.file?.id != null
? [...acc, parameter.file?.id]
: acc
}
return acc
}, [])
: []
const uniqueLabwareOffsets = allLabwareOffsets?.filter(
(offset, index, array) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ export function ProtocolRunRuntimeParameters({
// because the most recent analysis may not reflect the selected run (e.g. cloning a run
// from a historical protocol run from the device details page)
const run = useNotifyRunQuery(runId).data
const runTimeParameters =
(isRunTerminal
const runTimeParametersFromRun =
run?.data != null && 'runTimeParameters' in run?.data
? run?.data?.runTimeParameters
: mostRecentAnalysis?.runTimeParameters) ?? []
: []
const runTimeParametersFromAnalysis =
mostRecentAnalysis?.runTimeParameters ?? []
const runTimeParameters = isRunTerminal
? runTimeParametersFromRun
: runTimeParametersFromAnalysis
const hasRunTimeParameters = runTimeParameters.length > 0
const hasCustomRunTimeParameterValues = runTimeParameters.some(parameter =>
parameter.type !== 'csv_file' ? parameter.value !== parameter.default : true
Expand Down
6 changes: 5 additions & 1 deletion app/src/organisms/ProtocolUpload/hooks/useCloneRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export function useCloneRun(
)
const cloneRun = (): void => {
if (runRecord != null) {
const { protocolId, labwareOffsets, runTimeParameters } = runRecord.data
const { protocolId, labwareOffsets } = runRecord.data
const runTimeParameters =
'runTimeParameters' in runRecord.data
? runRecord.data.runTimeParameters
: []
const runTimeParameterValues = getRunTimeParameterValuesForRun(
runTimeParameters
)
Expand Down

0 comments on commit 1201666

Please sign in to comment.