- adapter: memory ids are strings; single-memory calls take only the id
(no ?mind= disambiguation). searchMemory takes the workspace as its own
parameter. New getMemoryCapabilities / setMemoryExtraction. Removed:
incrementFrameAccess, getMemoryOriginalSource, listSuppression,
allowReimport, getWeaverStatus, and the dead importPreview, importCommit
and getWikiWatermark. eraseMemory takes { id } or { sessionId }.
- memory-features reads GET /api/memory/capabilities for the knowledge
graph; history import, wiki, hooks, Room and the memory MCP stay hidden
(ADR-0002). useMemoryCapabilities re-renders the Memory screens.
- Settings > General has a Memory toggle for background fact extraction.
- Memory Center: the confidence filter, the erased-sources panel, the
original-source view and the Deprecated chip are gone; Erase forgets
every memory saved from the chat a memory came from and is offered only
for memories with a chat session. Memory kinds follow the contract.
- Trust views show short memory labels for the new string ids and drop the
per-row "not scored yet" badge (v1 stores no confidence).
- The Weaver maintenance view and the Cockpit weaver card are removed
(the weaver package and its routes are deleted).
- Timeline uses the contract kinds and maps important/temporary
importance.
Logs UF-033 (search scope sent as the workspace id), UF-034 (importance
mapping) and UF-035 (restore over open databases, open).
110 lines
4.0 KiB
TypeScript
110 lines
4.0 KiB
TypeScript
/**
|
|
* ADR-0002: the v1 memory feature map, its capability source, and the
|
|
* onboarding import step it hides.
|
|
*/
|
|
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
import { render, screen, cleanup, waitFor, renderHook } from '@testing-library/react';
|
|
import {
|
|
hasMemoryFeature,
|
|
isMemoryViewAvailable,
|
|
loadMemoryCapabilities,
|
|
setMemoryCapabilities,
|
|
useMemoryCapabilities,
|
|
type MemoryFeature,
|
|
} from '@/lib/memory-features';
|
|
import type { MemoryCapabilitiesResponse } from '@/lib/types';
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
adapter: {
|
|
connect: vi.fn(),
|
|
getProfile: vi.fn(),
|
|
trackTelemetry: vi.fn(),
|
|
scanClaudeCode: vi.fn(),
|
|
getMemoryCapabilities: vi.fn(),
|
|
},
|
|
}));
|
|
|
|
const report = (knowledgeGraph: boolean): MemoryCapabilitiesResponse => ({
|
|
capabilities: { extraction: true, semanticSearch: true, history: true, knowledgeGraph },
|
|
settings: { extraction: true },
|
|
});
|
|
|
|
vi.mock('@/lib/adapter', () => ({ adapter: mocks.adapter, default: vi.fn() }));
|
|
vi.mock('@/hooks/useOfflineStatus', () => ({ useOfflineStatus: () => false }));
|
|
vi.mock('@/lib/posthog', () => ({ captureOnboardingComplete: vi.fn() }));
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
vi.clearAllMocks();
|
|
setMemoryCapabilities(null);
|
|
});
|
|
|
|
describe('memory feature map (v1 defaults)', () => {
|
|
it.each<MemoryFeature>(['knowledgeGraph', 'importHistory', 'wiki', 'agentHooks', 'room', 'memoryMcp'])(
|
|
'%s is hidden',
|
|
(feature) => {
|
|
expect(hasMemoryFeature(feature)).toBe(false);
|
|
},
|
|
);
|
|
|
|
it('keeps the v1 Memory Center views and hides Graph, Imports and Wiki', () => {
|
|
for (const view of ['trust', 'memories', 'timeline']) {
|
|
expect(isMemoryViewAvailable(view), view).toBe(true);
|
|
}
|
|
for (const view of ['graph', 'harvest', 'wiki']) {
|
|
expect(isMemoryViewAvailable(view), view).toBe(false);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('memory feature map from the server capabilities', () => {
|
|
it('shows the graph only when the memory store reports it', () => {
|
|
setMemoryCapabilities(report(false));
|
|
expect(hasMemoryFeature('knowledgeGraph')).toBe(false);
|
|
setMemoryCapabilities(report(true));
|
|
expect(hasMemoryFeature('knowledgeGraph')).toBe(true);
|
|
expect(isMemoryViewAvailable('graph')).toBe(true);
|
|
});
|
|
|
|
it('keeps import, wiki, hooks, Room and the memory MCP hidden whatever the store reports', () => {
|
|
setMemoryCapabilities(report(true));
|
|
for (const feature of ['importHistory', 'wiki', 'agentHooks', 'room', 'memoryMcp'] as const) {
|
|
expect(hasMemoryFeature(feature), feature).toBe(false);
|
|
}
|
|
});
|
|
|
|
it('useMemoryCapabilities loads GET /api/memory/capabilities once and re-renders', async () => {
|
|
mocks.adapter.getMemoryCapabilities.mockResolvedValue(report(false));
|
|
const { result } = renderHook(() => useMemoryCapabilities());
|
|
expect(result.current).toBeNull();
|
|
await waitFor(() => expect(result.current).toEqual(report(false)));
|
|
await loadMemoryCapabilities();
|
|
expect(mocks.adapter.getMemoryCapabilities).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|
|
|
|
describe('OnboardingWizard without history import', () => {
|
|
it('resumes a persisted import step on the template step and never scans Claude Code', async () => {
|
|
mocks.adapter.connect.mockResolvedValue(undefined);
|
|
mocks.adapter.getProfile.mockResolvedValue(null);
|
|
const { default: OnboardingWizard } = await import('@/components/os/overlays/OnboardingWizard');
|
|
|
|
render(
|
|
<OnboardingWizard
|
|
serverBaseUrl="http://127.0.0.1:3333"
|
|
state={{ completed: false, step: 3 }}
|
|
onUpdate={vi.fn()}
|
|
onComplete={vi.fn()}
|
|
onDismiss={vi.fn()}
|
|
onFinish={vi.fn()}
|
|
/>,
|
|
);
|
|
|
|
expect(await screen.findByRole('heading', { name: /pick a starting point/i })).toBeInTheDocument();
|
|
// who-are-you · model · template · first-task: the import step has no number.
|
|
expect(screen.getByText('Step 3 of 4')).toBeInTheDocument();
|
|
await waitFor(() => expect(mocks.adapter.getProfile).toHaveBeenCalled());
|
|
expect(mocks.adapter.scanClaudeCode).not.toHaveBeenCalled();
|
|
});
|
|
});
|