Skip to content

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

feat(app): keep local-store controls off an engine without one

Shanuc1fad4233fbe
diff --git a/app/src/components/intelligence/MemoryControls.test.tsx b/app/src/components/intelligence/MemoryControls.test.tsx
index c91a49e947..3c4ab279fd 100644
--- a/app/src/components/intelligence/MemoryControls.test.tsx
+++ b/app/src/components/intelligence/MemoryControls.test.tsx
@@ -11,6 +11,11 @@ vi.mock('../../utils/tauriCommands', () => ({
memoryTreeResetTree: vi.fn().mockResolvedValue(undefined),
memoryTreeWipeAll: vi.fn().mockResolvedValue(undefined),
}));
+// The bound engine's families; `null` is "not known yet", which fails open.
+const engine = vi.hoisted(() => ({ capabilities: null as ReadonlySet<string> | null }));
+vi.mock('./useMemoryEngineCapabilities', () => ({
+ useMemoryEngine: () => ({ capabilities: engine.capabilities }),
+}));
const noop = () => {};
@@ -66,3 +71,32 @@ describe('<MemoryControls /> refresh feedback', () => {
expect(onRefresh).toHaveBeenCalledTimes(1);
});
});
+
+describe('<MemoryControls /> per engine', () => {
+ afterEach(() => {
+ engine.capabilities = null;
+ });
+
+ it('offers the local store controls for an engine that keeps one', () => {
+ engine.capabilities = new Set(['tree', 'chunks']);
+ render(<MemoryControls mode="tree" onModeChange={noop} onRefresh={noop} />);
+ expect(screen.getByTestId('memory-wipe-all')).toBeInTheDocument();
+ expect(screen.getByTestId('memory-reset-tree')).toBeInTheDocument();
+ expect(screen.getByTestId('memory-build-trees')).toBeInTheDocument();
+ expect(screen.getByTestId('memory-graph-refresh')).toBeInTheDocument();
+ });
+
+ it('offers only Refresh for hosted memory, which keeps no local store', () => {
+ engine.capabilities = new Set(['tree', 'retrieval', 'sources']);
+ render(<MemoryControls mode="tree" onModeChange={noop} onRefresh={noop} />);
+ expect(screen.queryByTestId('memory-wipe-all')).toBeNull();
+ expect(screen.queryByTestId('memory-reset-tree')).toBeNull();
+ expect(screen.queryByTestId('memory-build-trees')).toBeNull();
+ expect(screen.getByTestId('memory-graph-refresh')).toBeInTheDocument();
+ });
+
+ it('shows every control while the engine is not known', () => {
+ render(<MemoryControls mode="tree" onModeChange={noop} onRefresh={noop} />);
+ expect(screen.getByTestId('memory-wipe-all')).toBeInTheDocument();
+ });
+});
diff --git a/app/src/components/intelligence/MemoryControls.tsx b/app/src/components/intelligence/MemoryControls.tsx
index cb6549d510..6ee8d6ca06 100644
--- a/app/src/components/intelligence/MemoryControls.tsx
+++ b/app/src/components/intelligence/MemoryControls.tsx
@@ -14,6 +14,11 @@
*
* The parent owns the graph fetch: every mutation (and Refresh) calls
* `onRefresh()` so the caller re-pulls the graph on its own cadence.
+ *
+ * Everything but Refresh works on the engine's local chunk store and summary
+ * tree, so it shows only for an engine with `chunks`. Hosted memory draws its
+ * graph from the server's understanding and keeps no such store: it gets
+ * Refresh alone.
*/
import { useCallback, useState } from 'react';
@@ -29,6 +34,7 @@ import ChipTabs from '../layout/ChipTabs';
import Button from '../ui/Button';
import Separator from '../ui/Separator';
import { ObsidianVaultSection } from './ObsidianVaultSection';
+import { useMemoryEngine } from './useMemoryEngineCapabilities';
interface MemoryControlsProps {
mode: GraphMode;
@@ -48,6 +54,10 @@ export function MemoryControls({
contentRootAbs,
}: MemoryControlsProps) {
const { t } = useT();
+ // Fails open, like the family gate: while the engine is unknown, every
+ // control shows.
+ const { capabilities } = useMemoryEngine();
+ const localStore = !capabilities || capabilities.has('chunks');
const [building, setBuilding] = useState(false);
const [wiping, setWiping] = useState(false);
const [resetting, setResetting] = useState(false);
@@ -161,35 +171,39 @@ export function MemoryControls({
return (
<div className="flex flex-wrap items-center justify-between gap-3" data-testid="memory-actions">
- <ModeToggle mode={mode} onChange={onModeChange} />
+ {localStore ? <ModeToggle mode={mode} onChange={onModeChange} /> : <span />}
<div className="flex flex-wrap items-center gap-2">
- {/* Destructive actions — muted, set apart behind a divider. */}
- <Button
- variant="secondary"
- tone="danger"
- size="sm"
- onClick={handleWipe}
- disabled={busy}
- data-testid="memory-wipe-all"
- className="text-content-muted border-line"
- leadingIcon={wiping ? <Spinner /> : <TrashIcon />}
- title={t('workspace.wipeTitle')}>
- {wiping ? t('workspace.resetting') : t('workspace.resetMemory')}
- </Button>
- <Button
- variant="secondary"
- size="sm"
- onClick={handleResetTree}
- disabled={busy}
- data-testid="memory-reset-tree"
- className="text-content-muted border-line hover:border-amber-300 hover:bg-amber-50 hover:text-amber-700 dark:hover:border-amber-500/30 dark:hover:bg-amber-500/10 dark:hover:text-amber-300"
- leadingIcon={resetting ? <Spinner /> : <RefreshIcon />}
- title={t('workspace.resetTreeTitle')}>
- {resetting ? t('workspace.rebuilding') : t('workspace.resetMemoryTree')}
- </Button>
+ {localStore ? (
+ <>
+ {/* Destructive actions — muted, set apart behind a divider. */}
+ <Button
+ variant="secondary"
+ tone="danger"
+ size="sm"
+ onClick={handleWipe}
+ disabled={busy}
+ data-testid="memory-wipe-all"
+ className="text-content-muted border-line"
+ leadingIcon={wiping ? <Spinner /> : <TrashIcon />}
+ title={t('workspace.wipeTitle')}>
+ {wiping ? t('workspace.resetting') : t('workspace.resetMemory')}
+ </Button>
+ <Button
+ variant="secondary"
+ size="sm"
+ onClick={handleResetTree}
+ disabled={busy}
+ data-testid="memory-reset-tree"
+ className="text-content-muted border-line hover:border-amber-300 hover:bg-amber-50 hover:text-amber-700 dark:hover:border-amber-500/30 dark:hover:bg-amber-500/10 dark:hover:text-amber-300"
+ leadingIcon={resetting ? <Spinner /> : <RefreshIcon />}
+ title={t('workspace.resetTreeTitle')}>
+ {resetting ? t('workspace.rebuilding') : t('workspace.resetMemoryTree')}
+ </Button>
- <Separator orientation="vertical" className="mx-1 h-5 self-center bg-surface-strong" />
+ <Separator orientation="vertical" className="mx-1 h-5 self-center bg-surface-strong" />
+ </>
+ ) : null}
{/* Secondary actions — quiet ghost buttons. */}
<Button
@@ -203,20 +217,22 @@ export function MemoryControls({
title={t('common.refresh')}>
{t('common.refresh')}
</Button>
- {contentRootAbs ? (
+ {localStore && contentRootAbs ? (
<ObsidianVaultSection contentRootAbs={contentRootAbs} onToast={onToast} />
) : null}
{/* Primary action. */}
- <Button
- variant="primary"
- size="sm"
- onClick={handleBuildTrees}
- disabled={building}
- data-testid="memory-build-trees"
- leadingIcon={building ? <Spinner /> : <BrainIcon />}>
- {building ? t('workspace.building') : t('workspace.buildSummaryTrees')}
- </Button>
+ {localStore ? (
+ <Button
+ variant="primary"
+ size="sm"
+ onClick={handleBuildTrees}
+ disabled={building}
+ data-testid="memory-build-trees"
+ leadingIcon={building ? <Spinner /> : <BrainIcon />}>
+ {building ? t('workspace.building') : t('workspace.buildSummaryTrees')}
+ </Button>
+ ) : null}
</div>
</div>
);
diff --git a/app/src/components/settings/panels/MemoryDataPanel.tsx b/app/src/components/settings/panels/MemoryDataPanel.tsx
index 386ad4b392..7f2872fa63 100644
--- a/app/src/components/settings/panels/MemoryDataPanel.tsx
+++ b/app/src/components/settings/panels/MemoryDataPanel.tsx
@@ -88,7 +88,8 @@ const MemoryDataPanel = ({ embedded = false }: MemoryDataPanelProps = {}) => {
</div>
</dl>
</SettingsSection>
- <MemoryFamilyGate family="tree">
+ {/* The vault is the local chunk store's files: hosted memory has none. */}
+ <MemoryFamilyGate family="chunks">
<VaultHealthChecklist onToast={addToast} title={t('vaultHealth.setupTitle')} />
</MemoryFamilyGate>
<MemoryWindowControl onError={handleWindowError} onSaved={handleWindowSaved} />
diff --git a/app/src/pages/Brain.tsx b/app/src/pages/Brain.tsx
index 5608ba18a6..01e9fbe06c 100644
--- a/app/src/pages/Brain.tsx
+++ b/app/src/pages/Brain.tsx
@@ -449,10 +449,14 @@ export default function Brain() {
{activeTab === 'sync' && syncView === 'status' && (
<div className="space-y-5 animate-fade-up">
+ {/* The ingest pipeline's status is the local chunk store's:
+ hosted memory draws a tree but keeps no such store. */}
<MemoryFamilyGate family="tree">
- <Card padded divided={false}>
- <MemoryTreeStatusPanel onToast={addToast} />
- </Card>
+ <MemoryFamilyGate family="chunks">
+ <Card padded divided={false}>
+ <MemoryTreeStatusPanel onToast={addToast} />
+ </Card>
+ </MemoryFamilyGate>
</MemoryFamilyGate>
{/* openhuman#6257: what is syncing right now, beside the
history of what already ran. */}
diff --git a/app/src/pages/__tests__/Brain.test.tsx b/app/src/pages/__tests__/Brain.test.tsx
index 2ae673fc98..9b8819e193 100644
--- a/app/src/pages/__tests__/Brain.test.tsx
+++ b/app/src/pages/__tests__/Brain.test.tsx
@@ -226,6 +226,49 @@ describe('Brain page', () => {
expect(screen.queryByTestId('brain-sync-activity-card')).toBeNull();
});
+ // Hosted memory serves a tree — the server's understanding — but keeps no
+ // local chunk store: the graph draws, and the ingest pipeline's status panel
+ // says it is not available rather than reading a store that is not there.
+ const hostedWithTree = () => {
+ engineMock.get.mockResolvedValue({ driver: 'tinyhumans' });
+ engineMock.list.mockResolvedValue({
+ active: 'tinyhumans',
+ engines: [
+ {
+ id: 'tinyhumans',
+ label: 'CortexDB (via TinyHumans)',
+ capabilities: ['core', 'recall', 'portability', 'sources', 'retrieval', 'tree'],
+ },
+ ],
+ });
+ };
+
+ it('draws the graph on hosted memory', async () => {
+ graphExportMock.mockResolvedValue(makeGraph(2));
+ hostedWithTree();
+ await act(async () => {
+ renderWithProviders(<Brain />, { initialEntries: ['/?tab=graph'] });
+ });
+ await waitFor(() => {
+ expect(screen.getByTestId('memory-graph')).toHaveTextContent('nodes:2');
+ });
+ });
+
+ it('gates the local pipeline status on hosted memory', async () => {
+ graphExportMock.mockResolvedValue(makeGraph(0));
+ hostedWithTree();
+ await act(async () => {
+ renderWithProviders(<Brain />, { initialEntries: ['/?tab=sync'] });
+ });
+ await waitFor(() => {
+ const gated = screen
+ .getAllByTestId('memory-family-unavailable')
+ .map(node => node.getAttribute('data-family'));
+ expect(gated).toContain('chunks');
+ });
+ expect(screen.queryByTestId('brain-sync')).toBeNull();
+ });
+
// Hosted memory accepts synced items but reads no local agent transcripts:
// the sources registry renders, the coding-sessions card says it is not
// available instead of calling an RPC the engine refuses.