Subscribe to guild member lists (op 14) so other members and presences show #197

Manually merged
charles merged 0 commits from fix-member-list into main 2026-11-12 05:11:47 +00:00
Owner

Stacked on: #192 (fix-live-protocol, itself on #189). Merge those first; this PR's diff against main includes them until then.

Symptom

On a real instance the member list showed only the logged-in user. The real server puts only the session's own member (and the members in voice) into READY.guilds[].members / GUILD_CREATE, and guilds[].presences is always empty; everyone else arrives only in GUILD_MEMBER_LIST_UPDATE after the client subscribes with op 14. The client never subscribed, and its fixtures put every member into READY.

What the original does (fork citations)

  • Subscribe payload, op 14 LAZY_REQUEST (fluxer_app/src/features/gateway/transport/GatewaySocket.ts:669-673, types in GatewaySubscriptionLedger.ts:3-12):
    • on guild select, once per gateway session: {subscriptions: {<guild>: {active: true, sync: true}}} (GatewayGuildSubscriptionSynchronizer.ts:29-50, called from GatewaySessionPool.ts:112,364-370 and guild/events/GuildCreate.ts:90-100; flushed again when the connection is ready, PooledGatewayConnection.ts:918-933);
    • when the member list of a guild channel is shown: {<guild>: {active: true, sync: true (first time per session), member_list_channels: {<channel>: [[0, 99]]}}} (member/state/MemberSidebar.ts:975-1015, member/hooks/useMemberListSubscription.ts:33,51-350), widened by scroll position (channel/components/ChannelMembers.tsx:279-314) and resent after every reconnect (useMemberListSubscription.ts:310-321, MemberSidebar.ts:839-843). No explicit unsubscribe on channel/guild switch: the server keeps one member list per session (fluxer_gateway/src/session/session_guilds.erl:79-157, guild/guild_member_list_subscribe.erl:57-71).
    • members: [...] (presence subscriptions) only for open profiles (presence/state/MemberPresenceSubscription.ts).
  • Answer: GUILD_MEMBER_LIST_UPDATE {guild_id, id, channel_id, member_count, online_count, groups: [{id, count}], ops: [{op: "SYNC", range, items: [{group} | {member}]}]} — only SYNC exists (guild/guild_member_list_read.erl:114-165,369-371,443-473; client drops other ops, guild/events/GuildMemberListUpdate.ts:63-99). Sent once after the subscription (guild/guild_subscription_handler.erl:330-356) and the whole subscribed ranges again on every change (guild_dispatch_member_list.erl, guild_member_list_sync_batch.erl). Groups: hoisted roles by hoist position, online, offline (guild_member_list_groups.erl); offline group hidden above 1,000 (guild_member_list_read.erl:489-503).
  • Id-only conventions: a member row's member.user is full; its presence is the full presence (user included) when visible online, and {"status":"offline","mobile":false,"afk":false} without user otherwise (guild_member_list_connected.erl:24-44,86-104, presence/presence_payload.erl).
  • GUILD_SYNC: the guild ready object again after sync/an active switch (guild/guild_unified_subscriptions.erl:194-204, guild_sessions_passive.erl:60-80).
  • Guild PRESENCE_UPDATEs go only to sessions that named the user in members (guild/guild_presence.erl:162-215); guild members' presences otherwise come only in the member list.
  • GUILD_MEMBERS_CHUNK answers op 8 only; the web app does not use it for the member list.

