Daily use 11b: core-state-skeleton (#496) #555

Closed
charles wants to merge 0 commits from dailyuse-11b-core-state-skeleton into dailyuse
Owner

Stacked on: dailyuse-11a-core-dailyuse-ports

What

The daily-use state skeleton of fluxer-core (plan Task 11b):

  • New modules, each with its state type, Default and a stub reducer that App::apply runs on every logged-in event (before text chat), reset on logout:
    • notif_settings — NotifSettings { by_guild: HashMap<GuildKey, UserGuildSettings> }, MuteState, and the stub selectors is_muted / muted_until / level / mentions_me / is_collapsed (false / None / AllMessages / false / false).
    • social — Social { relationships, friends_tab, search, add_friend: AddFriendState }, social::relationship(&App, user) and Social::relationship.
    • invites — Invites { cache: code → InviteState::{Loading, Resolved, Failed}, modal, create, add_guild }.
    • switcher — Switcher { open, query, selected, recent_visits } (visits survive logout).
    • keynav — KeyNav (empty).
    • report — app.report: Option<ReportFlowState> (as spec §6.1).
  • menus::{channel, category, guild, dm, user(UserMenuContext)} returning empty MenuModels, menus::mute::item(&App, MuteTarget, &str) -> MenuItem (a submenu with no items until Task 12).
  • presence.me: OwnPresence { chosen, resets_at, custom, idle, afk, last_sent } (reset on logout, not on the cache → live READY swap); profiles.notes, profiles.modal: Option<ProfileModal>.
  • Relationships moved from chat::dms to app.social: ChatCtx gains social, Dms::toggle_pick reads ctx.social.relationship(..); selectors/sidebar.rs (DM welcome, friend picker, DM names) and fluxer-ui screens/main/dms/mod.rs (group-DM header button) read through social::relationship / app.social.
  • UserAction::Navigate, Switcher remain no-ops.

Tests

crates/fluxer-core/tests/dailyuse_ports.rs: state_defaults, stubs_emit_nothing, relationships_still_reach_friend_picker, dm_list_friend_flag_unchanged, plus the existing existing_tests_untouched. Seen failing (no fields/modules) before implementing, passing after. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. No desktop (FLUXER_DESKTOP_TESTS) tests apply.

Deviations

  • Existing tests touched mechanically: tests/chat_dms.rs reads app.social.relationships instead of app.chat.dms.relationships; tests/chat_ports.rs drops the chat.dms.relationships default assertion (the field moved; state_defaults covers it).
  • selectors/sidebar.rs is outside the Files list but had to change to compile (three reads of the moved field).
  • apps/fluxer/src/runtime.rs needed no change: it only produces ApiResult::Relationships; routing to social happens in App::apply.
  • read_state.rs needed no change for the skeleton (its daily-use work belongs to Tasks 13, 17, 22a).
  • State fields beyond the plan's named ones are kept minimal (e.g. AddFriendState { input }, Switcher without stored results — Task 19's selector computes them); later tasks extend them.

Closes #496

🤖 Generated with Claude Code

