Text chat 14: core expressions (#264) #312

Manually merged
charles merged 13 commits from textchat-14-core-expressions into textchat 2026-11-13 02:14:15 +00:00
Owner

What this builds

fluxer-core expressions (spec §6.2 "Expressions"), in chat/expressions.rs:

  • Guild emoji and stickers from READY / GUILD_CREATE / GUILD_SYNC, replaced by GUILD_EMOJIS_UPDATE / GUILD_STICKERS_UPDATE.
  • selectors::usable(&App, &EmojiRef, channel) -> Usability::{Yes, NeedsPremium, NeedsPermission} (as checkEmojiAvailability).
  • selectors::emoji_picker (Favorited, Frequently used top 42, guild sections in guild order, Unicode categories; merged search), sticker_picker, meme_picker, gif_picker.
  • Frecency recorded on send, react and pick; persisted in synced preferences, written 1.5 s after the last change (ApiRequest::PatchUserSettings) on top of the last snapshot so every other field stays byte for byte; replaced by another client's USER_SETTINGS_UPDATE. Soundboard favourites (#92) synced through the same preferences.
  • GIF search debounce 350/1000 ms, suggestions 250/900 ms via Effect::Schedule, featured cached per session, register-share on pick, auto-send or append with Shift. Stickers send alone or wait with text. Saved media from READY.favorite_memes and FAVORITE_MEME_* events.

How it was tested

crates/fluxer-core/tests/chat_expressions.rs: the 15 tests named in the plan, written first and seen failing, then passing. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally after merging the current origin/textchat.

Deviations from the plan

  • fluxer-proto: ReadyPayload.favorite_memes added (shaped from fluxer_api/src/api/rpc/RpcService.ts:1164, read by the original in GatewayReady.ts:150), so saved media arrive with READY. Small, own commit.
  • guilds.rs untouched: guild emoji/stickers are held in chat.expressions (guild_emojis / guild_stickers). session.rs keeps the instance's GIF provider config for the picker's attribution.
  • Outside the Files list, minimal: app.rs / chat/mod.rs pass soundboard favourites and the composer/settings into the expressions reducer; selectors/mod.rs re-exports the selectors; tests/chat_ports.rs skips the expression actions in stubs_emit_nothing (they are no longer stubs).

Review fixes (d1a94ee, tests in 9cd766e)

  • Finding 1 (blocking): the soundboard no longer reads synced favourites itself. The expressions compare each part of a snapshot with the last one; only a part another device changed replaces the local one and drops its pending change. Soundboard favourites reach the soundboard through Expressions::take_soundboard_adopt, applied in App after the text chat reduces (voice/soundboard.rs touched for this). The review's scenario (star, then an echo or an unrelated USER_SETTINGS_UPDATE within the debounce) is in soundboard_favourites_sync.
  • Finding 3: echoes no longer need to be byte-identical; the per-part comparison keeps pending local changes and writes them on top of the newest snapshot (patch answers included). Test in prefs_written_debounced_1500ms.
  • Finding 4: settings without synced_preferences change nothing (after the first snapshot). Test in prefs_from_other_client_replace_local.
  • Finding 2: follow-up #348 (base hash and SYNCED_PREFERENCES_CONFLICT).
  • Finding 5: left for Text chat 29 (#279): quick reactions and the context menu should emit PickEmoji { target: Reaction } so they count toward frecency.

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally on b1bb741 (latest origin/textchat merged).

Closes #264

🤖 Generated with Claude Code

## What this builds `fluxer-core` expressions (spec §6.2 "Expressions"), in `chat/expressions.rs`: - Guild emoji and stickers from `READY` / `GUILD_CREATE` / `GUILD_SYNC`, replaced by `GUILD_EMOJIS_UPDATE` / `GUILD_STICKERS_UPDATE`. - `selectors::usable(&App, &EmojiRef, channel) -> Usability::{Yes, NeedsPremium, NeedsPermission}` (as `checkEmojiAvailability`). - `selectors::emoji_picker` (Favorited, Frequently used top 42, guild sections in guild order, Unicode categories; merged search), `sticker_picker`, `meme_picker`, `gif_picker`. - Frecency recorded on send, react and pick; persisted in synced preferences, written 1.5 s after the last change (`ApiRequest::PatchUserSettings`) on top of the last snapshot so every other field stays byte for byte; replaced by another client's `USER_SETTINGS_UPDATE`. Soundboard favourites (#92) synced through the same preferences. - GIF search debounce 350/1000 ms, suggestions 250/900 ms via `Effect::Schedule`, featured cached per session, `register-share` on pick, auto-send or append with Shift. Stickers send alone or wait with text. Saved media from `READY.favorite_memes` and `FAVORITE_MEME_*` events. ## How it was tested `crates/fluxer-core/tests/chat_expressions.rs`: the 15 tests named in the plan, written first and seen failing, then passing. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally after merging the current `origin/textchat`. ## Deviations from the plan - `fluxer-proto`: `ReadyPayload.favorite_memes` added (shaped from `fluxer_api/src/api/rpc/RpcService.ts:1164`, read by the original in `GatewayReady.ts:150`), so saved media arrive with READY. Small, own commit. - `guilds.rs` untouched: guild emoji/stickers are held in `chat.expressions` (`guild_emojis` / `guild_stickers`). `session.rs` keeps the instance's GIF provider config for the picker's attribution. - Outside the Files list, minimal: `app.rs` / `chat/mod.rs` pass soundboard favourites and the composer/settings into the expressions reducer; `selectors/mod.rs` re-exports the selectors; `tests/chat_ports.rs` skips the expression actions in `stubs_emit_nothing` (they are no longer stubs). ## Review fixes (d1a94ee, tests in 9cd766e) - Finding 1 (blocking): the soundboard no longer reads synced favourites itself. The expressions compare each part of a snapshot with the last one; only a part another device changed replaces the local one and drops its pending change. Soundboard favourites reach the soundboard through `Expressions::take_soundboard_adopt`, applied in `App` after the text chat reduces (`voice/soundboard.rs` touched for this). The review's scenario (star, then an echo or an unrelated `USER_SETTINGS_UPDATE` within the debounce) is in `soundboard_favourites_sync`. - Finding 3: echoes no longer need to be byte-identical; the per-part comparison keeps pending local changes and writes them on top of the newest snapshot (patch answers included). Test in `prefs_written_debounced_1500ms`. - Finding 4: settings without `synced_preferences` change nothing (after the first snapshot). Test in `prefs_from_other_client_replace_local`. - Finding 2: follow-up #348 (base hash and `SYNCED_PREFERENCES_CONFLICT`). - Finding 5: left for Text chat 29 (#279): quick reactions and the context menu should emit `PickEmoji { target: Reaction }` so they count toward frecency. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally on b1bb741 (latest `origin/textchat` merged). Closes #264 🤖 Generated with [Claude Code](https://claude.com/claude-code)
# Conflicts:
#	crates/fluxer-proto/README.md
#	crates/fluxer-proto/src/gateway/events.rs
#	crates/fluxer-proto/src/models/channel.rs
#	crates/fluxer-proto/src/models/mod.rs
#	crates/fluxer-proto/src/models/settings.rs
#	crates/fluxer-proto/tests/models_roundtrip.rs
Refs #264

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Guild emoji and stickers from READY / GUILD_CREATE and the update events;
usability as checkEmojiAvailability (own guild, USE_EXTERNAL_EMOJIS /
STICKERS plus feature_global_expressions); the emoji picker's sections
(Favorited, Frequently used 42, guild sections, Unicode categories) and
merged search; sticker, saved media and GIF picker selectors.

Frecency counted on picks (composer, reaction, sticker, saved media) and
on the emoji of sent messages. The picker data, skin tone, favourite GIFs
and soundboard favourites (#92) are read from synced_preferences and
written 1.5 s after the last change on top of the last snapshot, every
other field byte for byte; an unreadable snapshot is never written over.

GIF search debounced 350/1000 ms, suggestions 250/900 ms, skeleton after
800 ms, featured cached per session, register-share on pick, auto-send or
append with Shift. Stickers send alone or wait with text; saved media send
favorite_meme_id and come with READY.favorite_memes (shaped from
fluxer_api/src/api/rpc/RpcService.ts:1164, read in GatewayReady.ts:150).

Refs #264

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Refs #264

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
# Conflicts:
#	crates/fluxer-proto/tests/models_roundtrip.rs
Author
Owner

Independent review: Text chat 14 (core expressions)

Scope: git diff origin/textchat...origin/textchat-14-core-expressions (11 files; the rest of 4eec2aa.. is Text chat 10 and later textchat merges).

Checked and OK

  • All 15 tests the plan names are in crates/fluxer-core/tests/chat_expressions.rs and assert the spec values: top 42, 1500 ms prefs debounce, GIF search 350/1000 ms, suggest 250/900 ms, skeleton 800 ms, register-share slug-else-id, sticker alone vs pending, favorite_meme_id.
  • Interfaces: selectors::{emoji_picker, sticker_picker, meme_picker, gif_picker, usable}, EmojiPickerModel { sections, locked_count, locked_guilds }, EmojiSection { id, label, icon, items }, EmojiCell { emoji, names, locked }, Usability::{Yes, NeedsPremium, NeedsPermission}, GifPickerModel { view, results, loading_skeleton, provider_name, .. } all exist as written.
  • Invariants: fluxer-core has no new dependency and does no I/O. Nothing logs URLs or paths. Text scanning uses get/char boundaries, so it cannot panic.
  • Writes are built on the last snapshot, and only dirty parts are re-encoded. prefs_write_preserves_unparsed_fields confirms that every other top-level field (unknown 999 included) stays byte for byte.
  • Deviation ReadyPayload.favorite_memes checked against the fork (RpcService.ts:1164, GatewayReady.ts:150). It is read leniently. OK.

Findings

  1. BLOCKING (loses user data): soundboard favourites starred locally are reverted by any USER_SETTINGS_UPDATE or UserSettingsPatched that arrives before the 1.5 s write, and the star is then never written. Soundboard::take_synced_favourites(settings, false) replaces favourites on every update/patch answer without checking for an echo or for pending local changes. The expressions side compares bytes, sees an echo, and keeps dirty.soundboard. When its timer fires, it writes ctx.soundboard_favourites, which is now the old list again, so next == base and nothing goes out. The server sends full settings in every USER_SETTINGS_UPDATE (guild-folder changes, DOB, voice-activity sharing, any other PATCH), and the echo of an in-flight expressions write does the same. I reproduced it with a scratch test: start from app(), ToggleFavouriteSound(key), then UserSettingsUpdate({synced_preferences: <same base>, theme: "light"}) within the debounce, then fire the 1500 ms timer. Result: favourites == ["default:1"], the starred key is gone, and no PATCH is sent. Fix: the soundboard should take synced favourites only when the expressions treat the snapshot as non-echo/remote, and never while dirty.soundboard is pending (for example, the expressions decide and pass the list through, or the soundboard skips when the snapshot's soundboard_favorites equals the last one it took). Add this scenario to soundboard_favourites_sync.

  2. minor (follow-up): no synced_preferences_base_hash and no conflict handling. The original sends synced_preferences_base_hash (sha256 of the base) and, on SYNCED_PREFERENCES_CONFLICT, refetches and merges (UserSettings.ts:990-1060). The proto (UserSettingsPatch.synced_preferences_base_hash) and fluxer-api (the conflict error) already support this. Without it, a write from the Electron app that lands between our last snapshot and our PATCH is overwritten by last-writer-wins. That includes non-picker fields. The window is about one gateway round trip. fluxer-core cannot hash without a dependency, so the runtime or fluxer-api could compute it from the base. Please open a follow-up issue linked from this PR.

  3. minor: echo detection compares exact bytes, but the server re-encodes the snapshot canonically (normalizeSyncedPreferencesSnapshot, UserAccountSettingsService.ts:522). If our encoding differs from the TS canonical form (field order, or unknown field 999 dropped by the TS decoder), every echo counts as a remote snapshot. A change made while a write is in flight (skin tone, favourite) would then be reverted to the server value. prefs_written_debounced_1500ms only checks a byte-identical echo. Consider adopting the patch answer's synced_preferences as the new base, as the original does with wireSyncedPreferencesBase = confirmedRaw, and re-applying the dirty fields on top instead of dropping them.

  4. minor: a user_settings object without a synced_preferences key reads as an empty snapshot (UserSettings::synced_prefs returns Ok(default)). The picker data is then replaced with empty data, and the next write encodes a near-empty snapshot. I reproduced this: the written snapshot was 9 bytes against 1238 before. The real server always sends the key (UserMappers.ts:367), so this only matters for partial payloads, but treating "key absent" as "unknown, keep base" would be safer.

  5. minor: frecency on quick reactions. The original also tracks emoji clicked in the hover bar's quick reactions and the context menu (MessageActionBar.tsx:182, MessageContextMenu.tsx:436). Here only PickEmoji and sent content count, so Text chat 29 must emit PickEmoji { target: Reaction } (or ToggleReaction must record) for parity. Noting it for Text chat 29.

CI: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally on 7efd571 (all steps passed; livekit-interop skipped as usual). Remote runners not checked.

Verdict: changes requested. One blocking finding (#1, soundboard favourites lost). The rest are minor or follow-up.

🤖 Generated with Claude Code

## Independent review: Text chat 14 (core expressions) Scope: `git diff origin/textchat...origin/textchat-14-core-expressions` (11 files; the rest of `4eec2aa..` is Text chat 10 and later textchat merges). **Checked and OK** - All 15 tests the plan names are in `crates/fluxer-core/tests/chat_expressions.rs` and assert the spec values: top 42, 1500 ms prefs debounce, GIF search 350/1000 ms, suggest 250/900 ms, skeleton 800 ms, register-share slug-else-id, sticker alone vs pending, `favorite_meme_id`. - Interfaces: `selectors::{emoji_picker, sticker_picker, meme_picker, gif_picker, usable}`, `EmojiPickerModel { sections, locked_count, locked_guilds }`, `EmojiSection { id, label, icon, items }`, `EmojiCell { emoji, names, locked }`, `Usability::{Yes, NeedsPremium, NeedsPermission}`, `GifPickerModel { view, results, loading_skeleton, provider_name, .. }` all exist as written. - Invariants: fluxer-core has no new dependency and does no I/O. Nothing logs URLs or paths. Text scanning uses `get`/char boundaries, so it cannot panic. - Writes are built on the last snapshot, and only dirty parts are re-encoded. `prefs_write_preserves_unparsed_fields` confirms that every other top-level field (unknown 999 included) stays byte for byte. - Deviation `ReadyPayload.favorite_memes` checked against the fork (`RpcService.ts:1164`, `GatewayReady.ts:150`). It is read leniently. OK. **Findings** 1. **BLOCKING (loses user data): soundboard favourites starred locally are reverted by any `USER_SETTINGS_UPDATE` or `UserSettingsPatched` that arrives before the 1.5 s write, and the star is then never written.** `Soundboard::take_synced_favourites(settings, false)` replaces `favourites` on every update/patch answer without checking for an echo or for pending local changes. The expressions side compares bytes, sees an echo, and keeps `dirty.soundboard`. When its timer fires, it writes `ctx.soundboard_favourites`, which is now the old list again, so `next == base` and nothing goes out. The server sends full settings in every `USER_SETTINGS_UPDATE` (guild-folder changes, DOB, voice-activity sharing, any other PATCH), and the echo of an in-flight expressions write does the same. I reproduced it with a scratch test: start from `app()`, `ToggleFavouriteSound(key)`, then `UserSettingsUpdate({synced_preferences: <same base>, theme: "light"})` within the debounce, then fire the 1500 ms timer. Result: `favourites == ["default:1"]`, the starred key is gone, and no PATCH is sent. Fix: the soundboard should take synced favourites only when the expressions treat the snapshot as non-echo/remote, and never while `dirty.soundboard` is pending (for example, the expressions decide and pass the list through, or the soundboard skips when the snapshot's `soundboard_favorites` equals the last one it took). Add this scenario to `soundboard_favourites_sync`. 2. **minor (follow-up): no `synced_preferences_base_hash` and no conflict handling.** The original sends `synced_preferences_base_hash` (sha256 of the base) and, on `SYNCED_PREFERENCES_CONFLICT`, refetches and merges (`UserSettings.ts:990-1060`). The proto (`UserSettingsPatch.synced_preferences_base_hash`) and fluxer-api (the conflict error) already support this. Without it, a write from the Electron app that lands between our last snapshot and our PATCH is overwritten by last-writer-wins. That includes non-picker fields. The window is about one gateway round trip. fluxer-core cannot hash without a dependency, so the runtime or fluxer-api could compute it from the base. Please open a `follow-up` issue linked from this PR. 3. **minor: echo detection compares exact bytes, but the server re-encodes the snapshot canonically** (`normalizeSyncedPreferencesSnapshot`, `UserAccountSettingsService.ts:522`). If our encoding differs from the TS canonical form (field order, or unknown field 999 dropped by the TS decoder), every echo counts as a remote snapshot. A change made while a write is in flight (skin tone, favourite) would then be reverted to the server value. `prefs_written_debounced_1500ms` only checks a byte-identical echo. Consider adopting the patch answer's `synced_preferences` as the new base, as the original does with `wireSyncedPreferencesBase = confirmedRaw`, and re-applying the dirty fields on top instead of dropping them. 4. **minor: a `user_settings` object without a `synced_preferences` key reads as an empty snapshot** (`UserSettings::synced_prefs` returns `Ok(default)`). The picker data is then replaced with empty data, and the next write encodes a near-empty snapshot. I reproduced this: the written snapshot was 9 bytes against 1238 before. The real server always sends the key (`UserMappers.ts:367`), so this only matters for partial payloads, but treating "key absent" as "unknown, keep base" would be safer. 5. **minor: frecency on quick reactions.** The original also tracks emoji clicked in the hover bar's quick reactions and the context menu (`MessageActionBar.tsx:182`, `MessageContextMenu.tsx:436`). Here only `PickEmoji` and sent content count, so Text chat 29 must emit `PickEmoji { target: Reaction }` (or `ToggleReaction` must record) for parity. Noting it for Text chat 29. **CI**: `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally on 7efd571 (all steps passed; livekit-interop skipped as usual). Remote runners not checked. **Verdict: changes requested.** One blocking finding (#1, soundboard favourites lost). The rest are minor or follow-up. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Review of #312: a soundboard star, a skin tone on its way, and a
settings update without synced_preferences.

Refs #264

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Each part of a snapshot replaces the local one only when another device
changed it; a pending local change otherwise survives and is written on
top. The soundboard no longer reads the settings itself: the expressions
decide and App applies their soundboard favourites after the text chat
reduces. Settings without synced_preferences change nothing.

Refs #264

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

Independent review: Text chat 14 (re-review at b1bb741, diff 9fcc13d..origin/textchat-14-core-expressions)

Checked: all 15 tests that Step 1 names exist and assert the plan's values (1500 ms debounce, top 42, 350/1000 and 250/900 ms GIF debounces, the 800 ms skeleton). The Interfaces names exist as the plan writes them: selectors::{emoji_picker, sticker_picker, meme_picker, gif_picker, usable}, EmojiPickerModel/EmojiSection/EmojiCell/SectionIcon, GifPickerModel { view, results, loading_skeleton, provider_name }, Usability::{Yes, NeedsPremium, NeedsPermission}. Crate invariants hold: no new dependency, no I/O, no file bytes or URLs in core. Writes rebuild the last snapshot and touch only the parts that changed, and prefs_write_preserves_unparsed_fields checks that every other top-level field stays byte for byte (Review Focus 3). Reading favorite_memes from READY matches the fork (RpcService.ts:1164). apply_remote's per-part changed() handles echoes, re-encoded echoes and updates to other settings correctly. Local FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci is green on b1bb741.

Findings

  1. Blocking (user data): a soundboard favourite deleted on another device comes back. apply_remote treats "first snapshot, synced list empty, local list non-empty" as the one-time migration (dirty.soundboard = true). That condition is true on every READY, not only once. Separately, favourites adopted from a snapshot (take_soundboard_adopt in App::apply) are never written to the local settings file, because persist::reduce saves voice.soundboard.prefs() only on ToggleFavouriteSound/SetSoundboardMute. So the local file keeps the old list forever.
    Scenario: device B starred x, and it synced. On device A the user unstars x, so the synced list is []. B adopts [] in memory, but its file still holds [x]. B restarts, loads [x], gets READY with [], and writes [x] back to the account. Every device sees x again.
    I confirmed this with a throwaway test, now removed: after the adopt it emits 0 SaveSettings and the file still holds the key; after the "restart" the write holds [key].
    Fix: persist the adopted list (save settings when take_soundboard_adopt returns Some). Also make the migration happen once, for example with a local soundboard_favourites_synced flag in LocalSettings set after the first successful write or adopt. Add a test for "remote clear, then restart, does not resurrect".
  2. Minor: a failed settings PATCH is not retried. write_prefs sets prefs.base = next and clears dirty before the answer arrives, and nothing handles EffectFailed for PatchUserSettings. If the PATCH fails, the next remote snapshot sees the part as "changed by another device" and reverts the local change. The next local write would re-send it only if no snapshot comes first. Suggest keeping the dirty flags until UserSettingsPatched arrives, or restoring them on failure. A follow-up issue is fine.
  3. Minor: a READY after a reconnect drops a pending change. self.prefs = PrefsSync::default() throws away a local change made within 1.5 s of a gateway re-identify: first replaces the picker data. This window is narrow, so a follow-up is fine.
  4. Minor (process): the task also touches fluxer-proto. It changes gateway/ready.rs (ReadyPayload.favorite_memes) and its README, so it touches a second crate outside the Files list. The plan says a two-crate task must be serialised and say so. The change is additive (lenient Vec, #[serde(default)]) and breaks no interface. Please say so in the PR body.

Earlier findings 2 (#348) and 5 (Text chat 29) are tracked as the PR body says. Findings 3 and 4 of the previous review are fixed and tested.

Verdict: changes requested. One blocking finding (1). ci is green locally; remote runners not checked.

## Independent review: Text chat 14 (re-review at b1bb741, diff 9fcc13d..origin/textchat-14-core-expressions) **Checked:** all 15 tests that Step 1 names exist and assert the plan's values (1500 ms debounce, top 42, 350/1000 and 250/900 ms GIF debounces, the 800 ms skeleton). The Interfaces names exist as the plan writes them: `selectors::{emoji_picker, sticker_picker, meme_picker, gif_picker, usable}`, `EmojiPickerModel/EmojiSection/EmojiCell/SectionIcon`, `GifPickerModel { view, results, loading_skeleton, provider_name }`, `Usability::{Yes, NeedsPremium, NeedsPermission}`. Crate invariants hold: no new dependency, no I/O, no file bytes or URLs in core. Writes rebuild the last snapshot and touch only the parts that changed, and `prefs_write_preserves_unparsed_fields` checks that every other top-level field stays byte for byte (Review Focus 3). Reading `favorite_memes` from READY matches the fork (`RpcService.ts:1164`). `apply_remote`'s per-part `changed()` handles echoes, re-encoded echoes and updates to other settings correctly. Local `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` is **green** on b1bb741. ### Findings 1. **Blocking (user data): a soundboard favourite deleted on another device comes back.** `apply_remote` treats "first snapshot, synced list empty, local list non-empty" as the one-time migration (`dirty.soundboard = true`). That condition is true on every `READY`, not only once. Separately, favourites adopted from a snapshot (`take_soundboard_adopt` in `App::apply`) are never written to the local settings file, because `persist::reduce` saves `voice.soundboard.prefs()` only on `ToggleFavouriteSound`/`SetSoundboardMute`. So the local file keeps the old list forever. Scenario: device B starred x, and it synced. On device A the user unstars x, so the synced list is `[]`. B adopts `[]` in memory, but its file still holds `[x]`. B restarts, loads `[x]`, gets `READY` with `[]`, and writes `[x]` back to the account. Every device sees x again. I confirmed this with a throwaway test, now removed: after the adopt it emits 0 `SaveSettings` and the file still holds the key; after the "restart" the write holds `[key]`. Fix: persist the adopted list (save settings when `take_soundboard_adopt` returns `Some`). Also make the migration happen once, for example with a local `soundboard_favourites_synced` flag in `LocalSettings` set after the first successful write or adopt. Add a test for "remote clear, then restart, does not resurrect". 2. **Minor: a failed settings PATCH is not retried.** `write_prefs` sets `prefs.base = next` and clears `dirty` before the answer arrives, and nothing handles `EffectFailed` for `PatchUserSettings`. If the PATCH fails, the next remote snapshot sees the part as "changed by another device" and reverts the local change. The next local write would re-send it only if no snapshot comes first. Suggest keeping the dirty flags until `UserSettingsPatched` arrives, or restoring them on failure. A follow-up issue is fine. 3. **Minor: a `READY` after a reconnect drops a pending change.** `self.prefs = PrefsSync::default()` throws away a local change made within 1.5 s of a gateway re-identify: `first` replaces the picker data. This window is narrow, so a follow-up is fine. 4. **Minor (process): the task also touches `fluxer-proto`.** It changes `gateway/ready.rs` (`ReadyPayload.favorite_memes`) and its README, so it touches a second crate outside the Files list. The plan says a two-crate task must be serialised and say so. The change is additive (lenient `Vec`, `#[serde(default)]`) and breaks no interface. Please say so in the PR body. Earlier findings 2 (#348) and 5 (Text chat 29) are tracked as the PR body says. Findings 3 and 4 of the previous review are fixed and tested. **Verdict: changes requested.** One blocking finding (1). ci is green locally; remote runners not checked.
- The soundboard favourites adopted from a snapshot are saved to the local
  settings (persist saves any change of them, whatever the event), and the
  "local list meets an empty synced list" migration runs once: the local
  settings remember that the list has been in step with the account
  ([voice.soundboard] synced, in fluxer-platform's settings file).
- A write of the synced preferences is tracked until answered; when it
  fails its parts go back into the snapshot and are pending again, and a
  snapshot that still holds what a write was built on is not another
  device's change.
- READY no longer resets the sync state: a change waiting in the debounce
  survives a re-identify.

Refs #264

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

Review round 1, addressed in 6de2258 (tests first; FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally).

Blocking: soundboard favourite deleted elsewhere comes back.

  • persist::reduce now saves the soundboard prefs whenever they differ from the store, on any event (READY included), not only on ToggleFavouriteSound/SetSoundboardMute. An adopted list is written to settings.toml.
  • The migration now runs only once. Soundboard::favourites_synced / SoundboardPrefs::synced ([voice.soundboard] synced = true) is set once the account's list is known to match the local one: a readable snapshot holds it, and no write of it is waiting or unanswered. ChatCtx::soundboard_synced gates the migration, so after that an empty synced list from another device wins, including on a machine that was off when the list was cleared.
  • Test: soundboard_favourites_cleared_elsewhere_stay_cleared. It covers the migration write, the answer saving synced, another device clearing the list (the empty list is adopted and saved), a restart (no write), and a stale local list after a restart (it gives way).
  • This touches fluxer-platform (src/settings.rs: one serde field with a default, plus its round-trip test), because the flag must survive a restart.

Minor: a failed write is reverted by the next snapshot.

  • write_prefs still advances base, so echoes stay harmless. It now records each write (PrefsWrite { id, fields, before }) until it is answered. If the write fails (EffectFailed with its id), its parts go back into base from before and are marked dirty again. A snapshot that still holds what an unanswered write was built on is not treated as another device's change. The write is not retried on its own, so a write that keeps failing cannot loop; the next change or the next snapshot writes it. Test: prefs_failed_write_keeps_the_local_change.

Minor: READY drops a change waiting in the debounce.

  • READY no longer resets PrefsSync. A re-identify compares parts with the known snapshot like any other snapshot, and merges usage instead of reloading it. Test: prefs_change_pending_survives_reidentify.

Minor: the second crate (fluxer-proto) is touched without saying so.

  • Noted here. The PR touches fluxer-proto (ReadyPayload.favorite_memes, lenient and additive, matching RpcService.ts:1164, and its README line). With this fix it also touches fluxer-platform (above). Both changes are additive.
Review round 1, addressed in 6de2258 (tests first; `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally). **Blocking: soundboard favourite deleted elsewhere comes back.** - `persist::reduce` now saves the soundboard prefs whenever they differ from the store, on any event (READY included), not only on `ToggleFavouriteSound`/`SetSoundboardMute`. An adopted list is written to `settings.toml`. - The migration now runs only once. `Soundboard::favourites_synced` / `SoundboardPrefs::synced` (`[voice.soundboard] synced = true`) is set once the account's list is known to match the local one: a readable snapshot holds it, and no write of it is waiting or unanswered. `ChatCtx::soundboard_synced` gates the migration, so after that an empty synced list from another device wins, including on a machine that was off when the list was cleared. - Test: `soundboard_favourites_cleared_elsewhere_stay_cleared`. It covers the migration write, the answer saving `synced`, another device clearing the list (the empty list is adopted and saved), a restart (no write), and a stale local list after a restart (it gives way). - This touches `fluxer-platform` (`src/settings.rs`: one serde field with a default, plus its round-trip test), because the flag must survive a restart. **Minor: a failed write is reverted by the next snapshot.** - `write_prefs` still advances `base`, so echoes stay harmless. It now records each write (`PrefsWrite { id, fields, before }`) until it is answered. If the write fails (`EffectFailed` with its id), its parts go back into `base` from `before` and are marked dirty again. A snapshot that still holds what an unanswered write was built on is not treated as another device's change. The write is not retried on its own, so a write that keeps failing cannot loop; the next change or the next snapshot writes it. Test: `prefs_failed_write_keeps_the_local_change`. **Minor: READY drops a change waiting in the debounce.** - READY no longer resets `PrefsSync`. A re-identify compares parts with the known snapshot like any other snapshot, and merges usage instead of reloading it. Test: `prefs_change_pending_survives_reidentify`. **Minor: the second crate (`fluxer-proto`) is touched without saying so.** - Noted here. The PR touches `fluxer-proto` (`ReadyPayload.favorite_memes`, lenient and additive, matching `RpcService.ts:1164`, and its README line). With this fix it also touches `fluxer-platform` (above). Both changes are additive.
Conflicts with Text chat 11 (composer), 12, 13, 15 and 18 resolved by keeping both sides.
The composer now inserts a picked emoji at the cursor itself, so the expressions only count
the pick (no second insertion); stickers and GIF links use the composer's Draft::new /
draft() and schedule the draft save. The 1500 ms prefs debounce test filters on its own timer,
since the pick also schedules the composer's 400 ms draft save.

Refs #264

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

Merged origin/textchat (b87bcd9) in 07ee073; FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally.

  • Conflicts with Text chat 11/12/13/15/18 (README, app.rs, chat/mod.rs, selectors/mod.rs, session.rs, tests/chat_ports.rs) resolved by keeping both sides.
  • Text chat 11 composer now inserts PickEmoji { target: Composer } at the cursor, so expressions no longer inserts it as well (it only records frecency and the pending pick). Without this the emoji would appear twice.
  • Pending stickers and GIF links appended to the draft use the composer's Draft::new(channel_id) / Composers::draft() (now pub(crate)), move the cursor to the end, and schedule the 400 ms draft save.
  • prefs_written_debounced_1500ms now filters on the 1500 ms timer, because the pick also schedules the composer's draft save.

🤖 Generated with Claude Code

Merged `origin/textchat` (b87bcd9) in 07ee073; `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. - Conflicts with Text chat 11/12/13/15/18 (README, `app.rs`, `chat/mod.rs`, `selectors/mod.rs`, `session.rs`, `tests/chat_ports.rs`) resolved by keeping both sides. - Text chat 11 composer now inserts `PickEmoji { target: Composer }` at the cursor, so `expressions` no longer inserts it as well (it only records frecency and the pending pick). Without this the emoji would appear twice. - Pending stickers and GIF links appended to the draft use the composer's `Draft::new(channel_id)` / `Composers::draft()` (now `pub(crate)`), move the cursor to the end, and schedule the 400 ms draft save. - `prefs_written_debounced_1500ms` now filters on the 1500 ms timer, because the pick also schedules the composer's draft save. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

Independent review: Text chat 14 (round 3, at 07ee073, diff b87bcd9..origin/textchat-14-core-expressions)

What I checked

  • Tests: all 15 tests that Step 1 names are in tests/chat_expressions.rs and assert the spec's values:

    • the 1500 ms prefs debounce;
    • "Frequently used" capped at 42;
    • GIF search 350/1000 ms, suggestions 250/900 ms, skeleton after 800 ms;
    • share id is the slug, else the id;
    • a sticker is sent alone, or held when the composer has text.

    The three tests added in round 2 are also present (soundboard list cleared elsewhere, failed write, re-identify).

  • Interfaces: the names exist exactly as the plan writes them:

    • selectors::{emoji_picker, sticker_picker, meme_picker, gif_picker, usable};
    • EmojiPickerModel { sections, locked_count, locked_guilds }, EmojiSection { id, label, icon, items }, EmojiCell { emoji, names, locked }, SectionIcon;
    • GifPickerModel { view, results, loading_skeleton, provider_name };
    • Usability::{Yes, NeedsPremium, NeedsPermission}.
  • Invariants:

    • fluxer-core gets no new dependency and does no I/O.
    • No file bytes, upload URLs or paths enter core, the logs or the fixtures. No new fixtures.
    • Server text is parsed without a panic path: custom_emoji_at and unicode_emoji_at slice only at char boundaries.
  • Review Focus 3:

    • Writes rebuild the last snapshot and replace only the parts that changed. prefs_write_preserves_unparsed_fields checks every other top-level field byte for byte, including unknown field 999 and emoji_picker field 9.
    • The 1.5 s debounce matches USAGE_SYNC_DEBOUNCE_MS in EmojiPicker.ts.
    • Usage is merged the way the original's mergeWireUsageMaps does it.
    • Saved media are read from READY, as the original does (RpcService.ts:1164, GatewayReady.ts:150).
  • Merge with Text chat 11: Text chat 11's composer inserts PickEmoji{Composer} at the cursor, and expressions now only counts the pick. I verified there is no double insert (frecency_recorded_on_send_react_pick asserts the draft is :blobwave:). Pending stickers go through Draft::sticker, which the Text chat 11/12 send paths turn into sticker_ids.

  • Settings load: persist::reduce now saves the soundboard prefs whenever they change. On Loaded, voice.load_settings runs before the comparison, so the loaded favourites are not overwritten.

Findings

  1. Minor (data, latent): ApiResult::UserSettingsPatched removes the oldest prefs write without checking which request it answers (expressions.rs, on_result). Today expressions is the only sender of PatchUserSettings, so this is correct for now. Once Text chat 19 patches the display settings through the same request, an answer to that patch will remove a prefs write that is still waiting. If that prefs write then fails, on_write_failed cannot find it. The next snapshot then looks like another device's change, and the local change is lost. Suggested fix: carry the EffectId on the answer, or have Text chat 19 route its answer separately. A follow-up issue (linked to Text chat 19) is enough.
  2. Minor: stickers, saved media and GIFs are sent straight as SendRichMessage, with no pending message. If the send fails, the user sees nothing. Possible follow-up for the UI tasks (27/28).
  3. Minor: a composer pick made while editing a message is still added to composer_picks. The next message the user sends in that channel then counts that emoji one time too few. The effect on frecency is negligible.
  4. Minor (process), already noted: this task also touches fluxer-proto (ReadyPayload.favorite_memes, additive) and fluxer-platform ([voice.soundboard] synced, serde default plus a round-trip test). Both changes are additive. Please say so in the PR body, as the plan asks.

Round 2's blocking finding (a soundboard favourite deleted on another device comes back) is fixed and tested. The two minor findings (failed write, re-identify) are also fixed and tested.

Local ci: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: not completed in this review session (the run was stopped while still compiling, when the review had to be returned), so I cannot confirm it is green; the implementer reports it green locally at 07ee073.

Verdict: no blocking findings in the code. Not approved yet, only because I could not confirm local ci; re-run FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci before adding ready-to-merge.

## Independent review: Text chat 14 (round 3, at 07ee073, diff b87bcd9..origin/textchat-14-core-expressions) **What I checked** - **Tests:** all 15 tests that Step 1 names are in `tests/chat_expressions.rs` and assert the spec's values: - the 1500 ms prefs debounce; - "Frequently used" capped at 42; - GIF search 350/1000 ms, suggestions 250/900 ms, skeleton after 800 ms; - share id is the slug, else the id; - a sticker is sent alone, or held when the composer has text. The three tests added in round 2 are also present (soundboard list cleared elsewhere, failed write, re-identify). - **Interfaces:** the names exist exactly as the plan writes them: - `selectors::{emoji_picker, sticker_picker, meme_picker, gif_picker, usable}`; - `EmojiPickerModel { sections, locked_count, locked_guilds }`, `EmojiSection { id, label, icon, items }`, `EmojiCell { emoji, names, locked }`, `SectionIcon`; - `GifPickerModel { view, results, loading_skeleton, provider_name }`; - `Usability::{Yes, NeedsPremium, NeedsPermission}`. - **Invariants:** - `fluxer-core` gets no new dependency and does no I/O. - No file bytes, upload URLs or paths enter core, the logs or the fixtures. No new fixtures. - Server text is parsed without a panic path: `custom_emoji_at` and `unicode_emoji_at` slice only at char boundaries. - **Review Focus 3:** - Writes rebuild the last snapshot and replace only the parts that changed. `prefs_write_preserves_unparsed_fields` checks every other top-level field byte for byte, including unknown field 999 and `emoji_picker` field 9. - The 1.5 s debounce matches `USAGE_SYNC_DEBOUNCE_MS` in `EmojiPicker.ts`. - Usage is merged the way the original's `mergeWireUsageMaps` does it. - Saved media are read from READY, as the original does (`RpcService.ts:1164`, `GatewayReady.ts:150`). - **Merge with Text chat 11:** Text chat 11's composer inserts `PickEmoji{Composer}` at the cursor, and expressions now only counts the pick. I verified there is no double insert (`frecency_recorded_on_send_react_pick` asserts the draft is `:blobwave:`). Pending stickers go through `Draft::sticker`, which the Text chat 11/12 send paths turn into `sticker_ids`. - **Settings load:** `persist::reduce` now saves the soundboard prefs whenever they change. On `Loaded`, `voice.load_settings` runs before the comparison, so the loaded favourites are not overwritten. ### Findings 1. **Minor (data, latent): `ApiResult::UserSettingsPatched` removes the oldest prefs write without checking which request it answers** (`expressions.rs`, `on_result`). Today `expressions` is the only sender of `PatchUserSettings`, so this is correct for now. Once Text chat 19 patches the display settings through the same request, an answer to that patch will remove a prefs write that is still waiting. If that prefs write then fails, `on_write_failed` cannot find it. The next snapshot then looks like another device's change, and the local change is lost. Suggested fix: carry the `EffectId` on the answer, or have Text chat 19 route its answer separately. A follow-up issue (linked to Text chat 19) is enough. 2. **Minor: stickers, saved media and GIFs are sent straight as `SendRichMessage`, with no pending message.** If the send fails, the user sees nothing. Possible follow-up for the UI tasks (27/28). 3. **Minor: a composer pick made while editing a message is still added to `composer_picks`.** The next message the user sends in that channel then counts that emoji one time too few. The effect on frecency is negligible. 4. **Minor (process), already noted:** this task also touches `fluxer-proto` (`ReadyPayload.favorite_memes`, additive) and `fluxer-platform` (`[voice.soundboard] synced`, serde default plus a round-trip test). Both changes are additive. Please say so in the PR body, as the plan asks. Round 2's blocking finding (a soundboard favourite deleted on another device comes back) is fixed and tested. The two minor findings (failed write, re-identify) are also fixed and tested. **Local ci:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: not completed in this review session (the run was stopped while still compiling, when the review had to be returned), so I cannot confirm it is green; the implementer reports it green locally at 07ee073. **Verdict: no blocking findings in the code. Not approved yet, only because I could not confirm local ci; re-run `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` before adding `ready-to-merge`.**
Author
Owner

Independent review: Text chat 14 (round 4, at 07ee073, diff b87bcd9..origin/textchat-14-core-expressions)

The remote branch has not changed since round 3. The implementer's fix for round-3 minor 3 and its merge of origin/textchat (12e0695) are local only. They are not on origin/textchat-14-core-expressions, so this round reviews 07ee073.

What I checked

  • Tests: all 15 tests that Step 1 names are in tests/chat_expressions.rs and assert the spec's values: prefs debounce 1500 ms, "Frequently used" capped at 42 (ordered by use), GIF search 350/1000 ms, suggestions 250/900 ms, skeleton after 800 ms, share id = slug else id, sticker sent alone or held with text, favorite_meme_id, and the FAVORITE_MEME_* events. The three round-2 tests are also present (soundboard list cleared elsewhere, failed write, re-identify).
  • Interfaces: the names match the plan exactly: selectors::{emoji_picker(&App, &str, &PickerFilter), sticker_picker, meme_picker, gif_picker(&App), usable(&App, &EmojiRef, Option<Snowflake>)}, EmojiPickerModel { sections, locked_count, locked_guilds }, EmojiSection { id, label, icon, items }, EmojiCell { emoji, names, locked }, SectionIcon, GifPickerModel { view, results, loading_skeleton, provider_name, .. }, Usability::{Yes, NeedsPremium, NeedsPermission}.
  • Invariants:
    • fluxer-core has no Cargo change, no I/O and no clock, and holds no file bytes, upload URLs or paths. Its logs carry no URLs.
    • No new fixtures. ReadyPayload.favorite_memes matches the fork (RpcService.ts:1164) and is read leniently.
    • Server text is scanned at char boundaries only (custom_emoji_at, unicode_emoji_at). Nonce arithmetic cannot panic.
    • The fluxer-platform change is additive: synced uses a serde default and is skipped when false.
  • Review Focus 3: each write is built on the last decoded snapshot, and only the parts that changed are re-encoded (usage_stats keeps each entry's unknown fields). prefs_write_preserves_unparsed_fields passes. Writes are debounced 1.5 s. Echoes, failed writes and re-identifies keep the pending local change.
  • Local ci: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci is green on 07ee073 ("all steps passed"; chat_expressions 18/18).

Findings

  1. Minor (round-3 #3, still open on the branch): while a message is being edited, a composer pick still goes into composer_picks (expressions.rs, PickEmoji). The fix and the test emoji_picked_into_an_edit_is_not_a_composer_pick exist only in the implementer's local worktree. Push them, or leave the item as is (frecency impact is negligible).
  2. Minor (process, round-3 #4, still open): the PR body lists the fluxer-proto change but still does not name the additive fluxer-platform change (SoundboardFile.synced plus its round-trip test).
  3. Minor (efficiency, new; for Text chat 27): emoji_picker calls usable() once per candidate. For every custom emoji, usable() rescans every guild's list (emoji_guild) and recomputes the guild features, limits and channel permissions. That makes the selector O(custom²) on each call. Candidate.guild is already known, so computing availability once per guild would make it linear. This only matters if the UI calls the selector on every frame; the picker task can memoise it instead.
  4. Round-3 #1 and #2 have follow-up issues: #373 and #374 (both open, label follow-up). OK.

Verdict: approved. No blocking findings, and local ci is green on 07ee073. If the local fix for minor 1 (with the 12e0695 merge) is pushed, re-run FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci on the new head before ready-to-merge.

🤖 Generated with Claude Code

## Independent review: Text chat 14 (round 4, at 07ee073, diff b87bcd9..origin/textchat-14-core-expressions) The remote branch has not changed since round 3. The implementer's fix for round-3 minor 3 and its merge of `origin/textchat` (12e0695) are local only. They are not on `origin/textchat-14-core-expressions`, so this round reviews 07ee073. **What I checked** - **Tests:** all 15 tests that Step 1 names are in `tests/chat_expressions.rs` and assert the spec's values: prefs debounce 1500 ms, "Frequently used" capped at 42 (ordered by use), GIF search 350/1000 ms, suggestions 250/900 ms, skeleton after 800 ms, share id = slug else id, sticker sent alone or held with text, `favorite_meme_id`, and the `FAVORITE_MEME_*` events. The three round-2 tests are also present (soundboard list cleared elsewhere, failed write, re-identify). - **Interfaces:** the names match the plan exactly: `selectors::{emoji_picker(&App, &str, &PickerFilter), sticker_picker, meme_picker, gif_picker(&App), usable(&App, &EmojiRef, Option<Snowflake>)}`, `EmojiPickerModel { sections, locked_count, locked_guilds }`, `EmojiSection { id, label, icon, items }`, `EmojiCell { emoji, names, locked }`, `SectionIcon`, `GifPickerModel { view, results, loading_skeleton, provider_name, .. }`, `Usability::{Yes, NeedsPremium, NeedsPermission}`. - **Invariants:** - `fluxer-core` has no Cargo change, no I/O and no clock, and holds no file bytes, upload URLs or paths. Its logs carry no URLs. - No new fixtures. `ReadyPayload.favorite_memes` matches the fork (`RpcService.ts:1164`) and is read leniently. - Server text is scanned at char boundaries only (`custom_emoji_at`, `unicode_emoji_at`). Nonce arithmetic cannot panic. - The `fluxer-platform` change is additive: `synced` uses a serde default and is skipped when false. - **Review Focus 3:** each write is built on the last decoded snapshot, and only the parts that changed are re-encoded (`usage_stats` keeps each entry's unknown fields). `prefs_write_preserves_unparsed_fields` passes. Writes are debounced 1.5 s. Echoes, failed writes and re-identifies keep the pending local change. - **Local ci:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` is **green** on 07ee073 ("all steps passed"; `chat_expressions` 18/18). ### Findings 1. **Minor (round-3 #3, still open on the branch):** while a message is being edited, a composer pick still goes into `composer_picks` (`expressions.rs`, `PickEmoji`). The fix and the test `emoji_picked_into_an_edit_is_not_a_composer_pick` exist only in the implementer's local worktree. Push them, or leave the item as is (frecency impact is negligible). 2. **Minor (process, round-3 #4, still open):** the PR body lists the `fluxer-proto` change but still does not name the additive `fluxer-platform` change (`SoundboardFile.synced` plus its round-trip test). 3. **Minor (efficiency, new; for Text chat 27):** `emoji_picker` calls `usable()` once per candidate. For every custom emoji, `usable()` rescans every guild's list (`emoji_guild`) and recomputes the guild features, limits and channel permissions. That makes the selector O(custom²) on each call. `Candidate.guild` is already known, so computing availability once per guild would make it linear. This only matters if the UI calls the selector on every frame; the picker task can memoise it instead. 4. Round-3 #1 and #2 have follow-up issues: #373 and #374 (both open, label `follow-up`). OK. **Verdict: approved. No blocking findings, and local ci is green on 07ee073.** If the local fix for minor 1 (with the 12e0695 merge) is pushed, re-run `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` on the new head before `ready-to-merge`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
charles manually merged commit a8c9c3f4fd into textchat 2026-11-13 02:14:15 +00:00
Sign in to join this conversation.
No description provided.