From e553b3945439c4ada96711d8a34af69872a3c1df Mon Sep 17 00:00:00 2001 From: SuperComboGamer Date: Wed, 10 Dec 2025 23:14:23 -0500 Subject: [PATCH] fix --- app/electron/services/codex-cli-detector.js | 11 ------- .../settings-view/hooks/use-cli-status.ts | 16 ++++----- app/src/components/views/setup-view.tsx | 15 ++++----- app/src/lib/electron.ts | 33 ++++--------------- 4 files changed, 21 insertions(+), 54 deletions(-) diff --git a/app/electron/services/codex-cli-detector.js b/app/electron/services/codex-cli-detector.js index d100fd10..42a47d0e 100644 --- a/app/electron/services/codex-cli-detector.js +++ b/app/electron/services/codex-cli-detector.js @@ -168,17 +168,6 @@ class CodexCliDetector { }; } - // If auth file exists, assume authenticated - if (fs.existsSync(authPath)) { - return { - authenticated: true, - method: 'auth_file', - hasAuthFile: true, - hasEnvKey: !!envApiKey, - authPath - }; - } - return { authenticated: false, method: 'none', diff --git a/app/src/components/views/settings-view/hooks/use-cli-status.ts b/app/src/components/views/settings-view/hooks/use-cli-status.ts index 0a9e2652..1fae138b 100644 --- a/app/src/components/views/settings-view/hooks/use-cli-status.ts +++ b/app/src/components/views/settings-view/hooks/use-cli-status.ts @@ -69,17 +69,15 @@ export function useCliStatus() { const result = await api.setup.getClaudeStatus(); if (result.success && result.auth) { const auth = result.auth; - // Map the method directly from detector - const methodMap: Record = { - oauth_token_env: "oauth_token_env", - oauth_token: "oauth_token", - api_key: "api_key", - api_key_env: "api_key_env", - none: "none", - }; + // Validate method is one of the expected values, default to "none" + const validMethods = ["oauth_token_env", "oauth_token", "api_key", "api_key_env", "none"] as const; + type AuthMethod = typeof validMethods[number]; + const method: AuthMethod = validMethods.includes(auth.method as AuthMethod) + ? (auth.method as AuthMethod) + : "none"; const authStatus = { authenticated: auth.authenticated, - method: methodMap[auth.method] || "none", + method, hasCredentialsFile: auth.hasCredentialsFile ?? false, oauthTokenValid: auth.hasStoredOAuthToken || auth.hasEnvOAuthToken, apiKeyValid: auth.hasStoredApiKey || auth.hasEnvApiKey, diff --git a/app/src/components/views/setup-view.tsx b/app/src/components/views/setup-view.tsx index 67bf4f7e..53bec8a1 100644 --- a/app/src/components/views/setup-view.tsx +++ b/app/src/components/views/setup-view.tsx @@ -233,16 +233,15 @@ function ClaudeSetupStep({ setClaudeCliStatus(cliStatus); if (result.auth) { - const methodMap: Record = { - oauth_token_env: "oauth_token_env", - oauth_token: "oauth_token", - api_key: "api_key", - api_key_env: "api_key_env", - none: "none", - }; + // Validate method is one of the expected values, default to "none" + const validMethods = ["oauth_token_env", "oauth_token", "api_key", "api_key_env", "none"] as const; + type AuthMethod = typeof validMethods[number]; + const method: AuthMethod = validMethods.includes(result.auth.method as AuthMethod) + ? (result.auth.method as AuthMethod) + : "none"; const authStatus = { authenticated: result.auth.authenticated, - method: methodMap[result.auth.method] || "none", + method, hasCredentialsFile: false, oauthTokenValid: result.auth.hasStoredOAuthToken || result.auth.hasEnvOAuthToken, apiKeyValid: result.auth.hasStoredApiKey || result.auth.hasEnvApiKey, diff --git a/app/src/lib/electron.ts b/app/src/lib/electron.ts index 9c18b921..f330a346 100644 --- a/app/src/lib/electron.ts +++ b/app/src/lib/electron.ts @@ -41,21 +41,7 @@ export interface StatResult { error?: string; } -// Auto Mode types - Import from electron.d.ts for internal use -import type { - AutoModeEvent as AutoModeEventType, - ModelDefinition as ModelDefinitionType, - ProviderStatus as ProviderStatusType, - WorktreeAPI as WorktreeAPIType, - GitAPI as GitAPIType, - WorktreeInfo as WorktreeInfoType, - WorktreeStatus as WorktreeStatusType, - FileDiffsResult as FileDiffsResultType, - FileDiffResult as FileDiffResultType, - FileStatus as FileStatusType, -} from "@/types/electron"; - -// Re-export types for external use +// Re-export types from electron.d.ts for external use export type { AutoModeEvent, ModelDefinition, @@ -69,17 +55,12 @@ export type { FileStatus, } from "@/types/electron"; -// Type aliases for internal use -type AutoModeEvent = AutoModeEventType; -type ModelDefinition = ModelDefinitionType; -type ProviderStatus = ProviderStatusType; -type WorktreeAPI = WorktreeAPIType; -type GitAPI = GitAPIType; -type WorktreeInfo = WorktreeInfoType; -type WorktreeStatus = WorktreeStatusType; -type FileDiffsResult = FileDiffsResultType; -type FileDiffResult = FileDiffResultType; -type FileStatus = FileStatusType; +// Import types for internal use in this file +import type { + AutoModeEvent, + WorktreeAPI, + GitAPI, +} from "@/types/electron"; // Feature type - Import from app-store import type { Feature } from "@/store/app-store";