Text chat 2: fluxer-proto chat requests and gateway events (#252) #299

Manually merged
charles merged 4 commits from textchat-2-proto-chat-requests-events into textchat 2026-11-12 13:49:37 +00:00
Owner

What this builds

fluxer-proto gains the chat requests and gateway events of Text chat 2 (spec §3.1).

Requests

  • SendMessageRequest gains message_reference, allowed_mentions, flags, attachments, sticker_ids, favorite_meme_id and tts. Each is left off the wire at its default, so a plain send is still {content, nonce} byte for byte.
  • MessageReferenceRequest, AllowedMentions / MentionParse, and AttachmentPayload / AttachmentPayloadId. Ids are sent as decimal strings, as the original sends them.
  • EditMessageRequest { content, flags, attachments, allowed_mentions }: every field is optional and only what changes is sent.
  • Presigned uploads: PresignRequest, PresignResponse (its URLs are SecretStrings and its Debug redacts them) and CompleteUploadsRequest.
  • PinsQuery / PinsPage, ReactionUsersPage, SearchRequest / SearchResponse::{Results, Indexing}, SavedMessage, SaveMessageRequest, MentionsQuery, CreateGroupDmRequest, EditChannelRequest, Channel.nicks, Relationship, the UserSettings accessors and UserSettingsPatch.
  • The request bodies are checked against their OpenAPI request schemas (spec_contract).

Gateway

  • These dispatches are now typed: MESSAGE_REACTION_ADD|ADD_MANY|REMOVE|REMOVE_ALL|REMOVE_EMOJI, CHANNEL_PINS_UPDATE|ACK, CHANNEL_RECIPIENT_ADD|REMOVE, SAVED_MESSAGE_CREATE|DELETE, RECENT_MENTION_DELETE and RELATIONSHIP_ADD|UPDATE|REMOVE.
  • MESSAGE_DELETE_BULK gains guild_id, READY.relationships is typed, and TYPED_DISPATCH_NAMES is updated.
  • Each new event and endpoint has a fixture shaped from the server source. The fixture commit names the server files.

Outside fluxer-proto, only the struct literals and the MESSAGE_DELETE_BULK match in fluxer-api/fluxer-devserver tests, apps/fluxer's runtime and fluxer-core changed, and only as much as needed to compile against the new shapes.

Notes for downstream tasks

  • GatewayEvent::SavedMessageCreate(Box<SavedMessage>): the plan's Interfaces block says SavedMessage, but the payload is boxed to satisfy clippy's large_enum_variant. Field access auto-derefs. To move the payload out (Text chat 15/19), use *saved.
  • Not modelled yet (tracked in #298): AttachmentPayload.duration / waveform (the original sends them for voice messages, MessageAttachmentUtils.ts:35-36) and MessageReferenceRequest.attachment_ids / embed_indices (partial forwards).
  • EditMessageRequest.allowed_mentions is included even though the plan's Interfaces block leaves it out. Spec §3.1 and buildMessageEditRequest (MessageRequestUtils.ts:164-180) both have it. Text chat 11 and 6 can set it.

Testing

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passes locally at 72b970a.

Closes #252

🤖 Generated with Claude Code

## What this builds `fluxer-proto` gains the chat requests and gateway events of Text chat 2 (spec §3.1). **Requests** - `SendMessageRequest` gains `message_reference`, `allowed_mentions`, `flags`, `attachments`, `sticker_ids`, `favorite_meme_id` and `tts`. Each is left off the wire at its default, so a plain send is still `{content, nonce}` byte for byte. - `MessageReferenceRequest`, `AllowedMentions` / `MentionParse`, and `AttachmentPayload` / `AttachmentPayloadId`. Ids are sent as decimal strings, as the original sends them. - `EditMessageRequest { content, flags, attachments, allowed_mentions }`: every field is optional and only what changes is sent. - Presigned uploads: `PresignRequest`, `PresignResponse` (its URLs are `SecretString`s and its `Debug` redacts them) and `CompleteUploadsRequest`. - `PinsQuery` / `PinsPage`, `ReactionUsersPage`, `SearchRequest` / `SearchResponse::{Results, Indexing}`, `SavedMessage`, `SaveMessageRequest`, `MentionsQuery`, `CreateGroupDmRequest`, `EditChannelRequest`, `Channel.nicks`, `Relationship`, the `UserSettings` accessors and `UserSettingsPatch`. - The request bodies are checked against their OpenAPI request schemas (`spec_contract`). **Gateway** - These dispatches are now typed: `MESSAGE_REACTION_ADD|ADD_MANY|REMOVE|REMOVE_ALL|REMOVE_EMOJI`, `CHANNEL_PINS_UPDATE|ACK`, `CHANNEL_RECIPIENT_ADD|REMOVE`, `SAVED_MESSAGE_CREATE|DELETE`, `RECENT_MENTION_DELETE` and `RELATIONSHIP_ADD|UPDATE|REMOVE`. - `MESSAGE_DELETE_BULK` gains `guild_id`, `READY.relationships` is typed, and `TYPED_DISPATCH_NAMES` is updated. - Each new event and endpoint has a fixture shaped from the server source. The fixture commit names the server files. Outside `fluxer-proto`, only the struct literals and the `MESSAGE_DELETE_BULK` match in `fluxer-api`/`fluxer-devserver` tests, `apps/fluxer`'s runtime and `fluxer-core` changed, and only as much as needed to compile against the new shapes. ## Notes for downstream tasks - **`GatewayEvent::SavedMessageCreate(Box<SavedMessage>)`**: the plan's Interfaces block says `SavedMessage`, but the payload is boxed to satisfy clippy's `large_enum_variant`. Field access auto-derefs. To move the payload out (Text chat 15/19), use `*saved`. - **Not modelled yet** (tracked in #298): `AttachmentPayload.duration` / `waveform` (the original sends them for voice messages, `MessageAttachmentUtils.ts:35-36`) and `MessageReferenceRequest.attachment_ids` / `embed_indices` (partial forwards). - **`EditMessageRequest.allowed_mentions`** is included even though the plan's Interfaces block leaves it out. Spec §3.1 and `buildMessageEditRequest` (`MessageRequestUtils.ts:164-180`) both have it. Text chat 11 and 6 can set it. ## Testing `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passes locally at 72b970a. Closes #252 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Gateway fixtures, shaped from the fork's server at ba98441b4:
- message_reaction_add (DM, session_id kept): fluxer_api/src/api/channel/
  services/interaction/MessageReactionService.ts:431-449, dispatched as is by
  ChannelGatewayDispatch.ts:46-50
- message_reaction_add_guild, message_reaction_remove (guild_id added,
  member with user, session_id stripped): fluxer_gateway/src/guild/
  guild_dispatch.erl:91,146-149 and guild_dispatch_decorate.erl:36-46,63-66
- message_reaction_add_many: fluxer_gateway/src/session/
  session_dispatch_voice.erl:157-195
- message_reaction_remove_all / _remove_emoji: MessageReactionService.ts:472-500
- message_delete_bulk: channel/services/message/MessageGatewayDispatch.ts:140-158
- channel_pins_update: channel/services/interaction/MessagePinService.ts:253-262
- channel_pins_ack: read_state/ReadStateService.ts:266-281
- channel_recipient_add / _remove: channel/services/group_dm/
  GroupDmOperationsService.ts:207-216,288-296
- saved_message_create (d is the MessageResponse itself), saved_message_delete,
  recent_mention_delete: user/services/UserContentService.ts:114-123,897-981
- relationship_add: user/services/UserRelationshipService.ts:703-720 via
  user/UserMappers.ts:375-394; relationship_remove ({id} only): :742-748
- message_update_unfurl (full message, member without user):
  guild_dispatch_decorate.erl:36-41

REST fixtures:
- presigned_uploads: channel/services/AttachmentUploadService.ts:228-285
- pins_page: packages/schema/src/domains/message/MessageResponseSchemas.ts:177-194
- reaction_users: MessageResponseSchemas.ts:200-204
- search_results / search_indexing (HTTP 200): MessageResponseSchemas.ts:208-233
- saved_messages: user/services/UserContentRequestService.ts:166-174,
  packages/schema/src/domains/user/UserResponseSchemas.ts:591-614
- mentions: MessageListResponse (MessageResponseSchemas.ts:237)
- relationships: UserMappers.ts:375-394, UserResponseSchemas.ts:492-505
- group_dm: ChannelSchemas.ts (nicks at :105-108)

Refs #252

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Requests: SendMessageRequest gains message_reference, allowed_mentions,
flags, attachments, sticker_ids, favorite_meme_id and tts (all left off the
wire at their default, so a plain send is still {content, nonce} byte for
byte); MessageReferenceRequest, AllowedMentions/MentionParse,
AttachmentPayload/AttachmentPayloadId (ids as decimal strings, as the
original sends them), EditMessageRequest with optional content, flags and
attachments; the presigned upload flow (PresignRequest, PresignResponse with
SecretString URLs and redacting Debug, CompleteUploadsRequest); PinsQuery /
PinsPage; ReactionUsersPage; SearchRequest / SearchResponse::{Results,
Indexing}; SavedMessage, SaveMessageRequest, MentionsQuery;
CreateGroupDmRequest, EditChannelRequest, Channel.nicks; Relationship;
UserSettings accessors and UserSettingsPatch.

Gateway: MESSAGE_REACTION_ADD|ADD_MANY|REMOVE|REMOVE_ALL|REMOVE_EMOJI,
CHANNEL_PINS_UPDATE|ACK, CHANNEL_RECIPIENT_ADD|REMOVE,
SAVED_MESSAGE_CREATE|DELETE, RECENT_MENTION_DELETE,
RELATIONSHIP_ADD|UPDATE|REMOVE typed; MESSAGE_DELETE_BULK gains guild_id;
READY.relationships typed. Request bodies are checked against their OpenAPI
request schemas.

The struct-literal changes in fluxer-api and fluxer-devserver tests,
apps/fluxer's runtime and fluxer-core's MESSAGE_DELETE_BULK match are the
minimum needed to compile against the new shapes.

Refs #252

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
EditMessageRequest gains allowed_mentions (Option, left out when unset),
as the original's buildMessageEditRequest sends it
(fork:fluxer_app/src/features/messaging/utils/MessageRequestUtils.ts:164-180)
and MessageUpdateRequestSchema accepts it (spec §3.1). The spec contract
test now checks the field against spec/openapi.json.

Refs #252

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Author
Owner

Review round 1: what changed for each finding (head 72b970a)

  • Blocking: not pushed and no PR. The branch is now pushed and this PR is open. The head is 010fcba plus one fix commit, 72b970a, so the findings reviewed at 010fcba still apply.
  • Minor: SavedMessageCreate holds Box<SavedMessage>. I kept the code as it is because the box is what clippy's large_enum_variant needs. The PR body now tells downstream tasks to use *saved when they move the payload out.
  • Minor: EditMessageRequest has no allowed_mentions. Fixed in 72b970a. I wrote the test first: edit_request_sends_only_what_changes now covers an edit with allowed_mentions, and spec_contract_new_request_types checks the field against MessageUpdateRequestSchema. The field is an Option and is left out when unset, as in buildMessageEditRequest. The README is updated too.
  • Minor: unmodelled fields (AttachmentPayload.duration/waveform, MessageReferenceRequest.attachment_ids/embed_indices). These are listed in the PR body and deferred to follow-up #298. Adding them now would change every struct-literal constructor, and no planned task needs them yet.

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passes locally.

Review round 1: what changed for each finding (head 72b970a) - **Blocking: not pushed and no PR.** The branch is now pushed and this PR is open. The head is 010fcba plus one fix commit, 72b970a, so the findings reviewed at 010fcba still apply. - **Minor: `SavedMessageCreate` holds `Box<SavedMessage>`.** I kept the code as it is because the box is what clippy's `large_enum_variant` needs. The PR body now tells downstream tasks to use `*saved` when they move the payload out. - **Minor: `EditMessageRequest` has no `allowed_mentions`.** Fixed in 72b970a. I wrote the test first: `edit_request_sends_only_what_changes` now covers an edit with `allowed_mentions`, and `spec_contract_new_request_types` checks the field against `MessageUpdateRequestSchema`. The field is an `Option` and is left out when unset, as in `buildMessageEditRequest`. The README is updated too. - **Minor: unmodelled fields** (`AttachmentPayload.duration`/`waveform`, `MessageReferenceRequest.attachment_ids`/`embed_indices`). These are listed in the PR body and deferred to follow-up #298. Adding them now would change every struct-literal constructor, and no planned task needs them yet. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passes locally.
Author
Owner

Independent review: Text chat 2 (head 72b970a)

Scope: the task's own changes (origin/textchat..72b970a; the rest of 6e2d238.. is the already-reviewed Text chat 1/4/7 merges).

Checks

  1. Plan tests: all 14 named tests exist (plain_send_serialises_like_before … user_settings_accessor_defaults in chat_requests.rs/chat_events.rs, spec_contract_new_request_types in spec_contract.rs) and assert what the plan says: plain send is byte-identical {"content","nonce"}; reply type:0 / forward type:1 + guild_id; allowed_mentions leaves empty lists off; multipart ids "0", "1" as the original's String(index); presigned payload carries upload_filename/file_size/content_type; both upload modes parse and Debug hides the URLs; {indexing:true} with 200 is Indexing; pins before is an ISO timestamp; one fixture per new dispatch; ADD_MANY entries in order with member only where present; guild message event member without user; settings defaults match UserSettings.ts:309-316 and RenderSpoilers wire values match UserConstants.ts:258-262.
  2. Interfaces: every name in the Task 2 Interfaces block exists with the stated fields (SendMessageRequest, MessageReferenceRequest, AllowedMentions, AttachmentPayload/AttachmentPayloadId::{Index,Snowflake}, EditMessageRequest, PresignRequest/PresignItem/PresignResponse/PresignedUpload/UploadMode/UploadPart with SecretString, CompleteUploadsRequest, PinsQuery/PinsPage/PinnedMessage, ReactionUsersPage, SearchRequest/SearchResponse::{Results,Indexing}/SearchResults, SavedMessage, MentionsQuery, CreateGroupDmRequest, EditChannelRequest, Relationship, UserSettingsPatch, the UserSettings accessors, all 16 GatewayEvent variants, ReactionEvent, ReactionAddMany/ReactionAddManyEntry, ReadyPayload.relationships: Vec<Relationship>, Channel.nicks, TYPED_DISPATCH_NAMES).
  3. Invariants: no new dependency (proto Cargo.toml untouched; secrecy was already there); fluxer-core/fluxer-api/devserver/app changes are only the mechanical ..Default::default() / guild_id updates the interface change forces. Fixtures checked against the fork: reaction payloads (MessageReactionService.ts:431-500), member with user on reactions and without on message events (guild_dispatch_decorate.erl:36-66), ADD_MANY (session_dispatch_voice.erl:156-195), CHANNEL_PINS_UPDATE/ACK, CHANNEL_RECIPIENT_ADD, RELATIONSHIP_REMOVE {id}, SAVED_MESSAGE_CREATE = the message, SavedMessageEntryResponse.message nullable. The fixture commit (92bfe2e) names the server file and line for each. Malformed payloads are errors, not panics (tested for all 15 new names). The presigned fixture's URLs are placeholders (*.example.invalid, fake signature), not real ones.
  4. Review Focus 1 (this task's part, the reaction fixtures): MESSAGE_REACTION_ADD (DM with session_id, guild with member), _ADD_MANY, _REMOVE, _REMOVE_ALL, _REMOVE_EMOJI are shaped like the server. They give Text chat 13 what it needs to tell the client's own echo apart (user_id, session_id in DMs).
  5. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a clean review worktree at 72b970a: all steps passed.

Findings

  • minor: GatewayEvent::SavedMessageCreate(Box<SavedMessage>) where the plan says SavedMessageCreate(SavedMessage). Pattern matches downstream work unchanged; code that builds the event (Text chat 15/20 tests, devserver) needs Box::new. The PR body notes this. No change needed.
  • minor: EditMessageRequest has an extra field, allowed_mentions, that the plan does not list. It is additive and correct: spec §3.1 PATCH and buildMessageEditRequest. Downstream code that builds it with ..Default::default() is unaffected.
  • minor: these fields are not modelled: AttachmentPayload.duration/waveform (voice messages, MessageAttachmentUtils.ts:35-36) and MessageReferenceRequest.attachment_ids/embed_indices. They are outside the plan's Interfaces block and tracked in follow-up #298.

No blocking findings.

Verdict: approved (0 blocking, local ci green; remote runners not checked by this review).

## Independent review: Text chat 2 (head 72b970a) Scope: the task's own changes (`origin/textchat..72b970a`; the rest of `6e2d238..` is the already-reviewed Text chat 1/4/7 merges). **Checks** 1. Plan tests: all 14 named tests exist (`plain_send_serialises_like_before` … `user_settings_accessor_defaults` in `chat_requests.rs`/`chat_events.rs`, `spec_contract_new_request_types` in `spec_contract.rs`) and assert what the plan says: plain send is byte-identical `{"content","nonce"}`; reply `type:0` / forward `type:1` + `guild_id`; `allowed_mentions` leaves empty lists off; multipart ids `"0"`, `"1"` as the original's `String(index)`; presigned payload carries `upload_filename`/`file_size`/`content_type`; both upload modes parse and `Debug` hides the URLs; `{indexing:true}` with 200 is `Indexing`; pins `before` is an ISO timestamp; one fixture per new dispatch; `ADD_MANY` entries in order with `member` only where present; guild message event `member` without `user`; settings defaults match `UserSettings.ts:309-316` and `RenderSpoilers` wire values match `UserConstants.ts:258-262`. 2. Interfaces: every name in the Task 2 Interfaces block exists with the stated fields (`SendMessageRequest`, `MessageReferenceRequest`, `AllowedMentions`, `AttachmentPayload`/`AttachmentPayloadId::{Index,Snowflake}`, `EditMessageRequest`, `PresignRequest`/`PresignItem`/`PresignResponse`/`PresignedUpload`/`UploadMode`/`UploadPart` with `SecretString`, `CompleteUploadsRequest`, `PinsQuery`/`PinsPage`/`PinnedMessage`, `ReactionUsersPage`, `SearchRequest`/`SearchResponse::{Results,Indexing}`/`SearchResults`, `SavedMessage`, `MentionsQuery`, `CreateGroupDmRequest`, `EditChannelRequest`, `Relationship`, `UserSettingsPatch`, the `UserSettings` accessors, all 16 `GatewayEvent` variants, `ReactionEvent`, `ReactionAddMany`/`ReactionAddManyEntry`, `ReadyPayload.relationships: Vec<Relationship>`, `Channel.nicks`, `TYPED_DISPATCH_NAMES`). 3. Invariants: no new dependency (proto `Cargo.toml` untouched; `secrecy` was already there); `fluxer-core`/`fluxer-api`/devserver/app changes are only the mechanical `..Default::default()` / `guild_id` updates the interface change forces. Fixtures checked against the fork: reaction payloads (`MessageReactionService.ts:431-500`), member with `user` on reactions and without on message events (`guild_dispatch_decorate.erl:36-66`), `ADD_MANY` (`session_dispatch_voice.erl:156-195`), `CHANNEL_PINS_UPDATE`/`ACK`, `CHANNEL_RECIPIENT_ADD`, `RELATIONSHIP_REMOVE {id}`, `SAVED_MESSAGE_CREATE` = the message, `SavedMessageEntryResponse.message` nullable. The fixture commit (92bfe2e) names the server file and line for each. Malformed payloads are errors, not panics (tested for all 15 new names). The presigned fixture's URLs are placeholders (`*.example.invalid`, fake signature), not real ones. 4. Review Focus 1 (this task's part, the reaction fixtures): `MESSAGE_REACTION_ADD` (DM with `session_id`, guild with `member`), `_ADD_MANY`, `_REMOVE`, `_REMOVE_ALL`, `_REMOVE_EMOJI` are shaped like the server. They give Text chat 13 what it needs to tell the client's own echo apart (`user_id`, `session_id` in DMs). 5. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a clean review worktree at 72b970a: **all steps passed**. **Findings** - *minor*: `GatewayEvent::SavedMessageCreate(Box<SavedMessage>)` where the plan says `SavedMessageCreate(SavedMessage)`. Pattern matches downstream work unchanged; code that builds the event (Text chat 15/20 tests, devserver) needs `Box::new`. The PR body notes this. No change needed. - *minor*: `EditMessageRequest` has an extra field, `allowed_mentions`, that the plan does not list. It is additive and correct: spec §3.1 PATCH and `buildMessageEditRequest`. Downstream code that builds it with `..Default::default()` is unaffected. - *minor*: these fields are not modelled: `AttachmentPayload.duration/waveform` (voice messages, `MessageAttachmentUtils.ts:35-36`) and `MessageReferenceRequest.attachment_ids/embed_indices`. They are outside the plan's Interfaces block and tracked in follow-up #298. No blocking findings. **Verdict: approved** (0 blocking, local ci green; remote runners not checked by this review).
charles manually merged commit 75adadb616 into textchat 2026-11-12 13:49:37 +00:00
Sign in to join this conversation.
No description provided.