Changes

  • fluxer-proto: gateway::member_list: LazyRequest/GuildSubscription/MemberListRange (op 14), GatewayEvent::GuildMemberListUpdate with MemberListGroup, MemberListOp::{Sync, Unknown}, MemberListItem::{Group, Member, Unreadable} (an unreadable row keeps its slot), MemberListPresence (user optional). GatewayEvent::GuildSync. Fixture fixtures/gateway/guild_member_list_update.json, tests tests/member_list.rs.
  • fluxer-core: MemberLists (app.member_lists): sends op 14 as above while the gateway session is live (again after READY/RESUMED), keeps the server list of the channel subscribed last per guild, widens the ranges to cover the whole list up to 10 ranges (1,000 rows). selectors::members::member_list uses it (groups, order, MemberGroup::count); without an answer it falls back to what READY had. Member rows fill Users, PresenceState and the guild's members. GUILD_CREATE/GUILD_SYNC now add their (partial) members instead of replacing them. Replay test checks member-list rows.
  • fluxer-ui: the group header shows the server's count (MemberGroupModel::count).
  • fluxer-devserver: READY and timeline GUILD_CREATEs carry only the signed-in member and no guild presences; op 14 is answered with GUILD_MEMBER_LIST_UPDATE laid out like the server's; a timeline PRESENCE_UPDATE resends the list. New end-to-end test apps/fluxer/tests/runtime.rs::the_member_list_arrives_after_subscribing (fails without the subscription).

Screenshot goldens: unchanged and pixel-identical; the basic scenario now also applies the member-list fixture and renders the same groups.

Also depends on a subscription the client does not send / handle

  • Guilds with more than 250 members are passive unless op 14 made them active: they get no MESSAGE_CREATE (except mentions), no typing and member events, only PASSIVE_UPDATES, which is not handled → #196. The selected guild is made active here.
  • Member lists longer than 1,000 rows need scroll-windowed ranges → #195.
  • Guild PRESENCE_UPDATE needs members: [...] (the web app uses it only for open profiles); presences of members not in a loaded list row are unknown (shown offline).
  • Thread subscriptions (threads, thread_member_lists) are not sent; threads are not modelled.

🤖 Generated with Claude Code

