Skip to content

exploration: add typed client event API#15

Draft
wouter173 wants to merge 2 commits into
mainfrom
feat/issue-8-make-event-api
Draft

exploration: add typed client event API#15
wouter173 wants to merge 2 commits into
mainfrom
feat/issue-8-make-event-api

Conversation

@wouter173

Copy link
Copy Markdown
Owner

Summary

  • add a typed makeEvent API for joined-room sync events
  • decode and refine custom event content before invoking handlers
  • route MatrixClient.onEvent through event definitions instead of raw sync-frame predicates
  • update the client example and add runtime/type-inference coverage

Verification

  • full workspace TypeScript typecheck
  • formatting check
  • 74 package tests
  • diff whitespace check

Closes #8

@wouter173 wouter173 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread packages/mxfx/src/client/event.ts Outdated
const state = room.stateAfter?.events ?? room.state?.events ?? []
const timeline = room.timeline?.events ?? []

return [...state, ...timeline].map(event => ({ ...event, roomId: roomId as RoomId }))

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@wouter173
wouter173 marked this pull request as draft July 17, 2026 09:01
@wouter173 wouter173 changed the title feat: add typed client event API [reference] feat: add typed client event API Jul 17, 2026
@wouter173 wouter173 changed the title [reference] feat: add typed client event API [insipration] feat: add typed client event API Jul 17, 2026
@wouter173 wouter173 added the exploration AI made pr and implementation prompted with limited knowledge to explore possible implementations label Jul 17, 2026
@wouter173 wouter173 changed the title [insipration] feat: add typed client event API exploration: add typed client event API Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exploration AI made pr and implementation prompted with limited knowledge to explore possible implementations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

makeEvent api

1 participant