Stacked on: dailyuse-11a-core-dailyuse-ports ## What The daily-use state skeleton of `fluxer-core` (plan Task 11b): - New modules, each with its state type, `Default` and a stub reducer that `App::apply` runs on every logged-in event (before text chat), reset on logout: - `notif_settings` — `NotifSettings { by_guild: HashMap<GuildKey, UserGuildSettings> }`, `MuteState`, and the stub selectors `is_muted` / `muted_until` / `level` / `mentions_me` / `is_collapsed` (false / None / AllMessages / false / false). - `social` — `Social { relationships, friends_tab, search, add_friend: AddFriendState }`, `social::relationship(&App, user)` and `Social::relationship`. - `invites` — `Invites { cache: code → InviteState::{Loading, Resolved, Failed}, modal, create, add_guild }`. - `switcher` — `Switcher { open, query, selected, recent_visits }` (visits survive logout). - `keynav` — `KeyNav` (empty). - `report` — `app.report: Option<ReportFlowState>` (as spec §6.1). - `menus::{channel, category, guild, dm, user(UserMenuContext)}` returning empty `MenuModel`s, `menus::mute::item(&App, MuteTarget, &str) -> MenuItem` (a submenu with no items until Task 12). - `presence.me: OwnPresence { chosen, resets_at, custom, idle, afk, last_sent }` (reset on logout, not on the cache → live READY swap); `profiles.notes`, `profiles.modal: Option<ProfileModal>`. - Relationships moved from `chat::dms` to `app.social`: `ChatCtx` gains `social`, `Dms::toggle_pick` reads `ctx.social.relationship(..)`; `selectors/sidebar.rs` (DM welcome, friend picker, DM names) and `fluxer-ui` `screens/main/dms/mod.rs` (group-DM header button) read through `social::relationship` / `app.social`. - `UserAction::Navigate`, `Switcher` remain no-ops. ## Tests `crates/fluxer-core/tests/dailyuse_ports.rs`: `state_defaults`, `stubs_emit_nothing`, `relationships_still_reach_friend_picker`, `dm_list_friend_flag_unchanged`, plus the existing `existing_tests_untouched`. Seen failing (no fields/modules) before implementing, passing after. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. No desktop (`FLUXER_DESKTOP_TESTS`) tests apply. ## Deviations - Existing tests touched mechanically: `tests/chat_dms.rs` reads `app.social.relationships` instead of `app.chat.dms.relationships`; `tests/chat_ports.rs` drops the `chat.dms.relationships` default assertion (the field moved; `state_defaults` covers it). - `selectors/sidebar.rs` is outside the Files list but had to change to compile (three reads of the moved field). - `apps/fluxer/src/runtime.rs` needed no change: it only produces `ApiResult::Relationships`; routing to `social` happens in `App::apply`. - `read_state.rs` needed no change for the skeleton (its daily-use work belongs to Tasks 13, 17, 22a). - State fields beyond the plan's named ones are kept minimal (e.g. `AddFriendState { input }`, `Switcher` without stored `results` — Task 19's selector computes them); later tasks extend them. Closes #496 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #495

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every UserAction, CoreEvent, Effect, ApiRequest/ApiResult and chat::Confirm
variant of the Daily use plan (Task 11a), plus the menu types (menus::MenuModel,
MenuItem, MenuItemKind, MenuItemId, MenuModel::flatten). New actions and events
do nothing yet; the runtime answers each new request with 501 CLIENT_NOT_WIRED
and logs Effect::Window until Daily use 28. MessageUser and CloseDm take a
confirmed flag and act as before; Notification gains icon (always None).

Refs #495

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #496

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
New domains notif_settings, social, invites, switcher, keynav and report with
their state, Default and stub reducers wired into App::apply; stub menu
builders (channel, category, guild, user, dm, mute::item); OwnPresence, profile
notes and modal state. Relationships move from chat::dms to app.social and are
read through social::relationship.

Refs #496

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

Independent review: Daily use 11b (core-state-skeleton)

Reviewed git diff 95b0926bf..origin/dailyuse-11b-core-state-skeleton (a1a50d0) cold.

(1) Plan tests. state_defaults, stubs_emit_nothing, relationships_still_reach_friend_picker and dm_list_friend_flag_unchanged are in tests/dailyuse_ports.rs. existing_tests_untouched (11a) is unchanged. They assert what the plan asks: every new domain is at its default, both logged out and after READY. The stub selectors answer false/None/AllMessages/false/false. The menus are empty, and the mute item is an empty submenu. Navigate, Switcher, OpenFriends, FriendsSearch, Report and Invite emit no effects and change no state. READY and ApiResult::Relationships fill social, the picker's reducer reads it, and logout clears it. The DM welcome relationship is still Friend. The only changes to existing tests are mechanical (chat_dms.rs field path, one removed assertion in chat_ports.rs).

(2) Interfaces. All of these exist exactly as the 11b block and the consuming tasks (12, 13, 15, 16a/b, 17, 18, 19, 23) name them:

  • notif_settings::{is_muted, muted_until -> Option<MuteState>, level, mentions_me, is_collapsed}
  • social::relationship(&App, user)
  • menus::{channel, category, guild, dm, user(UserMenuContext { user_id, guild_id, channel_id, message })} and menus::mute::item(&App, MuteTarget, &str) -> MenuItem
  • presence.me: OwnPresence { chosen, resets_at, custom, idle, afk, last_sent }
  • profiles.{notes, modal}, app.report: Option<ReportFlowState>
  • the Social, Invites and Switcher shapes of spec §6.1

