The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: files changed app/src/components/intelligence/MemoryFamilyGate.test.tsx,app/src/components/se
Steven Enamakel843dc3154d9f
diff --git a/app/src/components/intelligence/MemoryFamilyGate.test.tsx b/app/src/components/intelligence/MemoryFamilyGate.test.tsxindex 9286c18766..02f225f9d4 100644--- a/app/src/components/intelligence/MemoryFamilyGate.test.tsx+++ b/app/src/components/intelligence/MemoryFamilyGate.test.tsx@@ -7,6 +7,7 @@ import { beforeEach, describe, expect, test, vi } from 'vitest';import { renderWithProviders } from '../../test/test-utils';import MemoryFamilyGate from './MemoryFamilyGate';+import { resetMemoryEngineCacheForTests } from './useMemoryEngineCapabilities';const hoisted = vi.hoisted(() => ({ list: vi.fn(), get: vi.fn() }));@@ -27,6 +28,7 @@ describe('MemoryFamilyGate', () => {beforeEach(() => {hoisted.list.mockReset();hoisted.get.mockReset();+ resetMemoryEngineCacheForTests();});test('shows the empty state naming the engine when the family is missing', async () => {@@ -65,4 +67,37 @@ describe('MemoryFamilyGate', () => {expect(screen.getByText('goals body')).toBeTruthy();expect(screen.queryByTestId('memory-family-unavailable')).toBeNull();});++ test('shows a skeleton, not the children, while the engine is loading', async () => {+ let release: (v: unknown) => void = () => {};+ hoisted.get.mockReturnValue(new Promise(r => (release = r)));+ hoisted.list.mockResolvedValue({ active: 'mem0', engines: [] });+ renderWithProviders(+ <MemoryFamilyGate family="goals">+ <div>goals body</div>+ </MemoryFamilyGate>+ );+ expect(screen.getByTestId('memory-family-loading')).toBeTruthy();+ expect(screen.queryByText('goals body')).toBeNull();+ release({ driver: 'tinymemory' });+ await waitFor(() => expect(screen.queryByTestId('memory-family-loading')).toBeNull());+ });++ test('gates every family when memory is paused on the null driver', async () => {+ hoisted.get.mockResolvedValue({+ driver: 'null',+ fell_back_from: 'mem0',+ last_error: 'engine credential unavailable',+ });+ hoisted.list.mockResolvedValue({ active: 'null', engines: [] });+ renderWithProviders(+ <MemoryFamilyGate family="core">+ <div>core body</div>+ </MemoryFamilyGate>+ );+ await waitFor(() => expect(screen.getByTestId('memory-family-unavailable')).toBeTruthy());+ expect(screen.getByText('Memory is paused')).toBeTruthy();+ expect(screen.getByText('engine credential unavailable')).toBeTruthy();+ expect(screen.queryByText('core body')).toBeNull();+ });});diff --git a/app/src/components/intelligence/useMemoryEngineCapabilities.test.tsx b/app/src/components/intelligence/useMemoryEngineCapabilities.test.tsxnew file mode 100644index 0000000000..88405d42df--- /dev/null+++ b/app/src/components/intelligence/useMemoryEngineCapabilities.test.tsx@@ -0,0 +1,67 @@+/**+ * The shared engine cache: every reader in one view shares one+ * `engines_list` + `engine_get`, and a forced refresh re-fetches.+ */+import { act, renderHook, waitFor } from '@testing-library/react';+import { beforeEach, describe, expect, test, vi } from 'vitest';++import { resetMemoryEngineCacheForTests, useMemoryEngine } from './useMemoryEngineCapabilities';++const hoisted = vi.hoisted(() => ({ list: vi.fn(), get: vi.fn() }));++vi.mock('../../utils/tauriCommands/memoryEngine', () => ({+ memoryEnginesList: (...a: unknown[]) => hoisted.list(...a),+ memoryEngineGet: (...a: unknown[]) => hoisted.get(...a),+}));++beforeEach(() => {+ hoisted.list.mockReset();+ hoisted.get.mockReset();+ resetMemoryEngineCacheForTests();+ hoisted.get.mockResolvedValue({ driver: 'mem0' });+ hoisted.list.mockResolvedValue({+ active: 'mem0',+ engines: [{ id: 'mem0', label: 'Mem0', capabilities: ['core'] }],+ });+});++describe('useMemoryEngine', () => {+ test('several readers in one view share a single list + get', async () => {+ const a = renderHook(() => useMemoryEngine());+ const b = renderHook(() => useMemoryEngine());+ const c = renderHook(() => useMemoryEngine());+ await waitFor(() => expect(a.result.current.id).toBe('mem0'));+ await waitFor(() => expect(b.result.current.id).toBe('mem0'));+ await waitFor(() => expect(c.result.current.label).toBe('Mem0'));+ expect(hoisted.list).toHaveBeenCalledTimes(1);+ expect(hoisted.get).toHaveBeenCalledTimes(1);+ });++ test('a reader mounting within the TTL reuses the result', async () => {+ const first = renderHook(() => useMemoryEngine());+ await waitFor(() => expect(first.result.current.id).toBe('mem0'));+ const later = renderHook(() => useMemoryEngine());+ expect(later.result.current.id).toBe('mem0');+ expect(hoisted.get).toHaveBeenCalledTimes(1);+ });++ test('refresh forces a new fetch and fans out to every reader', async () => {+ const a = renderHook(() => useMemoryEngine());+ const b = renderHook(() => useMemoryEngine());+ await waitFor(() => expect(a.result.current.id).toBe('mem0'));+ hoisted.get.mockResolvedValue({ driver: 'null' });+ await act(async () => {+ await a.result.current.refresh();+ });+ await waitFor(() => expect(b.result.current.id).toBe('null'));+ expect(hoisted.get).toHaveBeenCalledTimes(2);+ });++ test('a failed fetch leaves capabilities unknown (fail open) and reports the error', async () => {+ hoisted.get.mockRejectedValue(new Error('offline'));+ const a = renderHook(() => useMemoryEngine());+ await waitFor(() => expect(a.result.current.loading).toBe(false));+ expect(a.result.current.capabilities).toBeNull();+ expect(a.result.current.error).toBeTruthy();+ });+});diff --git a/app/src/components/settings/panels/MemoryEnginePanel.test.tsx b/app/src/components/settings/panels/MemoryEnginePanel.test.tsxindex 56ac74e6c4..bf54098385 100644--- a/app/src/components/settings/panels/MemoryEnginePanel.test.tsx+++ b/app/src/components/settings/panels/MemoryEnginePanel.test.tsx@@ -11,7 +11,11 @@ import type {MemoryEngineDescriptor,MemoryEngineState,} from '../../../utils/tauriCommands/memoryEngine';-import MemoryEnginePanel, { MIGRATE_POLL_INTERVAL_MS } from './MemoryEnginePanel';+import { resetMemoryEngineCacheForTests } from '../../intelligence/useMemoryEngineCapabilities';+import MemoryEnginePanel, {+ MIGRATE_JOB_STORAGE_KEY,+ MIGRATE_POLL_INTERVAL_MS,+} from './MemoryEnginePanel';const hoisted = vi.hoisted(() => ({list: vi.fn(),@@ -19,6 +23,8 @@ const hoisted = vi.hoisted(() => ({set: vi.fn(),migrate: vi.fn(),status: vi.fn(),+ cancel: vi.fn(),+ storage: new Map<string, string>(),track: vi.fn(),auth: { isAuthenticated: true },}));@@ -29,6 +35,19 @@ vi.mock('../../../utils/tauriCommands/memoryEngine', () => ({memoryEngineSet: (...a: unknown[]) => hoisted.set(...a),memoryEngineMigrate: (...a: unknown[]) => hoisted.migrate(...a),memoryEngineMigrateStatus: (...a: unknown[]) => hoisted.status(...a),+ memoryEngineMigrateCancel: (...a: unknown[]) => hoisted.cancel(...a),+}));++vi.mock('../../../store/userScopedStorage', () => ({+ userScopedStorage: {+ getItem: async (k: string) => hoisted.storage.get(k) ?? null,+ setItem: async (k: string, v: string) => {+ hoisted.storage.set(k, v);+ },+ removeItem: async (k: string) => {+ hoisted.storage.delete(k);+ },+ },}));vi.mock('../../../services/analytics', () => ({@@ -101,6 +120,8 @@ const pick = (id: string) =>beforeEach(() => {vi.clearAllMocks();+ resetMemoryEngineCacheForTests();+ hoisted.storage.clear();hoisted.auth = { isAuthenticated: true };hoisted.list.mockResolvedValue({ engines: ENGINES, active: 'tinymemory' });hoisted.get.mockResolvedValue(state());@@ -267,9 +288,87 @@ describe('MemoryEnginePanel', () => {expect(screen.getByRole('radio', { name: /supermemory/i })).toBeEnabled();});- test('shows a fallback warning when the core fell back to local memory', async () => {- hoisted.get.mockResolvedValue(state({ fell_back_from: 'mem0', last_error: 'timeout' }));+ test('a failed bind says memory is paused (not local) and shows the reason', async () => {+ hoisted.get.mockResolvedValue(+ state({ driver: 'null', fell_back_from: 'mem0', last_error: 'engine credential unavailable' })+ );await renderPanel();- expect(screen.getByTestId('memory-engine-fallback')).toHaveTextContent('mem0');+ const warning = screen.getByTestId('memory-engine-fallback');+ expect(warning).toHaveTextContent('Memory is paused');+ expect(warning).toHaveTextContent('mem0');+ expect(warning).toHaveTextContent('engine credential unavailable');+ expect(warning).not.toHaveTextContent(/local memory/i);+ });++ test('cancel stops a running copy and leaves the panel on the previous engine', async () => {+ vi.useFakeTimers();+ hoisted.migrate.mockResolvedValue({ job_id: 'job-c' });+ hoisted.cancel.mockResolvedValue({ cancelled: true });+ hoisted.status+ .mockResolvedValueOnce({ state: 'running', copied: 1, total: null, error: null })+ .mockResolvedValue({ state: 'cancelled', copied: 1, total: null, error: null });+ renderWithProviders(<MemoryEnginePanel />);+ await act(async () => {+ await vi.advanceTimersByTimeAsync(0);+ });+ pick('mem0');+ fireEvent.click(screen.getByTestId('memory-engine-switch'));+ await act(async () => {+ await vi.advanceTimersByTimeAsync(0);+ });+ fireEvent.click(screen.getByTestId('memory-engine-copy-switch'));+ await act(async () => {+ await vi.advanceTimersByTimeAsync(0);+ });+ fireEvent.click(screen.getByTestId('memory-engine-cancel-migration'));+ await act(async () => {+ await vi.advanceTimersByTimeAsync(0);+ });+ expect(hoisted.cancel).toHaveBeenCalledWith('job-c');++ for (let i = 0; i < 2; i += 1) {+ await act(async () => {+ await vi.advanceTimersByTimeAsync(MIGRATE_POLL_INTERVAL_MS);+ });+ }+ expect(screen.queryByTestId('memory-engine-switch-dialog')).not.toBeInTheDocument();+ expect(hoisted.track).not.toHaveBeenCalled();+ expect(hoisted.storage.has(MIGRATE_JOB_STORAGE_KEY)).toBe(false);+ });++ test('the running migration job id is persisted and resumed on return', async () => {+ vi.useFakeTimers();+ hoisted.storage.set(+ MIGRATE_JOB_STORAGE_KEY,+ JSON.stringify({ jobId: 'job-r', driver: 'mem0' })+ );+ hoisted.status.mockResolvedValue({ state: 'running', copied: 3, total: null, error: null });+ renderWithProviders(<MemoryEnginePanel />);+ await act(async () => {+ await vi.advanceTimersByTimeAsync(0);+ });+ expect(hoisted.status).toHaveBeenCalledWith('job-r');+ expect(screen.getByTestId('memory-engine-progress')).toHaveTextContent('Copied 3 memories');+ });++ test('a stored job that already finished is cleared without a dialog', async () => {+ hoisted.storage.set(+ MIGRATE_JOB_STORAGE_KEY,+ JSON.stringify({ jobId: 'job-x', driver: 'mem0' })+ );+ hoisted.status.mockResolvedValue({ state: 'failed', copied: 0, total: null, error: 'x' });+ await renderPanel();+ await waitFor(() => expect(hoisted.storage.has(MIGRATE_JOB_STORAGE_KEY)).toBe(false));+ expect(screen.queryByTestId('memory-engine-switch-dialog')).not.toBeInTheDocument();+ });++ test('starting a copy persists the job id', async () => {+ hoisted.migrate.mockResolvedValue({ job_id: 'job-p' });+ hoisted.status.mockResolvedValue({ state: 'running', copied: 0, total: null, error: null });+ await renderPanel();+ pick('mem0');+ fireEvent.click(screen.getByTestId('memory-engine-switch'));+ fireEvent.click(await screen.findByTestId('memory-engine-copy-switch'));+ await waitFor(() => expect(hoisted.storage.get(MIGRATE_JOB_STORAGE_KEY)).toContain('job-p'));});});