Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(memory): add memory engine tab with enable and disable controls

Steven Enamakeleac5a65590aa
diff --git a/app/src/components/memory/MemoryDisabledCard.tsx b/app/src/components/memory/MemoryDisabledCard.tsx
new file mode 100644
index 0000000000..970b8f0a94
--- /dev/null
+++ b/app/src/components/memory/MemoryDisabledCard.tsx
@@ -0,0 +1,62 @@
+import { PowerOff } from 'lucide-react';
+
+import { cn } from '../../lib/cn';
+import { useT } from '../../lib/i18n/I18nContext';
+import { Badge, Button } from '../ui';
+
+export interface MemoryDisabledCardProps {
+ /** Memory is disabled right now (the `none` engine is selected). */
+ active: boolean;
+ /** A switch is in flight; the button waits. */
+ saving: boolean;
+ onDisable: () => void;
+}
+
+/**
+ * Memory → Provider: the "Disabled" option, beside the CortexDB card. It turns
+ * memory off completely; each engine's endpoint and key are kept, so picking a
+ * provider again turns it back on with no re-entry.
+ */
+export default function MemoryDisabledCard({ active, saving, onDisable }: MemoryDisabledCardProps) {
+ const { t } = useT();
+ return (
+ <div
+ className={cn(
+ 'flex items-start gap-2.5 rounded-xl border bg-surface px-3 py-2.5',
+ active ? 'border-primary-500/60' : 'border-line'
+ )}
+ data-testid="memory-engine-disabled">
+ <span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-strong ring-1 ring-line">
+ <PowerOff className="h-4 w-4 text-content-secondary" aria-hidden />
+ </span>
+ <div className="min-w-0 flex-1 space-y-2">
+ <div>
+ <div className="flex flex-wrap items-center justify-between gap-x-2 gap-y-1">
+ <h4 className="text-sm font-semibold text-content">
+ {t('memoryPage.engine.disabled.title')}
+ </h4>
+ {active && (
+ <Badge variant="primary" data-testid="memory-engine-disabled-active">
+ {t('memoryPage.engine.inUse')}
+ </Badge>
+ )}
+ </div>
+ <p className="text-xs leading-snug text-content-muted">
+ {t('memoryPage.engine.disabled.description')}
+ </p>
+ </div>
+ {!active && (
+ <Button
+ size="xs"
+ variant="secondary"
+ analyticsId="memory-engine-disable"
+ data-testid="memory-engine-disable"
+ disabled={saving}
+ onClick={onDisable}>
+ {t('memoryPage.engine.disabled.action')}
+ </Button>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/app/src/components/memory/MemoryEngineTab.tsx b/app/src/components/memory/MemoryEngineTab.tsx
index 22f4ae05ad..46facaaf95 100644
--- a/app/src/components/memory/MemoryEngineTab.tsx
+++ b/app/src/components/memory/MemoryEngineTab.tsx
@@ -22,7 +22,8 @@
*
* Which chip is in use is derived from `memory_engine_get`: `tinyhumans` is
* TinyHumans, and `cortexdb` is Local when its endpoint is loopback, else your
- * API key. Engines that are not supported yet are listed as coming soon.
+ * API key. `none` is the Disabled card beside it: memory turned off on purpose,
+ * with every connection's settings kept. Engines that are not supported yet are listed as coming soon.
*
* debug logging: DEBUG=openhuman:memory:engine
*/
@@ -34,7 +35,9 @@ import { useCoreState } from '../../providers/CoreStateProvider';
import {
type EngineSetRequest,
type EngineState,
+ isMemoryDisabled,
isMemoryOn,
+ MEMORY_DISABLED_ENGINE,
memoryEngineSet,
memoryErrorMessage,
} from '../../services/api/memoryApi';
@@ -47,6 +50,7 @@ import MemoryComingSoon from './MemoryComingSoon';
import MemoryConnectionPanel from './MemoryConnectionPanel';
import MemoryCortexAnnouncement from './MemoryCortexAnnouncement';
import MemoryCortexCard from './MemoryCortexCard';
+import MemoryDisabledCard from './MemoryDisabledCard';
import MemoryProviderLogo, { type MemoryProviderOption } from './MemoryProviderLogo';
export { CORTEXDB_SELF_HOST_DOCS_URL } from './MemoryConnectionPanel';
@@ -105,7 +109,7 @@ export default function MemoryEngineTab({ state, onStateChange, embedded }: Memo
const selected: EngineOption = picked ?? active ?? 'builtin';
// The key or Local connection whose modal is open.
const [dialog, setDialog] = useState<Exclude<EngineOption, 'builtin'> | null>(null);
- const [saving, setSaving] = useState<EngineOption | null>(null);
+ const [saving, setSaving] = useState<EngineOption | 'disabled' | null>(null);
const [errors, setErrors] = useState<Partial<Record<EngineOption, string>>>({});
const [cloudKey, setCloudKey] = useState('');
// Untouched (null) shows the configured local endpoint, which may arrive
@@ -159,10 +163,42 @@ export default function MemoryEngineTab({ state, onStateChange, embedded }: Memo
return <CenteredLoadingState label={t('memoryPage.loading')} />;
}
+ const disabled = isMemoryDisabled(state);
+
+ // Disabled: memory off on purpose. Every connection's settings are kept,
+ // so picking a provider again turns it back on.
+ const disable = async () => {
+ setSaving('disabled');
+ try {
+ const next = await memoryEngineSet({ engine: MEMORY_DISABLED_ENGINE });
+ log('memory disabled: status=%s', next.status);
+ onStateChange(next);
+ setPicked(null);
+ toast.add({ type: 'success', title: t('memoryPage.engine.disabled.toast') });
+ } catch (err) {
+ log('disable failed: %o', err);
+ toast.add({
+ type: 'error',
+ title: t('memoryPage.engine.disabled.toastFailed'),
+ description: memoryErrorMessage(err, t),
+ });
+ } finally {
+ setSaving(null);
+ }
+ };
+
// Off: a plain prompt to pick a provider. The core's reason is developer
// text ("legacy memory backend is unsupported…"), so it is not shown here;
// degraded and down keep theirs, which names what is wrong.
const statusBanner = (() => {
+ if (disabled) {
+ return (
+ <Alert variant="info" data-testid="memory-engine-status-disabled">
+ <AlertTitle>{t('memoryPage.disabled.title')}</AlertTitle>
+ <AlertDescription>{t('memoryPage.engine.disabled.banner')}</AlertDescription>
+ </Alert>
+ );
+ }
if (!on) {
return (
<Alert variant="info" data-testid="memory-engine-status-off">
@@ -322,6 +358,14 @@ export default function MemoryEngineTab({ state, onStateChange, embedded }: Memo
status={status}>
{selected === 'builtin' ? panel('builtin') : connectedLine(selected)}
</MemoryCortexCard>
+ {/* Onboarding embeds this tab to pick a provider, not to opt out. */}
+ {!embedded && (
+ <MemoryDisabledCard
+ active={disabled}
+ saving={saving !== null}
+ onDisable={() => void disable()}
+ />
+ )}
</div>
{dialog && (
diff --git a/app/src/services/api/memoryApi.ts b/app/src/services/api/memoryApi.ts
index 85f431e88d..06625e91c1 100644
--- a/app/src/services/api/memoryApi.ts
+++ b/app/src/services/api/memoryApi.ts
@@ -677,6 +677,14 @@ export function isOutOfCreditsMessage(
}
/** True when the engine state means memory is usable (an engine is set and not off). */
+/** Engine id that turns memory off completely (`memory_engine_set`). */
+export const MEMORY_DISABLED_ENGINE = 'none';
+
+/** Whether memory was turned off on purpose (the `none` engine). */
+export function isMemoryDisabled(state: EngineState | null | undefined): boolean {
+ return state?.engine === MEMORY_DISABLED_ENGINE;
+}
+
export function isMemoryOn(state: EngineState | null | undefined): boolean {
return Boolean(state && state.engine && state.status !== 'off');
}