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

feat(app): acknowledge animation when Flex receives a new protocol #13474

Merged
merged 3 commits into from
Sep 6, 2023
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
14 changes: 14 additions & 0 deletions app/src/App/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
useAllRunsQuery,
useHost,
useRunQuery,
useCreateLiveCommandMutation,
} from '@opentrons/react-api-client'
import {
getProtocol,
Expand All @@ -21,6 +22,7 @@ import {
} from '@opentrons/api-client'
import { checkShellUpdate } from '../redux/shell'
import { useToaster } from '../organisms/ToasterOven'
import type { SetStatusBarCreateCommand } from '@opentrons/shared-data/protocol/types/schemaV7/command/incidental'

import type { Dispatch } from '../redux/types'

Expand Down Expand Up @@ -50,6 +52,11 @@ export function useProtocolReceiptToast(): void {
const protocolIds = protocolIdsQuery.data?.data ?? []
const protocolIdsRef = React.useRef(protocolIds)
const hasRefetched = React.useRef(true)
const { createLiveCommand } = useCreateLiveCommandMutation()
const animationCommand: SetStatusBarCreateCommand = {
commandType: 'setStatusBar',
params: { animation: 'confirm' },
}

if (protocolIdsQuery.isRefetching) {
hasRefetched.current = false
Expand Down Expand Up @@ -98,6 +105,13 @@ export function useProtocolReceiptToast(): void {
console.error(`error invalidating protocols query: ${e.message}`)
)
})
.then(() => {
createLiveCommand({
command: animationCommand,
}).catch((e: Error) =>
console.warn(`cannot run status bar animation: ${e.message}`)
)
})
.catch((e: Error) => {
console.error(e)
})
Expand Down
9 changes: 9 additions & 0 deletions shared-data/js/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,12 @@ export interface GripperDefinition {
jawWidth: { min: number; max: number }
}
}

export type StatusBarAnimation =
| 'idle'
| 'confirm'
| 'updating'
| 'disco'
| 'off'

export type StatusBarAnimations = StatusBarAnimation[]
21 changes: 21 additions & 0 deletions shared-data/protocol/types/schemaV7/command/incidental.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { CommonCommandRunTimeInfo, CommonCommandCreateInfo } from '.'
import type { StatusBarAnimation } from '../../../../js/types'

export type IncidentalCreateCommand = SetStatusBarCreateCommand

export type IncidentalRunTimeCommand = SetStatusBarRunTimeCommand

export interface SetStatusBarCreateCommand extends CommonCommandCreateInfo {
commandType: 'setStatusBar'
params: SetStatusBarParams
}

export interface SetStatusBarRunTimeCommand
extends CommonCommandRunTimeInfo,
SetStatusBarCreateCommand {
result?: any
}

interface SetStatusBarParams {
animation: StatusBarAnimation
}
6 changes: 6 additions & 0 deletions shared-data/protocol/types/schemaV7/command/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import type { GantryRunTimeCommand, GantryCreateCommand } from './gantry'
import type { ModuleRunTimeCommand, ModuleCreateCommand } from './module'
import type { SetupRunTimeCommand, SetupCreateCommand } from './setup'
import type { TimingRunTimeCommand, TimingCreateCommand } from './timing'
import type {
IncidentalCreateCommand,
IncidentalRunTimeCommand,
} from './incidental'
import type {
AnnotationRunTimeCommand,
AnnotationCreateCommand,
Expand Down Expand Up @@ -51,6 +55,7 @@ export type CreateCommand =
| TimingCreateCommand // effecting the timing of command execution
| CalibrationCreateCommand // for automatic pipette calibration
| AnnotationCreateCommand // annotating command execution
| IncidentalCreateCommand // command with only incidental effects (status bar animations)

// commands will be required to have a key, but will not be created with one
export type RunTimeCommand =
Expand All @@ -61,6 +66,7 @@ export type RunTimeCommand =
| TimingRunTimeCommand // effecting the timing of command execution
| CalibrationRunTimeCommand // for automatic pipette calibration
| AnnotationRunTimeCommand // annotating command execution
| IncidentalRunTimeCommand // command with only incidental effects (status bar animations)

interface RunCommandError {
id: string
Expand Down