Matrix threads in the transport (M2.1, PR A) #96

Merged
dongar merged 1 commits from matrix-threads into main 2026-10-03 16:42:40 +00:00
Collaborator

M2.1, PR A of 4: Matrix threads in the transport (architecture L5: each work item's conversation is a thread).

Changes

  • Transport.post(text, *, thread=None) -> event_id. A top-level post's ID can root a thread. A threaded post carries m.relates_to: {rel_type: m.thread, event_id: root}, plus the standard reply fallback, so clients without thread support still show it as a reply.
  • InboundMessage gains event_id and thread, the root, or None at top level.
    • A message in a thread gives its root.
    • A plain reply from a client without threads joins the thread of the message it replies to, when the transport knows it: one it sent, or one it has seen. It remembers the last 2,000 events.
    • A rich reply's quoted lines (> <@x> …) are stripped from the text: they aren't what the sender said.
  • InMemoryTransport plays threads: post returns IDs, and receive(..., thread=).
  • Unchanged: send_message and friends stay for the old loop, now built on post. The old loop ignores threads.

Tests

  • Unit:
    • a threaded post's relation;
    • a threaded message's root;
    • plain replies joining threads, with the quote stripped;
    • a reply to an unknown message staying at top level;
    • a reply to the operator's own threaded message;
    • the in-memory fake.
  • Live, test_matrix_live: the homeserver accepts the relation and lists the reply under its root, through the v1 relations API.

559 unit and 20 integration tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE

M2.1, **PR A of 4: Matrix threads in the transport** (architecture L5: each work item's conversation is a thread). ## Changes - **`Transport.post(text, *, thread=None) -> event_id`.** A top-level post's ID can root a thread. A threaded post carries `m.relates_to: {rel_type: m.thread, event_id: root}`, plus the standard reply fallback, so clients without thread support still show it as a reply. - **`InboundMessage`** gains `event_id` and `thread`, the root, or None at top level. - **A message in a thread** gives its root. - **A plain reply** from a client without threads joins the thread of the message it replies to, when the transport knows it: one it sent, or one it has seen. It remembers the last 2,000 events. - **A rich reply's quoted lines** (`> <@x> …`) are stripped from the text: they aren't what the sender said. - **`InMemoryTransport`** plays threads: `post` returns IDs, and `receive(..., thread=)`. - **Unchanged:** `send_message` and friends stay for the old loop, now built on `post`. The old loop ignores threads. ## Tests - **Unit:** - a threaded post's relation; - a threaded message's root; - plain replies joining threads, with the quote stripped; - a reply to an unknown message staying at top level; - a reply to the operator's own threaded message; - the in-memory fake. - **Live, `test_matrix_live`:** the homeserver accepts the relation and lists the reply under its root, through the v1 relations API. 559 unit and 20 integration tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
dev-agent added 1 commit 2026-10-02 23:40:25 +00:00
Matrix threads in the transport (M2.1, PR A)
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m47s
6dff36f458
Transport.post(text, thread=...) returns the event ID, which can root a
thread; a threaded post carries m.thread with the reply fallback for
clients without threads. Inbound messages carry their event ID and thread
root: a message in a thread gives its root, a plain reply joins the
thread of the message it replies to when known, and the quoted lines of a
rich reply are no longer part of the text. The in-memory transport plays
threads for tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPQ14L3LikyefCMFBqEbKE
dongar approved these changes 2026-10-03 16:42:36 +00:00
dongar merged commit 64273557d3 into main 2026-10-03 16:42:40 +00:00
dongar deleted branch matrix-threads 2026-10-03 16:42:40 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dev/nisse#96