Skip to content

Commit 46bb2f7

Browse files
committed
putReadState: accept an equal-timestamp cursor as a forward move
The guard used a strict > comparison, so a same-millisecond write to a later message in the same batch was dropped as a no-op and the route echoed back the older cursor. Only a strictly older timestamp is a no-op now; an equal timestamp lands the incoming write.
1 parent 7e2140f commit 46bb2f7

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎packages/chat/src/store.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ export function createDrizzleChatStore<TSchema extends Record<string, unknown>>(
311311
workbenchReadState.principalId,
312312
],
313313
set: {
314-
lastSeenCreatedAt: sql`CASE WHEN excluded.last_seen_created_at > ${workbenchReadState.lastSeenCreatedAt} THEN excluded.last_seen_created_at ELSE ${workbenchReadState.lastSeenCreatedAt} END`,
315-
lastSeenId: sql`CASE WHEN excluded.last_seen_created_at > ${workbenchReadState.lastSeenCreatedAt} THEN excluded.last_seen_id ELSE ${workbenchReadState.lastSeenId} END`,
314+
lastSeenCreatedAt: sql`CASE WHEN excluded.last_seen_created_at >= ${workbenchReadState.lastSeenCreatedAt} THEN excluded.last_seen_created_at ELSE ${workbenchReadState.lastSeenCreatedAt} END`,
315+
lastSeenId: sql`CASE WHEN excluded.last_seen_created_at >= ${workbenchReadState.lastSeenCreatedAt} THEN excluded.last_seen_id ELSE ${workbenchReadState.lastSeenId} END`,
316316
},
317317
})
318318
.returning();
@@ -467,7 +467,7 @@ export function createInMemoryChatStore(): ChatStore {
467467
const existing = readStateByKey.get(key);
468468
if (
469469
existing !== undefined &&
470-
existing.lastSeenCreatedAt >= input.lastSeenCreatedAt
470+
existing.lastSeenCreatedAt > input.lastSeenCreatedAt
471471
) {
472472
return existing;
473473
}

0 commit comments

Comments
 (0)