Stacked on: #192 (`fix-live-protocol`, itself on #189). Merge those first; this PR's diff against `main` includes them until then. ## Symptom On a real instance the member list showed only the logged-in user. The real server puts only the session's own member (and the members in voice) into `READY.guilds[].members` / `GUILD_CREATE`, and `guilds[].presences` is always empty; everyone else arrives only in `GUILD_MEMBER_LIST_UPDATE` after the client subscribes with op 14. The client never subscribed, and its fixtures put every member into `READY`. ## What the original does (fork citations) - Subscribe payload, op 14 `LAZY_REQUEST` (`fluxer_app/src/features/gateway/transport/GatewaySocket.ts:669-673`, types in `GatewaySubscriptionLedger.ts:3-12`): - on guild select, once per gateway session: `{subscriptions: {<guild>: {active: true, sync: true}}}` (`GatewayGuildSubscriptionSynchronizer.ts:29-50`, called from `GatewaySessionPool.ts:112,364-370` and `guild/events/GuildCreate.ts:90-100`; flushed again when the connection is ready, `PooledGatewayConnection.ts:918-933`); - when the member list of a guild channel is shown: `{<guild>: {active: true, sync: true (first time per session), member_list_channels: {<channel>: [[0, 99]]}}}` (`member/state/MemberSidebar.ts:975-1015`, `member/hooks/useMemberListSubscription.ts:33,51-350`), widened by scroll position (`channel/components/ChannelMembers.tsx:279-314`) and resent after every reconnect (`useMemberListSubscription.ts:310-321`, `MemberSidebar.ts:839-843`). No explicit unsubscribe on channel/guild switch: the server keeps one member list per session (`fluxer_gateway/src/session/session_guilds.erl:79-157`, `guild/guild_member_list_subscribe.erl:57-71`). - `members: [...]` (presence subscriptions) only for open profiles (`presence/state/MemberPresenceSubscription.ts`). - Answer: `GUILD_MEMBER_LIST_UPDATE {guild_id, id, channel_id, member_count, online_count, groups: [{id, count}], ops: [{op: "SYNC", range, items: [{group} | {member}]}]}` — only `SYNC` exists (`guild/guild_member_list_read.erl:114-165,369-371,443-473`; client drops other ops, `guild/events/GuildMemberListUpdate.ts:63-99`). Sent once after the subscription (`guild/guild_subscription_handler.erl:330-356`) and the whole subscribed ranges again on every change (`guild_dispatch_member_list.erl`, `guild_member_list_sync_batch.erl`). Groups: hoisted roles by hoist position, `online`, `offline` (`guild_member_list_groups.erl`); offline group hidden above 1,000 (`guild_member_list_read.erl:489-503`). - Id-only conventions: a member row's `member.user` is full; its `presence` is the full presence (user included) when visible online, and `{"status":"offline","mobile":false,"afk":false}` **without user** otherwise (`guild_member_list_connected.erl:24-44,86-104`, `presence/presence_payload.erl`). - `GUILD_SYNC`: the guild ready object again after `sync`/an active switch (`guild/guild_unified_subscriptions.erl:194-204`, `guild_sessions_passive.erl:60-80`). - Guild `PRESENCE_UPDATE`s go only to sessions that named the user in `members` (`guild/guild_presence.erl:162-215`); guild members' presences otherwise come only in the member list. - `GUILD_MEMBERS_CHUNK` answers op 8 only; the web app does not use it for the member list. ## Changes - **fluxer-proto**: `gateway::member_list`: `LazyRequest`/`GuildSubscription`/`MemberListRange` (op 14), `GatewayEvent::GuildMemberListUpdate` with `MemberListGroup`, `MemberListOp::{Sync, Unknown}`, `MemberListItem::{Group, Member, Unreadable}` (an unreadable row keeps its slot), `MemberListPresence` (`user` optional). `GatewayEvent::GuildSync`. Fixture `fixtures/gateway/guild_member_list_update.json`, tests `tests/member_list.rs`. - **fluxer-core**: `MemberLists` (`app.member_lists`): sends op 14 as above while the gateway session is live (again after `READY`/`RESUMED`), keeps the server list of the channel subscribed last per guild, widens the ranges to cover the whole list up to 10 ranges (1,000 rows). `selectors::members::member_list` uses it (groups, order, `MemberGroup::count`); without an answer it falls back to what READY had. Member rows fill `Users`, `PresenceState` and the guild's members. `GUILD_CREATE`/`GUILD_SYNC` now add their (partial) members instead of replacing them. Replay test checks member-list rows. - **fluxer-ui**: the group header shows the server's count (`MemberGroupModel::count`). - **fluxer-devserver**: READY and timeline `GUILD_CREATE`s carry only the signed-in member and no guild presences; op 14 is answered with `GUILD_MEMBER_LIST_UPDATE` laid out like the server's; a timeline `PRESENCE_UPDATE` resends the list. New end-to-end test `apps/fluxer/tests/runtime.rs::the_member_list_arrives_after_subscribing` (fails without the subscription). Screenshot goldens: unchanged and pixel-identical; the basic scenario now also applies the member-list fixture and renders the same groups. ## Also depends on a subscription the client does not send / handle - Guilds with more than 250 members are passive unless op 14 made them active: they get no `MESSAGE_CREATE` (except mentions), no typing and member events, only `PASSIVE_UPDATES`, which is not handled → #196. The selected guild is made active here. - Member lists longer than 1,000 rows need scroll-windowed ranges → #195. - Guild `PRESENCE_UPDATE` needs `members: [...]` (the web app uses it only for open profiles); presences of members not in a loaded list row are unknown (shown offline). - Thread subscriptions (`threads`, `thread_member_lists`) are not sent; threads are not modelled. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Solve the fork's ALTCHA captcha in fluxer-api
All checks were successful
ci / Linux (x86_64) (push) Successful in 16m3s
ci / Windows (x64) (push) Successful in 16m12s
d281e073da
A 400 CAPTCHA_REQUIRED / INVALID_CAPTCHA carrying an ALTCHA v2 challenge
is now solved by the client (PBKDF2-HMAC-SHA-256 over nonce || counter_be32,
counters from 0 until the key starts with keyPrefix) and the same request is
sent again with X-Captcha-Token, at most twice per request, as the web
app's CaptchaInterceptor does for every request. The search runs in
spawn_blocking on up to 8 threads, bounded by 60 s and the challenge's
expiry, and stops when the request is dropped. The token is byte for byte
the web client's encoding.

