fix: resolve frozen terminal for OpenAI/3P provider users (#3)

The showSetupScreens() early return for CLAUDE_CODE_USE_OPENAI skipped
all trust state initialization (setSessionTrustAccepted, GrowthBook,
getSystemContext), causing downstream config lookups to fail silently.
This prevented the REPL component tree from mounting correctly —
useInput never fired, stdin stayed in cooked mode, and the terminal
appeared frozen.

Fix: skip only the UI dialogs (onboarding, trust, MCP approval) for
OpenAI provider while still running the critical state initialization
that the REPL depends on.

Closes #3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
gnanam1990
2026-04-01 12:17:31 +05:30
parent 752c71c30b
commit d1267393a9

View File

@@ -103,13 +103,16 @@ export async function renderAndRun(root: Root, element: React.ReactNode): Promis
} }
export async function showSetupScreens(root: Root, permissionMode: PermissionMode, allowDangerouslySkipPermissions: boolean, commands?: Command[], claudeInChrome?: boolean, devChannels?: ChannelEntry[]): Promise<boolean> { export async function showSetupScreens(root: Root, permissionMode: PermissionMode, allowDangerouslySkipPermissions: boolean, commands?: Command[], claudeInChrome?: boolean, devChannels?: ChannelEntry[]): Promise<boolean> {
if ("production" === 'test' || isEnvTruthy(false) || process.env.IS_DEMO // Skip onboarding in demo mode if ("production" === 'test' || isEnvTruthy(false) || process.env.IS_DEMO // Skip onboarding in demo mode
|| isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI) // Skip onboarding for OpenAI provider
) { ) {
return false; return false;
} }
const isOpenAIProvider = isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI);
const config = getGlobalConfig(); const config = getGlobalConfig();
let onboardingShown = false; let onboardingShown = false;
if (!config.theme || !config.hasCompletedOnboarding // always show onboarding at least once
// Skip onboarding dialog for OpenAI provider (no Anthropic account needed)
if (!isOpenAIProvider && (!config.theme || !config.hasCompletedOnboarding) // always show onboarding at least once
) { ) {
onboardingShown = true; onboardingShown = true;
const { const {
@@ -130,10 +133,9 @@ export async function showSetupScreens(root: Root, permissionMode: PermissionMod
// Note: non-interactive sessions (CI/CD with -p) never reach showSetupScreens at all. // Note: non-interactive sessions (CI/CD with -p) never reach showSetupScreens at all.
// Skip permission checks in claubbit // Skip permission checks in claubbit
if (!isEnvTruthy(process.env.CLAUBBIT)) { if (!isEnvTruthy(process.env.CLAUBBIT)) {
// Fast-path: skip TrustDialog import+render when CWD is already trusted. // Skip trust dialog UI for OpenAI provider (no Anthropic auth), but still
// If it returns true, the TrustDialog would auto-resolve regardless of // run trust state initialization below so the REPL mounts correctly.
// security features, so we can skip the dynamic import and render cycle. if (!isOpenAIProvider && !checkHasTrustDialogAccepted()) {
if (!checkHasTrustDialogAccepted()) {
const { const {
TrustDialog TrustDialog
} = await import('./components/TrustDialog/TrustDialog.js'); } = await import('./components/TrustDialog/TrustDialog.js');
@@ -142,6 +144,8 @@ export async function showSetupScreens(root: Root, permissionMode: PermissionMod
// Signal that trust has been verified for this session. // Signal that trust has been verified for this session.
// GrowthBook checks this to decide whether to include auth headers. // GrowthBook checks this to decide whether to include auth headers.
// Critical for OpenAI provider: without this, downstream config lookups
// may fail silently, preventing the REPL from mounting (frozen terminal).
setSessionTrustAccepted(true); setSessionTrustAccepted(true);
// Reset and reinitialize GrowthBook after trust is established. // Reset and reinitialize GrowthBook after trust is established.
@@ -153,6 +157,8 @@ export async function showSetupScreens(root: Root, permissionMode: PermissionMod
// Now that trust is established, prefetch system context if it wasn't already // Now that trust is established, prefetch system context if it wasn't already
void getSystemContext(); void getSystemContext();
// Skip MCP approval dialogs for OpenAI provider (no interactive auth prompts)
if (!isOpenAIProvider) {
// If settings are valid, check for any mcp.json servers that need approval // If settings are valid, check for any mcp.json servers that need approval
const { const {
errors: allErrors errors: allErrors
@@ -170,6 +176,7 @@ export async function showSetupScreens(root: Root, permissionMode: PermissionMod
await showSetupDialog(root, done => <ClaudeMdExternalIncludesDialog onDone={done} isStandaloneDialog externalIncludes={externalIncludes} />); await showSetupDialog(root, done => <ClaudeMdExternalIncludesDialog onDone={done} isStandaloneDialog externalIncludes={externalIncludes} />);
} }
} }
}
// Track current repo path for teleport directory switching (fire-and-forget) // Track current repo path for teleport directory switching (fire-and-forget)
// This must happen AFTER trust to prevent untrusted directories from poisoning the mapping // This must happen AFTER trust to prevent untrusted directories from poisoning the mapping