refactor(sync): replace message reloads with incremental tail sync

This commit is contained in:
weishu
2026-07-28 12:20:53 +08:00
parent 2235b924a7
commit faf70c64dd
28 changed files with 2927 additions and 2077 deletions
+39 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { ListCodexSessionsRpcResponseSchema } from './apiTypes'
import { ListCodexSessionsRpcResponseSchema, MessagesQuerySchema } from './apiTypes'
describe('ListCodexSessionsRpcResponseSchema', () => {
it('preserves Codex session messages when parsing runner RPC responses', () => {
@@ -29,3 +29,41 @@ describe('ListCodexSessionsRpcResponseSchema', () => {
}
})
})
describe('MessagesQuerySchema', () => {
it('parses a forward cursor with a bounded snapshot and epoch', () => {
expect(MessagesQuerySchema.parse({
afterAt: '1000',
afterSeq: '10',
untilAt: '2000',
untilSeq: '20',
epoch: '3',
limit: '200'
})).toEqual({
afterAt: 1000,
afterSeq: 10,
untilAt: 2000,
untilSeq: 20,
epoch: 3,
limit: 200
})
})
it('rejects mixed before and after directions', () => {
expect(MessagesQuerySchema.safeParse({
beforeAt: 1000,
beforeSeq: 10,
afterAt: 2000,
afterSeq: 20
}).success).toBe(false)
})
it('rejects an unpaired or unscoped until cursor', () => {
expect(MessagesQuerySchema.safeParse({ untilAt: 2000, untilSeq: 20 }).success).toBe(false)
expect(MessagesQuerySchema.safeParse({ afterAt: 1000, afterSeq: 10, untilAt: 2000 }).success).toBe(false)
})
it('rejects epoch without a forward cursor', () => {
expect(MessagesQuerySchema.safeParse({ epoch: 1 }).success).toBe(false)
})
})