fix(github): address PR feedback for onboarding flow

- Set competing provider flags to undefined in updateSettingsForSource to ensure clean GitHub boot
- Fix resolveProviderRequest to default to github:copilot when OPENAI_MODEL is unset
- Hydrate secure tokens and managed settings in system-check.ts to prevent false negatives
- Add models:read scope to GitHub device flow
This commit is contained in:
Rithul Kamesh
2026-04-02 15:38:54 +05:30
parent f07f11b7b6
commit 0a42839475
4 changed files with 22 additions and 5 deletions

View File

@@ -447,6 +447,13 @@ async function main(): Promise<void> {
const options = parseOptions(process.argv.slice(2)) const options = parseOptions(process.argv.slice(2))
const results: CheckResult[] = [] const results: CheckResult[] = []
const { enableConfigs } = await import('../src/utils/config.js')
enableConfigs()
const { applySafeConfigEnvironmentVariables } = await import('../src/utils/managedEnv.js')
applySafeConfigEnvironmentVariables()
const { hydrateGithubModelsTokenFromSecureStorage } = await import('../src/utils/githubModelsCredentials.js')
hydrateGithubModelsTokenFromSecureStorage()
results.push(checkNodeVersion()) results.push(checkNodeVersion())
results.push(checkBunRuntime()) results.push(checkBunRuntime())
results.push(checkBuildArtifacts()) results.push(checkBuildArtifacts())

View File

@@ -29,6 +29,11 @@ function mergeUserSettingsEnv(model: string): { ok: boolean; detail?: string } {
env: { env: {
CLAUDE_CODE_USE_GITHUB: '1', CLAUDE_CODE_USE_GITHUB: '1',
OPENAI_MODEL: model, OPENAI_MODEL: model,
CLAUDE_CODE_USE_OPENAI: undefined as any,
CLAUDE_CODE_USE_GEMINI: undefined as any,
CLAUDE_CODE_USE_BEDROCK: undefined as any,
CLAUDE_CODE_USE_VERTEX: undefined as any,
CLAUDE_CODE_USE_FOUNDRY: undefined as any,
}, },
}) })
if (error) { if (error) {
@@ -49,6 +54,7 @@ function OnboardGithub(props: {
verification_uri: string verification_uri: string
} | null>(null) } | null>(null)
const [patDraft, setPatDraft] = useState('') const [patDraft, setPatDraft] = useState('')
const [cursorOffset, setCursorOffset] = useState(0)
const finalize = useCallback( const finalize = useCallback(
async (token: string, model: string = DEFAULT_MODEL) => { async (token: string, model: string = DEFAULT_MODEL) => {
@@ -117,7 +123,7 @@ function OnboardGithub(props: {
<Text color="red">{errorMsg}</Text> <Text color="red">{errorMsg}</Text>
<Select <Select
options={options} options={options}
onChange={v => { onChange={(v: string) => {
if (v === 'back') { if (v === 'back') {
setStep('menu') setStep('menu')
setErrorMsg(null) setErrorMsg(null)
@@ -161,7 +167,7 @@ function OnboardGithub(props: {
value={patDraft} value={patDraft}
mask="*" mask="*"
onChange={setPatDraft} onChange={setPatDraft}
onSubmit={async value => { onSubmit={async (value: string) => {
const t = value.trim() const t = value.trim()
if (!t) { if (!t) {
return return
@@ -172,6 +178,9 @@ function OnboardGithub(props: {
setStep('menu') setStep('menu')
setPatDraft('') setPatDraft('')
}} }}
columns={80}
cursorOffset={cursorOffset}
onChangeCursorOffset={setCursorOffset}
/> />
</Box> </Box>
) )
@@ -202,7 +211,7 @@ function OnboardGithub(props: {
</Text> </Text>
<Select <Select
options={menuOptions} options={menuOptions}
onChange={v => { onChange={(v: string) => {
if (v === 'cancel') { if (v === 'cancel') {
onDone('GitHub onboard cancelled', { display: 'system' }) onDone('GitHub onboard cancelled', { display: 'system' })
return return

View File

@@ -194,11 +194,12 @@ export function resolveProviderRequest(options?: {
baseUrl?: string baseUrl?: string
fallbackModel?: string fallbackModel?: string
}): ResolvedProviderRequest { }): ResolvedProviderRequest {
const isGithubMode = isEnvTruthy(process.env.CLAUDE_CODE_USE_GITHUB)
const requestedModel = const requestedModel =
options?.model?.trim() || options?.model?.trim() ||
process.env.OPENAI_MODEL?.trim() || process.env.OPENAI_MODEL?.trim() ||
options?.fallbackModel?.trim() || options?.fallbackModel?.trim() ||
'gpt-4o' (isGithubMode ? 'github:copilot' : 'gpt-4o')
const descriptor = parseModelDescriptor(requestedModel) const descriptor = parseModelDescriptor(requestedModel)
const rawBaseUrl = const rawBaseUrl =
options?.baseUrl ?? options?.baseUrl ??

View File

@@ -11,7 +11,7 @@ export const GITHUB_DEVICE_ACCESS_TOKEN_URL =
'https://github.com/login/oauth/access_token' 'https://github.com/login/oauth/access_token'
/** Match runtime devsper github_oauth DEFAULT_SCOPE */ /** Match runtime devsper github_oauth DEFAULT_SCOPE */
export const DEFAULT_GITHUB_DEVICE_SCOPE = 'read:user' export const DEFAULT_GITHUB_DEVICE_SCOPE = 'read:user,models:read'
export class GitHubDeviceFlowError extends Error { export class GitHubDeviceFlowError extends Error {
constructor(message: string) { constructor(message: string) {