Voice 10: fluxer-core::voice soundboard and entrance sounds (#71) #130

Manually merged
charles merged 0 commits from voice-10-core-soundboard into voice 2026-11-11 23:43:26 +00:00
Owner

What

The soundboard and entrance sounds in fluxer-core::voice (Voice spec §5.2):

  • voice/soundboard.rs: Soundboard (by_guild, defaults, favourites <= 100, cooldown_until, listener_mutes, upload state), lazy per-guild fetch on OpenSoundboard, the three GUILD_SOUNDBOARD_SOUND_* events, VOICE_CHANNEL_EFFECT_SEND -> FetchMedia -> AudioCommand::PlayClip with gain capped at 3, sender marked speaking for duration + 80 ms, emoji shown (active_effects), 429 cooldown from retry_after or 2000 ms, upload validation (name 2-32, <= 20 MiB, MP3/OGG/M4A/WAV sniffed, <= 200 per guild), selectors soundboard_picker, can_use_soundboard.
  • voice/entrance.rs: after connecting, FetchEntranceSounds then PostEntranceSound with the scope-resolved selection (guild, guilds, global / dms, global); ENTRANCE_SOUND_PLAY plays after the sender's join chime, waiting up to 1500 ms for their voice state.
  • ApiRequest/ApiResult/UserAction variants as in the Interfaces block (plus FetchEntranceSounds, SoundSent, EntranceSoundPosted); favourites and listener mutes persisted in LocalSettings::soundboard.

Testing

crates/fluxer-core/tests/soundboard.rs: all nine plan tests, driven through App::apply with the scrubbed fixtures. Unit tests for favourite keys, audio sniffing, name checks, entrance scope fallback. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally.

Deviations / outside the Files list

  • guilds.rs: Guilds::permissions_in(user, channel) extracted from selectors::sidebar::can_view (which now uses it) so the soundboard can check CONNECT/SPEAK/USE_SOUNDBOARD/USE_EXTERNAL_SOUNDS.
  • voice/live.rs: has_room made pub(crate); user_speaking includes a playing clip unless the sender shows muted.
  • tests/calls.rs: the api helper ignores FetchEntranceSounds, which every connection now makes.
  • apps/fluxer/src/runtime.rs: arms for the new requests so the workspace compiles; FetchMedia downloads and drops the bytes until Voice 14 wires the audio engine.
  • fluxer-platform settings: [voice.soundboard] table (favourites, listener_mutes) with a round-trip assertion.
  • persist.rs: #[allow(clippy::large_enum_variant)] on PersistResult (the new boxed field tipped Loaded over the lint threshold; boxing it would touch ~20 call sites).
  • SoundCreated/SoundUpdated carry Box<SoundboardSound>.
  • Default sounds without a URL are dropped (this client bundles none); per-user entrance volume is not ported.

Closes #71

🤖 Generated with Claude Code

## What The soundboard and entrance sounds in `fluxer-core::voice` (Voice spec §5.2): - `voice/soundboard.rs`: `Soundboard` (by_guild, defaults, favourites <= 100, cooldown_until, listener_mutes, upload state), lazy per-guild fetch on `OpenSoundboard`, the three `GUILD_SOUNDBOARD_SOUND_*` events, `VOICE_CHANNEL_EFFECT_SEND` -> `FetchMedia` -> `AudioCommand::PlayClip` with gain capped at 3, sender marked speaking for duration + 80 ms, emoji shown (`active_effects`), 429 cooldown from `retry_after` or 2000 ms, upload validation (name 2-32, <= 20 MiB, MP3/OGG/M4A/WAV sniffed, <= 200 per guild), selectors `soundboard_picker`, `can_use_soundboard`. - `voice/entrance.rs`: after connecting, `FetchEntranceSounds` then `PostEntranceSound` with the scope-resolved selection (guild, guilds, global / dms, global); `ENTRANCE_SOUND_PLAY` plays after the sender's join chime, waiting up to 1500 ms for their voice state. - `ApiRequest`/`ApiResult`/`UserAction` variants as in the Interfaces block (plus `FetchEntranceSounds`, `SoundSent`, `EntranceSoundPosted`); favourites and listener mutes persisted in `LocalSettings::soundboard`. ## Testing `crates/fluxer-core/tests/soundboard.rs`: all nine plan tests, driven through `App::apply` with the scrubbed fixtures. Unit tests for favourite keys, audio sniffing, name checks, entrance scope fallback. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally. ## Deviations / outside the Files list - `guilds.rs`: `Guilds::permissions_in(user, channel)` extracted from `selectors::sidebar::can_view` (which now uses it) so the soundboard can check CONNECT/SPEAK/USE_SOUNDBOARD/USE_EXTERNAL_SOUNDS. - `voice/live.rs`: `has_room` made `pub(crate)`; `user_speaking` includes a playing clip unless the sender shows muted. - `tests/calls.rs`: the `api` helper ignores `FetchEntranceSounds`, which every connection now makes. - `apps/fluxer/src/runtime.rs`: arms for the new requests so the workspace compiles; `FetchMedia` downloads and drops the bytes until Voice 14 wires the audio engine. - `fluxer-platform` settings: `[voice.soundboard]` table (favourites, listener_mutes) with a round-trip assertion. - `persist.rs`: `#[allow(clippy::large_enum_variant)]` on `PersistResult` (the new boxed field tipped `Loaded` over the lint threshold; boxing it would touch ~20 call sites). - `SoundCreated`/`SoundUpdated` carry `Box<SoundboardSound>`. - Default sounds without a URL are dropped (this client bundles none); per-user entrance volume is not ported. Closes #71 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(core): soundboard and entrance sounds
All checks were successful
ci / Linux (x86_64) (push) Successful in 8m43s
ci / Windows (x64) (push) Successful in 8m5s
add3ec139a
Refs #71

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

Independent review: Voice 10 (core-soundboard), commit add3ec1

I reviewed only 4b4e513..origin/voice-10-core-soundboard.

(1) Plan tests: all 9 named tests are in crates/fluxer-core/tests/soundboard.rs and check the spec's values: gain = sound volume × soundboard volume × output volume, capped at 3 (Review Focus 5; it also covers NaN and infinite inputs); speaking lasts the clip duration + 80 ms; a 429 sets the cooldown from retry_after, or 2000 ms when it is missing; at most 100 favourites with keys <guild|default>:<sound>, kept in the settings; picker order is favourites, current guild, external guilds, defaults, with USE_EXTERNAL_SOUNDS gating the external ones; the three gateway events update the list; upload checks name 2–32, size up to 20 MiB and at most 200 sounds per guild before any request; the entrance sound is posted after connect and plays after the join chime.

(2) Interfaces: Soundboard { by_guild, defaults, favourites: Vec<String>, cooldown_until, listener_mutes }, every ApiRequest/ApiResult/UserAction variant listed, and soundboard_picker(&App) -> PickerModel, can_use_soundboard(&App) -> bool and active_effects(&App) exist, re-exported from selectors. cooldown_until is an Option<SendCooldown> (a timer and its duration), not a timestamp. That fits the store having no clock, and the UI only needs to check is_some.

(3) Invariants: fluxer-core gains no dependency and no I/O. Server data cannot panic it: favourite keys are parsed with checks, durations are capped at MAX_CLIP_DURATION, gains are clamped, and the settings file is normalised on load. SoundBytes Debug does not print the file. No tokens are in code or fixtures. fetch_media (from Task 2) does not attach auth. The clippy::large_enum_variant allow on PersistResult is reasonable: it has a reason and covers a one-shot variant. The muted-sender speaking rule (shown_muted = self_mute | mute | suppress) matches participant_speaking and spec §5.2. Moving the permission code from sidebar::can_view into Guilds::permissions_in keeps the behaviour the same.

(4) Review Focus 5: met (see (1)).

(5) FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: green locally (all steps passed).

Findings

  • minor: The plan says "FetchMedia (skipped when the audio engine reports the clip cached)". Core always emits FetchMedia for a clip key it is not already fetching, and leaves the cache short-cut to the runtime (the ApiResult::Media doc says "or the audio engine still has it"). This is fine as long as Voice 14 answers FetchMedia from the engine cache without a download. Voice 14 should note it.
  • minor: shown_muted does not count deaf/self_deaf, whereas spec "effective mute" does. This matches the existing participant_speaking, and a deafened sender cannot send a sound, so the only case left is an entrance sound from a deafened joiner showing them speaking. Cosmetic.
  • minor: The entrance clip ignores per-user entrance volume and mute. The module doc says this is deliberate; it may need a parity entry later.

Verdict: APPROVE. No blocking findings, and ci is green locally.

## Independent review: Voice 10 (core-soundboard), commit add3ec1 I reviewed only `4b4e513..origin/voice-10-core-soundboard`. **(1) Plan tests:** all 9 named tests are in `crates/fluxer-core/tests/soundboard.rs` and check the spec's values: gain = sound volume × soundboard volume × output volume, capped at 3 (Review Focus 5; it also covers NaN and infinite inputs); speaking lasts the clip duration + 80 ms; a 429 sets the cooldown from `retry_after`, or 2000 ms when it is missing; at most 100 favourites with keys `<guild|default>:<sound>`, kept in the settings; picker order is favourites, current guild, external guilds, defaults, with `USE_EXTERNAL_SOUNDS` gating the external ones; the three gateway events update the list; upload checks name 2–32, size up to 20 MiB and at most 200 sounds per guild before any request; the entrance sound is posted after connect and plays after the join chime. **(2) Interfaces:** `Soundboard { by_guild, defaults, favourites: Vec<String>, cooldown_until, listener_mutes }`, every `ApiRequest`/`ApiResult`/`UserAction` variant listed, and `soundboard_picker(&App) -> PickerModel`, `can_use_soundboard(&App) -> bool` and `active_effects(&App)` exist, re-exported from `selectors`. `cooldown_until` is an `Option<SendCooldown>` (a timer and its duration), not a timestamp. That fits the store having no clock, and the UI only needs to check `is_some`. **(3) Invariants:** fluxer-core gains no dependency and no I/O. Server data cannot panic it: favourite keys are parsed with checks, durations are capped at `MAX_CLIP_DURATION`, gains are clamped, and the settings file is normalised on load. `SoundBytes` Debug does not print the file. No tokens are in code or fixtures. `fetch_media` (from Task 2) does not attach auth. The `clippy::large_enum_variant` allow on `PersistResult` is reasonable: it has a reason and covers a one-shot variant. The muted-sender speaking rule (`shown_muted` = self_mute | mute | suppress) matches `participant_speaking` and spec §5.2. Moving the permission code from `sidebar::can_view` into `Guilds::permissions_in` keeps the behaviour the same. **(4) Review Focus 5:** met (see (1)). **(5) `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`:** green locally (`all steps passed`). ### Findings - **minor:** The plan says "FetchMedia (skipped when the audio engine reports the clip cached)". Core always emits `FetchMedia` for a clip key it is not already fetching, and leaves the cache short-cut to the runtime (the `ApiResult::Media` doc says "or the audio engine still has it"). This is fine as long as Voice 14 answers `FetchMedia` from the engine cache without a download. Voice 14 should note it. - **minor:** `shown_muted` does not count `deaf`/`self_deaf`, whereas spec "effective mute" does. This matches the existing `participant_speaking`, and a deafened sender cannot send a sound, so the only case left is an entrance sound from a deafened joiner showing them speaking. Cosmetic. - **minor:** The entrance clip ignores per-user entrance volume and mute. The module doc says this is deliberate; it may need a parity entry later. **Verdict: APPROVE.** No blocking findings, and ci is green locally.
charles manually merged commit 09de2137ea into voice 2026-11-11 23:43:26 +00:00
Sign in to join this conversation.
No description provided.