mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 21:03:08 +00:00
fix: infinite loop when checking cli status
This commit is contained in:
@@ -65,22 +65,40 @@ export function ClaudeSetupStep({
|
|||||||
const [apiKey, setApiKey] = useState("");
|
const [apiKey, setApiKey] = useState("");
|
||||||
const [showTokenModal, setShowTokenModal] = useState(false);
|
const [showTokenModal, setShowTokenModal] = useState(false);
|
||||||
|
|
||||||
|
// Memoize API functions to prevent infinite loops
|
||||||
|
const statusApi = useCallback(
|
||||||
|
() => getElectronAPI().setup?.getClaudeStatus() || Promise.reject(),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const installApi = useCallback(
|
||||||
|
() => getElectronAPI().setup?.installClaude() || Promise.reject(),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const getStoreState = useCallback(
|
||||||
|
() => useSetupStore.getState().claudeCliStatus,
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
// Use custom hooks
|
// Use custom hooks
|
||||||
const { isChecking, checkStatus } = useCliStatus({
|
const { isChecking, checkStatus } = useCliStatus({
|
||||||
cliType: "claude",
|
cliType: "claude",
|
||||||
statusApi: () =>
|
statusApi,
|
||||||
getElectronAPI().setup?.getClaudeStatus() || Promise.reject(),
|
|
||||||
setCliStatus: setClaudeCliStatus,
|
setCliStatus: setClaudeCliStatus,
|
||||||
setAuthStatus: setClaudeAuthStatus,
|
setAuthStatus: setClaudeAuthStatus,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onInstallSuccess = useCallback(() => {
|
||||||
|
checkStatus();
|
||||||
|
}, [checkStatus]);
|
||||||
|
|
||||||
const { isInstalling, installProgress, install } = useCliInstallation({
|
const { isInstalling, installProgress, install } = useCliInstallation({
|
||||||
cliType: "claude",
|
cliType: "claude",
|
||||||
installApi: () =>
|
installApi,
|
||||||
getElectronAPI().setup?.installClaude() || Promise.reject(),
|
|
||||||
onProgressEvent: getElectronAPI().setup?.onInstallProgress,
|
onProgressEvent: getElectronAPI().setup?.onInstallProgress,
|
||||||
onSuccess: checkStatus,
|
onSuccess: onInstallSuccess,
|
||||||
getStoreState: () => useSetupStore.getState().claudeCliStatus,
|
getStoreState,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { isSaving: isSavingOAuth, saveToken: saveOAuthToken } = useTokenSave({
|
const { isSaving: isSavingOAuth, saveToken: saveOAuthToken } = useTokenSave({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect, useCallback } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
@@ -58,21 +58,34 @@ export function CodexSetupStep({
|
|||||||
const [showApiKeyInput, setShowApiKeyInput] = useState(false);
|
const [showApiKeyInput, setShowApiKeyInput] = useState(false);
|
||||||
const [apiKey, setApiKey] = useState("");
|
const [apiKey, setApiKey] = useState("");
|
||||||
|
|
||||||
|
// Memoize API functions to prevent infinite loops
|
||||||
|
const statusApi = useCallback(
|
||||||
|
() => getElectronAPI().setup?.getCodexStatus() || Promise.reject(),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const installApi = useCallback(
|
||||||
|
() => getElectronAPI().setup?.installCodex() || Promise.reject(),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
// Use custom hooks
|
// Use custom hooks
|
||||||
const { isChecking, checkStatus } = useCliStatus({
|
const { isChecking, checkStatus } = useCliStatus({
|
||||||
cliType: "codex",
|
cliType: "codex",
|
||||||
statusApi: () =>
|
statusApi,
|
||||||
getElectronAPI().setup?.getCodexStatus() || Promise.reject(),
|
|
||||||
setCliStatus: setCodexCliStatus,
|
setCliStatus: setCodexCliStatus,
|
||||||
setAuthStatus: setCodexAuthStatus,
|
setAuthStatus: setCodexAuthStatus,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onInstallSuccess = useCallback(() => {
|
||||||
|
checkStatus();
|
||||||
|
}, [checkStatus]);
|
||||||
|
|
||||||
const { isInstalling, installProgress, install } = useCliInstallation({
|
const { isInstalling, installProgress, install } = useCliInstallation({
|
||||||
cliType: "codex",
|
cliType: "codex",
|
||||||
installApi: () =>
|
installApi,
|
||||||
getElectronAPI().setup?.installCodex() || Promise.reject(),
|
|
||||||
onProgressEvent: getElectronAPI().setup?.onInstallProgress,
|
onProgressEvent: getElectronAPI().setup?.onInstallProgress,
|
||||||
onSuccess: checkStatus,
|
onSuccess: onInstallSuccess,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { isSaving: isSavingKey, saveToken: saveApiKeyToken } = useTokenSave({
|
const { isSaving: isSavingKey, saveToken: saveApiKeyToken } = useTokenSave({
|
||||||
|
|||||||
Reference in New Issue
Block a user