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/memory/MemoryConversationsTab.test.tsx
Steven Enamakelc2d1350a0e0c
diff --git a/app/src/components/memory/MemoryConversationsTab.test.tsx b/app/src/components/memory/MemoryConversationsTab.test.tsxindex 11654d6ed2..0f969e88be 100644--- a/app/src/components/memory/MemoryConversationsTab.test.tsx+++ b/app/src/components/memory/MemoryConversationsTab.test.tsx@@ -1,70 +1,133 @@import { fireEvent, screen, waitFor } from '@testing-library/react';import { beforeEach, describe, expect, it, vi } from 'vitest';-import type { ConversationsSettings } from '../../services/api/memoryApi';+import type { MemoryPolicy } from '../../services/api/memoryApi';import { renderWithProviders } from '../../test/test-utils';import MemoryConversationsTab from './MemoryConversationsTab';-const hoisted = vi.hoisted(() => ({ get: vi.fn(), set: vi.fn() }));+const hoisted = vi.hoisted(() => ({+ policyGet: vi.fn(),+ policySet: vi.fn(),+ agents: vi.fn(),+ items: vi.fn(),+}));vi.mock('../../services/api/memoryApi', async importOriginal => ({...(await importOriginal<typeof import('../../services/api/memoryApi')>()),- memoryConversationsGet: (...a: unknown[]) => hoisted.get(...a),- memoryConversationsSet: (...a: unknown[]) => hoisted.set(...a),+ memoryPolicyGet: (...a: unknown[]) => hoisted.policyGet(...a),+ memoryPolicySet: (...a: unknown[]) => hoisted.policySet(...a),+ memoryAgentsList: (...a: unknown[]) => hoisted.agents(...a),+ memoryItemsList: (...a: unknown[]) => hoisted.items(...a),+}));++// The backfill card has its own suite.+vi.mock('./MemoryConversationsBackfill', () => ({+ default: () => <div data-testid="stub-backfill" />,}));-const SETTINGS: ConversationsSettings = {- enabled: true,- batch_turns: 4,- idle_secs: 120,- recent: [{ thread_id: 'thread-1', turns: 6, stored_at: '2026-10-01T10:00:00Z' }],+const POLICY: MemoryPolicy = {+ log_conversations: true,+ recall: {+ enabled: true,+ budget_tokens: 1500,+ learnings_limit: 8,+ brain_limit: 6,+ history_limit: 6,+ team_limit: 4,+ build_beliefs_every: 20,+ pre_turn_timeout_ms: 1500,+ compaction_timeout_ms: 5000,+ build_delay_secs: 30,+ },+ root: 'user:me',+ agent_id: 'main',+ host_bound: false,};beforeEach(() => {- hoisted.get.mockReset().mockResolvedValue(SETTINGS);- hoisted.set.mockReset();+ hoisted.policyGet.mockReset().mockResolvedValue(POLICY);+ hoisted.policySet.mockReset();+ hoisted.agents.mockReset().mockResolvedValue({+ root: 'user:me',+ agents: [+ { agent_id: 'main', turns: 6 },+ { agent_id: 'researcher', turns: 2 },+ ],+ });+ hoisted.items.mockReset();});describe('MemoryConversationsTab', () => {- it('shows the settings and the recently stored threads', async () => {+ it('shows the logging switch, the agents and the backfill card', async () => {renderWithProviders(<MemoryConversationsTab />);- expect(await screen.findByTestId('memory-conversation-thread-1')).toHaveTextContent('6 turns');- expect(screen.getByLabelText('Turns per batch')).toHaveValue(4);- expect(screen.getByLabelText('Save when idle')).toHaveValue(120);+ expect(await screen.findByTestId('memory-agent-main')).toHaveTextContent('6 turns');+ expect(screen.getByTestId('memory-agent-researcher')).toHaveTextContent('2 turns');+ expect(screen.getByTestId('memory-conversations-log')).toBeChecked();+ expect(screen.getByTestId('stub-backfill')).toBeInTheDocument();});- it('turns automatic storage off', async () => {- hoisted.set.mockResolvedValue({ ...SETTINGS, enabled: false });+ it('turns turn logging off through the policy', async () => {+ hoisted.policySet.mockResolvedValue({ ...POLICY, log_conversations: false });renderWithProviders(<MemoryConversationsTab />);- fireEvent.click(await screen.findByTestId('memory-conversations-enabled'));- await waitFor(() => expect(hoisted.set).toHaveBeenCalledWith({ enabled: false }));- await waitFor(() => expect(screen.getByLabelText('Turns per batch')).toBeDisabled());+ fireEvent.click(await screen.findByTestId('memory-conversations-log'));+ await waitFor(() =>+ expect(hoisted.policySet).toHaveBeenCalledWith({ log_conversations: false })+ );+ await waitFor(() => expect(screen.getByTestId('memory-conversations-log')).not.toBeChecked());});- it('saves a new batch size on commit and ignores an invalid one', async () => {- hoisted.set.mockResolvedValue({ ...SETTINGS, batch_turns: 8 });+ it("opens an agent's stored conversations and pages through them", async () => {+ hoisted.items+ .mockResolvedValueOnce({+ items: [{ id: 'c1', kind: 'conversation', text: 'We talked about Atlas', meta: {} }],+ next_cursor: 'n1',+ })+ .mockResolvedValueOnce({+ items: [{ id: 'c2', kind: 'conversation', text: 'And the launch', meta: {} }],+ next_cursor: null,+ });renderWithProviders(<MemoryConversationsTab />);- const batch = await screen.findByLabelText('Turns per batch');+ fireEvent.click(await screen.findByTestId('memory-agent-researcher-open'));- fireEvent.change(batch, { target: { value: '0' } });- fireEvent.blur(batch);- expect(hoisted.set).not.toHaveBeenCalled();- expect(batch).toHaveValue(4);+ await waitFor(() =>+ expect(hoisted.items).toHaveBeenCalledWith({+ filter: { kinds: ['conversation'], agent_id: 'researcher' },+ limit: 20,+ cursor: undefined,+ })+ );+ expect(await screen.findByTestId('memory-hit-c1')).toHaveTextContent('We talked about Atlas');- fireEvent.change(batch, { target: { value: '8' } });- fireEvent.blur(batch);- await waitFor(() => expect(hoisted.set).toHaveBeenCalledWith({ batch_turns: 8 }));+ fireEvent.click(screen.getByTestId('memory-conversations-more'));+ expect(await screen.findByTestId('memory-hit-c2')).toBeInTheDocument();+ expect(screen.getByTestId('memory-hit-c1')).toBeInTheDocument();+ expect(hoisted.items).toHaveBeenLastCalledWith(expect.objectContaining({ cursor: 'n1' }));++ // Clicking again closes it.+ fireEvent.click(screen.getByTestId('memory-agent-researcher-open'));+ expect(screen.queryByTestId('memory-agent-researcher-items')).not.toBeInTheDocument();+ });++ it('says when an agent has nothing stored', async () => {+ hoisted.items.mockResolvedValue({ items: [], next_cursor: null });+ renderWithProviders(<MemoryConversationsTab />);+ fireEvent.click(await screen.findByTestId('memory-agent-main-open'));+ expect(await screen.findByTestId('memory-agent-main-items')).toHaveTextContent(+ 'No conversations stored for this agent yet.'+ );});- it('shows the empty recent list', async () => {- hoisted.get.mockResolvedValue({ ...SETTINGS, recent: [] });+ it('shows the empty agent list', async () => {+ hoisted.agents.mockResolvedValue({ root: 'user:me', agents: [] });renderWithProviders(<MemoryConversationsTab />);expect(await screen.findByTestId('memory-conversations-empty')).toBeInTheDocument();});it('shows a load error', async () => {- hoisted.get.mockRejectedValue(new Error('MEMORY_OFF'));+ hoisted.policyGet.mockRejectedValue(new Error('MEMORY_OFF'));+ hoisted.agents.mockRejectedValue(new Error('MEMORY_OFF'));renderWithProviders(<MemoryConversationsTab />);expect(await screen.findByTestId('memory-conversations-error')).toHaveTextContent('MEMORY_OFF');+ expect(screen.queryByTestId('memory-conversations-log')).not.toBeInTheDocument();});});