Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
chore: update state check openclaw running
Faisal Amir7bfad7b92de5
diff --git a/web-app/src/components/left-sidebar/NavMain.tsx b/web-app/src/components/left-sidebar/NavMain.tsxindex da3cb216f..7786d5c24 100644--- a/web-app/src/components/left-sidebar/NavMain.tsx+++ b/web-app/src/components/left-sidebar/NavMain.tsx@@ -11,7 +11,7 @@ import { useTranslation } from '@/i18n/react-i18next-compat'import { Link, useNavigate } from '@tanstack/react-router'import { PlatformMetaKey } from '@/containers/PlatformMetaKey'-import React, { useRef, useEffect, useState } from 'react'+import React, { useRef } from 'react'import {SearchIcon,type SearchIconHandle,@@ -40,7 +40,7 @@ import { useSearchDialog } from '@/hooks/useSearchDialog'import { useProjectDialog } from '@/hooks/useProjectDialog'import { useAgentMode } from '@/hooks/useAgentMode'import { TEMPORARY_CHAT_ID } from '@/constants/chat'-import { isOpenClawRunning } from '@/utils/openclaw'+import { useAppState } from '@/hooks/useAppState'type AnimatedIconHandle =| SearchIconHandle@@ -175,11 +175,7 @@ export function NavMain() {const { open: searchOpen, setOpen: setSearchOpen } = useSearchDialog()const { open: projectDialogOpen, setOpen: setProjectDialogOpen } =useProjectDialog()- const [openClawAvailable, setOpenClawAvailable] = useState(false)-- useEffect(() => {- isOpenClawRunning().then(setOpenClawAvailable)- }, [])+ const openClawAvailable = useAppState((state) => state.openClawRunning)const navMainItems = getNavMainItems(() => setProjectDialogOpen(true),diff --git a/web-app/src/hooks/useAppState.ts b/web-app/src/hooks/useAppState.tsindex bf9d758f4..d39d21831 100644--- a/web-app/src/hooks/useAppState.ts+++ b/web-app/src/hooks/useAppState.ts@@ -22,6 +22,7 @@ type AppState = {ragToolNames: Set<string>mcpToolNames: Set<string>serverStatus: 'running' | 'stopped' | 'pending'+ openClawRunning: booleanabortControllers: Record<string, AbortController>tokenSpeed?: TokenSpeedshowOutOfContextDialog?: boolean@@ -30,6 +31,7 @@ type AppState = {activeModels: string[]cancelToolCall?: () => voidsetServerStatus: (value: 'running' | 'stopped' | 'pending') => void+ setOpenClawRunning: (running: boolean) => voidupdateStreamingContent: (content: ThreadMessage | undefined) => voidupdateLoadingModel: (loading: boolean) => voidupdateTools: (tools: MCPTool[]) => void@@ -58,6 +60,7 @@ export const useAppState = create<AppState>()((set) => ({ragToolNames: new Set<string>(),mcpToolNames: new Set<string>(),serverStatus: 'stopped',+ openClawRunning: false,abortControllers: {},tokenSpeed: undefined,currentToolCall: undefined,@@ -87,6 +90,7 @@ export const useAppState = create<AppState>()((set) => ({set({ mcpToolNames: new Set(names) })},setServerStatus: (value) => set({ serverStatus: value }),+ setOpenClawRunning: (running) => set({ openClawRunning: running }),setAbortController: (threadId, controller) => {set((state) => ({abortControllers: {diff --git a/web-app/src/utils/openclaw.ts b/web-app/src/utils/openclaw.tsindex 23afe8ee2..531734c20 100644--- a/web-app/src/utils/openclaw.ts+++ b/web-app/src/utils/openclaw.ts@@ -1,5 +1,6 @@import { invoke } from '@tauri-apps/api/core'import { useAgentMode } from '@/hooks/useAgentMode'+import { useAppState } from '@/hooks/useAppState'/** OpenClaw gateway base URL for the OpenAI-compatible HTTP API. */export const OPENCLAW_GATEWAY_URL = 'http://127.0.0.1:18789/v1'@@ -32,6 +33,8 @@ export function setOpenClawRunningState(isRunning: boolean): void {openClawRunningCache = isRunninglastCheckTime = Date.now()+ useAppState.getState().setOpenClawRunning(isRunning)+// When OpenClaw is stopped, clear agent mode for all threads so the UI revertsif (!isRunning) {useAgentMode.getState().clearAll()