refactor(web): move the Memory screens onto the memory contract API (P1.5)

- 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).
This commit is contained in:
shumeiko.it
2026-10-24 12:39:17 +02:00
parent 06d4532598
commit d433dca857
33 changed files with 480 additions and 847 deletions

View File

@@ -1,9 +1,18 @@
/**
* ADR-0002: the v1 memory feature map and the onboarding import step it hides.
* 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 } from '@testing-library/react';
import { hasMemoryFeature, isMemoryViewAvailable, type MemoryFeature } from '@/lib/memory-features';
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: {
@@ -11,9 +20,15 @@ const mocks = vi.hoisted(() => ({
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() }));
@@ -21,6 +36,7 @@ vi.mock('@/lib/posthog', () => ({ captureOnboardingComplete: vi.fn() }));
afterEach(() => {
cleanup();
vi.clearAllMocks();
setMemoryCapabilities(null);
});
describe('memory feature map (v1 defaults)', () => {
@@ -32,7 +48,7 @@ describe('memory feature map (v1 defaults)', () => {
);
it('keeps the v1 Memory Center views and hides Graph, Imports and Wiki', () => {
for (const view of ['trust', 'memories', 'timeline', 'weaver']) {
for (const view of ['trust', 'memories', 'timeline']) {
expect(isMemoryViewAvailable(view), view).toBe(true);
}
for (const view of ['graph', 'harvest', 'wiki']) {
@@ -41,6 +57,32 @@ describe('memory feature map (v1 defaults)', () => {
});
});
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);