Text chat 56: fluxer-core soundboard: preview, live cooldown, managing any guild's sounds, editing (#385) #399

Manually merged
charles merged 2 commits from textchat-56-core-soundboard-parity into textchat 2026-11-13 03:30:12 +00:00
Owner

What this builds (Text chat 56, fluxer-core soundboard)

  • Preview (SoundboardPlaybackEngine.preview): UserAction::PreviewSound { guild_id, sound_id, volume } fetches the sound under the same clip key that playing it uses, then sends AudioCommand::PlayClip under PREVIEW_CLIP_TAG (ClipTag(u64::MAX)) at soundboard_gain(volume.unwrap_or(sound.volume), soundboard_volume, output_volume), using the new ClipKind::Preview { gain }. It plays in or out of a call and ignores "Play soundboard sounds", the listener mutes and deafening. Nobody is marked as speaking and no effect emoji shows. PreviewLocalSound { bytes, content_type, volume } sends AudioCommand::PlayClipBytes under a fresh local:<n> key. StopPreview sends AudioCommand::StopClip(PREVIEW_CLIP_TAG). Only one preview plays at a time: a new preview drops one still being fetched and stops one that is playing. Soundboard::previewing is set on play and cleared by ClipFinished of that tag or by StopPreview. The ClipFinished of a preview the store already stopped is counted and ignored, so it does not end the next preview.
  • Live cooldown (#138): SendCooldown { timer, duration, remaining, tick }. The first tick fires at remaining % 1 s (or 1 s when that is zero), then every 1 s. The last second ends with timer, so no extra tick is scheduled for it. PickerModel::cooldown is now remaining.
  • Managing sounds of any guild (#140): Guilds::guild_permissions(user, guild) is the base of permissions_in, which now uses it. selectors::can_manage_sound and selectors::can_upload_sound are new.
  • Editing: UserAction::EditSound { guild_id, sound_id, name, volume, emoji } sends ApiRequest::UpdateSound with only the changed fields. An emoji change writes both emoji_id and emoji_name; removing the emoji sends null/null. Nothing is sent when nothing changed, and an invalid name is not sent. The outcome is in Soundboard::edit: EditState, which SoundUpdated clears. RenameSound is unchanged.

Tests

All 20 tests the plan names are in crates/fluxer-core/tests/soundboard.rs. I saw them fail to compile before the implementation and pass after it. The existing soundboard and entrance tests still pass. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci passes locally on Linux.

Deviations from the plan

  • The plan says UploadError::Name. The merged code has UploadError::NameLength, so I used that.
  • apps/fluxer/src/audio_rt.rs is outside the Files list. I changed it only so the runtime compiles with the two new AudioCommand variants:
    • PlayClipBytes goes to AudioEngine::play_clip with the bytes.
    • StopClip sets the clip's gain to 0 for now, because AudioEngine::stop_clip comes in Task 58. Task 61 does the full wiring.
  • I did not need to change effect.rs: ApiRequest::UpdateSound already existed.

Closes #385

🤖 Generated with Claude Code

## What this builds (Text chat 56, `fluxer-core` soundboard) - **Preview** (`SoundboardPlaybackEngine.preview`): `UserAction::PreviewSound { guild_id, sound_id, volume }` fetches the sound under the same clip key that playing it uses, then sends `AudioCommand::PlayClip` under `PREVIEW_CLIP_TAG` (`ClipTag(u64::MAX)`) at `soundboard_gain(volume.unwrap_or(sound.volume), soundboard_volume, output_volume)`, using the new `ClipKind::Preview { gain }`. It plays in or out of a call and ignores "Play soundboard sounds", the listener mutes and deafening. Nobody is marked as speaking and no effect emoji shows. `PreviewLocalSound { bytes, content_type, volume }` sends `AudioCommand::PlayClipBytes` under a fresh `local:<n>` key. `StopPreview` sends `AudioCommand::StopClip(PREVIEW_CLIP_TAG)`. Only one preview plays at a time: a new preview drops one still being fetched and stops one that is playing. `Soundboard::previewing` is set on play and cleared by `ClipFinished` of that tag or by `StopPreview`. The `ClipFinished` of a preview the store already stopped is counted and ignored, so it does not end the next preview. - **Live cooldown** (#138): `SendCooldown { timer, duration, remaining, tick }`. The first tick fires at `remaining % 1 s` (or 1 s when that is zero), then every 1 s. The last second ends with `timer`, so no extra tick is scheduled for it. `PickerModel::cooldown` is now `remaining`. - **Managing sounds of any guild** (#140): `Guilds::guild_permissions(user, guild)` is the base of `permissions_in`, which now uses it. `selectors::can_manage_sound` and `selectors::can_upload_sound` are new. - **Editing**: `UserAction::EditSound { guild_id, sound_id, name, volume, emoji }` sends `ApiRequest::UpdateSound` with only the changed fields. An emoji change writes both `emoji_id` and `emoji_name`; removing the emoji sends `null`/`null`. Nothing is sent when nothing changed, and an invalid name is not sent. The outcome is in `Soundboard::edit: EditState`, which `SoundUpdated` clears. `RenameSound` is unchanged. ## Tests All 20 tests the plan names are in `crates/fluxer-core/tests/soundboard.rs`. I saw them fail to compile before the implementation and pass after it. The existing soundboard and entrance tests still pass. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` passes locally on Linux. ## Deviations from the plan - The plan says `UploadError::Name`. The merged code has `UploadError::NameLength`, so I used that. - `apps/fluxer/src/audio_rt.rs` is outside the Files list. I changed it only so the runtime compiles with the two new `AudioCommand` variants: - `PlayClipBytes` goes to `AudioEngine::play_clip` with the bytes. - `StopClip` sets the clip's gain to 0 for now, because `AudioEngine::stop_clip` comes in Task 58. Task 61 does the full wiring. - I did not need to change `effect.rs`: `ApiRequest::UpdateSound` already existed. Closes #385 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #385

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

Independent review: Text chat 56 (9424abd, diff 6113a8e..textchat-56-core-soundboard-parity)

Checks

  1. Tests: all 20 tests the plan names are in crates/fluxer-core/tests/soundboard.rs, and each asserts what the plan asks with the spec's values. The cooldown runs 2400 ms, then a tick at 400 ms, then 2000, then 1000, shown as 3, 2, 1 seconds. The fallback counts down from 2 s. Clearing the emoji sends {"emoji_id":null,"emoji_name":null}. An invalid name and an edit with no changes send nothing.
  2. Interfaces: these all exist as the plan writes them: PreviewSound, PreviewLocalSound, StopPreview, PlayClipBytes {key, bytes, content_type, gain, tag}, StopClip(ClipTag), PREVIEW_CLIP_TAG, ClipKind::Preview { gain } (pub(crate); Task 57 uses it inside core), Soundboard::previewing, SendCooldown {timer, duration, remaining, tick}, PickerModel::cooldown = remaining, Guilds::guild_permissions, can_manage_sound, can_upload_sound, EditSound, EditState::{Idle, Saving, Failed}, and RenameSound is kept. The one deviation is UploadError::NameLength in place of the plan's UploadError::Name. The merged code already uses NameLength, so this is accepted.
  3. Invariants: fluxer-core gets no new dependency. Sound bytes enter core only as SoundBytes, whose Debug prints only the byte count. No path, URL or bytes are logged, and the change adds no new fixtures. permissions_in now builds on guild_permissions and behaves the same as before.
  4. Review Focus: no item belongs to this task.
  5. FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in the review worktree: all steps passed.

Findings

  • minor, voice/soundboard.rs (stopped_previews): the counter is wrong whenever the engine sends no ClipFinished for a stopped preview.
    • With the interim audio_rt (until Task 61), StopClip only sets the gain to 0. The next PlayClip under the same tag replaces the old clip in the engine (engine.rs "The same tag again replaces what it was playing"), and the engine reports no ClipFinished for it. So whenever a new preview replaces one that is playing, the counter stays at 1, and previewing stays true after the new preview ends.
    • The same happens after Task 58/61 if stop_clip reports nothing when the clip has already ended (the race the implementer describes).
    • Once off, the counter stays off until the call channel changes, and never resets outside a call.
    • Task 58/61 should make stop_clip report ClipFinished exactly once per StopClip, even when nothing is playing, or the store should track previews by generation instead of counting.
    • Only the button state is affected; no data is lost. Proposed as a follow-up.
  • minor, voice/soundboard.rs (channel change): joining a call resets previewing to false without sending StopClip. An out-of-call preview that is still playing then shows as stopped. This is only the button state.
  • minor, edit_sound: for a sound whose list is not loaded, every field is sent, including emoji_id/emoji_name: null when emoji is None, which clears a server-side emoji. The dialog always opens from a loaded tile, so this is acceptable. Noted for Task 59.
  • minor, PreviewLocalSound gain: this uses soundboard volume × output volume. The entrance trimmer (Tasks 57/60) may want the output volume alone, as playPreview does.

Verdict: approve. There are no blocking findings, and local CI is green.

## Independent review: Text chat 56 (9424abd, diff 6113a8e..textchat-56-core-soundboard-parity) **Checks** 1. Tests: all 20 tests the plan names are in `crates/fluxer-core/tests/soundboard.rs`, and each asserts what the plan asks with the spec's values. The cooldown runs 2400 ms, then a tick at 400 ms, then 2000, then 1000, shown as 3, 2, 1 seconds. The fallback counts down from 2 s. Clearing the emoji sends `{"emoji_id":null,"emoji_name":null}`. An invalid name and an edit with no changes send nothing. 2. Interfaces: these all exist as the plan writes them: `PreviewSound`, `PreviewLocalSound`, `StopPreview`, `PlayClipBytes {key, bytes, content_type, gain, tag}`, `StopClip(ClipTag)`, `PREVIEW_CLIP_TAG`, `ClipKind::Preview { gain }` (pub(crate); Task 57 uses it inside core), `Soundboard::previewing`, `SendCooldown {timer, duration, remaining, tick}`, `PickerModel::cooldown = remaining`, `Guilds::guild_permissions`, `can_manage_sound`, `can_upload_sound`, `EditSound`, `EditState::{Idle, Saving, Failed}`, and `RenameSound` is kept. The one deviation is `UploadError::NameLength` in place of the plan's `UploadError::Name`. The merged code already uses `NameLength`, so this is accepted. 3. Invariants: fluxer-core gets no new dependency. Sound bytes enter core only as `SoundBytes`, whose `Debug` prints only the byte count. No path, URL or bytes are logged, and the change adds no new fixtures. `permissions_in` now builds on `guild_permissions` and behaves the same as before. 4. Review Focus: no item belongs to this task. 5. `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in the review worktree: **all steps passed**. **Findings** - **minor**, `voice/soundboard.rs` (`stopped_previews`): the counter is wrong whenever the engine sends no `ClipFinished` for a stopped preview. - With the interim `audio_rt` (until Task 61), `StopClip` only sets the gain to 0. The next `PlayClip` under the same tag replaces the old clip in the engine (`engine.rs` "The same tag again replaces what it was playing"), and the engine reports no `ClipFinished` for it. So whenever a new preview replaces one that is playing, the counter stays at 1, and `previewing` stays true after the new preview ends. - The same happens after Task 58/61 if `stop_clip` reports nothing when the clip has already ended (the race the implementer describes). - Once off, the counter stays off until the call channel changes, and never resets outside a call. - Task 58/61 should make `stop_clip` report `ClipFinished` exactly once per `StopClip`, even when nothing is playing, or the store should track previews by generation instead of counting. - Only the button state is affected; no data is lost. Proposed as a follow-up. - **minor**, `voice/soundboard.rs` (channel change): joining a call resets `previewing` to false without sending `StopClip`. An out-of-call preview that is still playing then shows as stopped. This is only the button state. - **minor**, `edit_sound`: for a sound whose list is not loaded, every field is sent, including `emoji_id`/`emoji_name: null` when `emoji` is `None`, which clears a server-side emoji. The dialog always opens from a loaded tile, so this is acceptable. Noted for Task 59. - **minor**, `PreviewLocalSound` gain: this uses soundboard volume × output volume. The entrance trimmer (Tasks 57/60) may want the output volume alone, as `playPreview` does. **Verdict: approve.** There are no blocking findings, and local CI is green.
Merge remote-tracking branch 'origin/textchat' into textchat-56-core-soundboard-parity
Some checks failed
ci / Windows (x64) (push) Successful in 9m52s
ci / Start the release build (push) Has been cancelled
ci / Linux (x86_64) (push) Has been cancelled
8784e9cd78
charles manually merged commit 8784e9cd78 into textchat 2026-11-13 03:30:11 +00:00
Sign in to join this conversation.
No description provided.