feat: chat + optmz control panel

This commit is contained in:
thanhnv
2026-07-10 16:26:30 +09:00
parent d882a9dc23
commit 7cea023dce
28 changed files with 1702 additions and 402 deletions
@@ -47,6 +47,23 @@ test('chat ask returns certified read-only answer with evidence sources', () =>
});
});
test('chat history returns only integrity-checked previews for the requesting actor', () => {
withTempChatState(() => {
const svc = new ChatService();
svc.ask({ message: 'Summarize Plan 18 MVP-0 status', chatId: 'history-chat' }, viewer);
svc.ask({ message: 'Summarize Plan 18 MVP-2 status', chatId: 'history-chat' }, viewer);
svc.ask({ message: 'Summarize Plan 18 MVP-0 status', chatId: 'other-actor' }, { ...viewer, actor: 'someone-else' });
const history = svc.history(viewer, 'history-chat') as any;
assert.equal(history.ok, true);
assert.equal(history.turns.length, 2);
assert.equal(history.turns[0].chat_id, 'history-chat');
assert.ok(history.turns.every((turn: any) => turn.prompt_preview && turn.audit_hash));
assert.equal(history.conversations.length, 1);
assert.equal(history.conversations[0].chat_id, 'history-chat');
});
});
test('chat ask denies prompt injection and returns governed block response', () => {
withTempChatState(() => {
const svc = new ChatService();