From 841914696a8469dc2f2ec5c4983e1cd85cea4079 Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Sat, 17 Jan 2026 11:37:53 -0800 Subject: [PATCH] fix: show correct auth type immediately on startup (#576) Co-authored-by: Letta --- src/cli/components/WelcomeScreen.tsx | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/cli/components/WelcomeScreen.tsx b/src/cli/components/WelcomeScreen.tsx index 4d88de0..9a96cd7 100644 --- a/src/cli/components/WelcomeScreen.tsx +++ b/src/cli/components/WelcomeScreen.tsx @@ -23,7 +23,17 @@ function toTildePath(absolutePath: string): string { } /** - * Determine the auth method used + * Synchronously determine auth method from env vars (for initial render). + * Returns null if we need to check keychain/settings asynchronously. + */ +function getInitialAuthMethod(): "url" | "api-key" | null { + if (process.env.LETTA_BASE_URL) return "url"; + if (process.env.LETTA_API_KEY) return "api-key"; + return null; // Need async check for keychain/settings +} + +/** + * Determine the auth method used (async for keychain access) */ async function getAuthMethod(): Promise<"url" | "api-key" | "oauth"> { // Check if custom URL is being used @@ -84,14 +94,18 @@ export function WelcomeScreen({ ? (getModelDisplayName(fullModel) ?? fullModel.split("/").pop()) : undefined; - // Get auth method + // Get auth method - use sync check for env vars, async only for keychain + const initialAuth = getInitialAuthMethod(); const [authMethod, setAuthMethod] = useState<"url" | "api-key" | "oauth">( - "oauth", + initialAuth ?? "oauth", ); useEffect(() => { - getAuthMethod().then(setAuthMethod); - }, []); + // Only run async check if env vars didn't determine auth method + if (!initialAuth) { + getAuthMethod().then(setAuthMethod); + } + }, [initialAuth]); const authDisplay = authMethod === "url" ? process.env.LETTA_BASE_URL || "Custom URL"