chenbhao commited on
Commit
6cc93c0
·
1 Parent(s): 656bec6

fix: openrouter 和 local 切换后加载成了 fallback model list

Browse files
src/components/SearchableModelPicker.tsx CHANGED
@@ -47,6 +47,7 @@ export function SearchableModelPicker({
47
  const [focusedModel, setFocusedModel] = useState<string | undefined>(initialValue)
48
 
49
  const isFastMode = useAppState(s => isFastModeEnabled() ? s.fastMode : false)
 
50
  const [hasToggledEffort, setHasToggledEffort] = useState(false)
51
  const effortValue = useAppState(s => s.effortValue)
52
  const [effort, setEffort] = useState<EffortLevel | undefined>(
@@ -62,7 +63,7 @@ export function SearchableModelPicker({
62
  console.error('Error getting model options:', error)
63
  return []
64
  }
65
- }, [isFastMode])
66
 
67
  // Filter options based on search query
68
  const filteredOptions = React.useMemo(() => {
 
47
  const [focusedModel, setFocusedModel] = useState<string | undefined>(initialValue)
48
 
49
  const isFastMode = useAppState(s => isFastModeEnabled() ? s.fastMode : false)
50
+ const authVersion = useAppState(s => s.authVersion)
51
  const [hasToggledEffort, setHasToggledEffort] = useState(false)
52
  const effortValue = useAppState(s => s.effortValue)
53
  const [effort, setEffort] = useState<EffortLevel | undefined>(
 
63
  console.error('Error getting model options:', error)
64
  return []
65
  }
66
+ }, [isFastMode, authVersion])
67
 
68
  // Filter options based on search query
69
  const filteredOptions = React.useMemo(() => {
src/utils/auth.ts CHANGED
@@ -446,14 +446,6 @@ export async function saveLocalModelConfig(baseUrl: string, modelName: string):
446
  // Clear provider cache so it will be re-read on next access
447
  const { clearStoredProviderCache } = await import('./model/providers.js')
448
  clearStoredProviderCache()
449
-
450
- // Clear OpenRouter models cache so it will be refetched with new API key
451
- try {
452
- const { clearOpenRouterModelsCache } = await import('./model/openRouterModels.js')
453
- clearOpenRouterModelsCache()
454
- } catch (error) {
455
- // Ignore errors from clearing cache
456
- }
457
  }
458
 
459
  export function getLocalModelName(): string | null {
 
446
  // Clear provider cache so it will be re-read on next access
447
  const { clearStoredProviderCache } = await import('./model/providers.js')
448
  clearStoredProviderCache()
 
 
 
 
 
 
 
 
449
  }
450
 
451
  export function getLocalModelName(): string | null {
src/utils/model/modelOptions.ts CHANGED
@@ -488,46 +488,9 @@ function getModelOptionsBase(fastMode = false): ModelOption[] {
488
  ]
489
  }
490
 
491
- // Fallback: show some popular OpenRouter models
492
- const fallbackModels = [
493
- {
494
- value: 'anthropic/claude-sonnet-4.6',
495
- label: 'Anthropic: Claude Sonnet 4.6',
496
- description: 'Best for everyday tasks',
497
- },
498
- {
499
- value: 'anthropic/claude-opus-4.6',
500
- label: 'Anthropic: Claude Opus 4.6',
501
- description: 'Most capable for complex work',
502
- },
503
- {
504
- value: 'anthropic/claude-haiku-4.5',
505
- label: 'Anthropic: Claude Haiku 4.5',
506
- description: 'Fastest for quick answers',
507
- },
508
- {
509
- value: 'openai/gpt-5.4',
510
- label: 'OpenAI: GPT-5.4',
511
- description: 'Most capable OpenAI model',
512
- },
513
- {
514
- value: 'openai/gpt-5.4-mini',
515
- label: 'OpenAI: GPT-5.4 Mini',
516
- description: 'Faster, more efficient option',
517
- },
518
- {
519
- value: 'google/gemini-2.5-pro',
520
- label: 'Google: Gemini 2.5 Pro',
521
- description: 'Advanced reasoning and coding',
522
- },
523
- {
524
- value: 'meta-llama/llama-4-400b',
525
- label: 'Meta: Llama 4 400B',
526
- description: 'Open-source flagship model',
527
- },
528
- ]
529
-
530
- return [getDefaultOptionForUser(fastMode), ...fallbackModels]
531
  }
532
 
533
  // PAYG 3P: Default (Sonnet 4.5) + Sonnet (3P custom) or Sonnet 4.6/1M + Opus (3P custom) or Opus 4.1/Opus 4.6/Opus1M + Haiku + Opus 4.1
 
488
  ]
489
  }
490
 
491
+ // No cached models yet, just show Default option
492
+ // The background fetch will populate the cache for next time
493
+ return [getDefaultOptionForUser(fastMode)]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
494
  }
495
 
496
  // PAYG 3P: Default (Sonnet 4.5) + Sonnet (3P custom) or Sonnet 4.6/1M + Opus (3P custom) or Opus 4.1/Opus 4.6/Opus1M + Haiku + Opus 4.1