fix(memory-v2): align Runtime Control section enabled badge with active switches.
Runtime control has no top-level enabled field; derive section status from agent resolve, injection mode, and lifecycle flags so the admin page matches saved production config. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import type {
|
||||
MemoryV2RuntimeStatusResponse,
|
||||
PersonalMemoryCandidateListResponse,
|
||||
} from '../../types';
|
||||
import { isMemoryV2SectionEnabled } from './memory-v2-config';
|
||||
|
||||
type BackendKey =
|
||||
| 'pgvector'
|
||||
@@ -923,7 +924,8 @@ export function MemoryV2Page() {
|
||||
{CAPABILITIES.map((capability, index) => {
|
||||
const section = draft[capability.key];
|
||||
const currentSection = current[capability.key];
|
||||
const enabled = Boolean(section.enabled);
|
||||
const enabled = isMemoryV2SectionEnabled(capability.key, section);
|
||||
const savedEnabled = isMemoryV2SectionEnabled(capability.key, currentSection);
|
||||
const accent = BACKEND_ACCENTS[index % BACKEND_ACCENTS.length];
|
||||
return (
|
||||
<section
|
||||
@@ -1015,8 +1017,8 @@ export function MemoryV2Page() {
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<span className={`asset-status ${Boolean(currentSection.enabled) ? 'is-on' : ''}`}>
|
||||
当前保存:{Boolean(currentSection.enabled) ? '启用' : '关闭'}
|
||||
<span className={`asset-status ${savedEnabled ? 'is-on' : ''}`}>
|
||||
当前保存:{savedEnabled ? '启用' : '关闭'}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { MemoryV2AdminSection } from '../../types';
|
||||
|
||||
type CapabilityKey =
|
||||
| 'candidateMemory'
|
||||
| 'runtimeControl'
|
||||
| 'policy'
|
||||
| 'retriever'
|
||||
| 'lifecycle'
|
||||
| 'persona'
|
||||
| 'graph'
|
||||
| 'userMemory'
|
||||
| 'pluginHealth';
|
||||
|
||||
function modeEnabled(value: unknown) {
|
||||
const mode = String(value ?? 'off').trim().toLowerCase();
|
||||
return mode !== '' && mode !== 'off';
|
||||
}
|
||||
|
||||
export function isMemoryV2SectionEnabled(
|
||||
sectionKey: CapabilityKey,
|
||||
section: MemoryV2AdminSection | undefined,
|
||||
): boolean {
|
||||
const config = section ?? {};
|
||||
if (sectionKey === 'runtimeControl') {
|
||||
return Boolean(config.agentResolveEnabled)
|
||||
|| modeEnabled(config.agentInjectionMode)
|
||||
|| Boolean(config.promotionEnabled)
|
||||
|| Boolean(config.compactionV2Enabled)
|
||||
|| Boolean(config.reflectionEnabled)
|
||||
|| Boolean(config.lifecycleWorkerEnabled)
|
||||
|| modeEnabled(config.lifecycleRolloutMode);
|
||||
}
|
||||
return Boolean(config.enabled);
|
||||
}
|
||||
Reference in New Issue
Block a user