|
1 | | -import { useState, useRef, useEffect, useCallback } from 'react' |
| 1 | +import { useState, useRef, useEffect, useCallback, useMemo } from 'react' |
2 | 2 | import { Layout as UiLayout } from '@ui/components/editor/settings/Layout' |
3 | 3 | import { NavigationItem as UiNavigationItem } from '@ui/components/editor/settings/NavigationItem' |
4 | 4 | import { ModelProvidersSection } from './sections/ModelProvidersSection' |
@@ -104,6 +104,7 @@ type Props = { |
104 | 104 | checkpoint_lifespan: number |
105 | 105 | edit_format_instructions: EditFormatInstructions |
106 | 106 | clear_checks_in_workspace_behavior: 'ignore-open-editors' | 'uncheck-all' |
| 107 | + extended_cache_duration_for_anthropic: boolean |
107 | 108 | fix_all_automatically: boolean |
108 | 109 | set_providers: (providers: ProviderForClient[]) => void |
109 | 110 | set_edit_context_configs: (configs: ConfigurationForClient[]) => void |
@@ -132,6 +133,7 @@ type Props = { |
132 | 133 | value: 'ignore-open-editors' | 'uncheck-all' |
133 | 134 | ) => void |
134 | 135 | on_fix_all_automatically_change: (enabled: boolean) => void |
| 136 | + on_extended_cache_duration_for_anthropic_change: (enabled: boolean) => void |
135 | 137 | on_open_keybindings: (search?: string) => void |
136 | 138 | on_open_editor_settings: () => void |
137 | 139 | on_open_ignore_patterns_settings: () => void |
@@ -181,6 +183,10 @@ export const Home: React.FC<Props> = (props) => { |
181 | 183 | useState('') |
182 | 184 | const [stuck_sections, set_stuck_sections] = useState(new Set<NavItem>()) |
183 | 185 |
|
| 186 | + const has_anthropic_provider = useMemo(() => { |
| 187 | + return props.providers.some((p) => p.name == 'Anthropic') |
| 188 | + }, [props.providers]) |
| 189 | + |
184 | 190 | const handle_stuck_change = useCallback((id: NavItem, is_stuck: boolean) => { |
185 | 191 | set_stuck_sections((prev) => { |
186 | 192 | const is_currently_stuck = prev.has(id) |
@@ -420,6 +426,22 @@ export const Home: React.FC<Props> = (props) => { |
420 | 426 | on_edit_provider={props.on_edit_provider} |
421 | 427 | on_change_api_key={props.on_change_api_key} |
422 | 428 | /> |
| 429 | + {has_anthropic_provider && ( |
| 430 | + <UiItem |
| 431 | + title={t('model-providers.extended-cache.anthropic.title')} |
| 432 | + description={t( |
| 433 | + 'model-providers.extended-cache.anthropic.description' |
| 434 | + )} |
| 435 | + slot_right={ |
| 436 | + <UiToggler |
| 437 | + is_on={props.extended_cache_duration_for_anthropic} |
| 438 | + on_toggle={ |
| 439 | + props.on_extended_cache_duration_for_anthropic_change |
| 440 | + } |
| 441 | + /> |
| 442 | + } |
| 443 | + /> |
| 444 | + )} |
423 | 445 | </UiGroup> |
424 | 446 | </UiSection> |
425 | 447 | <UiSection |
|
0 commit comments