Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix(chat): refetch model props on load-state change for live context counter
Akarshan Biswasc07d84023895
diff --git a/web-app/src/hooks/useTokensCount.ts b/web-app/src/hooks/useTokensCount.tsindex d54cdf04b..bc75ed9e0 100644--- a/web-app/src/hooks/useTokensCount.ts+++ b/web-app/src/hooks/useTokensCount.ts@@ -106,6 +106,13 @@ export const useTokensCount = (messages: ThreadMessage[] = []) => {const liveStats = useAppState((s) =>threadId ? s.liveTokenStatsByThread[threadId] : undefined)+ // getModelProps only succeeds once the router has autoloaded the model, which+ // normally doesn't happen until the first turn is sent. Refetch as soon as that+ // load finishes so the counter can appear mid-turn instead of waiting for the+ // full response (and the resulting messages.length bump) to land.+ const loadingModel = useAppState((s) =>+ threadId ? s.loadingModels[threadId] : s.loadingModel+ )useEffect(() => {if (!modelId) {@@ -134,7 +141,7 @@ export const useTokensCount = (messages: ThreadMessage[] = []) => {if (id !== reqId.current) returnsetLoading(false)})- }, [modelId, messages.length])+ }, [modelId, messages.length, loadingModel])const tokenData: TokenCountData = useMemo(() => {if (selectedProvider !== 'llamacpp' || !modelId) {