From b399fb8c8e3ab37737c53d888fc5830c34a6bd64 Mon Sep 17 00:00:00 2001 From: Alex Creasy Date: Tue, 24 Oct 2023 11:36:53 +0100 Subject: [PATCH] Fixes: Bias metric chart selector shows a selected, non-existent chart when metrics are deleted by direct call to the TrustyAI API (#1533) --- frontend/src/pages/modelServing/screens/metrics/BiasTab.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/pages/modelServing/screens/metrics/BiasTab.tsx b/frontend/src/pages/modelServing/screens/metrics/BiasTab.tsx index c74810d314..9431eeeed5 100644 --- a/frontend/src/pages/modelServing/screens/metrics/BiasTab.tsx +++ b/frontend/src/pages/modelServing/screens/metrics/BiasTab.tsx @@ -36,6 +36,10 @@ const BiasTab: React.FC = () => { React.useEffect(() => { if (loaded && !loadError) { + // It's possible a biasMetricConfig was deleted by the user directly accessing a backend API. We need to verify + // that any saved state in the session storage is not stale and if it is, remove it. + setSelectedBiasConfigs(selectedBiasConfigs.filter((x) => biasMetricConfigs.includes(x))); + if (firstRender.current) { // If the user has just navigated here AND they haven't previously selected any charts to display, // don't show them the "No selected" empty state, instead show them the first available chart.