The panel stored notes, todos and plans inside one shared JSON file that six unrelated domains also wrote to, synchronised itself through window CustomEvents, and could only read plans. It is now Project knowledge: server-owned storage with explicit routes, a store with rollback, a section sidebar, plans that open and edit in place, and search across all of it. Notes and plans the user pins travel with every message sent in that project. Pinning is project state, not an attachment to one message, so it holds until unpinned and the work status panel names what is riding along and can detach it. Agent memory is added alongside, in two scopes: what is true about the user, and what is true about this codebase. The split is not cosmetic — a wrong project fact costs one project and is noticed, while a wrong global fact quietly shapes every session everywhere and the user has no code to check it against. It stays separate from notes so an agent mistake cannot land in what the user wrote. Sessions receive an index of titles only; bodies are read on demand, because an index carrying full text grows until it crowds out the conversation. Deciding what a session must be told, and whether it has been told, now lives on the server. The client owned it before, which meant sessions started without a UI — scheduled tasks, sessions the agent dispatches — received nothing at all, and a tab's record of what it had sent outlived the conversation: after compaction the agent no longer held the block while the tab went on believing it did. What was delivered is recorded in the session's own metadata, and compaction restores it through the runtime that already restores pinned messages, in the same turn. Agent memory ships dark behind OPENCHAMBER_MEMORY_ENABLE: unset, there is no tool, no routes, no session index, no settings row and no panel tab. Absent rather than switched off, so nothing invites turning on a feature that has not been announced. Pinned notes and plans are unaffected and ship as normal.
75 lines
2.6 KiB
TypeScript
75 lines
2.6 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
|
|
import { classifyMemory, countHighlightedMemories, memoryViewKey } from './agentMemoryBadges';
|
|
import type { AgentMemoryEntry } from './agentMemoryApi';
|
|
|
|
const entry = (overrides: Partial<AgentMemoryEntry> = {}): AgentMemoryEntry => ({
|
|
id: 'mem-1',
|
|
title: 'Uses bun',
|
|
body: 'Tests run with bun test.',
|
|
type: 'fact',
|
|
createdAt: 100,
|
|
updatedAt: 100,
|
|
...overrides,
|
|
});
|
|
|
|
describe('classifying an entry against the last look', () => {
|
|
test('an entry stored since the last look is new', () => {
|
|
expect(classifyMemory(entry({ createdAt: 200, updatedAt: 200 }), 100)).toBe('new');
|
|
});
|
|
|
|
test('an entry rewritten since the last look is changed, not new', () => {
|
|
// The distinction matters: a memory the agent invented and one it quietly
|
|
// rewrote need different attention.
|
|
expect(classifyMemory(entry({ createdAt: 50, updatedAt: 200 }), 100)).toBe('changed');
|
|
});
|
|
|
|
test('an untouched entry carries no badge', () => {
|
|
expect(classifyMemory(entry({ createdAt: 50, updatedAt: 50 }), 100)).toBeNull();
|
|
});
|
|
|
|
test('a rewrite the user already saw carries no badge', () => {
|
|
expect(classifyMemory(entry({ createdAt: 10, updatedAt: 50 }), 100)).toBeNull();
|
|
});
|
|
|
|
test('everything is new before the user has ever looked', () => {
|
|
expect(classifyMemory(entry({ createdAt: 1, updatedAt: 1 }), 0)).toBe('new');
|
|
});
|
|
|
|
test('an entry stored exactly at the last look is not re-announced', () => {
|
|
expect(classifyMemory(entry({ createdAt: 100, updatedAt: 100 }), 100)).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('counting what deserves a glance', () => {
|
|
test('counts new and changed together', () => {
|
|
const count = countHighlightedMemories([
|
|
entry({ id: 'a', createdAt: 200, updatedAt: 200 }),
|
|
entry({ id: 'b', createdAt: 50, updatedAt: 200 }),
|
|
entry({ id: 'c', createdAt: 50, updatedAt: 50 }),
|
|
], 100);
|
|
|
|
expect(count).toBe(2);
|
|
});
|
|
|
|
test('an untouched store counts nothing', () => {
|
|
expect(countHighlightedMemories([entry({ createdAt: 1, updatedAt: 1 })], 100)).toBe(0);
|
|
});
|
|
});
|
|
|
|
describe('where each scope keeps its mark', () => {
|
|
test('global has one mark', () => {
|
|
expect(memoryViewKey('global', '/tmp/anything')).toBe('global');
|
|
});
|
|
|
|
test('each project keeps its own', () => {
|
|
// One shared project mark would let opening one project silently clear
|
|
// another project's badges.
|
|
expect(memoryViewKey('project', '/tmp/a')).not.toBe(memoryViewKey('project', '/tmp/b'));
|
|
});
|
|
|
|
test('a project scope with no path never collides with global', () => {
|
|
expect(memoryViewKey('project', null)).not.toBe('global');
|
|
});
|
|
});
|