Skip to content

Commit

Permalink
feat(app): visualize the step timeline and deck state of a protocol
Browse files Browse the repository at this point in the history
Create an experimental tool, behind a feature flag, that allows users to inspect the timeline of
atomic commands and the resulting deck state of the robot at ever frame of the timeline.
  • Loading branch information
b-cooper committed Jun 21, 2024
1 parent 0344070 commit 0604088
Show file tree
Hide file tree
Showing 13 changed files with 34,455 additions and 35,680 deletions.
40 changes: 21 additions & 19 deletions app-shell/src/protocol-editor-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import path from 'path'

import { getConfig } from './config'
import { createLogger } from './log'
import { PROTOCOLS_DIRECTORY_PATH, analyzeProtocolByKey, getProtocolSourceJSON, overwriteProtocol } from './protocol-storage/file-system'
import {
PROTOCOLS_DIRECTORY_PATH,
analyzeProtocolByKey,
getProtocolSourceJSON,
overwriteProtocol,
} from './protocol-storage/file-system'

const protocolEditorUiConfig = getConfig('protocolEditorUi')
const log = createLogger('protocolEditorUi')
Expand All @@ -30,7 +35,6 @@ const WINDOW_OPTS = {
),
}


const protocolEditorPath =
protocolEditorUiConfig.url.protocol === 'file:'
? path.join(app.getAppPath(), protocolEditorUiConfig.url.path)

Check failure on line 40 in app-shell/src/protocol-editor-ui.ts

View workflow job for this annotation

GitHub Actions / js checks

Unsafe argument of type `any` assigned to a parameter of type `string`

Check failure on line 40 in app-shell/src/protocol-editor-ui.ts

View workflow job for this annotation

GitHub Actions / js checks

Unsafe argument of type `any` assigned to a parameter of type `string`
Expand All @@ -39,13 +43,10 @@ const protocolEditorPath =
export function createProtocolEditorUi(srcFilePath: string): BrowserWindow {
log.debug('Creating protocol editor window', { options: WINDOW_OPTS })

const subWindow = new BrowserWindow(WINDOW_OPTS).once(
'ready-to-show',
() => {
log.debug('Protocol Editor window ready to show')
subWindow.show()
}
)
const subWindow = new BrowserWindow(WINDOW_OPTS).once('ready-to-show', () => {
log.debug('Protocol Editor window ready to show')
subWindow.show()
})
const protocolEditorUrl = `${protocolEditorUiConfig.url.protocol}//${protocolEditorPath}`

log.info(`Loading ${protocolEditorUrl}`)
Expand All @@ -65,17 +66,18 @@ export function createProtocolEditorUi(srcFilePath: string): BrowserWindow {
const protocolSourceJSON = getProtocolSourceJSON(srcFilePath)
protocolSourceJSON.then(json => {
subWindow.webContents.send('open-protocol-in-designer', json)
ipcMain.once('save-protocol-file-to-filesystem', (_event, fileName, fileData) => {
overwriteProtocol(srcFilePath, fileName, fileData).then(() => {
const { protocolKey } = /.*\/(?<protocolKey>.*)\/src.*/.exec(srcFilePath)?.groups ?? {}
return analyzeProtocolByKey(
protocolKey,
PROTOCOLS_DIRECTORY_PATH
)
})
})
ipcMain.once(
'save-protocol-file-to-filesystem',
(_event, fileName, fileData) => {
overwriteProtocol(srcFilePath, fileName, fileData).then(() => {
const { protocolKey } =
/.*\/(?<protocolKey>.*)\/src.*/.exec(srcFilePath)?.groups ?? {}
return analyzeProtocolByKey(protocolKey, PROTOCOLS_DIRECTORY_PATH)
})
}
)
})
});
})

return subWindow
}
2 changes: 1 addition & 1 deletion app/src/App/DesktopApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { ProtocolTimeline } from '../pages/Protocols/ProtocolDetails/ProtocolTim
import { PortalRoot as ModalPortalRoot } from './portal'
import { DesktopAppFallback } from './DesktopAppFallback'

import type { RouteProps, DesktopRouteParams } from './types'
import type { RouteProps, DesktopRouteParams } from './types'

export const DesktopApp = (): JSX.Element => {
useSoftwareUpdatePoll()
Expand Down
5 changes: 4 additions & 1 deletion app/src/molecules/Command/utils/getCommandTextData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import type {
import type { CommandTextData } from '../types'

export function getCommandTextData(
protocolData: CompletedProtocolAnalysis | LegacyGoodRunData | ProtocolAnalysisOutput,
protocolData:
| CompletedProtocolAnalysis
| LegacyGoodRunData
| ProtocolAnalysisOutput,
protocolCommands?: RunTimeCommand[]
): CommandTextData {
const { pipettes, labware, modules, liquids } = protocolData
Expand Down
Loading

0 comments on commit 0604088

Please sign in to comment.