From 3f7fa33aa110da4a10cef56fffec4233c5455ba4 Mon Sep 17 00:00:00 2001
From: Askhz <1361267452@qq.com>
Date: Tue, 21 Apr 2026 21:08:44 +0800
Subject: [PATCH 1/2] fix: not login can not show model
---
src/commands/model/model.tsx | 10 ++++++++++
src/components/ConsoleOAuthFlow.tsx | 8 ++++++++
2 files changed, 18 insertions(+)
diff --git a/src/commands/model/model.tsx b/src/commands/model/model.tsx
index 4a6114fde..f1d11fddc 100644
--- a/src/commands/model/model.tsx
+++ b/src/commands/model/model.tsx
@@ -37,6 +37,7 @@ import { generateMachineId, saveCoStrictCredentials } from '../../costrict/provi
import { extractExpiryFromJWT } from '../../costrict/provider/token.js';
import { updateSettingsForSource } from '../../utils/settings/settings.js';
import { useSetAppState as useSetGlobalAppState } from '../../state/AppState.js';
+import { isNotLoggedIn } from '../../utils/logoV2Utils.js';
function ModelPickerWrapper({
onDone,
@@ -339,6 +340,15 @@ export const call: LocalJSXCommandCall = async (onDone, _context, args) => {
return ;
}
+ // Check if user is logged in before showing model picker
+ if (isNotLoggedIn()) {
+ // User is not logged in, redirect to login
+ onDone('You need to login first. Use /login to authenticate.', {
+ display: 'system',
+ });
+ return;
+ }
+
return ;
};
diff --git a/src/components/ConsoleOAuthFlow.tsx b/src/components/ConsoleOAuthFlow.tsx
index 0f6acd502..751fe12c1 100644
--- a/src/components/ConsoleOAuthFlow.tsx
+++ b/src/components/ConsoleOAuthFlow.tsx
@@ -288,6 +288,8 @@ export function ConsoleOAuthFlow({
updateSettingsForSource('userSettings', { model: getDefaultSonnetModel() } as any)
// Clear costrict env var to prevent conflicts
delete process.env.CLAUDE_CODE_USE_COSTRICT
+ // Reset AppState model so logo reflects the new provider default
+ setAppState(prev => ({ ...prev, mainLoopModel: null, mainLoopModelForSession: null }))
setOAuthStatus({ state: 'success' })
void sendNotification(
@@ -734,6 +736,8 @@ function OAuthStatusMessage({
delete process.env.CLAUDE_CODE_USE_COSTRICT
// Set default model to sonnet for this provider
updateSettingsForSource('userSettings', { model: getDefaultSonnetModel() } as any)
+ // Reset AppState model so logo reflects the new provider default
+ setAppState(prev => ({ ...prev, mainLoopModel: null, mainLoopModelForSession: null }))
setOAuthStatus({ state: 'success' })
void onDone()
}
@@ -958,6 +962,8 @@ function OAuthStatusMessage({
delete process.env.CLAUDE_CODE_USE_COSTRICT
// Set default model to sonnet for this provider
updateSettingsForSource('userSettings', { model: getDefaultSonnetModel() } as any)
+ // Reset AppState model so logo reflects the new provider default
+ setAppState(prev => ({ ...prev, mainLoopModel: null, mainLoopModelForSession: null }))
setOAuthStatus({ state: 'success' })
void onDone()
}
@@ -1195,6 +1201,8 @@ function OAuthStatusMessage({
delete process.env.CLAUDE_CODE_USE_COSTRICT
// Set default model to sonnet for this provider
updateSettingsForSource('userSettings', { model: getDefaultSonnetModel() } as any)
+ // Reset AppState model so logo reflects the new provider default
+ setAppState(prev => ({ ...prev, mainLoopModel: null, mainLoopModelForSession: null }))
setOAuthStatus({ state: 'success' })
void onDone()
}
From c1b7bbc2d315eed6b639280d6f696db33debf57f Mon Sep 17 00:00:00 2001
From: Askhz <1361267452@qq.com>
Date: Wed, 22 Apr 2026 11:17:28 +0800
Subject: [PATCH 2/2] fix: restrict ANTHROPIC_MODEL to anthropic-compatible
providers in model picker
- Only show ANTHROPIC_MODEL env var model for firstParty/bedrock/vertex/foundry
- Do not leak it into OpenAI/Gemini/Grok/CoStrict pickers
- Remove settings.model from custom model options
Co-Authored-By: Claude Opus 4.6
---
src/utils/model/modelOptions.ts | 52 ++++++++++++---------------------
1 file changed, 18 insertions(+), 34 deletions(-)
diff --git a/src/utils/model/modelOptions.ts b/src/utils/model/modelOptions.ts
index 55a5c2fde..e3b10576d 100644
--- a/src/utils/model/modelOptions.ts
+++ b/src/utils/model/modelOptions.ts
@@ -1,5 +1,4 @@
// biome-ignore-all assist/source/organizeImports: ANT-ONLY import markers must not be reordered
-import { getInitialMainLoopModel } from '../../bootstrap/state.js'
import {
isClaudeAISubscriber,
isMaxSubscriber,
@@ -25,7 +24,6 @@ import {
getDefaultHaikuModel,
getDefaultMainLoopModelSetting,
getMarketingNameForModel,
- getUserSpecifiedModelSetting,
isOpus1mMergeEnabled,
getOpus46PricingSuffix,
renderDefaultModelSetting,
@@ -542,45 +540,31 @@ export function getModelOptions(fastMode = false): ModelOption[] {
}
}
- // Add custom model from either the current model value or the initial one
- // if it is not already in the options.
- let customModel: ModelSetting = null
- const currentMainLoopModel = getUserSpecifiedModelSetting()
- const initialMainLoopModel = getInitialMainLoopModel()
- if (currentMainLoopModel !== undefined && currentMainLoopModel !== null) {
- customModel = currentMainLoopModel
- } else if (initialMainLoopModel !== null) {
- customModel = initialMainLoopModel
- }
- if (customModel === null || options.some(opt => opt.value === customModel)) {
- return filterModelOptionsByAllowlist(options)
- } else if (customModel === 'opusplan') {
- return filterModelOptionsByAllowlist([...options, getOpusPlanOption()])
- } else if (customModel === 'opus' && getAPIProvider() === 'firstParty') {
- return filterModelOptionsByAllowlist([
- ...options,
- getMaxOpusOption(fastMode),
- ])
- } else if (customModel === 'opus[1m]' && getAPIProvider() === 'firstParty') {
- return filterModelOptionsByAllowlist([
- ...options,
- getMergedOpus1MOption(fastMode),
- ])
- } else {
- // Try to show a human-readable label for known Anthropic models, with an
- // upgrade hint if the alias now resolves to a newer version.
- const knownOption = getKnownModelOption(customModel)
+ // Add ANTHROPIC_MODEL env var model as a custom option, but only for
+ // anthropic-compatible providers. settings.model is NOT added here.
+ const provider = getAPIProvider()
+ const envModel =
+ provider === 'firstParty' ||
+ provider === 'bedrock' ||
+ provider === 'vertex' ||
+ provider === 'foundry'
+ ? process.env.ANTHROPIC_MODEL
+ : undefined
+
+ if (envModel && !options.some(opt => opt.value === envModel)) {
+ const knownOption = getKnownModelOption(envModel)
if (knownOption) {
options.push(knownOption)
} else {
options.push({
- value: customModel,
- label: customModel,
- description: 'Custom model',
+ value: envModel,
+ label: envModel,
+ description: 'Custom model (ANTHROPIC_MODEL)',
})
}
- return filterModelOptionsByAllowlist(options)
}
+
+ return filterModelOptionsByAllowlist(options)
}
/**