From 1eee19a3ea9db9a33cf770ae9f8796c31898300f Mon Sep 17 00:00:00 2001 From: wsp Date: Fri, 21 Aug 2026 13:07:33 +0800 Subject: [PATCH] feat(settings): simplify memory configuration - combine memory generation and session usage into one toggle - keep common policies and model selectors directly accessible - move extraction and consolidation limits into advanced settings - update localized copy and settings search metadata --- .../settings/settingsTabSearchContent.ts | 10 +- .../config/components/MemoriesConfig.scss | 36 +++ .../config/components/MemoriesConfig.tsx | 303 ++++++++++-------- .../src/locales/en-US/settings/memories.json | 14 +- .../src/locales/zh-CN/settings/memories.json | 14 +- .../src/locales/zh-TW/settings/memories.json | 14 +- 6 files changed, 243 insertions(+), 148 deletions(-) create mode 100644 src/web-ui/src/infrastructure/config/components/MemoriesConfig.scss diff --git a/src/web-ui/src/app/scenes/settings/settingsTabSearchContent.ts b/src/web-ui/src/app/scenes/settings/settingsTabSearchContent.ts index 8a504458b5..4e1e77ed26 100644 --- a/src/web-ui/src/app/scenes/settings/settingsTabSearchContent.ts +++ b/src/web-ui/src/app/scenes/settings/settingsTabSearchContent.ts @@ -141,11 +141,13 @@ export const SETTINGS_TAB_SEARCH_CONTENT: Record summary { + padding: var(--bf-appearance-token-size-gap-4); + cursor: pointer; + font-size: var(--bf-appearance-token-font-size-sm); + font-weight: var(--bf-appearance-token-font-weight-semibold); + color: var(--bf-appearance-token-color-text-primary); + } + + &[open] > summary { + border-bottom: 1px solid var(--bf-appearance-token-config-page-divider); + } +} + +.bitfun-memories-config__advanced-content { + padding: var(--bf-appearance-token-size-gap-4); + + .bitfun-config-page-section { + gap: var(--bf-appearance-token-size-gap-3); + } + + .bitfun-config-page-section__header { + display: none; + } + + .bitfun-config-page-section__body { + background: transparent; + border: 0; + border-radius: 0; + box-shadow: none; + } +} diff --git a/src/web-ui/src/infrastructure/config/components/MemoriesConfig.tsx b/src/web-ui/src/infrastructure/config/components/MemoriesConfig.tsx index f1d6c81bb7..dd48cef290 100644 --- a/src/web-ui/src/infrastructure/config/components/MemoriesConfig.tsx +++ b/src/web-ui/src/infrastructure/config/components/MemoriesConfig.tsx @@ -24,6 +24,7 @@ import { ConfigPageRow, ConfigPageSection, } from './common'; +import './MemoriesConfig.scss'; const log = createLogger('MemoriesConfig'); @@ -160,6 +161,27 @@ const MemoriesConfig: React.FC = () => { } }, [config, notifyError, notifySuccess, t]); + const updateMemoryEnabled = useCallback(async (enabled: boolean) => { + const previous = config; + const next = { + ...config, + generate_memories: enabled, + use_memories: enabled, + }; + setSavingKey('generate_memories'); + setConfig(next); + try { + await configManager.setConfig('memories', next); + notifySuccess(t('messages.saved')); + } catch (error) { + log.error('Failed to save memory enabled state', error); + setConfig(previous); + notifyError(error instanceof Error ? error.message : t('messages.saveFailed')); + } finally { + setSavingKey(null); + } + }, [config, notifyError, notifySuccess, t]); + const updateModelSelector = useCallback(( key: 'extract_model' | 'consolidation_model', value: string | number | (string | number)[], @@ -211,7 +233,11 @@ const MemoriesConfig: React.FC = () => { if (loading) { return ( - + @@ -220,10 +246,15 @@ const MemoriesConfig: React.FC = () => { ); } - const memoryWorkDisabled = !config.generate_memories; + const memoryEnabled = config.generate_memories && config.use_memories; + const memoryWorkDisabled = !memoryEnabled; return ( - + { - void updateConfig('generate_memories', event.target.checked)} - disabled={savingKey === 'generate_memories'} - size="small" - /> - - - void updateConfig('use_memories', event.target.checked)} - disabled={savingKey === 'use_memories'} + checked={memoryEnabled} + onChange={(event) => void updateMemoryEnabled(event.target.checked)} + disabled={savingKey === 'generate_memories' || savingKey === 'use_memories'} size="small" /> @@ -307,7 +325,7 @@ const MemoriesConfig: React.FC = () => { void updateConfig('generate_for_btw_sessions', event.target.checked)} - disabled={savingKey === 'generate_for_btw_sessions'} + disabled={savingKey === 'generate_for_btw_sessions' || memoryWorkDisabled} size="small" /> @@ -332,89 +350,7 @@ const MemoriesConfig: React.FC = () => { - - - void updateConfig('min_rollout_idle_hours', value)} - min={1} - max={48} - step={1} - unit={t('units.hours')} - size="small" - disabled={savingKey === 'min_rollout_idle_hours' || memoryWorkDisabled} - /> - - - - void updateConfig('max_rollout_age_days', value)} - min={0} - max={config.max_unused_days} - step={1} - unit={t('units.days')} - size="small" - disabled={savingKey === 'max_rollout_age_days' || memoryWorkDisabled} - /> - - - - void updateConfig('max_rollouts_per_startup', value)} - min={1} - max={128} - step={1} - size="small" - disabled={savingKey === 'max_rollouts_per_startup' || memoryWorkDisabled} - /> - - - - void updateConfig('max_rollouts_scan_limit', value)} - min={1} - max={50000} - step={100} - size="small" - disabled={savingKey === 'max_rollouts_scan_limit' || memoryWorkDisabled} - /> - - - - void updateConfig('phase1_max_concurrency', value)} - min={1} - max={16} - step={1} - size="small" - disabled={savingKey === 'phase1_max_concurrency' || memoryWorkDisabled} - /> - - + { disabled={savingKey === 'extract_model' || memoryWorkDisabled} /> - - - - - void updateConfig('max_raw_memories_for_consolidation', value)} - min={1} - max={4096} - step={1} - size="small" - disabled={savingKey === 'max_raw_memories_for_consolidation' || memoryWorkDisabled} - /> - - - - void updateConfig('max_unused_days', value)} - min={config.max_rollout_age_days} - max={365} - step={1} - unit={t('units.days')} - size="small" - disabled={savingKey === 'max_unused_days' || memoryWorkDisabled} - /> - - { /> + +
+ {t('sections.advanced.title')} +
+ + + void updateConfig('min_rollout_idle_hours', value)} + min={1} + max={48} + step={1} + unit={t('units.hours')} + size="small" + disabled={savingKey === 'min_rollout_idle_hours' || memoryWorkDisabled} + /> + + + + void updateConfig('max_rollout_age_days', value)} + min={0} + max={config.max_unused_days} + step={1} + unit={t('units.days')} + size="small" + disabled={savingKey === 'max_rollout_age_days' || memoryWorkDisabled} + /> + + + + void updateConfig('max_rollouts_per_startup', value)} + min={1} + max={128} + step={1} + size="small" + disabled={savingKey === 'max_rollouts_per_startup' || memoryWorkDisabled} + /> + + + + void updateConfig('max_rollouts_scan_limit', value)} + min={1} + max={50000} + step={100} + size="small" + disabled={savingKey === 'max_rollouts_scan_limit' || memoryWorkDisabled} + /> + + + + void updateConfig('phase1_max_concurrency', value)} + min={1} + max={16} + step={1} + size="small" + disabled={savingKey === 'phase1_max_concurrency' || memoryWorkDisabled} + /> + + + void updateConfig('max_raw_memories_for_consolidation', value)} + min={1} + max={4096} + step={1} + size="small" + disabled={savingKey === 'max_raw_memories_for_consolidation' || memoryWorkDisabled} + /> + + + + void updateConfig('max_unused_days', value)} + min={config.max_rollout_age_days} + max={365} + step={1} + unit={t('units.days')} + size="small" + disabled={savingKey === 'max_unused_days' || memoryWorkDisabled} + /> + + +
+