fix(chat): translate session replay cursors
Memind CI / Test, build, and release guards (pull_request) Successful in 2m55s
Memind CI / Test, build, and release guards (pull_request) Successful in 2m55s
This commit is contained in:
@@ -23,7 +23,7 @@ function createMockPool() {
|
||||
}
|
||||
if (sql.includes('WHERE id = ? AND agent_session_id = ?')) {
|
||||
const row = events.find((item) => item.id === params[0]);
|
||||
return [[row ? { created_at: row.created_at } : undefined].filter(Boolean)];
|
||||
return [[row].filter(Boolean)];
|
||||
}
|
||||
if (sql.includes('created_at > ?')) {
|
||||
const after = Number(params[2]);
|
||||
@@ -67,12 +67,14 @@ test('session stream store append and replay with cursor', async () => {
|
||||
sessionId: 'sess-1',
|
||||
payload: { type: 'Message', message: { role: 'assistant', content: [] } },
|
||||
id: 'evt-1',
|
||||
upstreamEventId: 'upstream-1',
|
||||
});
|
||||
await store.appendEvent({
|
||||
userId: 'user-1',
|
||||
sessionId: 'sess-1',
|
||||
payload: { type: 'Finish' },
|
||||
id: 'evt-2',
|
||||
upstreamEventId: 'upstream-2',
|
||||
});
|
||||
|
||||
const head = await store.listEventsForUser('user-1', 'sess-1');
|
||||
@@ -82,7 +84,10 @@ test('session stream store append and replay with cursor', async () => {
|
||||
assert.equal(tail.events.length, 1);
|
||||
assert.equal(tail.events[0].payload.type, 'Finish');
|
||||
assert.equal(tail.cursorMiss, false);
|
||||
assert.equal(tail.cursorEvent.id, first.id);
|
||||
assert.equal(tail.cursorEvent.upstreamEventId, 'upstream-1');
|
||||
|
||||
const miss = await store.listEventsForUser('user-1', 'sess-1', { afterEventId: 'missing' });
|
||||
assert.equal(miss.cursorMiss, true);
|
||||
assert.equal(miss.cursorEvent, null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user