Text chat 20: devserver textchat scenario (#270) #305
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "textchat-20-devserver-textchat"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on: origin/textchat-2-proto-chat-requests-events, origin/textchat-3-proto-expressions-threads-prefs
What this builds
The
textchatscenario offluxer-devserver(Text chat spec §12, plan Task 20):fixtures/gateway/textchat_ready.json(guild with a still and an animated custom emoji, two stickers, thethreadskey with two threads (one archived), a read-only #announcements, the DM with ada and the group DM "Weekend plans", friends, a pending request and a block) andfixtures/textchat/history.json(1-10 image mosaics, alt text, spoiler, video, audio, files, an expired attachment, every embed type plus link, both stickers, a forward, a reply and a reply to a deleted message, pin/join/thread-created system messages, reactions, a thread starter, DM and group DM history). Everything is copied from the server-shaped Text chat 1-3 fixtures; the commit message cites the server files and lines.payload_json+files[n]), the presigned flow (PUTto a local URL that refuses anAuthorizationheader, multipart parts, complete;presigned = truealso flips the discovery feature), edit/delete, reactions (MESSAGE_REACTION_ADD; a scriptedMESSAGE_REACTION_ADD_MANYviaChatScript::trigger("reaction-burst"), also timed at 5 s), pins (CHANNEL_PINS_UPDATE, type 6 system message,MESSAGE_UPDATE, in the server's order), search ({indexing: true}HTTP 200 on the first search of a scope, then substring results), bookmarks, mentions, group DMs and recipients (+ system messages), relationships, settings (USER_SETTINGS_UPDATE), saved media, guild emoji/stickers, GIFs from fixtures, threads, refresh-urls, and an unfurlMESSAGE_UPDATE(whole message) 1 s after a sent link. Errors use the fork's codes (CANNOT_SEND_EMPTY_MESSAGE,INVALID_FORM_BODY+errors[].code,FILE_SIZE_TOO_LARGE,MISSING_PERMISSIONS,MAX_REACTIONS,CANNOT_MODIFY_SYSTEM_WEBHOOK,NOT_FRIENDS_WITH_USER,FEATURE_TEMPORARILY_DISABLED, ...). Message events carryguild_idandmemberwithoutuser./emoji/{cp}.svgand/media/emoji/{cp}.svg(drawn SVG),/media/emojis/{id}.webpand/media/stickers/{id}.webp(animated only when the expression is andanimated=true),/media/attachments/{c}/{a}/{name}(uploaded bytes, else a picture of the attachment's aspect ratio encoded as its extension, a WAV tone for audio, filler for other types),/media/external/....extends = "<scenario>"in scenario files;textchat_presigned.tomlistextchatwithpresigned = true.How it was tested
crates/fluxer-devserver/tests/textchat.rs(written first, seen failing, then passing):multipart_send_stores_attachments_and_echoes,presigned_flow_put_complete_send,presign_is_refused_when_the_instance_does_not_offer_it,attachment_limits_enforced,reaction_put_emits_event_and_add_many_script,pin_emits_three_events,search_indexing_then_results,unfurl_update_after_link,group_dm_recipient_events,twemoji_svg_served,scenario_fixtures_parse_with_proto_types, plusedit_delete_save_and_thread_endpointsandreplies_forwards_stickers_and_saved_media. Every REST answer and gateway event is read through thefluxer-prototypes.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally (Linux). Smoke-ranfluxer-devserver --scenario textchat_presigned. No desktop-only tests in this task.Deviations from the plan
fixtures/textchat/history.json(the showcase history;fixtures/restis reserved for model round-trip fixtures),fixtures/scenarios/textchat_presigned.toml,src/voice.rs(the guild permission computation is nowVoice::guild_permissions, shared by the chat checks; STREAM logic unchanged),Cargo.tomldev-dependencyreqwest(already a workspace dependency; no new crate). The chat HTTP handlers are achat_routesmodule insidehttp.rs.reqwest, asfluxer-apidoes not have the Text chat 5/6 calls on this base yet.fluxer-proto(dispatch name lists and counts 62/24,models/mod.rs,settings.rsaccessors of both, README,models_roundtrip.rslists);cargo xtask ciwas green on that base before any code of this task.Closes #270
🤖 Generated with Claude Code
Failing tests for Text chat 3 (expressions.rs, threads.rs, prefs.rs) and the fixtures they read, each shaped from the fork at ba98441b4: - gateway/guild_emojis_update.json, guild_stickers_update.json: fluxer_api/src/api/guild/services/content/EmojiService.ts:301-307 and StickerService.ts:342-348 ({emojis}/{stickers} via mapGuildEmojiToResponse / mapGuildStickerToResponse, guild/GuildModel.ts:98-118), guild_id added by fluxer_gateway/src/guild/guild_dispatch.erl:91. - gateway/thread_create.json, thread_update.json, thread_delete.json, thread_members_update.json, thread_member_update.json: fluxer_api/src/api/channel/services/thread/ThreadDispatch.ts:26-93 (thread object from ThreadMappers.ts:42-92); the internal _fluxer_* keys are stripped by guild_dispatch.erl:131-136 / guild_thread_payload.erl:139-146. - gateway/thread_list_sync.json: fluxer_gateway/src/guild/guild_thread_view.erl:100-123. - gateway/favorite_meme_create.json, favorite_meme_delete.json: fluxer_api/src/api/favorite_meme/FavoriteMemeService.ts:213-218, 454-458 and FavoriteMemeModel.ts:9-32. - gateway/user_settings_update_prefs.json: fluxer_api/src/api/user/services/UserAccountUpdatePropagator.ts:17-23, user/UserMappers.ts:296-375. - rest/guild_emojis.json, guild_stickers.json: GuildEmojiController.ts:111-133 (GuildEmojiWithUserResponse, packages/schema/src/domains/guild/GuildEmojiSchemas.ts:9-39). - rest/gifs_featured.json, gifs_search.json: packages/schema/src/domains/gif/GifSchemas.ts:36-88, fluxer_gifs/src/types.rs:70-100 (placeholder left out when absent). - rest/memes.json: FavoriteMemeModel.ts:9-32 (nullable fields written as null). - rest/thread_created.json: ThreadController.ts:134-169 (201 ThreadChannelResponse), ThreadMappers.ts:19-41 (own member: muted, mute_config null), 58-92. - prefs/synced_preferences.b64: encoded by the fork's own protobuf-es encoder (packages/schema/src/gen/fluxer/user/preferences/v1/*_pb.ts, packages/schema/src/domains/user/SyncedPreferencesCodec.ts), run read-only; how is in fixtures/prefs/README.md. Refs #253 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>READY and channel history of the `textchat` scenario, built from the server-shaped fixtures of Text chat 1-3 (only ids, channels, authors and hosts change): - gateway/textchat_ready.json: fixtures/gateway/ready.json with the guild's emojis/stickers (rest/guild_emojis.json, rest/guild_stickers.json without the uploader), the `threads` key the gateway adds per guild (fluxer_gateway/src/guild/guild_data.erl:127) holding two ThreadChannelResponse objects (rest/thread_created.json; packages/schema/src/domains/channel/ThreadSchemas.ts:62), a group DM (rest/group_dm.json; ChannelSchemas.ts:51-105, `nicks`), and READY relationships with the user's id only (RelationshipResponse, packages/schema/src/domains/user/UserResponseSchemas.ts:492). - textchat/history.json: MessageResponseSchema messages (packages/schema/src/domains/message/MessageResponseSchemas.ts:122-172; attachments :23-47, references :51, snapshots :90) copied from rest/message_{attachments,embeds,sticker,forward,reply,system_pin, reactions,thread}.json and gateway/message_update_unfurl.json. - scenarios/textchat.toml, textchat_presigned.toml (extends textchat). Refs #270 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>The devserver serves text chat (Text chat spec §12): sending as JSON or multipart (payload_json + files[n]) and the presigned upload flow (PUT to a local URL without a token, parts, complete; switched by `presigned`, which also sets the discovery feature), edits and deletes, reactions (MESSAGE_REACTION_ADD, scripted MESSAGE_REACTION_ADD_MANY), pins (CHANNEL_PINS_UPDATE + system message + MESSAGE_UPDATE), search ({indexing: true} on the first search of a scope, then substring results), bookmarks, mentions, group DMs and recipients, relationships, settings, saved media, guild emoji/stickers, GIFs, threads, and an unfurl MESSAGE_UPDATE after a sent link; each with the server's validation (limits, permissions, empty message, 30 reactions, pin types). Media: Twemoji SVGs, custom emoji and sticker WebPs, attachments (uploaded bytes or drawn by size and type) and proxied embed media. Refs #270 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>Independent review: Text chat 20 (devserver textchat)
Scope:
cb35156..f3f9e90(commits8609ab3andf3f9e90). I also checked the stacked mergecb35156, as the implementer asked.Plan tests (1). All ten tests the plan names are in
tests/textchat.rs, along with 3 extra ones, and they assert the spec's values: 10 files max (FILE_INDEX_EXCEEDS_MAXIMUM); 25 MiB + 1 refused on both upload paths; empty message (CANNOT_SEND_EMPTY_MESSAGE); 2001 UTF-16 units (CONTENT_EXCEEDS_MAX_LENGTH); 30 distinct reactions (MAX_REACTIONS); a pin of a system message refused (CANNOT_MODIFY_SYSTEM_WEBHOOK, i.e.CannotEditSystemMessageError); the pin events in the order CHANNEL_PINS_UPDATE → type-6 MESSAGE_CREATE → MESSAGE_UPDATEpinned:true(matchesMessagePinService.ts:144-146);{indexing:true}with HTTP 200 on the first search, then substring results; the unfurl arriving 900 ms or more later as a full MESSAGE_UPDATE with a link embed; a presigned PUT with auth refused; a multipart send refused beforecomplete; presign answering 403FEATURE_TEMPORARILY_DISABLEDwhen the flag is off (matchesAttachmentUploadService.ts:188); Twemoji SVG plus emoji/sticker WebPs (animated and still), attachments andexternal/all served.Interfaces (2). The scenario
textchat(andtextchat_presigned,presigned = true, which also flips the discovery feature) contains everything the plan lists: emoji (still and animated), 2 stickers, thethreadskey with 2 threads, 1–10 image mosaics, video, audio, file, spoiler, alt text, an expired attachment, every embed type, a sticker, a forward, a reply and a reply to a deleted message, pin, join and thread system messages, the scriptedMESSAGE_REACTION_ADD_MANY, pins, a group DM, relationships, saved messages, memes and GIFs. The media paths match the spec.Invariants (3). Only
fluxer-devserver(plus fixtures) changed. No new non-dev dependency;reqwestis a dev-dependency that was already in the workspace. Fixtures contain no tokens, signed URLs or local paths;fluxer.forked.iohosts are rewritten to the devserver. The new code adds no logging of upload URLs; the only new log line is a warn on a failed scripted step. The ADD_MANY shape{channel_id, message_id, guild_id?, reactions:[{user_id, emoji, member?}]}and sending a lone entry as MESSAGE_REACTION_ADD both matchsession_dispatch_voice.erl:150-195. Guild message events carrymemberwithoutuser. The fixture commit names its server sources.Review Focus #4. Multipart parsing (
payload_json,files[n]/legacyfile, id mapping) followsMessageRequestParser.ts. Presigned: singlepart up to 10 MiB, multipart part size fromresolveAttachmentUploadPartSize, PUT without auth, completion required. Correct.Stacked merge
cb35156. Every line either parent added to the 7 conflicted files is in the result, apart from the expected count, import-list and doc-comment rewrites. The totals are consistent: 62 typed + 24 untyped = 86, as in each parent (51+35, 47+39). I found no lost hunks.CI (5).
cargo xtask ciin a fresh review worktree: green (EXIT 0;tests/textchat.rs13/13 pass).Findings
search.rs: "indexed" is tracked per sorted channel set rather than per channel, so a search over[A,B]after one over[A]answers{indexing:true}again. The scope-less search also covers channels the user cannot view (e.g. no VIEW_CHANNEL). Harmless for the client tests, but it differs a little from the spec's "first search per channel".voice.rs:Voice::guild_permissionstakes the voice lock while chat holds the World lock (World → Voice). This is safe today because no voice path takes the World lock. A comment on the lock order would keep it that way.No blocking findings.
Verdict: APPROVE (0 blocking, 2 minor; local CI green; the remote runners are left to the integrator).