Skip to content

Commit 55acbaf

Browse files
committed
Disable claude oauth
1 parent 5fce596 commit 55acbaf

File tree

9 files changed

+60
-18
lines changed

9 files changed

+60
-18
lines changed

cli/src/chat.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { useReviewStore } from './state/review-store'
5353
import { useFeedbackStore } from './state/feedback-store'
5454
import { useMessageBlockStore } from './state/message-block-store'
5555
import { usePublishStore } from './state/publish-store'
56+
import { CLAUDE_OAUTH_ENABLED } from '@codebuff/common/constants/claude-oauth'
5657
import { reportActivity } from './utils/activity-tracker'
5758
import { trackEvent } from './utils/analytics'
5859
import { getClaudeOAuthStatus } from './utils/claude-oauth'
@@ -1292,7 +1293,7 @@ export const Chat = ({
12921293
})
12931294
const hasStatusIndicatorContent = statusIndicatorState.kind !== 'idle'
12941295

1295-
const isClaudeOAuthActive = getClaudeOAuthStatus().connected
1296+
const isClaudeOAuthActive = CLAUDE_OAUTH_ENABLED && getClaudeOAuthStatus().connected
12961297

12971298
// Fetch Claude quota when OAuth is active
12981299
const { data: claudeQuota } = useClaudeQuotaQuery({

cli/src/commands/command-registry.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CLAUDE_OAUTH_ENABLED } from '@codebuff/common/constants/claude-oauth'
12
import open from 'open'
23

34
import { handleAdsEnable, handleAdsDisable } from './ads'
@@ -474,6 +475,17 @@ export const COMMAND_REGISTRY: CommandDefinition[] = [
474475
name: 'connect:claude',
475476
aliases: ['claude'],
476477
handler: (params) => {
478+
if (!CLAUDE_OAUTH_ENABLED) {
479+
params.setMessages((prev) => [
480+
...prev,
481+
getUserMessage(params.inputValue.trim()),
482+
getSystemMessage(
483+
'Claude OAuth connection has been disabled. Use /subscribe for usage across all models.',
484+
),
485+
])
486+
clearInput(params)
487+
return
488+
}
477489
// Enter connect:claude mode to show the OAuth banner
478490
useChatStore.getState().setInputMode('connect:claude')
479491
params.saveToHistory(params.inputValue.trim())

cli/src/commands/router.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AnalyticsEvent } from '@codebuff/common/constants/analytics-events'
2+
import { CLAUDE_OAUTH_ENABLED } from '@codebuff/common/constants/claude-oauth'
23
import { runTerminalCommand } from '@codebuff/sdk'
34

45

@@ -341,6 +342,10 @@ export async function routeUserPrompt(
341342

342343
// Handle connect:claude mode input (authorization code)
343344
if (inputMode === 'connect:claude') {
345+
if (!CLAUDE_OAUTH_ENABLED) {
346+
setInputMode('default')
347+
return
348+
}
344349
const code = trimmed
345350
if (code) {
346351
const result = await handleClaudeAuthCode(code)

cli/src/components/input-mode-banner.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CLAUDE_OAUTH_ENABLED } from '@codebuff/common/constants/claude-oauth'
12
import React from 'react'
23

34
import { ClaudeConnectBanner } from './claude-connect-banner'
@@ -26,7 +27,10 @@ const BANNER_REGISTRY: Record<
2627
usage: ({ showTime }) => <UsageBanner showTime={showTime} />,
2728
referral: () => <ReferralBanner />,
2829
help: () => <HelpBanner />,
29-
'connect:claude': () => <ClaudeConnectBanner />,
30+
...(CLAUDE_OAUTH_ENABLED
31+
? { 'connect:claude': () => <ClaudeConnectBanner /> }
32+
: {}),
33+
3034
subscriptionLimit: () => <SubscriptionLimitBanner />,
3135
}
3236

cli/src/components/usage-banner.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CLAUDE_OAUTH_ENABLED } from '@codebuff/common/constants/claude-oauth'
12
import { isClaudeOAuthValid } from '@codebuff/sdk'
23
import { TextAttributes } from '@opentui/core'
34
import open from 'open'
@@ -47,8 +48,8 @@ export const UsageBanner = ({ showTime }: { showTime: number }) => {
4748
const sessionCreditsUsed = useChatStore((state) => state.sessionCreditsUsed)
4849
const setInputMode = useChatStore((state) => state.setInputMode)
4950

50-
// Check if Claude OAuth is connected
51-
const isClaudeConnected = isClaudeOAuthValid()
51+
// Check if Claude OAuth is connected (only when feature is enabled)
52+
const isClaudeConnected = CLAUDE_OAUTH_ENABLED && isClaudeOAuthValid()
5253

5354
// Fetch Claude quota data if connected
5455
const { data: claudeQuota, isLoading: isClaudeLoading } = useClaudeQuotaQuery({

cli/src/data/slash-commands.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CLAUDE_OAUTH_ENABLED } from '@codebuff/common/constants/claude-oauth'
12
import { AGENT_MODES } from '../utils/constants'
23
import { CREDITS_REFERRAL_BONUS } from '@codebuff/common/old-constants'
34

@@ -36,12 +37,17 @@ export const SLASH_COMMANDS: SlashCommand[] = [
3637
aliases: ['h', '?'],
3738
implicitCommand: true,
3839
},
39-
{
40-
id: 'connect:claude',
41-
label: 'connect:claude (deprecated)',
42-
description: 'Claude subscription will be removed March 1st',
43-
aliases: ['claude'],
44-
},
40+
...(CLAUDE_OAUTH_ENABLED
41+
? [
42+
{
43+
id: 'connect:claude',
44+
label: 'connect:claude (deprecated)',
45+
description: 'Claude subscription will be removed March 1st',
46+
aliases: ['claude'],
47+
},
48+
]
49+
: []),
50+
4551
{
4652
id: 'ads:enable',
4753
label: 'ads:enable',

cli/src/init/init-app.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CLAUDE_OAUTH_ENABLED } from '@codebuff/common/constants/claude-oauth'
12
import {
23
getClaudeOAuthCredentials,
34
getValidClaudeOAuthCredentials,
@@ -27,11 +28,13 @@ export async function initializeApp(params: { cwd?: string }): Promise<void> {
2728

2829
// Refresh Claude OAuth credentials in the background if they exist
2930
// This ensures the subscription status is up-to-date on startup
30-
const claudeCredentials = getClaudeOAuthCredentials()
31-
if (claudeCredentials) {
32-
getValidClaudeOAuthCredentials().catch((error) => {
33-
// Log refresh errors at debug level - will be retried on next API call
34-
console.debug('Failed to refresh Claude OAuth credentials:', error)
35-
})
31+
if (CLAUDE_OAUTH_ENABLED) {
32+
const claudeCredentials = getClaudeOAuthCredentials()
33+
if (claudeCredentials) {
34+
getValidClaudeOAuthCredentials().catch((error) => {
35+
// Log refresh errors at debug level - will be retried on next API call
36+
console.debug('Failed to refresh Claude OAuth credentials:', error)
37+
})
38+
}
3639
}
3740
}

common/src/constants/claude-oauth.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
* These are used by the CLI for the OAuth PKCE flow and by the SDK for direct Anthropic API calls.
44
*/
55

6+
/**
7+
* Feature flag for Claude OAuth (connect:claude) functionality.
8+
* Set to true to re-enable Claude OAuth across:
9+
* - CLI: /connect:claude command, OAuth banner, usage display
10+
* - SDK: Direct Anthropic API routing via OAuth token
11+
* - Init: Background credential refresh on startup
12+
*/
13+
export const CLAUDE_OAUTH_ENABLED = false
14+
615
// OAuth client ID used by Claude Code and third-party apps like opencode
716
export const CLAUDE_OAUTH_CLIENT_ID = '9d1c250a-e61b-44d9-88ed-5944d1962f5e'
817

sdk/src/impl/model-provider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { BYOK_OPENROUTER_HEADER } from '@codebuff/common/constants/byok'
1313
import {
1414
CLAUDE_CODE_SYSTEM_PROMPT_PREFIX,
1515
CLAUDE_OAUTH_BETA_HEADERS,
16+
CLAUDE_OAUTH_ENABLED,
1617
isClaudeModel,
1718
toAnthropicModelId,
1819
} from '@codebuff/common/constants/claude-oauth'
@@ -171,8 +172,8 @@ export async function getModelForRequest(params: ModelRequestParams): Promise<Mo
171172
const { apiKey, model, skipClaudeOAuth } = params
172173

173174
// Check if we should use Claude OAuth direct
174-
// Skip if explicitly requested, if rate-limited, or if not a Claude model
175-
if (!skipClaudeOAuth && !isClaudeOAuthRateLimited() && isClaudeModel(model)) {
175+
// Skip if feature disabled, explicitly requested, if rate-limited, or if not a Claude model
176+
if (CLAUDE_OAUTH_ENABLED && !skipClaudeOAuth && !isClaudeOAuthRateLimited() && isClaudeModel(model)) {
176177
// Get valid credentials (will refresh if needed)
177178
const claudeOAuthCredentials = await getValidClaudeOAuthCredentials()
178179
if (claudeOAuthCredentials) {

0 commit comments

Comments
 (0)