chat::dms reads relationships through ctx.social.relationship(..) because the reducer has no &App. This is equivalent to the plan's call.

(3) Invariants. fluxer-core gains no iced, wgpu, winit, reqwest or tokio-tungstenite, and does no I/O. fluxer-ui changes only one read path. No fixtures, secrets or file paths. Nothing can panic on server data (the relationship handling is the old code, moved). Every new domain is reset on logout. The reducers run before chat, which reads social through ChatCtx. selectors/sidebar.rs is outside the Files list, but no task running alongside 11b (21, 25) owns it, so file ownership is not broken.

(4) Parity spot checks against fluxer-soundboard:

  • RELATIONSHIP_REMOVE carries only {id} (features/relationship/events/RelationshipRemove.ts:10-16); social removes by id. OK.
  • RELATIONSHIP_UPDATE carries the full mapped relationship (UserRelationshipService.ts:723-739), so replacing the entry gives the same result as the fork's withUpdates merge. OK.
  • The friends page's default tab is 'online' (DMFriendsView.tsx:106), the same as FriendsTab::Online. OK.
  • Recent visits survive the reset on logout: SelectedChannel.reset() keeps recentlyVisitedChannels (SelectedChannel.ts:282-291), and Switcher::clear_account keeps recent_visits. OK.

(5) Review Focus. No item is specific to 11b.

(6) CI. I ran FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in the review worktree: green (xtask ci: all steps passed). The first run hit a one-off SIGSEGV inside the fluxer-ui screenshots test binary after one test, with no assertion failures. Running that binary alone passed 123/123, and a full rerun of the gate passed. It looks like a renderer or driver flake on a busy machine, not this change; I am mentioning it in case it happens again.

Findings

  • minor (presence.rs, OwnPresence::default): chosen defaults to Online. Spec §3.3 says presence is invisible until settings load. This changes nothing today, because nothing sends op 3 yet. Task 14 owns presence.rs and must make sure the op 3 sent before settings load is invisible, whether through the default or a flag.
  • minor (report.rs, ReportFlowState.screens: Vec<String>): Task 23's steps are {screen_id, option_id} or {screen_id, item_ids}, so Task 23 will need to reshape this field. It owns report.rs, so there is no interface break.

Verdict: APPROVE: no blocking findings, local CI green.

