Skip to content

Commit 8137b66

Browse files
fix: 修复初次登陆的校验问题
1 parent b681139 commit 8137b66

2 files changed

Lines changed: 9 additions & 94 deletions

File tree

src/components/Onboarding.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ export function Onboarding({ onDone }: Props): React.ReactNode {
148148
}
149149

150150
const steps: OnboardingStep[] = []
151-
if (oauthEnabled) {
152-
steps.push({ id: 'preflight', component: preflightStep })
153-
}
151+
// Preflight check disabled — users may use third-party API providers
152+
// if (oauthEnabled) {
153+
// steps.push({ id: 'preflight', component: preflightStep })
154+
// }
154155
steps.push({ id: 'theme', component: themeStep })
155156

156157
if (apiKeyNeedingApproval) {

src/utils/preflightChecks.tsx

Lines changed: 5 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import axios from 'axios'
21
import React, { useEffect, useState } from 'react'
3-
import { logEvent } from 'src/services/analytics/index.js'
4-
import { Spinner } from '../components/Spinner.js'
5-
import { getOauthConfig } from '../constants/oauth.js'
62
import { useTimeout } from '../hooks/useTimeout.js'
73
import { Box, Text } from '@anthropic/ink'
8-
import { getSSLErrorHint } from '../services/api/errorUtils.js'
9-
import { getUserAgent } from './http.js'
10-
import { logError } from './log.js'
4+
import { Spinner } from '../components/Spinner.js'
115

126
export interface PreflightCheckResult {
137
success: boolean
@@ -16,66 +10,9 @@ export interface PreflightCheckResult {
1610
}
1711

1812
async function checkEndpoints(): Promise<PreflightCheckResult> {
19-
try {
20-
const oauthConfig = getOauthConfig()
21-
const tokenUrl = new URL(oauthConfig.TOKEN_URL)
22-
const endpoints = [
23-
`${oauthConfig.BASE_API_URL}/api/hello`,
24-
`${tokenUrl.origin}/v1/oauth/hello`,
25-
]
26-
27-
const checkEndpoint = async (
28-
url: string,
29-
): Promise<PreflightCheckResult> => {
30-
try {
31-
const response = await axios.get(url, {
32-
headers: { 'User-Agent': getUserAgent() },
33-
})
34-
if (response.status !== 200) {
35-
const hostname = new URL(url).hostname
36-
return {
37-
success: false,
38-
error: `Failed to connect to ${hostname}: Status ${response.status}`,
39-
}
40-
}
41-
return { success: true }
42-
} catch (error) {
43-
const hostname = new URL(url).hostname
44-
const sslHint = getSSLErrorHint(error)
45-
return {
46-
success: false,
47-
error: `Failed to connect to ${hostname}: ${error instanceof Error ? (error as ErrnoException).code || error.message : String(error)}`,
48-
sslHint: sslHint ?? undefined,
49-
}
50-
}
51-
}
52-
53-
const results = await Promise.all(endpoints.map(checkEndpoint))
54-
const failedResult = results.find(result => !result.success)
55-
56-
if (failedResult) {
57-
// Log failure to Statsig
58-
logEvent('tengu_preflight_check_failed', {
59-
isConnectivityError: false,
60-
hasErrorMessage: !!failedResult.error,
61-
isSSLError: !!failedResult.sslHint,
62-
})
63-
}
64-
65-
return failedResult || { success: true }
66-
} catch (error) {
67-
logError(error as Error)
68-
69-
// Log to Statsig
70-
logEvent('tengu_preflight_check_failed', {
71-
isConnectivityError: true,
72-
})
73-
74-
return {
75-
success: false,
76-
error: `Connectivity check error: ${error instanceof Error ? (error as ErrnoException).code || error.message : String(error)}`,
77-
}
78-
}
13+
// Skip connectivity check — users may use third-party API providers
14+
// (OpenAI, Gemini, Grok, etc.) or be behind restricted networks.
15+
return { success: true }
7916
}
8017

8118
interface PreflightStepProps {
@@ -104,10 +41,8 @@ export function PreflightStep({
10441
useEffect(() => {
10542
if (result?.success) {
10643
onSuccess()
107-
} else if (result && !result.success) {
108-
const timer = setTimeout(() => process.exit(1), 100)
109-
return () => clearTimeout(timer)
11044
}
45+
// Failure branch removed — preflight check always succeeds
11146
}, [result, onSuccess])
11247

11348
return (
@@ -123,27 +58,6 @@ export function PreflightStep({
12358
<Box flexDirection="column" gap={1}>
12459
<Text color="error">Unable to connect to Anthropic services</Text>
12560
<Text color="error">{result?.error}</Text>
126-
{result?.sslHint ? (
127-
<Box flexDirection="column" gap={1}>
128-
<Text>{result.sslHint}</Text>
129-
<Text color="suggestion">
130-
See https://code.claude.com/docs/en/network-config
131-
</Text>
132-
</Box>
133-
) : (
134-
<Box flexDirection="column" gap={1}>
135-
<Text>
136-
Please check your internet connection and network settings.
137-
</Text>
138-
<Text>
139-
Note: Claude Code might not be available in your country.
140-
Check supported countries at{' '}
141-
<Text color="suggestion">
142-
https://anthropic.com/supported-countries
143-
</Text>
144-
</Text>
145-
</Box>
146-
)}
14761
</Box>
14862
)
14963
)}

0 commit comments

Comments
 (0)