mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-10 04:00:24 +00:00
fix: install when the task is running (#480)
This commit is contained in:
commit
c2dc0d2f8a
1 changed files with 24 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect } from 'react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useInstallationStore } from '@/store/installationStore';
|
||||
import { useAuthStore } from '@/store/authStore';
|
||||
|
||||
|
|
@ -8,15 +8,25 @@ import { useAuthStore } from '@/store/authStore';
|
|||
*/
|
||||
export const useInstallationSetup = () => {
|
||||
const { initState, setInitState } = useAuthStore();
|
||||
|
||||
|
||||
// Use ref to track if initial check is done to prevent repeated checks
|
||||
const hasCheckedOnMount = useRef(false);
|
||||
|
||||
// Extract only the functions we need to avoid dependency issues
|
||||
const startInstallation = useInstallationStore(state => state.startInstallation);
|
||||
const addLog = useInstallationStore(state => state.addLog);
|
||||
const setSuccess = useInstallationStore(state => state.setSuccess);
|
||||
const setError = useInstallationStore(state => state.setError);
|
||||
|
||||
// Check tool installation status on mount
|
||||
// Check tool installation status on mount - but only during setup phase
|
||||
useEffect(() => {
|
||||
// Only run this check once on initial mount
|
||||
if (hasCheckedOnMount.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
hasCheckedOnMount.current = true;
|
||||
|
||||
const checkToolInstalled = async () => {
|
||||
try {
|
||||
console.log('[useInstallationSetup] Checking tool installation status...');
|
||||
|
|
@ -24,16 +34,15 @@ export const useInstallationSetup = () => {
|
|||
|
||||
console.log('[useInstallationSetup] Tool check result:', result, 'initState:', initState);
|
||||
|
||||
// If tools are NOT installed and we're in done state, go back to carousel
|
||||
if (result.success && initState === "done" && !result.isInstalled) {
|
||||
console.log('[useInstallationSetup] Tool not installed, setting initState to carousel');
|
||||
setInitState("carousel");
|
||||
}
|
||||
|
||||
// If tools ARE installed and we're in carousel state, go to done
|
||||
if (result.success && initState === "carousel" && result.isInstalled) {
|
||||
console.log('[useInstallationSetup] Tools installed but initState is carousel, setting to done');
|
||||
setInitState("done");
|
||||
// Only perform tool check during setup phase (permissions or carousel)
|
||||
// Once user is in 'done' state (main app), don't check again
|
||||
// This prevents unexpected navigation away from the main app
|
||||
if (initState !== 'done') {
|
||||
// If tools ARE installed and we're in carousel state, go to done
|
||||
if (result.success && initState === "carousel" && result.isInstalled) {
|
||||
console.log('[useInstallationSetup] Tools installed but initState is carousel, setting to done');
|
||||
setInitState("done");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[useInstallationSetup] Tool installation check failed:", error);
|
||||
|
|
@ -57,7 +66,8 @@ export const useInstallationSetup = () => {
|
|||
|
||||
checkToolInstalled();
|
||||
checkBackendStatus();
|
||||
}, [initState, setInitState, startInstallation]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// Setup Electron IPC listeners (only once)
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue