exploration: add typed client event API#15
Conversation
wouter173
left a comment
There was a problem hiding this comment.
Review summary: the typed makeEvent API, schema-failure filtering, public export, inference coverage, and example are well structured. One correctness issue remains in joined-room extraction: state events duplicated between state_after and timeline are delivered twice. Please deduplicate merged events by eventId and add a regression test. Focused makeEvent tests pass (3/3).
| const state = room.stateAfter?.events ?? room.state?.events ?? [] | ||
| const timeline = room.timeline?.events ?? [] | ||
|
|
||
| return [...state, ...timeline].map(event => ({ ...event, roomId: roomId as RoomId })) |
There was a problem hiding this comment.
[P1] Deduplicate state_after against timeline events. With use_state_after=true, state_after covers updates through the end of the timeline, so a state event can also be present in timeline. Concatenating both arrays invokes the subscription callback twice for the same event. Please deduplicate the merged events by eventId (while retaining timeline-only/intermediate events) and add a regression test with the same state event in both arrays.
There was a problem hiding this comment.
Fixed in 4bf911b. joinedRoomEvents now deduplicates per room by first occurrence of eventId across the selected state source followed by the timeline. This preserves the existing state-before-timeline order, gives the state copy precedence when an event appears in both, and retains timeline-only/intermediate events. The regression uses a conflicting duplicate payload to verify precedence; focused tests pass 4/4 and the full package suite passes 75/75.
Summary
Verification
Closes #8