Task 11: Presence, users, UI state (#11) #42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/11-core-presence-ui"
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 this builds
Task 11 of the Foundation plan, in
fluxer-core:Users { by_id }(users.rs): everyUserPartialseen inREADY(users, the logged-in user, DM recipients, guild members, presences),GUILD_CREATE,GUILD_MEMBER_*,CHANNEL_CREATE/UPDATErecipients,PRESENCE_UPDATE,USER_UPDATE, message authors and mentions (gateway and REST results). Newest copy wins; users are not removed while logged in.PresenceState { by_user }(presence.rs): fromREADY/GUILD_CREATEpresencesandPRESENCE_UPDATE.READYreplaces the previous session's presences. Offline users are not kept; read withPresenceState::status(user_id).UiState(ui.rs): selected guild/channel,last_channel_per_guild, drafts, member list toggle, sidebar width (default 320, clamped 200..=480), window focus, settings tab.SelectGuildrestores the channel last open there (also for the DM list); a deleted channel or a left guild is deselected and forgotten (anunavailableguild keeps the selection).selectors::members:member_list(app, guild),display_name(app, user_id, guild), plusstatus_of(app, user_id).Appgainspub users: Users;App::applycalls the three reducers and, when the session goes from logged in to logged out, clears users, presences and the account's part of the UI state (layout stays).How it was tested
crates/fluxer-core/tests/presence_ui.rs(13 tests, written first and seen failing): the five the plan names (presence_update_changes_status,member_list_hoists_roles_then_online_offline,select_guild_restores_last_channel,display_name_precedence,sidebar_width_clamped) plus users learned from READY/presences/messages, READY replacing presences, deleted channel/guild handling, drafts, settings tab, UI defaults and logout clearing. They use theready,presence_updateandmessage_creategateway fixtures.cargo xtask ciis green locally.Deviations from the plan / things to look at
Guilds/GuildRecordare declared inapp.rshere with exactly the shape of Task 9's Interfaces block (by_id,guild,roles,channels,members,member_count: u64,unavailable), without reducers.member_listanddisplay_namehave to read guild members and roles, and Task 9 runs in parallel, so nothing fills them yet; the tests insert aGuildRecordbuilt from the READY fixture. When Task 9 lands, its definition replaces this one (expect a mechanical conflict inapp.rs,lib.rsandselectors/mod.rs).MemberGrouphas a third fieldkind: MemberGroupKind { Role, Online, Offline }: with onlyrole: Option<Role>the "Online" and "Offline" groups cannot be told apart.hoist_position(falling back toposition) descending; a member is listed once, under their highest hoisted role; offline and invisible members go to "Offline" whatever their roles; members sorted by display name ignoring case; empty groups omitted; unknown or unavailable guild gives an empty list.status_ofshows the logged-in user with thestatusof the synced user settings, or online when there is none.last_channel_per_guildis keyed byOption<Snowflake>(None= DM list).SelectChannelrecords the channel under the currently selected guild, since the channel store (Task 9) is not available to look up its guild.UiStatehas an extralast_settings_tabsoOpenSettings(None)can reopen the last tab.SendDraftremoves the draft in the UI reducer. The messages reducer of Task 10 must run beforeself.ui.reduceinApp::applyif it readsui.drafts(commented there).display_namereturns"Unknown User"for an id the client has never seen.SidebarResizeddoes not persist yet (PersistOp::SaveSettingsis Task 12).Stacked on: task/8-core-store-session
Closes #11
🤖 Generated with Claude Code
Independent review: Task 11 (core-presence-ui) at
f4ce82eScope:
git diff cacedcb..origin/task/11-core-presence-ui(9 files, fluxer-core only).Checks
crates/fluxer-core/tests/presence_ui.rsand assert the plan's behaviour:presence_update_changes_status,member_list_hoists_roles_then_online_offline,select_guild_restores_last_channel,display_name_precedence(nick > global_name > username),sidebar_width_clamped(default 320, clamp 200..=480, boundaries 199/200/480/481 covered). 8 further tests. Failing-first commit95b44a0precedes the implementation.Users { by_id },PresenceState { by_user: HashMap<Snowflake, UserStatus> }, everyUiStatefield with the plan's types and defaults,member_list(app, guild) -> Vec<MemberGroup>,display_name(app, user_id, Option<Snowflake>) -> Stringall exist as written.Appgainspub users: Users.unwrap/index/expecton server data in the new source; unknown statuses, unknown role ids, unknown guilds and unseen users are handled without panicking.cargo xtask ciin the review worktree: all steps passed (presence_ui: 13 passed; screenshot tests skipped as configured). Remote runners not checked.Findings
app.rs):Guilds/GuildRecordare declared here with Task 9's shape and no reducers. Task 9 creates them inguilds.rs; expect conflicts inapp.rs,lib.rsandselectors/mod.rs, and Task 9's definition should win. Until Task 9 lands,member_listis only exercised against a hand-built record; rerun the member tests through the realReadyreducer when integrating.selectors/members.rs,ui.rs):MemberGrouphas an extrakindfield andUiStatean extralast_settings_tab. Additive for readers, but consumers cannot build these with the plan's struct literal. Hoist order (hoist_position ?? position, descending) matches the fork'sGuildRole.ts/guild_member_list_groups.erl.ui.rs):SelectGuildrestoresselected_channeldirectly, without aSelectChannelaction. Task 10 fetches the first page onSelectChannelonly, so a restored channel with no loaded messages would stay empty unless Task 10 also reacts toSelectGuild/the selection change. Also,SelectChannelfiles the channel under the currently selected guild, which is wrong if a channel is ever opened from outside its guild (notification, jump link).users.rs,presence.rs): reducers are not gated on being logged in. A lateApiResult::Messagesor gateway event arriving after logout repopulatesusers/presence, which then survive into the next account's session until itsREADY(presence is cleared onREADY, users are not).app.rs): the ordering constraint (messages reducer must readui.draftsbeforeself.ui.reduceonSendDraft) is only a comment; Task 10 needs to honour it and should test it.Verdict: APPROVE (0 blocking, 5 minor; local ci green)