Voice 6: fluxer-core::voice voice-state store and selectors (#67) #104
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "voice-6-core-voice-states"
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?
What
fluxer-core::voice: the voice-state store and the sidebar's voice selectors (Voice plan Task 6, spec §5.1).App.voice: Voice, for now withstates: VoiceStatesonly; later tasks add their fields.VoiceStates(port of the fork'sVoiceGatewayStateMachine.ts): oneVoiceStateper connection, indexed by channel and by user.apply,in_channel,of_user,by_connection,remove_guild, plusreplace_guild,iter,len,is_empty,clear.READYreplaces everything fromguilds[].voice_states(the listing guild's id is authoritative),GUILD_CREATEreplaces that guild's states,GUILD_DELETE(left or outage) drops them,VOICE_STATE_UPDATEapplies;channel_id: nullremoves the connection, an emptyconnection_idis ignored, and a rejoin of the same gateway session under a new connection id drops the stale one (as the original). Reduced only while logged in; cleared on logout; not seeded from the cachedREADY.selectors::voice_channel_participants->Vec<VoiceParticipantRow>andselectors::voice_channel_user_count.membera voice state carries fills a gap inapp.usersand the guild's members (the original'sGuildMembers.hydrateIfMissing), never replacing a known one.How it was tested
crates/fluxer-core/tests/voice_states.rs, written first and seen failing against stubs: the seven tests the plan names (ready_seeds_states,update_moves_user_between_channels,channel_null_removes_connection,two_devices_of_one_user_group,unknown_user_or_channel_does_not_panic_or_appear_elsewhere,guild_delete_drops_states, proptestany_sequence_of_updates_keeps_indexes_consistentagainst a model) plus six more (fixture update, stale session, member hydration,GUILD_CREATEreplacement, logout, collation).FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally.Review focus 3 is covered by
unknown_user_or_channel_does_not_panic_or_appear_elsewhere: states for an unknown user/channel/guild are kept only under the channel they name and appear in no other channel.Deviations from the plan / things to look at
voice-6-core-voice-states:voice/6-...cannot exist beside the branchvoice(refname conflict), same as Voice 1 and 3.devices= that user's connection count in the channel. The UI groups rows withdevices > 1.avataris the user's avatar hash (Option<String>), sinceavatar_urlneeds the endpoints and a pixel size only the view knows.voice_channel_user_countcounts connections, not users: that is what the original'sChannelItem.tsxdoes (Object.keys(getAllVoiceStatesInChannel(..)).length).Intl.Collator({numeric, sensitivity: 'base'}), then join order, then user id. Here: case-insensitive with numeric digit runs, then user id, then connection id. Not reproduced: accent-insensitivity (needs collation tables, no new dependency), and the per-component snapshot that freezes a name and keeps arrival order among equal names (view state).speakingis alwaysfalseuntil Voice 8 adds the live room.guilds.rsandusers.rs(member hydration; the plan's "guild/ready reducers"),selectors/mod.rs(re-exports),Cargo.toml(proptestas dev-dependency, already in the workspace, for the proptest the plan asks for),README.md.Stacked on: voice-1-proto-voice-gateway
Closes #67
🤖 Generated with Claude Code
Independent review — Voice 6 (core-voice-states), head
d245b6fReviewed
2be0cff..d245b6fcold, against the plan's Task 6, spec §5.1 and the fork'sVoiceGatewayStateMachine.ts/VoiceParticipantSortUtils.ts.1. Tests named by the plan — all seven present in
crates/fluxer-core/tests/voice_states.rsand asserting what the plan says:ready_seeds_states,update_moves_user_between_channels,channel_null_removes_connection,two_devices_of_one_user_group,unknown_user_or_channel_does_not_panic_or_appear_elsewhere,guild_delete_drops_states, proptestany_sequence_of_updates_keeps_indexes_consistent(checked against a model, including the empty connection id and guild replace/remove). Six extra tests. 13/13 pass.2. Interfaces —
App.voice: Voice { states },VoiceStates::{apply(&VoiceState), in_channel, of_user, by_connection(&str), remove_guild},voice_channel_participants(&App, channel_id) -> Vec<VoiceParticipantRow>with all 14 fields under the plan's names (devices: u8), andvoice_channel_user_countexist as written and are re-exported fromselectors.3. Invariants —
fluxer-coregains only theproptestdev-dependency (already in the workspace); no iced/wgpu/winit/reqwest/tungstenite, no I/O. No panicking path on server data: no indexing/unwrap in the store or selector,devicessaturates, and the comparatorcollateis a total preorder (lexicographic over tokens, digit runs as one class), sosort_bycannot hit the inconsistent-order panic. No secrets in code or tests.4. Review Focus 3 — covered: states for an unseen user/channel/guild, without a channel, and with an empty connection id neither panic nor show in any other channel; a state is indexed only under the channel it names. The stale-session rule matches the fork (same guild + channel + session_id, other connection id).
5. CI —
cargo xtask ciin the review worktree: all steps passed (screenshot step skipped,FLUXER_SCREENSHOT_TESTSunset; this task has no UI). Remote runners not checked.Findings
crates/fluxer-core/src/selectors/voice.rs:voice_channel_user_countcounts connections, not users, despite its name (a user on two devices counts twice). Matches the original'sChannelItem.tsxper the implementer and is documented; Voice 16 must not use it as a distinct-user count.selectors/voice.rs: ordering differs from the original in the disclosed ways (no accent folding, no join-order tie-break, no frozen-name snapshot; ties fall to user id). Rows can reorder when a nickname changes while in the channel. Voice 16 or a follow-up should decide whether the snapshot belongs in the view.selectors/voice.rs: unknown users are listed (last, as "Unknown User") where the original leaves them out until resolved. Not a phantom in a wrong channel, so Review Focus 3 holds; Voice 16 to filter or keep.crates/fluxer-core/src/users.rs:Users::reduceis not gated on being logged in, so aVOICE_STATE_UPDATEthat arrives after logout still hydrates its member's user intoapp.users(the voice store itself correctly drops it). Same pre-existing behaviour asPRESENCE_UPDATE; worth one follow-up for the whole reducer rather than a fix here.guilds.rs,users.rs(hydrate-if-missing) andCargo.tomlare outside the task's Files list. The change is small, tested (member_of_an_update_names_a_user_not_seen_before) and never overwrites a known member/user; hydrated members do enterGuildRecord.memberswithout touchingmember_count, as in the original.avataris the avatar hash (Option<String>), not a URL; the plan leaves the type open. Voice 16 builds the image throughavatar_url.Verdict: APPROVE — no blocking findings, local ci green.