feat: add session library backend APIs

Add persisted session and pattern metadata for pinning, archiving, manual titles, and favorite patterns. Expose backend query and mutation APIs for session library features, and cover the shared helpers with tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-22 19:33:20 +01:00
co-authored by Copilot
parent 585f2740a5
commit 4a229a1f88
10 changed files with 606 additions and 3 deletions
+23
View File
@@ -4,6 +4,7 @@ import type { PatternDefinition } from '@shared/domain/pattern';
import {
applyScratchpadSessionConfig,
createScratchpadSessionConfig,
resolveSessionTitle,
resolveScratchpadSessionConfig,
type SessionRecord,
} from '@shared/domain/session';
@@ -95,3 +96,25 @@ describe('scratchpad session config helpers', () => {
expect(updated.agents[1]).toEqual(pattern.agents[1]);
});
});
describe('session title helpers', () => {
test('keeps a manual title instead of recomputing it from the first user message', () => {
const pattern = createPattern();
const session = createSession({
title: 'Release readiness review',
titleSource: 'manual',
});
expect(
resolveSessionTitle(session, pattern, [
{
id: 'msg-1',
role: 'user',
authorName: 'You',
content: 'Investigate why the version badge keeps saying unknown after refresh.',
createdAt: '2026-03-23T00:00:00.000Z',
},
]),
).toBe('Release readiness review');
});
});