From f95b1148d9e930144b8c211f45bd5f5046850a29 Mon Sep 17 00:00:00 2001 From: Pim Hutting Date: Tue, 13 Jan 2026 00:53:41 +0100 Subject: [PATCH] chore: made last page access more sensible still didnt work with CB ref: N25B-400 --- src/pages/MonitoringPage/MonitoringPage.tsx | 23 ++++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/pages/MonitoringPage/MonitoringPage.tsx b/src/pages/MonitoringPage/MonitoringPage.tsx index 059fa06..8b3ccb9 100644 --- a/src/pages/MonitoringPage/MonitoringPage.tsx +++ b/src/pages/MonitoringPage/MonitoringPage.tsx @@ -24,17 +24,24 @@ const MonitoringPage: React.FC = () => { const [phaseIndex, setPhaseIndex] = React.useState(0); - const isFinished = phaseIndex >= phaseIds.length; //determines if experiment is over - + //see if we reached end node + const [isFinished, setIsFinished] = React.useState(false); + const handleStreamUpdate = React.useCallback((data: any) => { // Check for phase updates if (data.type === 'phase_update' && data.phase_id) { - const allIds = getPhaseIds(); - const newIndex = allIds.indexOf(data.phase_id); - if (newIndex !== -1) { - setPhaseIndex(newIndex); - setGoalIndex(0); //when phase change we reset the index - } + if (data.phase_id === "end") { + setIsFinished(true); + } else { + setIsFinished(false); + + const allIds = getPhaseIds(); + const newIndex = allIds.indexOf(data.phase_id); + if (newIndex !== -1) { + setPhaseIndex(newIndex); + setGoalIndex(0); + } + } } else if (data.type === 'goal_update') { const currentPhaseGoals = getGoalsInPhase(phaseIds[phaseIndex]) as any[];