Stop watching an ended stream by itself; soundboard one sound per user and 5/2s limit (#867, #869) #875

Closed
charles wants to merge 0 commits from fix-867-869-stream-end-soundboard-limits into textchat
Owner

Closes #867
Closes #869

#867 — a stream that ends stops being watched by itself

What the original does (~/src/fluxer-soundboard):

  • If the streamer's voice state has self_stream:false and there is no screen-share track, the open call view drops the watch at once (pruneInactiveWatchedStreamsForChannel).
  • If TrackUnpublished arrives while the voice state still shares, the drop waits PUBLISHER_REPUBLISH_GRACE_MS (4 s, deferStopWatchingStreamKey). A republish within that time cancels it.
  • If the sharer leaves the channel, the watch is dropped.
  • The viewer's own reconnect keeps its watch keys.
  • When the focused stream's key goes, the pin is cleared and the view goes back to the grid. Focus does not move to another stream. The PiP closes, or shows another watched stream if there is one.

Cause: Flaxative dropped a watched key only when its streamer left the channel. A share that stopped stayed watched as "Stream ended". It kept the focus view and the PiP card until the user clicked "Stop watching". That behaviour was deliberate, but it was not what the original does.

Fix (fluxer-core voice/stream/watch.rs):

  • A key is dropped at once when its streamer's voice state no longer shares and the room has no publication of it.
  • A key is dropped REPUBLISH_GRACE (4 s) after its publication went while the voice state still shares, unless it is published again in that time.
  • The grace only runs while this client's own room is joined, so a room replacement or reconnect drops nothing.
  • The op 4 goes out in the same event. No viewer chime plays.
  • The UI's focus and PiP already follow the watch list, so they go with it.
  • A new share by the same person is not watched automatically.
  • One difference remains: during the 4 s grace the tile shows "Stream ended". The original shows no such overlay then.

Tests:

  • Core (tests/stream_watch.rs): sharer_stopping_ends_the_watch (both orders of voice state and unpublish), sharer_leaving_ends_the_watch, a_brief_interruption_keeps_the_watch_a_longer_one_ends_it, ending_one_of_two_watched_streams_keeps_the_other, own_room_being_replaced_ends_no_watch.
  • Headless UI (fluxer-ui/tests/stream_focus.rs): stream_ending_closes_the_focus_view_and_the_pip_card. It renders the call view and checks that the "{name}'s screen" title and "LIVE" are gone, there is no focus and no "Stop watching stream" button, and the PiP model is None after the grace.
  • Runtime against DevServer + FakeRoom (apps/fluxer/tests/screenshare_runtime.rs): watched_stream_ending_stops_watching_by_itself (quick republish keeps the watch; unpublishing for good ends it after ≥ 4 s and its frames leave the bus) and streamer_voice_state_not_sharing_stops_watching_at_once.
  • stream_tile.rs and streamer_leaving_prunes_key asserted the old "stays ended" behaviour. They now assert the new one.

#869 — one sound per user, 5 sounds per 2 s per user (deliberate divergence)

Cause: this is new behaviour. The original mixes every relayed sound and relies on the server's 10 per 10 s limit.

Fix (fluxer-core voice/soundboard.rs):

  • One sound per user. ClipPlayer keeps each user's current clip until the engine reports its end, even past the speaking mark, so a clip longer than announced is still stopped. When a user's new soundboard or entrance sound is requested, it sends AudioCommand::StopClip for that user's current clip and drops their clips still waiting for a file. Previews and other users are untouched.
  • Stop through the existing port. This uses the existing StopClip(ClipTag), keyed per user in the store. fluxer-audio is unchanged.
  • Rate limit. SoundRateLimit is a sliding window on the store clock (notif_settings.now()): 5 per 2 s per user.
    • Incoming sounds from others beyond the limit are dropped: not shown, not played, and they stop nothing.
    • The user's own PlaySound beyond the limit is not sent. It starts the picker's existing cooldown ("Slow down! You can play another sound in N seconds.") until the oldest send leaves the window.
    • A send the server refuses is removed from the window.
    • The user's own sounds relayed back by the server are not counted a second time.
    • Entrance sounds are not counted, but they stop that user's playing sound.
    • Per-user mute and volume are unchanged.
  • Recorded in docs/parity/voice.md.

Tests:

  • Unit tests in soundboard.rs: exactly 5 allowed, the 6th dropped, the window slides; users are independent; a clock set back is handled.
  • Integration tests in tests/soundboard.rs:
    • a_new_sound_stops_the_one_its_sender_still_plays (other users mix; own sounds)
    • a_clip_longer_than_announced_is_still_stopped_by_the_next
    • a_sound_still_waiting_for_its_file_never_plays_after_a_newer_one
    • incoming_sounds_beyond_five_in_two_seconds_are_dropped
    • own_sends_beyond_five_in_two_seconds_are_not_sent_and_count_down
    • entrance_sounds_are_not_counted_but_stop_the_users_sound
    • listener_mute_and_volume_still_apply_under_the_new_rules
  • effect_send_plays_with_capped_gain now plays its two simultaneous clips from two users.
  • voice_acceptance paces its 10 sends to the client limit, so the 429 still comes from the server.

Gate

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: ==> xtask ci: all steps passed. Goldens are unchanged.

🤖 Generated with Claude Code

Closes #867 Closes #869 ## #867 — a stream that ends stops being watched by itself **What the original does** (`~/src/fluxer-soundboard`): - If the streamer's voice state has `self_stream:false` and there is no screen-share track, the open call view drops the watch at once (`pruneInactiveWatchedStreamsForChannel`). - If `TrackUnpublished` arrives while the voice state still shares, the drop waits `PUBLISHER_REPUBLISH_GRACE_MS` (4 s, `deferStopWatchingStreamKey`). A republish within that time cancels it. - If the sharer leaves the channel, the watch is dropped. - The viewer's own reconnect keeps its watch keys. - When the focused stream's key goes, the pin is cleared and the view goes back to the grid. Focus does not move to another stream. The PiP closes, or shows another watched stream if there is one. **Cause:** Flaxative dropped a watched key only when its streamer left the channel. A share that stopped stayed watched as "Stream ended". It kept the focus view and the PiP card until the user clicked "Stop watching". That behaviour was deliberate, but it was not what the original does. **Fix** (`fluxer-core` `voice/stream/watch.rs`): - A key is dropped at once when its streamer's voice state no longer shares and the room has no publication of it. - A key is dropped `REPUBLISH_GRACE` (4 s) after its publication went while the voice state still shares, unless it is published again in that time. - The grace only runs while this client's own room is joined, so a room replacement or reconnect drops nothing. - The op 4 goes out in the same event. No viewer chime plays. - The UI's focus and PiP already follow the watch list, so they go with it. - A new share by the same person is not watched automatically. - One difference remains: during the 4 s grace the tile shows "Stream ended". The original shows no such overlay then. **Tests:** - Core (`tests/stream_watch.rs`): `sharer_stopping_ends_the_watch` (both orders of voice state and unpublish), `sharer_leaving_ends_the_watch`, `a_brief_interruption_keeps_the_watch_a_longer_one_ends_it`, `ending_one_of_two_watched_streams_keeps_the_other`, `own_room_being_replaced_ends_no_watch`. - Headless UI (`fluxer-ui/tests/stream_focus.rs`): `stream_ending_closes_the_focus_view_and_the_pip_card`. It renders the call view and checks that the "{name}'s screen" title and "LIVE" are gone, there is no focus and no "Stop watching stream" button, and the PiP model is `None` after the grace. - Runtime against DevServer + FakeRoom (`apps/fluxer/tests/screenshare_runtime.rs`): `watched_stream_ending_stops_watching_by_itself` (quick republish keeps the watch; unpublishing for good ends it after ≥ 4 s and its frames leave the bus) and `streamer_voice_state_not_sharing_stops_watching_at_once`. - `stream_tile.rs` and `streamer_leaving_prunes_key` asserted the old "stays ended" behaviour. They now assert the new one. ## #869 — one sound per user, 5 sounds per 2 s per user (deliberate divergence) **Cause:** this is new behaviour. The original mixes every relayed sound and relies on the server's 10 per 10 s limit. **Fix** (`fluxer-core` `voice/soundboard.rs`): - **One sound per user.** `ClipPlayer` keeps each user's current clip until the engine reports its end, even past the speaking mark, so a clip longer than announced is still stopped. When a user's new soundboard or entrance sound is requested, it sends `AudioCommand::StopClip` for that user's current clip and drops their clips still waiting for a file. Previews and other users are untouched. - **Stop through the existing port.** This uses the existing `StopClip(ClipTag)`, keyed per user in the store. fluxer-audio is unchanged. - **Rate limit.** `SoundRateLimit` is a sliding window on the store clock (`notif_settings.now()`): 5 per 2 s per user. - Incoming sounds from others beyond the limit are dropped: not shown, not played, and they stop nothing. - The user's own `PlaySound` beyond the limit is not sent. It starts the picker's existing cooldown ("Slow down! You can play another sound in N seconds.") until the oldest send leaves the window. - A send the server refuses is removed from the window. - The user's own sounds relayed back by the server are not counted a second time. - Entrance sounds are not counted, but they stop that user's playing sound. - Per-user mute and volume are unchanged. - Recorded in `docs/parity/voice.md`. **Tests:** - Unit tests in `soundboard.rs`: exactly 5 allowed, the 6th dropped, the window slides; users are independent; a clock set back is handled. - Integration tests in `tests/soundboard.rs`: - `a_new_sound_stops_the_one_its_sender_still_plays` (other users mix; own sounds) - `a_clip_longer_than_announced_is_still_stopped_by_the_next` - `a_sound_still_waiting_for_its_file_never_plays_after_a_newer_one` - `incoming_sounds_beyond_five_in_two_seconds_are_dropped` - `own_sends_beyond_five_in_two_seconds_are_not_sent_and_count_down` - `entrance_sounds_are_not_counted_but_stop_the_users_sound` - `listener_mute_and_volume_still_apply_under_the_new_rules` - `effect_send_plays_with_capped_gain` now plays its two simultaneous clips from two users. - `voice_acceptance` paces its 10 sends to the client limit, so the 429 still comes from the server. ## Gate `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: `==> xtask ci: all steps passed`. Goldens are unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A new soundboard or entrance sound of a user stops theirs still playing
(StopClip of the clip the store tracks per user, kept until the engine
reports its end) and drops theirs still waiting for a file; different
users still mix. Each user is held to 5 soundboard sounds in a sliding
2 s window on the store clock: others' sounds beyond it are dropped,
the user's own are not sent and the picker shows the cooldown notice.
Entrance sounds are not counted. A deliberate divergence, recorded in
docs/parity/voice.md.

Refs #869

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As the original: a watched key is dropped at once when its streamer's
voice state no longer shares and the room has no publication of it
(pruneInactiveWatchedStreamsForChannel), or REPUBLISH_GRACE (4 s, the
original's PUBLISHER_REPUBLISH_GRACE_MS) after its publication went
while the voice state still shares, unless it is published again
meanwhile. The grace runs only while this client's own room is joined,
so its own reconnect or room replacement drops nothing. The op 4 goes
out in the same event; no viewer chime. The call view's focus and the
picture-in-picture card follow the watch list, so they go with it.

Refs #867

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 429 step sends 10 sounds to reach the dev server's limit; with the
client's limit of 5 in 2 s they now wait out the client window, so the
refusal is still the server's.

Refs #869

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

Merged into textchat by hand (the merge API returns 405); the commits are in the branch.

Merged into `textchat` by hand (the merge API returns 405); the commits are in the branch.
charles closed this pull request 2026-11-18 07:43:52 +00:00
charles referenced this pull request from a commit 2026-11-18 07:45:41 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.