Fix app stream/timeline ordering desync and init lifecycle race (#73)

* fix(app): enforce canonical stream sequencing and init resolution

* refactor: extract timeline and stream reducers to pure functions
This commit is contained in:
Mohamed Boudra
2026-02-23 19:30:48 +07:00
committed by GitHub
parent 9b6f5e028c
commit a134132418
12 changed files with 1732 additions and 109 deletions
@@ -0,0 +1,26 @@
import { describe, expect, it } from "vitest";
import { __private__ } from "./use-agent-initialization";
describe("useAgentInitialization timeline request policy", () => {
it("uses canonical tail bootstrap when cursor is missing", () => {
expect(__private__.buildInitialTimelineRequest(undefined)).toEqual({
direction: "tail",
limit: 200,
projection: "canonical",
});
});
it("uses canonical catch-up after the current cursor when present", () => {
expect(
__private__.buildInitialTimelineRequest({
epoch: "epoch-1",
endSeq: 42,
})
).toEqual({
direction: "after",
cursor: { epoch: "epoch-1", seq: 42 },
limit: 0,
projection: "canonical",
});
});
});