Skip to content

Commit 8c92593

Browse files
authored
fix(app): Show module setup screen on the Desktop app for the given module. (#18487)
1 parent 0b50d03 commit 8c92593

File tree

6 files changed

+31
-5
lines changed

6 files changed

+31
-5
lines changed

app/src/App/OnDeviceDisplayApp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export const OnDeviceDisplayApp = (): JSX.Element => {
206206
<FirmwareUpdateTakeover />
207207
{showModuleSetupModal && localRobot?.name != null ? (
208208
<ModuleWizardFlows
209+
showSetupLauncher={true}
209210
closeFlow={() => {
210211
setShowModuleSetupModal(false)
211212
}}

app/src/App/hooks.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { checkShellUpdate } from '/app/redux/shell'
2222
import { useNotifyDeckConfigurationQuery } from '../resources/deck_configuration'
2323
import { useAttachedPipettes } from '../resources/instruments'
2424
import { useAttachedModules } from '../resources/modules'
25+
import { useCurrentRunId } from '../resources/runs'
2526
import { SharedScrollRefContext } from './ODDProviders/ScrollRefProvider'
2627

2728
import type { AttachedModule } from '@opentrons/api-client'
@@ -32,6 +33,7 @@ const UPDATE_RECHECK_INTERVAL_MS = 60000
3233
const PROTOCOL_IDS_RECHECK_INTERVAL_MS = 3000
3334
const ATTACHED_MODULE_POLL_MS = 5000
3435
const DECK_CONFIG_POLL_MS = 5000
36+
const CURRENT_RUN_POLL = 5000
3537

3638
export function useSoftwareUpdatePoll(): void {
3739
const dispatch = useDispatch<Dispatch>()
@@ -153,17 +155,19 @@ export function useModuleAttachedToast(
153155
launchModuleSetupCallback: () => void
154156
): void {
155157
const newModules = useGetNewModules()
158+
const currentRunId = useCurrentRunId({ refetchInterval: CURRENT_RUN_POLL })
156159
const attachedPipettes = useAttachedPipettes(newModules.length > 0)
157160
const { t, i18n } = useTranslation(['module_wizard_flows', 'shared'])
158161
const { makeToast } = useToaster()
159162
const moduleSerials = newModules.map(m => m.serialNumber)
160163
const moduleSerialsRef = useRef(moduleSerials)
164+
const runInProgress = currentRunId != null
161165

162166
useEffect(() => {
163167
const newModuleSerials = difference(moduleSerials, moduleSerialsRef.current)
164168
const hasPipette =
165169
attachedPipettes.left != null || attachedPipettes.right != null
166-
if (hasPipette && newModuleSerials.length > 0) {
170+
if (!runInProgress && hasPipette && newModuleSerials.length > 0) {
167171
makeToast(t('module_added') as string, 'info', {
168172
buttonText: i18n.format(t('shared:close'), 'capitalize'),
169173
linkText: t('module_added_link'),
@@ -175,7 +179,7 @@ export function useModuleAttachedToast(
175179
moduleSerialsRef.current = moduleSerials
176180
// dont want this hook to rerun when other deps change
177181
// eslint-disable-next-line react-hooks/exhaustive-deps
178-
}, [moduleSerials])
182+
}, [moduleSerials, runInProgress])
179183
}
180184

181185
export function useScrollRef(): {

app/src/organisms/ModuleCard/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ export const ModuleCard = (props: ModuleCardProps): JSX.Element | null => {
293293
{showCalModal ? (
294294
<ModuleWizardFlows
295295
attachedModule={module}
296+
showSetupLauncher={true}
296297
closeFlow={() => {
297298
setShowCalModal(false)
298299
}}

app/src/organisms/ModuleWizardFlows/SelectModule.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ interface SelectModuleProps {
3232
isOnDevice: boolean
3333
selectedModule: AttachedModule | null
3434
setSelectedModule: (module: AttachedModule | null) => void
35+
setShowLaunchSetup: (show: boolean) => void
36+
attachedModuleOnLaunch?: AttachedModule | null
3537
}
3638

3739
interface ModuleNameAndPort {
@@ -45,10 +47,17 @@ export function SelectModule(props: SelectModuleProps): JSX.Element {
4547
isOnDevice,
4648
selectedModule,
4749
setSelectedModule,
50+
setShowLaunchSetup,
51+
attachedModuleOnLaunch = null,
4852
} = props
4953
const { t } = useTranslation('module_wizard_flows')
5054

51-
const newModules = useGetNewModules()
55+
const availableModules = useGetNewModules()
56+
const newModules =
57+
attachedModuleOnLaunch !== null
58+
? [attachedModuleOnLaunch]
59+
: availableModules
60+
5261
const isSingleModule = newModules.length === 1
5362
const sendIdentifyModule = useSendIdentifyModule()
5463
const [stackerNotInstalled, setStackerNotInstalled] = useState(false)
@@ -100,6 +109,7 @@ export function SelectModule(props: SelectModuleProps): JSX.Element {
100109
}
101110
// Proceed to module setup
102111
buildFlowForSelectedModule(module)
112+
setShowLaunchSetup(false)
103113
}
104114
}
105115

app/src/organisms/ModuleWizardFlows/Success.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ export const BODY_STYLE = css`
3434

3535
interface SuccessProps extends ModuleSetupWizardStepProps {
3636
setSelectedModule: (module: AttachedModule | null) => void
37+
attachedModuleOnLaunch?: AttachedModule | null
3738
}
3839

3940
export function Success(props: SuccessProps): JSX.Element {
4041
const {
4142
proceed,
4243
attachedModule,
44+
attachedModuleOnLaunch = null,
4345
isRobotMoving,
4446
isOnDevice,
4547
restartSetup,
@@ -69,7 +71,7 @@ export function Success(props: SuccessProps): JSX.Element {
6971
>
7072
<Flex flexDirection={DIRECTION_ROW} gridGap={SPACING.spacing8}>
7173
<>
72-
{newModules.length > 0 ? (
74+
{newModules.length > 0 && attachedModuleOnLaunch == null ? (
7375
isOnDevice ? (
7476
<SmallButton
7577
buttonType="secondary"

app/src/organisms/ModuleWizardFlows/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interface ModuleWizardFlowsProps {
3030
closeFlow: () => void
3131
robotName: string
3232
attachedModule?: AttachedModule
33+
showSetupLauncher?: boolean
3334
isLoadedInRun?: boolean
3435
onComplete?: () => void
3536
}
@@ -41,6 +42,7 @@ export function ModuleWizardFlows(
4142
attachedModule: attachedModuleOnLaunch,
4243
robotName,
4344
isLoadedInRun = false,
45+
showSetupLauncher = false,
4446
closeFlow,
4547
onComplete,
4648
} = props
@@ -70,10 +72,13 @@ export function ModuleWizardFlows(
7072
const [selectedModule, setSelectedModule] = useState<AttachedModule | null>(
7173
null
7274
)
75+
const [showLaunchSetup, setShowLaunchSetup] = useState<boolean>(
76+
showSetupLauncher
77+
)
7378
const [createdAdapterId, setCreatedAdapterId] = useState<string | null>(null)
7479

7580
if (wizardFlowBaseProps.attachedPipette == null) return null
76-
if (wizardFlowBaseProps.attachedModule == null) {
81+
if (showLaunchSetup || wizardFlowBaseProps.attachedModule == null) {
7782
return (
7883
<ModuleWizardScreen
7984
isRobotMoving={wizardFlowBaseProps.isRobotMoving}
@@ -93,6 +98,8 @@ export function ModuleWizardFlows(
9398
buildFlowForSelectedModule={buildFlowForSelectedModule}
9499
selectedModule={selectedModule}
95100
setSelectedModule={setSelectedModule}
101+
setShowLaunchSetup={setShowLaunchSetup}
102+
attachedModuleOnLaunch={attachedModuleOnLaunch}
96103
/>
97104
</ModuleWizardScreen>
98105
)
@@ -272,6 +279,7 @@ export function ModuleWizardFlows(
272279
: handleCleanUpAndClose
273280
}
274281
attachedModule={wizardFlowBaseProps.attachedModule}
282+
attachedModuleOnLaunch={attachedModuleOnLaunch}
275283
attachedPipette={wizardFlowBaseProps.attachedPipette}
276284
setSelectedModule={setSelectedModule}
277285
/>

0 commit comments

Comments
 (0)