Skip to content

Commit dff6347

Browse files
authored
fix(app): fix auto transitioning run from recovery-paused to waiting recovery (#16259)
Closes EXEC-702 In #16245, we made sure to block an open door while on the recovery splash view, but the logic for automatically transition a run from paused -> awaiting recovery is not quite right, which results in the app seemingly automatically issuing a POST play to transition a run from a recovery paused state to awaiting recovery whenever a user opens the door during error recovery flows (ie, anywhere but the splash screen). The tricky part is that when checking the network tab, there are no POST requests to initiate the transition. This problem occurs because another app issues the POST request. The logic for dispatching this POST in the useEffect condition within RecoverySplash is to check if the error recovery wizard is active, but this doesn't account for any other app that isn't doing the recovery. The solution: if the current app displays the takeover modal (which is true for any app except the sole app controlling the robot), then don't fire the POST request.
1 parent cf27f54 commit dff6347

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

app/src/organisms/ErrorRecoveryFlows/RecoverySplash.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ export function useRecoverySplash(
6262
type RecoverySplashProps = ErrorRecoveryFlowsProps &
6363
ERUtilsResults & {
6464
isOnDevice: boolean
65-
isWizardActive: boolean
6665
failedCommand: ReturnType<typeof useRetainedFailedCommandBySource>
6766
robotType: RobotType
6867
robotName: string
68+
/* Whether the app should resume any paused recovery state without user action. */
69+
resumePausedRecovery: boolean
6970
toggleERWizAsActiveUser: UseRecoveryTakeoverResult['toggleERWizAsActiveUser']
7071
analytics: UseRecoveryAnalyticsResult
7172
}
@@ -79,7 +80,7 @@ export function RecoverySplash(props: RecoverySplashProps): JSX.Element | null {
7980
robotName,
8081
runStatus,
8182
recoveryActionMutationUtils,
82-
isWizardActive,
83+
resumePausedRecovery,
8384
} = props
8485
const { t } = useTranslation('error_recovery')
8586
const errorKind = getErrorKind(failedCommand?.byRunRecord ?? null)
@@ -99,12 +100,15 @@ export function RecoverySplash(props: RecoverySplashProps): JSX.Element | null {
99100

100101
// Resume recovery when the run when the door is closed.
101102
// The CTA/flow for handling a door open event within the ER wizard is different, and because this splash always renders
102-
// behind the wizard, we want to ensure we only implicitly resume recovery when only viewing the splash.
103+
// behind the wizard, we want to ensure we only implicitly resume recovery when only viewing the splash from this app.
103104
React.useEffect(() => {
104-
if (runStatus === RUN_STATUS_AWAITING_RECOVERY_PAUSED && !isWizardActive) {
105+
if (
106+
runStatus === RUN_STATUS_AWAITING_RECOVERY_PAUSED &&
107+
resumePausedRecovery
108+
) {
105109
recoveryActionMutationUtils.resumeRecovery()
106110
}
107-
}, [runStatus, isWizardActive])
111+
}, [runStatus, resumePausedRecovery])
108112
const buildDoorOpenAlert = (): void => {
109113
makeToast(t('close_door_to_resume') as string, WARNING_TOAST)
110114
}

app/src/organisms/ErrorRecoveryFlows/__tests__/RecoverySplash.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('RecoverySplash', () => {
9595
recoveryActionMutationUtils: {
9696
resumeRecovery: mockResumeRecovery,
9797
} as any,
98-
isWizardActive: false,
98+
resumePausedRecovery: true,
9999
}
100100

101101
vi.mocked(StepInfo).mockReturnValue(<div>MOCK STEP INFO</div>)
@@ -177,7 +177,7 @@ describe('RecoverySplash', () => {
177177
expect(mockMakeToast).toHaveBeenCalled()
178178
})
179179

180-
it(`should transition the run status from ${RUN_STATUS_AWAITING_RECOVERY_PAUSED} to ${RUN_STATUS_AWAITING_RECOVERY}`, () => {
180+
it(`should transition the run status from ${RUN_STATUS_AWAITING_RECOVERY_PAUSED} to ${RUN_STATUS_AWAITING_RECOVERY} when resumePausedRecovery is true`, () => {
181181
props = { ...props, runStatus: RUN_STATUS_AWAITING_RECOVERY_PAUSED }
182182

183183
render(props)

app/src/organisms/ErrorRecoveryFlows/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ export function ErrorRecoveryFlows(
147147
failedCommand: failedCommandBySource,
148148
})
149149

150+
console.log('=>(index.tsx:180) showTakeover', showTakeover)
151+
150152
return (
151153
<>
152154
{showTakeover ? (
@@ -176,7 +178,7 @@ export function ErrorRecoveryFlows(
176178
isOnDevice={isOnDevice}
177179
toggleERWizAsActiveUser={toggleERWizAsActiveUser}
178180
failedCommand={failedCommandBySource}
179-
isWizardActive={renderWizard}
181+
resumePausedRecovery={!renderWizard && !showTakeover}
180182
/>
181183
) : null}
182184
</>

0 commit comments

Comments
 (0)