Skip to content

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

test(memory): cover the stored-items tile and its namespace-summaries wrapper\n\nThe diff-coverage gate failed at 58% (5 of 12 changed lines uncovered):\n`memoryNamespaceSummaries` had no test at all, and the detached-promise\ncatch in `useMemoryTreeStatus` that falls `storedItems` back to null was\nnever driven.\n\n- memoryTree.test.ts: dispatch + envelope-unwrap cases for\n `memoryNamespaceSummaries`, matching the file's existing per-wrapper shape.\n- MemoryTreeStatusPanel.test.tsx: the inline `memoryNamespaceSummaries` stub\n becomes a named mock so it can be re-programmed per test, then two cases —\n the total renders thousands-separated, and a rejected summaries call leaves\n the placeholder up while the rest of the panel stays live (only a pipeline\n failure owns the panel-wide error).\n\nTests only; no production code touched. Both new cases were checked against\na revert: pointing the wrapper at a wrong method name and swapping the catch's\n`setStoredItems(null)` for `0` fails exactly these two and nothing else.\n

M3gA-Mind91d760ba3d5c
diff --git a/app/src/components/intelligence/MemoryTreeStatusPanel.test.tsx b/app/src/components/intelligence/MemoryTreeStatusPanel.test.tsx
index 3a3587da01..a13e13d76d 100644
--- a/app/src/components/intelligence/MemoryTreeStatusPanel.test.tsx
+++ b/app/src/components/intelligence/MemoryTreeStatusPanel.test.tsx
@@ -23,6 +23,7 @@ const mockPipelineStatus = vi.fn();
const mockSetEnabled = vi.fn();
const mockSyncStatusList = vi.fn();
const mockRetryFailed = vi.fn();
+const mockNamespaceSummaries = vi.fn();
// #5324: the panel now navigates (budget CTA) and dispatches (escalating the
// blocking cause to the shell-mounted UserErrorCenter). Stub both so the
// suite keeps rendering the panel bare, without a Router or a Redux store.
@@ -50,7 +51,7 @@ vi.mock('../../utils/tauriCommands', async importOriginal => {
memoryTreeSetEnabled: (...args: unknown[]) => mockSetEnabled(...args),
memorySyncStatusList: (...args: unknown[]) => mockSyncStatusList(...args),
memoryTreeRetryFailed: (...args: unknown[]) => mockRetryFailed(...args),
- memoryNamespaceSummaries: vi.fn(async () => ({ namespaces: [], total_documents: 0 })),
+ memoryNamespaceSummaries: (...args: unknown[]) => mockNamespaceSummaries(...args),
};
});
@@ -84,8 +85,12 @@ describe('<MemoryTreeStatusPanel />', () => {
mockSetEnabled.mockReset();
mockSyncStatusList.mockReset();
mockRetryFailed.mockReset();
+ mockNamespaceSummaries.mockReset();
mockTrackAnalyticsEvent.mockReset();
mockSyncStatusList.mockResolvedValue([]); // default: empty, harmless to existing tests
+ // Same default the inline stub used to hard-code, now re-programmable
+ // per test so the failure branch can be driven.
+ mockNamespaceSummaries.mockResolvedValue({ namespaces: [], total_documents: 0 });
});
afterEach(() => {
@@ -681,6 +686,42 @@ describe('<MemoryTreeStatusPanel />', () => {
// The button must stay usable so a transient failure is not a dead end.
expect(screen.getByTestId('memory-tree-retry-failed')).not.toBeDisabled();
});
+
+ // -- stored-items tile ----------------------------------------------------
+ // The stored-document total rides the same poll as the pipeline status but
+ // comes from a different store, and it is fetched on a detached promise so a
+ // failure there must NOT wipe the panel. These pin both halves of that.
+
+ it('renders the stored-items total from the namespace summaries', async () => {
+ mockPipelineStatus.mockResolvedValue(payload());
+ mockNamespaceSummaries.mockResolvedValue({
+ namespaces: [{ namespace: 'slack', count: 1500, last_updated: null }],
+ total_documents: 1500,
+ });
+
+ render(<MemoryTreeStatusPanel />);
+
+ await waitFor(() => {
+ expect(screen.getByTestId('memory-stored-items')).toHaveTextContent('1,500');
+ });
+ });
+
+ it('keeps the panel alive and shows the placeholder when the summaries call fails', async () => {
+ // Detached-promise failure path: `storedItems` falls back to null, which
+ // renders the skeleton rather than a number. The pipeline status still
+ // resolved, so nothing else on the panel may degrade — in particular the
+ // panel-wide error must stay clear, because only a pipeline failure owns it.
+ mockPipelineStatus.mockResolvedValue(payload());
+ mockNamespaceSummaries.mockRejectedValue(new Error('namespace summaries down'));
+
+ render(<MemoryTreeStatusPanel />);
+
+ await waitFor(() => {
+ expect(screen.getByTestId('memory-tree-total-chunks')).toHaveTextContent('1,234');
+ });
+ expect(screen.queryByTestId('memory-stored-items')).not.toBeInTheDocument();
+ expect(screen.getByTestId('memory-tree-status-label')).toHaveTextContent(/running/i);
+ });
});
describe('integration health helpers', () => {
diff --git a/app/src/utils/tauriCommands/memoryTree.test.ts b/app/src/utils/tauriCommands/memoryTree.test.ts
index 1d30f01543..6b67b74228 100644
--- a/app/src/utils/tauriCommands/memoryTree.test.ts
+++ b/app/src/utils/tauriCommands/memoryTree.test.ts
@@ -8,6 +8,7 @@ import { beforeEach, describe, expect, type Mock, test, vi } from 'vitest';
import { callCoreRpc } from '../../services/coreRpcClient';
import {
+ memoryNamespaceSummaries,
memorySyncStatusList,
memoryTreeBackfillStatus,
memoryTreeChunkScore,
@@ -487,3 +488,40 @@ describe('memoryTreeRetryFailed', () => {
expect(out).toEqual({ requeued: 0 });
});
});
+
+describe('memoryNamespaceSummaries', () => {
+ // The stored-document total is the sync-verification number the tree tiles
+ // cannot answer (#5932: a user watched 100 items land while the tree figure
+ // sat at 2), so both the dispatch and the envelope unwrap are pinned here.
+ test('dispatches openhuman.memory_namespace_summaries and returns the rows plus total', async () => {
+ mockCallCoreRpc.mockResolvedValueOnce({
+ result: {
+ namespaces: [
+ { namespace: 'slack', count: 80, last_updated: '2026-09-01T12:00:00Z' },
+ { namespace: 'gmail', count: 20, last_updated: null },
+ ],
+ total_documents: 100,
+ },
+ logs: ['memory::namespaces: summaries n=2 total=100'],
+ });
+
+ const out = await memoryNamespaceSummaries();
+
+ expect(mockCallCoreRpc).toHaveBeenCalledWith({
+ method: 'openhuman.memory_namespace_summaries',
+ params: {},
+ });
+ expect(out.total_documents).toBe(100);
+ expect(out.namespaces).toHaveLength(2);
+ expect(out.namespaces[0].namespace).toBe('slack');
+ expect(out.namespaces[0].count).toBe(80);
+ });
+
+ test('passes through bare-shape responses (no logs envelope) unchanged', async () => {
+ mockCallCoreRpc.mockResolvedValueOnce({ namespaces: [], total_documents: 0 });
+
+ const out = await memoryNamespaceSummaries();
+
+ expect(out).toEqual({ namespaces: [], total_documents: 0 });
+ });
+});