From 0a428394757cd918efbff6ff8cc78054c76d85d2 Mon Sep 17 00:00:00 2001 From: Rithul Kamesh Date: Thu, 2 Apr 2026 15:38:54 +0530 Subject: [PATCH] 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 --- scripts/system-check.ts | 7 +++++++ src/commands/onboard-github/onboard-github.tsx | 15 ++++++++++++--- src/services/api/providerConfig.ts | 3 ++- src/services/github/deviceFlow.ts | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/system-check.ts b/scripts/system-check.ts index 6626149a..34990b04 100644 --- a/scripts/system-check.ts +++ b/scripts/system-check.ts @@ -447,6 +447,13 @@ async function main(): Promise { const options = parseOptions(process.argv.slice(2)) 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(checkBunRuntime()) results.push(checkBuildArtifacts()) diff --git a/src/commands/onboard-github/onboard-github.tsx b/src/commands/onboard-github/onboard-github.tsx index 26088392..66326957 100644 --- a/src/commands/onboard-github/onboard-github.tsx +++ b/src/commands/onboard-github/onboard-github.tsx @@ -29,6 +29,11 @@ function mergeUserSettingsEnv(model: string): { ok: boolean; detail?: string } { env: { CLAUDE_CODE_USE_GITHUB: '1', 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) { @@ -49,6 +54,7 @@ function OnboardGithub(props: { verification_uri: string } | null>(null) const [patDraft, setPatDraft] = useState('') + const [cursorOffset, setCursorOffset] = useState(0) const finalize = useCallback( async (token: string, model: string = DEFAULT_MODEL) => { @@ -117,7 +123,7 @@ function OnboardGithub(props: { {errorMsg} { + onChange={(v: string) => { if (v === 'cancel') { onDone('GitHub onboard cancelled', { display: 'system' }) return diff --git a/src/services/api/providerConfig.ts b/src/services/api/providerConfig.ts index bbbc2cb9..90643aa1 100644 --- a/src/services/api/providerConfig.ts +++ b/src/services/api/providerConfig.ts @@ -194,11 +194,12 @@ export function resolveProviderRequest(options?: { baseUrl?: string fallbackModel?: string }): ResolvedProviderRequest { + const isGithubMode = isEnvTruthy(process.env.CLAUDE_CODE_USE_GITHUB) const requestedModel = options?.model?.trim() || process.env.OPENAI_MODEL?.trim() || options?.fallbackModel?.trim() || - 'gpt-4o' + (isGithubMode ? 'github:copilot' : 'gpt-4o') const descriptor = parseModelDescriptor(requestedModel) const rawBaseUrl = options?.baseUrl ?? diff --git a/src/services/github/deviceFlow.ts b/src/services/github/deviceFlow.ts index 0e207b7f..379d757e 100644 --- a/src/services/github/deviceFlow.ts +++ b/src/services/github/deviceFlow.ts @@ -11,7 +11,7 @@ export const GITHUB_DEVICE_ACCESS_TOKEN_URL = 'https://github.com/login/oauth/access_token' /** 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 { constructor(message: string) {