From ae5dd80d67cc9335d622c89162ac6d677d6fd4e3 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Mon, 19 Jun 2023 05:06:52 -0700 Subject: [PATCH] Allow user to reset ui debugger after fatal error Summary: Previously there was no way to get of this state Reviewed By: aigoncharov Differential Revision: D46803900 fbshipit-source-id: 2eb0eb41b58064659ef1d2cff245a2b8d7e2f261 --- .../components/StreamInterceptorErrorView.tsx | 19 ++++--------------- .../public/ui-debugger/components/main.tsx | 17 +++++++++++++---- desktop/plugins/public/ui-debugger/index.tsx | 11 ++++++++++- desktop/plugins/public/ui-debugger/types.tsx | 4 +++- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/desktop/plugins/public/ui-debugger/components/StreamInterceptorErrorView.tsx b/desktop/plugins/public/ui-debugger/components/StreamInterceptorErrorView.tsx index d8ea47e88..0d2c66609 100644 --- a/desktop/plugins/public/ui-debugger/components/StreamInterceptorErrorView.tsx +++ b/desktop/plugins/public/ui-debugger/components/StreamInterceptorErrorView.tsx @@ -7,30 +7,19 @@ * @format */ -import {Button, Result} from 'antd'; +import {Result} from 'antd'; import * as React from 'react'; export function StreamInterceptorErrorView({ - retryCallback, + button, title, message, }: { title: string; message: string; - retryCallback?: () => void; + button: React.ReactNode; }): React.ReactElement { return ( - - Retry - - ) - } - /> + ); } diff --git a/desktop/plugins/public/ui-debugger/components/main.tsx b/desktop/plugins/public/ui-debugger/components/main.tsx index 821918215..bd9f9e4bc 100644 --- a/desktop/plugins/public/ui-debugger/components/main.tsx +++ b/desktop/plugins/public/ui-debugger/components/main.tsx @@ -50,11 +50,16 @@ export function Component() { setBottomPanelComponent(undefined); }; - if (streamState.state === 'UnrecoverableError') { + if (streamState.state === 'FatalError') { return ( + Reset + + } /> ); } @@ -64,7 +69,11 @@ export function Component() { + Retry + + } /> ); } diff --git a/desktop/plugins/public/ui-debugger/index.tsx b/desktop/plugins/public/ui-debugger/index.tsx index 6caa88d7a..9e4a9cf5b 100644 --- a/desktop/plugins/public/ui-debugger/index.tsx +++ b/desktop/plugins/public/ui-debugger/index.tsx @@ -136,7 +136,16 @@ export function plugin(client: PluginClient) { error, ); - uiState.streamState.set({state: 'UnrecoverableError'}); + uiState.streamState.set({ + state: 'FatalError', + error: error, + clearCallBack: async () => { + uiState.streamState.set({state: 'Ok'}); + nodesAtom.set(new Map()); + frameworkEvents.set(new Map()); + snapshot.set(null); + }, + }); } } diff --git a/desktop/plugins/public/ui-debugger/types.tsx b/desktop/plugins/public/ui-debugger/types.tsx index 7a02b670f..1e2dcf09a 100644 --- a/desktop/plugins/public/ui-debugger/types.tsx +++ b/desktop/plugins/public/ui-debugger/types.tsx @@ -16,7 +16,9 @@ export type StreamState = retryCallback: () => Promise; } | { - state: 'UnrecoverableError'; + state: 'FatalError'; + error: Error; + clearCallBack: () => Promise; }; export type Events = {