ApiError::CaptchaRequired is left for captchas the client cannot solve
(unknown provider, malformed challenge, timeout, both solutions refused);
INVALID_CAPTCHA maps to it instead of a plain 400 that the core read as
wrong credentials. The login screen's message says so.

Test vector fixtures/captcha/altcha_login.json was produced by the fork's
own AltchaProvider; the API tests run against a mock that verifies tokens
the way the fork does. Adds ring (already in the graph via rustls) as a
direct dependency of fluxer-api.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`threads` was logged before the cap of 8 (the web app's MAX_SOLVER_WORKERS)
that `solve` applies, so a 32-core machine logged threads=32 while 8 ran.
Clamp before logging; behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read READY as a real Fluxer server sends it
All checks were successful
ci / Linux (x86_64) (push) Successful in 14m30s
ci / Windows (x64) (push) Successful in 15m57s
3bf4ee7931
The server deduplicates users in READY: guilds[].members[].user is
{"id"} only and the full users are in the top-level `users` list
(session_ready_collect.erl). fluxer-proto required a full user on every
member, so a real READY failed to parse as a whole and the client showed
no guilds, no DMs and "Unknown User".

- fluxer-proto: `UserRef` (full user or `{"id"}` reference) for
  GuildMember::user, Presence::user (the offline PRESENCE_UPDATE sent when
  a friend/group-DM subscription is dropped) and GUILD_MEMBER_REMOVE's
  user (always a reference). `ReadyPayload::resolve_users()` fills the
  references from `users` and `user`.
- Every list of ReadyPayload / GuildReadyData is read leniently: a
  malformed entry is dropped with a warning instead of losing the
  session; a malformed guild object leaves `properties: None`. Adds
  `tracing` to fluxer-proto for that warning.
- fluxer-core: members and presences that are references add nothing to
  the user cache; names come from READY.users, unknown users show as
  Unknown User.
- fixtures/gateway/ready.json now has the real structure (member user
  references, `users` with every member, relationships without `user`,
  empty guild presences, sessions/version/...), with the same fake
  identities. The devserver resolves it before indexing message authors.
- tests/replay.rs in fluxer-core: with FLUXER_REPLAY_DIR set, replays a
  --record recording through the parsers and the store and reports
  mismatches by key path and redacted error only; skipped otherwise.
- Regression tests: references resolved via `users`, an unknown member
  user id kept, malformed members/channels/users/guilds dropped without
  failing READY, references in GUILD_MEMBER_REMOVE and PRESENCE_UPDATE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Subscribe to guild member lists as the web app does
All checks were successful
ci / Linux (x86_64) (push) Successful in 37m5s
ci / Windows (x64) (push) Successful in 29m8s
0b6c986ffd
The real server sends only the user's own member in READY and no guild
presences; the other members arrive in GUILD_MEMBER_LIST_UPDATE after an
op 14 (LAZY_REQUEST) subscription, which the client never sent.

- fluxer-proto: LazyRequest/GuildSubscription/MemberListRange, the
  GUILD_MEMBER_LIST_UPDATE and GUILD_SYNC dispatches, with a fixture.
- fluxer-core: MemberLists sends {active, sync} on guild select and the
  shown channel's member list ranges, again after every reconnect; keeps
  the server list and feeds member_list, users and presences from it;
  falls back to READY's members when no answer comes. GUILD_CREATE and
  GUILD_SYNC add their partial members instead of replacing them.
- fluxer-ui: group headers show the server's count.
- fluxer-devserver: READY and GUILD_CREATE carry only the signed-in
  member; op 14 is answered with a server-shaped member list, and
  presence changes resend it. New end-to-end test.

Follow-ups: #195 (scroll ranges past 1,000 rows), #196 (PASSIVE_UPDATES).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
charles manually merged commit 421838b9e4 into main 2026-11-12 05:11:47 +00:00
Sign in to join this conversation.
No description provided.