From 97097556c7ec08d4e2fee51909b18cdcf277303d Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sun, 13 Oct 2024 16:14:43 -0500 Subject: [PATCH] ensure we get reindex progress on mount --- web/src/pages/Explore.tsx | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/web/src/pages/Explore.tsx b/web/src/pages/Explore.tsx index 4aebaefd1..e4bb49521 100644 --- a/web/src/pages/Explore.tsx +++ b/web/src/pages/Explore.tsx @@ -193,6 +193,17 @@ export default function Explore() { // embeddings reindex progress + const { send: sendReindexCommand } = useWs( + "embeddings_reindex_progress", + "embeddingsReindexProgress", + ); + + useEffect(() => { + sendReindexCommand("embeddingsReindexProgress"); + // only run on mount + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + const { payload: reindexProgress } = useEmbeddingsReindexProgress(); const embeddingsReindexing = useMemo(() => { @@ -210,10 +221,10 @@ export default function Explore() { // model states - const { send: sendCommand } = useWs("model_state", "modelState"); + const { send: sendModelCommand } = useWs("model_state", "modelState"); useEffect(() => { - sendCommand("modelState"); + sendModelCommand("modelState"); // only run on mount // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -299,14 +310,18 @@ export default function Explore() { />
- {reindexProgress.time_remaining >= 0 && ( + {reindexProgress.time_remaining !== null && (
- Estimated time remaining: + {reindexProgress.time_remaining === -1 + ? "Starting up..." + : "Estimated time remaining:"}
- {formatSecondsToDuration( - reindexProgress.time_remaining, - ) || "Finishing shortly"} + {reindexProgress.time_remaining >= 0 && + (formatSecondsToDuration( + reindexProgress.time_remaining, + ) || + "Finishing shortly")}
)}