HEL-823 A3: days/memories, creation wizard, settings pages on cef8ae5 (author delivery, 15 modified + 1 handoff per CHANGES-HEL-823.json)

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
Chief Engineer
2026-10-24 08:26:54 +08:00
co-authored by multica-agent
parent cef8ae5581
commit 0bc4a9e68e
16 changed files with 383 additions and 56 deletions
+1
View File
@@ -19,6 +19,7 @@ describe('local persistence and restore boundary', () => {
it('corrupt storage produces a visible boundary instead of new creation', () => { vi.stubGlobal('localStorage', { getItem: () => '{invalid' }); expect(loadState().state).toBeNull(); expect(loadState().error).not.toBe(''); });
it('rejects another companion, malformed records and oversized files', () => { const s = seed(); expect(() => parseState(JSON.stringify({ ...s, identity: { ...identity, id: 'other' } }), identity)).toThrow('另一位'); expect(() => parseState(JSON.stringify({ ...s, messages: [{ text: 'invalid' }] }), identity)).toThrow(); expect(() => parseState(' '.repeat(5000001))).toThrow('太大'); });
it('untrusted text stays text, arbitrary keys are dropped, pending turns cancelled on restore', () => { const s = seed(); s.messages.push({ id: 'script', role: 'companion', text: '<img src=x onerror=alert(1)>', lifeIds: [], status: 'pending' }); const parsed = parseState(JSON.stringify({ ...s, script: 'evil' }), identity); expect(parsed.messages.at(-1)?.text).toContain('<img'); expect(parsed.messages.at(-1)?.status).toBe('cancelled'); expect(parsed).not.toHaveProperty('script'); });
it('keeps when she told you only on shared records', () => { const s = seed(); s.events[3] = { ...s.events[3], told: '13:20 告诉你' }; const parsed = parseState(JSON.stringify(s), identity); expect(parsed.events.find(e => e.id === 'book')?.told).toBe('19:46 告诉你'); expect(parsed.events.find(e => e.id === 'secret')).not.toHaveProperty('told'); });
});
describe('turn/epoch cancellation', () => {
it('rejects old results after new turn, cancel, exit, and resync', () => { const g = new TurnGate(); const a = g.begin('a'); const e = { t: 'chat.delta' as const, epoch: 1, turn_id: 'a', delta: '旧' }; expect(g.accepts(e)).toBe(true); g.begin('b'); expect(a.aborted).toBe(true); expect(g.accepts(e)).toBe(false); g.cancel(); expect(g.accepts({ ...e, turn_id: 'b' })).toBe(false); g.begin('b'); g.resync(); g.begin('c'); expect(g.accepts({ ...e, turn_id: 'c' })).toBe(false); });