Daily use 1: proto notification settings, presence, passive updates, user limit (#486) #536

Closed
charles wants to merge 0 commits from dailyuse-1-proto-notification-presence into dailyuse
Owner

What

fluxer-proto types and server-shaped fixtures for Daily use 1 (spec §3.3, §3.4, §5):

  • models::guild_settings: UserGuildSettings (original's defaults: all messages, mobile_push true), ChannelOverride (Default = new override, Inherit), MuteConfig { end_time, selected_time_window: i64 /* ms, §17 Q10 */ }, MessageNotifications::{Null, AllMessages, OnlyMentions, NoMessages, Inherit, Unknown(i8)}, UserGuildSettingsPatch (only set fields; mute_config/channel_overrides are Option<Option<_>>, the whole map or null). Lenient reading: a bad member is its default, a bad override is dropped, overrides also read as a list with channel_id (as the original accepts); written back exactly as the server writes it (channel_overrides: null when empty).
  • CustomStatus { text, expires_at, emoji_id, emoji_name, emoji_animated } replaces the raw Value in Presence, MemberListPresence and op 3 PresenceUpdate; CustomStatus::from_json normalises like CustomStatus.ts:55-73 (trim, 128 chars, empty → None); any malformed value is None, never an error.
  • UserSettings::{status, status_resets_at, status_resets_to, custom_status, afk_timeout (600, clamped 60–600), trusted_domains, default_hide_muted_channels, developer_mode}; UserSettingsPatch gains status, nullable status_resets_at/status_resets_to/custom_status, trusted_domains, default_hide_muted_channels.
  • ReadyPayload.user_guild_settings, GatewayEvent::UserGuildSettingsUpdate, GatewayEvent::PassiveUpdates(PassiveUpdates { guild_id, channels, voice_states }) (moved from untyped to typed dispatch names); Channel.user_limit: Option<u16> (0/null/bad → None).
  • Fixtures: fixtures/rest/{user_guild_settings,user_guild_settings_me,user_settings_status}.json, fixtures/gateway/{user_guild_settings_update,passive_updates,presence_update_custom_status}.json; server sources named in commit f2ba60d (UserResponseSchemas.ts:330-336,447-486, UserMappers.ts:296-466, guild_passive_sync.erl:211-217, guild_passive_sync_voice.erl, MuteOptions.ts:50-56).

Tests

tests/guild_settings.rs (ready_user_guild_settings_parse, channel_overrides_keyed_by_id, mute_config_null_and_ms, unknown_notification_level_kept, patch_serialises_full_override_map_or_null, passive_updates_parse, channel_user_limit, proptest arbitrary_guild_settings_json_never_panics incl. read→write→read equality), tests/presence.rs (custom_status_shapes_and_garbage_is_none, status_patch_nullable_fields, user_settings_accessor_defaults), spec_contract_new_types plus the extended UserSettingsPatch in spec_contract_new_request_types; new REST fixtures added to models_roundtrip. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally. No desktop (FLUXER_DESKTOP_TESTS) tests apply.

Deviations from the plan

  • ChannelOverride also carries unread_badges: Option<MessageNotifications> and flags: Option<i32>, and UserGuildSettings unread_badges: the server sends them, and since a write replaces the whole override map, dropping them would clobber what the Electron client set (Review Focus 1). Not used by this client.
  • The new test files' names follow the plan; channel_user_limit lives in tests/guild_settings.rs.
  • Outside the crate: crates/fluxer-core/src/chat/threads.rs gains user_limit: None in its Channel literal (one line, to compile).
  • Response types are not in the CONTRACTS table (that checker forbids an Option for the required version, which the plan types as Option<u64>); spec_contract_new_types checks properties and required fields directly instead.

Closes #486

🤖 Generated with Claude Code

## What `fluxer-proto` types and server-shaped fixtures for Daily use 1 (spec §3.3, §3.4, §5): - `models::guild_settings`: `UserGuildSettings` (original's defaults: all messages, `mobile_push` true), `ChannelOverride` (`Default` = new override, `Inherit`), `MuteConfig { end_time, selected_time_window: i64 /* ms, §17 Q10 */ }`, `MessageNotifications::{Null, AllMessages, OnlyMentions, NoMessages, Inherit, Unknown(i8)}`, `UserGuildSettingsPatch` (only set fields; `mute_config`/`channel_overrides` are `Option<Option<_>>`, the whole map or `null`). Lenient reading: a bad member is its default, a bad override is dropped, overrides also read as a list with `channel_id` (as the original accepts); written back exactly as the server writes it (`channel_overrides: null` when empty). - `CustomStatus { text, expires_at, emoji_id, emoji_name, emoji_animated }` replaces the raw `Value` in `Presence`, `MemberListPresence` and op 3 `PresenceUpdate`; `CustomStatus::from_json` normalises like `CustomStatus.ts:55-73` (trim, 128 chars, empty → `None`); any malformed value is `None`, never an error. - `UserSettings::{status, status_resets_at, status_resets_to, custom_status, afk_timeout (600, clamped 60–600), trusted_domains, default_hide_muted_channels, developer_mode}`; `UserSettingsPatch` gains `status`, nullable `status_resets_at`/`status_resets_to`/`custom_status`, `trusted_domains`, `default_hide_muted_channels`. - `ReadyPayload.user_guild_settings`, `GatewayEvent::UserGuildSettingsUpdate`, `GatewayEvent::PassiveUpdates(PassiveUpdates { guild_id, channels, voice_states })` (moved from untyped to typed dispatch names); `Channel.user_limit: Option<u16>` (`0`/null/bad → `None`). - Fixtures: `fixtures/rest/{user_guild_settings,user_guild_settings_me,user_settings_status}.json`, `fixtures/gateway/{user_guild_settings_update,passive_updates,presence_update_custom_status}.json`; server sources named in commit f2ba60d (`UserResponseSchemas.ts:330-336,447-486`, `UserMappers.ts:296-466`, `guild_passive_sync.erl:211-217`, `guild_passive_sync_voice.erl`, `MuteOptions.ts:50-56`). ## Tests `tests/guild_settings.rs` (`ready_user_guild_settings_parse`, `channel_overrides_keyed_by_id`, `mute_config_null_and_ms`, `unknown_notification_level_kept`, `patch_serialises_full_override_map_or_null`, `passive_updates_parse`, `channel_user_limit`, proptest `arbitrary_guild_settings_json_never_panics` incl. read→write→read equality), `tests/presence.rs` (`custom_status_shapes_and_garbage_is_none`, `status_patch_nullable_fields`, `user_settings_accessor_defaults`), `spec_contract_new_types` plus the extended `UserSettingsPatch` in `spec_contract_new_request_types`; new REST fixtures added to `models_roundtrip`. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. No desktop (`FLUXER_DESKTOP_TESTS`) tests apply. ## Deviations from the plan - `ChannelOverride` also carries `unread_badges: Option<MessageNotifications>` and `flags: Option<i32>`, and `UserGuildSettings` `unread_badges`: the server sends them, and since a write replaces the whole override map, dropping them would clobber what the Electron client set (Review Focus 1). Not used by this client. - The new test files' names follow the plan; `channel_user_limit` lives in `tests/guild_settings.rs`. - Outside the crate: `crates/fluxer-core/src/chat/threads.rs` gains `user_limit: None` in its `Channel` literal (one line, to compile). - Response types are not in the `CONTRACTS` table (that checker forbids an `Option` for the required `version`, which the plan types as `Option<u64>`); `spec_contract_new_types` checks properties and required fields directly instead. Closes #486 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Shaped like the server:
- rest/user_guild_settings.json, rest/user_guild_settings_me.json and
  gateway/user_guild_settings_update.json: UserGuildSettingsResponse,
  packages/schema/src/domains/user/UserResponseSchemas.ts:447-486, as
  fluxer_api/src/api/user/UserMappers.ts:409-466 writes it (channel_overrides an
  object keyed by channel id, null when empty; mute_config null or
  {end_time, selected_time_window}; unread_badges null; flags only when set).
  selected_time_window in ms as the client sends it
  (fluxer_app/src/features/channel/components/MuteOptions.ts:50-56; an
  indefinite mute is mute_config null).
- gateway/passive_updates.json: fluxer_gateway/src/guild/guild_passive_sync.erl:211-217
  ({guild_id, channels: {channel_id: last_message_id}, voice_states?}); voice
  states as guild_passive_sync_voice.erl:61-128 (a removed one has channel_id null).
- gateway/presence_update_custom_status.json and rest/user_settings_status.json:
  CustomStatusResponse and UserSettingsResponse, UserResponseSchemas.ts:330-336,
  :340-460, as UserMappers.ts:296-372 writes them.

Refs #486

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UserGuildSettings, ChannelOverride, MuteConfig (ms), MessageNotifications and
UserGuildSettingsPatch (whole channel_overrides map or null); READY
user_guild_settings, USER_GUILD_SETTINGS_UPDATE and PASSIVE_UPDATES typed;
CustomStatus replaces the raw Value in presences, member-list rows and op 3
(garbage reads as None); UserSettings status/custom status/afk/trusted
domains/hide-muted/developer-mode accessors and patch fields; Channel.user_limit.
fluxer-core's thread-to-channel literal gains user_limit: None to compile.

Refs #486

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Independent review: Daily use 1 (f2de7cd..33b06c9)

I read the change cold and checked it against the plan's Task 1, spec §3.4 and §5, and the fork sources.

  1. Named tests (plan Step 1): all 12 exist and assert what the plan asks. ready_user_guild_settings_parse, channel_overrides_keyed_by_id, mute_config_null_and_ms (3 600 000 ms; 259 200 000 still fits), unknown_notification_level_kept, patch_serialises_full_override_map_or_null, passive_updates_parse and channel_user_limit are in tests/guild_settings.rs, along with the proptest arbitrary_guild_settings_json_never_panics, which also checks that what is read round-trips. custom_status_shapes_and_garbage_is_none, status_patch_nullable_fields and user_settings_accessor_defaults are in tests/presence.rs. spec_contract_new_types is in spec_contract.rs.
  2. Interfaces: every name in the Interfaces block exists as written: UserGuildSettings, ChannelOverride, MuteConfig (ms, i64), MessageNotifications::{Null..Inherit, Unknown(i8)}, UserGuildSettingsPatch (with Option<Option<..>> for mute_config and channel_overrides), ReadyPayload.user_guild_settings, GatewayEvent::{UserGuildSettingsUpdate, PassiveUpdates}, PassiveUpdates, CustomStatus in Presence/op 3/member-list rows, the UserSettings accessors, the new UserSettingsPatch fields and Channel.user_limit: Option<u16>. The extra unread_badges/flags fields are additive and justified (whole-map writes, Review Focus 1). The server preserves flags when the writer cannot set them (UserAccountSettingsService.ts:345-366), so writing the flags it read back is safe.
  3. Invariants: fluxer-proto stays pure data. The only change outside it is one user_limit: None line in fluxer-core. Everything is read leniently: bad overrides are dropped, bad levels fall back to their default, a bad custom status is None. No secrets or paths in the fixtures. The overrides map round-trips byte for byte (asserted against the fixture). UserSettings stays raw JSON.
  4. Parity spot-checks (fork): (a) the levels match NotificationConstants.ts (-1..3). (b) The defaults match UserGuildSettings.ts:67-87 (ALL_MESSAGES, mobile_push true, override INHERIT, unread_badges null). (c) The PASSIVE_UPDATES shape matches guild_passive_sync.erl:211-217: binary channel→last-message-id map, and voice_states omitted when empty. (d) The response shape (channel_overrides null when empty, flags only when set) matches UserMappers.ts:409-466. (e) The trim and 128-character cut match CustomStatus.ts normalizeCustomStatus. (f) Leaving null custom-status fields off op 3 is safe: the gateway's field_or_null treats absent as null (presence_update.erl:199-215).
  5. Review Focus 1 and 7: the whole override map or null is written (Focus 1). The never-panics proptest is in place (Focus 7).

Findings

  • minor: CustomStatus::from_json does not convert a Unicode emoji_name shortcode to its surrogate (normalizeEmojiNameToSurrogate, CustomStatus.ts:62). This is display-side, and core or UI can apply it (Task 14/32).
  • minor: CustomStatus written as a response shape leaves out emoji_animated when false, although the response schema requires it. The client never writes a response, so this has no effect.

CI: I started FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in the review worktree, but it had not finished (still compiling) when this review had to be submitted, so I have no local result to record. The implementer reports it green; someone needs to confirm before merge.

Verdict: no blocking code findings. Not approved yet: the local CI gate is unconfirmed. Re-run the gate; if it is green, this can be marked ready-to-merge.

**Independent review: Daily use 1 (f2de7cd..33b06c9)** I read the change cold and checked it against the plan's Task 1, spec §3.4 and §5, and the fork sources. 1. **Named tests (plan Step 1):** all 12 exist and assert what the plan asks. `ready_user_guild_settings_parse`, `channel_overrides_keyed_by_id`, `mute_config_null_and_ms` (3 600 000 ms; 259 200 000 still fits), `unknown_notification_level_kept`, `patch_serialises_full_override_map_or_null`, `passive_updates_parse` and `channel_user_limit` are in tests/guild_settings.rs, along with the proptest `arbitrary_guild_settings_json_never_panics`, which also checks that what is read round-trips. `custom_status_shapes_and_garbage_is_none`, `status_patch_nullable_fields` and `user_settings_accessor_defaults` are in tests/presence.rs. `spec_contract_new_types` is in spec_contract.rs. 2. **Interfaces:** every name in the Interfaces block exists as written: `UserGuildSettings`, `ChannelOverride`, `MuteConfig` (ms, i64), `MessageNotifications::{Null..Inherit, Unknown(i8)}`, `UserGuildSettingsPatch` (with `Option<Option<..>>` for `mute_config` and `channel_overrides`), `ReadyPayload.user_guild_settings`, `GatewayEvent::{UserGuildSettingsUpdate, PassiveUpdates}`, `PassiveUpdates`, `CustomStatus` in `Presence`/op 3/member-list rows, the `UserSettings` accessors, the new `UserSettingsPatch` fields and `Channel.user_limit: Option<u16>`. The extra `unread_badges`/`flags` fields are additive and justified (whole-map writes, Review Focus 1). The server preserves `flags` when the writer cannot set them (UserAccountSettingsService.ts:345-366), so writing the flags it read back is safe. 3. **Invariants:** fluxer-proto stays pure data. The only change outside it is one `user_limit: None` line in fluxer-core. Everything is read leniently: bad overrides are dropped, bad levels fall back to their default, a bad custom status is None. No secrets or paths in the fixtures. The overrides map round-trips byte for byte (asserted against the fixture). `UserSettings` stays raw JSON. 4. **Parity spot-checks (fork):** (a) the levels match NotificationConstants.ts (-1..3). (b) The defaults match UserGuildSettings.ts:67-87 (ALL_MESSAGES, mobile_push true, override INHERIT, unread_badges null). (c) The PASSIVE_UPDATES shape matches guild_passive_sync.erl:211-217: binary channel→last-message-id map, and `voice_states` omitted when empty. (d) The response shape (channel_overrides null when empty, `flags` only when set) matches UserMappers.ts:409-466. (e) The trim and 128-character cut match CustomStatus.ts normalizeCustomStatus. (f) Leaving null custom-status fields off op 3 is safe: the gateway's `field_or_null` treats absent as null (presence_update.erl:199-215). 5. **Review Focus 1 and 7:** the whole override map or null is written (Focus 1). The never-panics proptest is in place (Focus 7). **Findings** - minor: `CustomStatus::from_json` does not convert a Unicode `emoji_name` shortcode to its surrogate (`normalizeEmojiNameToSurrogate`, CustomStatus.ts:62). This is display-side, and core or UI can apply it (Task 14/32). - minor: `CustomStatus` written as a response shape leaves out `emoji_animated` when false, although the response schema requires it. The client never writes a response, so this has no effect. **CI:** I started `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in the review worktree, but it had not finished (still compiling) when this review had to be submitted, so I have no local result to record. The implementer reports it green; someone needs to confirm before merge. **Verdict:** no blocking code findings. Not approved yet: the local CI gate is unconfirmed. Re-run the gate; if it is green, this can be marked ready-to-merge.
Author
Owner

Review round 1, minor findings. No code changes; branch head stays at 33b06c9.

  1. emoji_name shortcode to surrogate (presence.rs): deferred to follow-up #546. fluxer-proto is pure data and has no emoji table (that lives in fluxer-emoji), and adding that dependency here is not in this task. The conversion belongs in core or the UI, where the status is shown or written (Task 14 or Task 32).
  2. emoji_animated left out when false (presence.rs): no change. The same struct also serialises the op 3 status and the settings PATCH body (CustomStatusPayload, UserRequestSchemas.ts:242-269), which has no emoji_animated member. The client never writes a CustomStatusResponse, and reading tolerates absent and null. The current behaviour fits what the client actually sends.
  3. Local CI gate had no result: re-ran FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci on 33b06c9 in a clean target dir. All steps passed (fmt, clippy, deny, core isolation, parity, tests); livekit-interop was skipped as usual.

🤖 Generated with Claude Code

Review round 1, minor findings. No code changes; branch head stays at 33b06c9. 1. **emoji_name shortcode to surrogate** (`presence.rs`): deferred to follow-up #546. `fluxer-proto` is pure data and has no emoji table (that lives in `fluxer-emoji`), and adding that dependency here is not in this task. The conversion belongs in core or the UI, where the status is shown or written (Task 14 or Task 32). 2. **emoji_animated left out when false** (`presence.rs`): no change. The same struct also serialises the op 3 status and the settings `PATCH` body (`CustomStatusPayload`, `UserRequestSchemas.ts:242-269`), which has no `emoji_animated` member. The client never writes a `CustomStatusResponse`, and reading tolerates absent and `null`. The current behaviour fits what the client actually sends. 3. **Local CI gate had no result**: re-ran `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` on 33b06c9 in a clean target dir. All steps passed (fmt, clippy, deny, core isolation, parity, tests); livekit-interop was skipped as usual. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Independent review, round 2: Daily use 1 (f2de7cd..33b06c9)

I read the diff cold and checked it against plan Task 1, spec §3.3, §3.4 and §5, and the fork sources.

  • Plan tests: all 12 named tests exist (tests/guild_settings.rs, tests/presence.rs, spec_contract_new_types). They use the spec's values: 3 600 000 ms, 259 200 000 ms still fits, the levels -1 to 3 plus Unknown(n) written back, and afk_timeout defaulting to 600 and clamped to 60–600.
  • Interfaces: every name and signature in the block is present. The proptest covers Review Focus 7 for this task: arbitrary guild-settings JSON never panics, and whatever parses round-trips.
  • Invariants: fluxer-core changes by one line (user_limit: None). There is no I/O, and no tokens, signed URLs or file paths in the code or fixtures. The fixtures are shaped like the server: UserMappers.ts:409-466 (overrides keyed by id, null when empty, flags only when set) and guild_passive_sync.erl:211-217 (the ids are Erlang binaries, so the client reads strings). The settings fixtures round-trip byte for byte.
  • Parity, spot-checked against the fork:
    • Defaults match UserGuildSettings.ts:67-87.
    • The levels match NotificationConstants.ts.
    • The custom-status normalisation matches CustomStatus.ts:55-73.
    • The PASSIVE_UPDATES shape matches PassiveUpdates.ts.
    • The request schemas are plain z.object, which removes unknown keys and does not reject them.
  • CI: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci on 33b06c9 passed every step (exit 0).

Findings (all minor, none blocking):

  1. [minor] Extra struct fields (guild_settings.rs). UserGuildSettings and ChannelOverride have unread_badges (and flags on the override) that the plan's Interfaces block does not list. This is right per spec §3.4: it keeps them through a whole-map write. Later tasks that build these structs as literals must add ..Default::default().
  2. [minor] Unknown level breaks a whole-map write (guild_settings.rs). An unknown level read into an override is written back unchanged. The server's UserNotificationSettingsSchema would then reject the whole PATCH. This only happens if the server sent such a value. Task 12 can decide whether to normalise it before writing.
  3. [minor] Character count vs UTF-16 (presence.rs). CustomStatus::from_json cuts the text at 128 chars, but the original (slice) and the server limit count UTF-16 units. Text the client reads is already within the limit, so this does not matter on read. The editor (Task 14/32) must count UTF-16 units before a PATCH.
  4. [info] Earlier findings re-checked. The shortcode-to-surrogate conversion is deferred to #546, which is fine. Leaving out emoji_animated: false on op 3 is harmless: fluxer_gateway never reads emoji_animated, and CustomStatusPayload removes it.

Verdict: approve. No blocking findings, and local CI is green.

**Independent review, round 2: Daily use 1 (f2de7cd..33b06c9)** I read the diff cold and checked it against plan Task 1, spec §3.3, §3.4 and §5, and the fork sources. - **Plan tests:** all 12 named tests exist (`tests/guild_settings.rs`, `tests/presence.rs`, `spec_contract_new_types`). They use the spec's values: 3 600 000 ms, 259 200 000 ms still fits, the levels -1 to 3 plus `Unknown(n)` written back, and `afk_timeout` defaulting to 600 and clamped to 60–600. - **Interfaces:** every name and signature in the block is present. The proptest covers Review Focus 7 for this task: arbitrary guild-settings JSON never panics, and whatever parses round-trips. - **Invariants:** fluxer-core changes by one line (`user_limit: None`). There is no I/O, and no tokens, signed URLs or file paths in the code or fixtures. The fixtures are shaped like the server: `UserMappers.ts:409-466` (overrides keyed by id, `null` when empty, `flags` only when set) and `guild_passive_sync.erl:211-217` (the ids are Erlang binaries, so the client reads strings). The settings fixtures round-trip byte for byte. - **Parity, spot-checked against the fork:** - Defaults match `UserGuildSettings.ts:67-87`. - The levels match `NotificationConstants.ts`. - The custom-status normalisation matches `CustomStatus.ts:55-73`. - The `PASSIVE_UPDATES` shape matches `PassiveUpdates.ts`. - The request schemas are plain `z.object`, which removes unknown keys and does not reject them. - **CI:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` on 33b06c9 passed every step (exit 0). Findings (all minor, none blocking): 1. **[minor] Extra struct fields (`guild_settings.rs`).** `UserGuildSettings` and `ChannelOverride` have `unread_badges` (and `flags` on the override) that the plan's Interfaces block does not list. This is right per spec §3.4: it keeps them through a whole-map write. Later tasks that build these structs as literals must add `..Default::default()`. 2. **[minor] Unknown level breaks a whole-map write (`guild_settings.rs`).** An unknown level read into an override is written back unchanged. The server's `UserNotificationSettingsSchema` would then reject the whole PATCH. This only happens if the server sent such a value. Task 12 can decide whether to normalise it before writing. 3. **[minor] Character count vs UTF-16 (`presence.rs`).** `CustomStatus::from_json` cuts the text at 128 chars, but the original (`slice`) and the server limit count UTF-16 units. Text the client reads is already within the limit, so this does not matter on read. The editor (Task 14/32) must count UTF-16 units before a PATCH. 4. **[info] Earlier findings re-checked.** The shortcode-to-surrogate conversion is deferred to #546, which is fine. Leaving out `emoji_animated: false` on op 3 is harmless: `fluxer_gateway` never reads `emoji_animated`, and `CustomStatusPayload` removes it. **Verdict: approve.** No blocking findings, and local CI is green.
Author
Owner

Merged into dailyuse at 863726f (combined merge of the first twelve Daily use tasks).

Merged into `dailyuse` at 863726f (combined merge of the first twelve Daily use tasks).
charles closed this pull request 2026-11-14 13:03:52 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.