## Independent review: Daily use 11b (core-state-skeleton) Reviewed `git diff 95b0926bf..origin/dailyuse-11b-core-state-skeleton` (a1a50d0) cold. **(1) Plan tests.** `state_defaults`, `stubs_emit_nothing`, `relationships_still_reach_friend_picker` and `dm_list_friend_flag_unchanged` are in `tests/dailyuse_ports.rs`. `existing_tests_untouched` (11a) is unchanged. They assert what the plan asks: every new domain is at its default, both logged out and after READY. The stub selectors answer false/None/AllMessages/false/false. The menus are empty, and the mute item is an empty submenu. Navigate, Switcher, OpenFriends, FriendsSearch, Report and Invite emit no effects and change no state. READY and `ApiResult::Relationships` fill `social`, the picker's reducer reads it, and logout clears it. The DM welcome relationship is still Friend. The only changes to existing tests are mechanical (`chat_dms.rs` field path, one removed assertion in `chat_ports.rs`). **(2) Interfaces.** All of these exist exactly as the 11b block and the consuming tasks (12, 13, 15, 16a/b, 17, 18, 19, 23) name them: - `notif_settings::{is_muted, muted_until -> Option<MuteState>, level, mentions_me, is_collapsed}` - `social::relationship(&App, user)` - `menus::{channel, category, guild, dm, user(UserMenuContext { user_id, guild_id, channel_id, message })}` and `menus::mute::item(&App, MuteTarget, &str) -> MenuItem` - `presence.me: OwnPresence { chosen, resets_at, custom, idle, afk, last_sent }` - `profiles.{notes, modal}`, `app.report: Option<ReportFlowState>` - the `Social`, `Invites` and `Switcher` shapes of spec §6.1 `chat::dms` reads relationships through `ctx.social.relationship(..)` because the reducer has no `&App`. This is equivalent to the plan's call. **(3) Invariants.** fluxer-core gains no iced, wgpu, winit, reqwest or tokio-tungstenite, and does no I/O. fluxer-ui changes only one read path. No fixtures, secrets or file paths. Nothing can panic on server data (the relationship handling is the old code, moved). Every new domain is reset on logout. The reducers run before chat, which reads `social` through `ChatCtx`. `selectors/sidebar.rs` is outside the Files list, but no task running alongside 11b (21, 25) owns it, so file ownership is not broken. **(4) Parity spot checks** against `fluxer-soundboard`: - `RELATIONSHIP_REMOVE` carries only `{id}` (`features/relationship/events/RelationshipRemove.ts:10-16`); `social` removes by id. OK. - `RELATIONSHIP_UPDATE` carries the full mapped relationship (`UserRelationshipService.ts:723-739`), so replacing the entry gives the same result as the fork's `withUpdates` merge. OK. - The friends page's default tab is `'online'` (`DMFriendsView.tsx:106`), the same as `FriendsTab::Online`. OK. - Recent visits survive the reset on logout: `SelectedChannel.reset()` keeps `recentlyVisitedChannels` (`SelectedChannel.ts:282-291`), and `Switcher::clear_account` keeps `recent_visits`. OK. **(5) Review Focus.** No item is specific to 11b. **(6) CI.** I ran `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in the review worktree: green (`xtask ci: all steps passed`). The first run hit a one-off SIGSEGV inside the `fluxer-ui` screenshots test binary after one test, with no assertion failures. Running that binary alone passed 123/123, and a full rerun of the gate passed. It looks like a renderer or driver flake on a busy machine, not this change; I am mentioning it in case it happens again. ### Findings - **minor** (`presence.rs`, `OwnPresence::default`): `chosen` defaults to `Online`. Spec §3.3 says presence is `invisible` until settings load. This changes nothing today, because nothing sends op 3 yet. Task 14 owns `presence.rs` and must make sure the op 3 sent before settings load is `invisible`, whether through the default or a flag. - **minor** (`report.rs`, `ReportFlowState.screens: Vec<String>`): Task 23's steps are `{screen_id, option_id}` or `{screen_id, item_ids}`, so Task 23 will need to reshape this field. It owns `report.rs`, so there is no interface break. **Verdict: APPROVE: no blocking findings, local CI green.**
Author
Owner

Review: Daily use 11b (core-state-skeleton)

Scope: git diff 95b0926..origin/dailyuse-11b-core-state-skeleton (a1a50d0), read cold.

Checks

  1. Plan tests: state_defaults, stubs_emit_nothing, relationships_still_reach_friend_picker, dm_list_friend_flag_unchanged are in crates/fluxer-core/tests/dailyuse_ports.rs, and existing_tests_untouched comes from 11a. They assert the stub defaults (false / None / AllMessages / false / false), empty menus and a mute row with no items. They also assert that relationships move via READY, ApiResult::Relationships and logout, and that the picker reducer reads them through social.
  2. Interfaces: notif_settings::{is_muted, muted_until -> Option<MuteState>, level, mentions_me(&App,&Message), is_collapsed} match the plan. So do social::relationship(app, user) and Social::relationship, plus menus::{channel, category, guild, dm, user(&App, UserMenuContext { user_id, guild_id, channel_id, message: Option<(channel, message)> })} and menus::mute::item(&App, MuteTarget, label). Navigate and Switcher are no-ops. The spec §6.1 state names are present: app.{notif_settings, social, invites, switcher, report}, presence.me: OwnPresence { chosen, resets_at, custom, idle, afk, last_sent }, profiles.{notes, modal}.
  3. Invariants: no iced/wgpu/winit/reqwest/tungstenite in core and no I/O. The only UI change is a read through social::relationship. No new fixtures, no secrets. Nothing left reads chat.dms.relationships. Logout resets every new domain, and the switcher keeps recent_visits because they belong to the machine. The social reducer runs before chat::reduce, so the picker sees the same event's relationships.
  4. Parity spot-checks against the fork: the default friends tab is 'online' (DMFriendsView.tsx:106), which matches FriendsTab::Online. The default own status is StatusTypes.ONLINE (LocalPresence.ts:40), which matches OwnPresence::default. Idle is 10 minutes (ui/state/Idle.ts:7), which matches the idle doc. Idle applies only over online (LocalPresence.ts:84), which the doc says too. RELATIONSHIP_REMOVE is keyed by id only, which matches.
  5. Review Focus: none belongs to 11b.
  6. Local FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: green ("xtask ci: all steps passed", exit 0; livekit-interop skipped as usual).

Findings

  • minor: spec §6.1 lists Switcher.results, which is not stored here. The PR justifies this (Task 19's selector computes the results), and that is acceptable. Task 19 should record the divergence.
  • minor: the plan's Files list names read_state.rs and runtime.rs, and neither changed. That is correct, because App::apply already routes ApiResult::Relationships. The plan line is stale, and nothing needs to change.
  • minor: two existing tests were edited mechanically for the move (chat_dms.rs field path, and chat_ports.rs dropping the moved field's assertion). Both are unavoidable, and the coverage moved to relationships_still_reach_friend_picker.

Verdict: approve (0 blocking, 3 minor; local ci green)

## Review: Daily use 11b (core-state-skeleton) Scope: `git diff 95b0926..origin/dailyuse-11b-core-state-skeleton` (a1a50d0), read cold. **Checks** 1. Plan tests: `state_defaults`, `stubs_emit_nothing`, `relationships_still_reach_friend_picker`, `dm_list_friend_flag_unchanged` are in `crates/fluxer-core/tests/dailyuse_ports.rs`, and `existing_tests_untouched` comes from 11a. They assert the stub defaults (`false` / `None` / `AllMessages` / `false` / `false`), empty menus and a mute row with no items. They also assert that relationships move via READY, `ApiResult::Relationships` and logout, and that the picker reducer reads them through `social`. 2. Interfaces: `notif_settings::{is_muted, muted_until -> Option<MuteState>, level, mentions_me(&App,&Message), is_collapsed}` match the plan. So do `social::relationship(app, user)` and `Social::relationship`, plus `menus::{channel, category, guild, dm, user(&App, UserMenuContext { user_id, guild_id, channel_id, message: Option<(channel, message)> })}` and `menus::mute::item(&App, MuteTarget, label)`. `Navigate` and `Switcher` are no-ops. The spec §6.1 state names are present: `app.{notif_settings, social, invites, switcher, report}`, `presence.me: OwnPresence { chosen, resets_at, custom, idle, afk, last_sent }`, `profiles.{notes, modal}`. 3. Invariants: no iced/wgpu/winit/reqwest/tungstenite in core and no I/O. The only UI change is a read through `social::relationship`. No new fixtures, no secrets. Nothing left reads `chat.dms.relationships`. Logout resets every new domain, and the switcher keeps `recent_visits` because they belong to the machine. The social reducer runs before `chat::reduce`, so the picker sees the same event's relationships. 4. Parity spot-checks against the fork: the default friends tab is `'online'` (`DMFriendsView.tsx:106`), which matches `FriendsTab::Online`. The default own status is `StatusTypes.ONLINE` (`LocalPresence.ts:40`), which matches `OwnPresence::default`. Idle is 10 minutes (`ui/state/Idle.ts:7`), which matches the `idle` doc. Idle applies only over online (`LocalPresence.ts:84`), which the doc says too. `RELATIONSHIP_REMOVE` is keyed by `id` only, which matches. 5. Review Focus: none belongs to 11b. 6. Local `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: green ("xtask ci: all steps passed", exit 0; livekit-interop skipped as usual). **Findings** - minor: spec §6.1 lists `Switcher.results`, which is not stored here. The PR justifies this (Task 19's selector computes the results), and that is acceptable. Task 19 should record the divergence. - minor: the plan's Files list names `read_state.rs` and `runtime.rs`, and neither changed. That is correct, because `App::apply` already routes `ApiResult::Relationships`. The plan line is stale, and nothing needs to change. - minor: two existing tests were edited mechanically for the move (`chat_dms.rs` field path, and `chat_ports.rs` dropping the moved field's assertion). Both are unavoidable, and the coverage moved to `relationships_still_reach_friend_picker`. **Verdict: approve (0 blocking, 3 minor; local ci green)**
Author
Owner

Merged into dailyuse at f7972c3 (combined merge of 23 Daily use tasks plus textchat).

Merged into `dailyuse` at f7972c3 (combined merge of 23 Daily use tasks plus `textchat`).
charles closed this pull request 2026-11-15 06:08:59 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.