| import { useEffect, useRef } from 'react'; |
| import { useSetupStore } from '@/store/setup-store'; |
| import { getHttpApiClient } from '@/lib/http-api-client'; |
|
|
| |
| |
| |
| |
| |
| export function useCursorStatusInit() { |
| |
| |
| const setCursorCliStatus = useSetupStore((s) => s.setCursorCliStatus); |
| const initialized = useRef(false); |
|
|
| useEffect(() => { |
| |
| if (initialized.current) { |
| return; |
| } |
| |
| |
| const currentStatus = useSetupStore.getState().cursorCliStatus; |
| if (currentStatus !== null) { |
| initialized.current = true; |
| return; |
| } |
| initialized.current = true; |
|
|
| const initCursorStatus = async () => { |
| try { |
| const api = getHttpApiClient(); |
| const statusResult = await api.setup.getCursorStatus(); |
|
|
| if (statusResult.success) { |
| setCursorCliStatus({ |
| installed: statusResult.installed ?? false, |
| version: statusResult.version ?? undefined, |
| auth: statusResult.auth?.authenticated |
| ? { |
| authenticated: true, |
| method: statusResult.auth.method || 'unknown', |
| } |
| : undefined, |
| }); |
| } |
| } catch (error) { |
| |
| console.debug('[CursorStatusInit] Failed to check cursor status:', error); |
| } |
| }; |
|
|
| initCursorStatus(); |
| }, [setCursorCliStatus]); |
| } |
|
|