mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-14 00:00:49 +00:00
Revert "fix: login (#739)"
This reverts commite0f867d26e, reversing changes made toe3c61a958b.
This commit is contained in:
parent
e0f867d26e
commit
692cc64d15
5 changed files with 7 additions and 68 deletions
|
|
@ -69,7 +69,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||
checkInstallBrowser: () => ipcRenderer.invoke('check-install-browser'),
|
||||
getInstallationStatus: () => ipcRenderer.invoke('get-installation-status'),
|
||||
restartBackend: () => ipcRenderer.invoke('restart-backend'),
|
||||
getBackendPort: () => ipcRenderer.invoke('get-backend-port'),
|
||||
onInstallDependenciesStart: (callback: () => void) => {
|
||||
ipcRenderer.on('install-dependencies-start', callback);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,12 +7,11 @@ import { useAuthStore } from '@/store/authStore';
|
|||
* This should be called once in your App component or Layout component
|
||||
*/
|
||||
export const useInstallationSetup = () => {
|
||||
const { initState, setInitState, email } = useAuthStore();
|
||||
const { initState, setInitState } = useAuthStore();
|
||||
|
||||
const hasCheckedOnMount = useRef(false);
|
||||
const installationCompleted = useRef(false);
|
||||
const backendReady = useRef(false);
|
||||
const previousEmail = useRef<string | null>(null);
|
||||
const startInstallation = useInstallationStore(state => state.startInstallation);
|
||||
const performInstallation = useInstallationStore(state => state.performInstallation);
|
||||
const addLog = useInstallationStore(state => state.addLog);
|
||||
|
|
@ -21,59 +20,6 @@ export const useInstallationSetup = () => {
|
|||
const setBackendError = useInstallationStore(state => state.setBackendError);
|
||||
const setWaitingBackend = useInstallationStore(state => state.setWaitingBackend);
|
||||
|
||||
// Monitor email changes to detect account switching
|
||||
useEffect(() => {
|
||||
// Detect new login: email changed from null/different to a new value
|
||||
if (previousEmail.current !== email && email !== null) {
|
||||
console.log('[useInstallationSetup] Account switch detected:', previousEmail.current, '->', email);
|
||||
|
||||
// For account switching, tools are already installed, only backend needs restart
|
||||
// So we mark installation as completed and only wait for backend
|
||||
installationCompleted.current = true;
|
||||
backendReady.current = false;
|
||||
|
||||
// Set to waiting-backend state since backend is restarting
|
||||
if (initState === 'carousel') {
|
||||
console.log('[useInstallationSetup] New account login detected, waiting for backend restart');
|
||||
setWaitingBackend();
|
||||
|
||||
// Poll backend status every 2 seconds to ensure we catch when it's ready
|
||||
// This is a fallback in case the backend-ready event is missed
|
||||
const pollInterval = setInterval(async () => {
|
||||
try {
|
||||
const backendPort = await window.electronAPI.getBackendPort();
|
||||
if (backendPort && backendPort > 0) {
|
||||
console.log('[useInstallationSetup] Backend poll detected ready on port:', backendPort);
|
||||
|
||||
// Verify backend is actually responding
|
||||
const response = await fetch(`http://localhost:${backendPort}/health`).catch(() => null);
|
||||
if (response && response.ok) {
|
||||
console.log('[useInstallationSetup] Backend health check passed');
|
||||
clearInterval(pollInterval);
|
||||
|
||||
if (!backendReady.current) {
|
||||
backendReady.current = true;
|
||||
setSuccess();
|
||||
setInitState('done');
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('[useInstallationSetup] Backend poll check failed:', error);
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
// Clear polling after 30 seconds to prevent infinite polling
|
||||
setTimeout(() => {
|
||||
clearInterval(pollInterval);
|
||||
}, 30000);
|
||||
}
|
||||
}
|
||||
|
||||
// Update previous email
|
||||
previousEmail.current = email;
|
||||
}, [email, initState, setWaitingBackend, setSuccess, setInitState]);
|
||||
|
||||
useEffect(() => {
|
||||
if (hasCheckedOnMount.current) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import light from "@/assets/light.png";
|
|||
import dark from "@/assets/dark.png";
|
||||
import transparent from "@/assets/transparent.png";
|
||||
import { useAuthStore } from "@/store/authStore";
|
||||
import { useInstallationStore } from "@/store/installationStore";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { proxyFetchPut, proxyFetchGet } from "@/api/http";
|
||||
import { createRef, RefObject } from "react";
|
||||
|
|
@ -30,7 +29,6 @@ import useChatStoreAdapter from "@/hooks/useChatStoreAdapter";
|
|||
export default function SettingGeneral() {
|
||||
const { t } = useTranslation();
|
||||
const authStore = useAuthStore();
|
||||
const resetInstallation = useInstallationStore(state => state.reset);
|
||||
const navigate = useNavigate();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const setAppearance = authStore.setAppearance;
|
||||
|
|
@ -161,7 +159,6 @@ export default function SettingGeneral() {
|
|||
size="xs"
|
||||
onClick={() => {
|
||||
chatStore.clearTasks();
|
||||
resetInstallation(); // Reset installation state for new account
|
||||
authStore.logout();
|
||||
navigate("/login");
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -80,8 +80,7 @@ const authStore = create<AuthState>()(
|
|||
token: null,
|
||||
username: null,
|
||||
email: null,
|
||||
user_id: null,
|
||||
initState: 'carousel' // Reset to carousel state to wait for backend restart
|
||||
user_id: null
|
||||
}),
|
||||
|
||||
// set related methods
|
||||
|
|
|
|||
12
src/types/electron.d.ts
vendored
12
src/types/electron.d.ts
vendored
|
|
@ -56,16 +56,14 @@ interface ElectronAPI {
|
|||
error?: string
|
||||
}>;
|
||||
restartBackend: () => Promise<{ success: boolean; error?: string }>;
|
||||
getBackendPort: () => Promise<number>;
|
||||
onInstallDependenciesStart: (callback: () => void) => void;
|
||||
onInstallDependenciesLog: (callback: (data: { type: string; data: string }) => void) => void;
|
||||
onInstallDependenciesComplete: (callback: (data: { success: boolean; code?: number; error?: string }) => void) => void;
|
||||
onBackendReady: (callback: (data: { success: boolean; port?: number; error?: string }) => void) => void;
|
||||
onUpdateNotification: (callback: (data: {
|
||||
type: string;
|
||||
currentVersion: string;
|
||||
previousVersion: string;
|
||||
reason: string;
|
||||
onUpdateNotification: (callback: (data: {
|
||||
type: string;
|
||||
currentVersion: string;
|
||||
previousVersion: string;
|
||||
reason: string;
|
||||
}) => void) => void;
|
||||
removeAllListeners: (channel: string) => void;
|
||||
getEmailFolderPath: (email: string) => Promise<{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue