Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/components/LiveGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export const smoothenDataPoint = (curr: number, next: number) => {
return (next / 1000) * 0.25 + curr * 0.75;
};

const LiveGraph = () => {
interface LiveGraphProps {
paused?: boolean;
}

const LiveGraph = ({ paused }: LiveGraphProps) => {
const { isConnected, status } = useConnectionStage();
const connectActions = useConnectActions();
const [{ graphColorScheme, graphLineScheme, graphLineWeight }] =
Expand Down Expand Up @@ -110,12 +114,15 @@ const LiveGraph = () => {
]);

useEffect(() => {
if (isConnected || status === ConnectionStatus.ReconnectingAutomatically) {
if (
(isConnected || status === ConnectionStatus.ReconnectingAutomatically) &&
!paused
) {
chart?.start();
} else {
chart?.stop();
}
}, [chart, isConnected, status]);
}, [chart, isConnected, paused, status]);

// Draw on graph to display that users are recording.
const isRecording = useStore((s) => s.isRecording);
Expand Down
9 changes: 8 additions & 1 deletion src/components/LiveGraphPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import AlertIcon from "./AlertIcon";
import InfoToolTip from "./InfoToolTip";
import LiveGraph from "./LiveGraph";
import PredictedAction from "./PredictedAction";
import { TrainModelDialogStage } from "../model";
import { useStore } from "../store";

interface LiveGraphPanelProps {
showPredictedAction?: boolean;
Expand All @@ -41,6 +43,11 @@ const LiveGraphPanel = ({
showDisconnectedOverlay = true,
}: LiveGraphPanelProps) => {
const { actions, status, isConnected } = useConnectionStage();
const isTraining = useStore(
(s) =>
s.trainModelDialogStage === TrainModelDialogStage.Help ||
s.trainModelDialogStage === TrainModelDialogStage.TrainingInProgress
);
const parentPortalRef = useRef(null);
const logging = useLogging();
const isReconnecting =
Expand Down Expand Up @@ -165,7 +172,7 @@ const LiveGraphPanel = ({
</HStack>
</Portal>
<HStack position="absolute" width="100%" height="100%" spacing={0}>
<LiveGraph />
<LiveGraph paused={isTraining} />
{showPredictedAction && <PredictedAction />}
</HStack>
</HStack>
Expand Down
4 changes: 3 additions & 1 deletion src/components/TrainModelFlowDialogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ const TrainModelDialogs = ({ finalFocusRef }: TrainModelDialogsProps) => {
const result = await trainModel();
if (result) {
navigate(createTestingModelPageUrl());
// Push it onto the event queue after the navigate call
setTimeout(() => closeTrainModelDialogs(), 0);
}
},
[navigate, setSettings, trainModel]
[closeTrainModelDialogs, navigate, setSettings, trainModel]
);
return (
<>
Expand Down
9 changes: 8 additions & 1 deletion src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,13 @@ const createMlStore = (logging: Logging) => {
} else {
await trainModel();
callback?.();
// Push the trainModelDialogStage change to the back of the event queue so it happens
// after navigation changes.
setTimeout(
() =>
set({ trainModelDialogStage: TrainModelDialogStage.Closed }),
0
);
}
},

Expand Down Expand Up @@ -1195,7 +1202,7 @@ const createMlStore = (logging: Logging) => {
{
model,
trainModelDialogStage: model
? TrainModelDialogStage.Closed
? TrainModelDialogStage.TrainingInProgress
: TrainModelDialogStage.TrainingError,
timestamp,
...updatedProject,
Expand Down
Loading