Screen share 9: watching, subscriptions, stream volume, viewer chimes (#156) #206
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "screenshare-9-core-watching"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on: screenshare-8-core-stream-ports
What this builds (Screen share 9, spec §3.5 and §6.3 "Watch", "Subscriptions", "Remote stream state")
UserAction::{WatchStream, AddStream, StopWatching, StopWatchingAll, SetStreamVolume { key, percent }, SetStreamMuted { key, muted }}.voice/stream/watch.rs: the watch list. A key is taken only if its streamer is in the key's channel right now and it is not this client's own key. Watch/Add outside the key's channel joins it (or moves there), and the join's op 4 carries the key. A key is pruned when its streamer leaves the channel, and all keys go when the connection leaves voice or moves. A key is rewritten when its streamer starts sharing from a new connection.voice/connection.rs: every op 4 (join, move, flag change, resend after RESUMED/READY) carriesviewer_stream_keyswith the current flags (Link::sentreplacessent_flags). It only includes keys the gateway accepts: same guild and channel as the connection, and the streamer present there. This covers review focus 2.voice/live.rs: screen-share video is subscribed iff watched, and its audio iff watched and not effectively deafened. Each is told once per publication. AfterReconnectedonly the tracks that were being received are asked for again. Cameras keep the old "told false once" behaviour. The stream gain isstream_gain(vol, muted, output)=volume_gain(vol) × volume_gain(output), or 0 when muted, sent onPlaybackSource::Stream(identity).voice/stream/audio_prefs.rs:StreamAudioPrefs(volume 0–200, muted, last used). They are kept inLocalSettings::stream_audio, kept across logout, and pruned on load and every 10 min.Sound.tsone-shot queue.RemoteStream/RemoteStreamState::{Waiting, Buffering, Playing { w, h }, Ended, Failed { code }}per watched video sid;Streams::remote_for(&key).Tests
crates/fluxer-core/tests/stream_watch.rs: the plan's 12 tests. I watched them fail (they did not compile) before the implementation, and they pass now.audio_prefs.rs. Thefluxer-platformsettings round-trip test now covers[voice.stream_audio].FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally. No real-device tests apply to this task.Deviations / things to look at
VoiceEvent::SubscriptionFailed { identity, sid, error }inport.rs: no existing event reports a subscription failure.fluxer-voicedoes not emit it yet; Screen share 16/17 should.fluxer-platform/src/settings.rs(outside the Files list): I added the[voice.stream_audio]table so the prefs survive a restart. Without it, "persisted" would only reachLocalSettings.VideoFrameInfoarrives only on the first frame and on size changes (Task 16), soBufferingmeans "no first frame within 5 s of subscribing". It is not a stall detector.voice_livetest still holds: afterReconnected, unwatched screen tracks are not told again.Closes #156
🤖 Generated with Claude Code
Independent review: Screen share 9 (core watching), commit
748af6fScope:
git diff 0d406eb..origin/screenshare-9-core-watching.Local gate:
FLUXER_SCREENSHOT_TESTS=1 cargo xtask cipasses in a clean review worktree (all steps; livekit-interop skipped as designed).Checks
crates/fluxer-core/tests/stream_watch.rsand check what the plan says. They use the spec values: 180 ms debounce, 900 ms cooldown, 5 s buffering, 6 h TTL and 10 min prune, gain =volume_gain(vol) × volume_gain(output)(0 when muted), video subscribed iff watched, audio iff watched and not deaf, and the own key is never watched or received.UserAction::{WatchStream, AddStream, StopWatching, StopWatchingAll, SetStreamVolume { key, percent }, SetStreamMuted { key, muted }},StreamAudioPrefs(persisted, pruned on load and each tick),RemoteStream/RemoteStreamState(Waiting/Buffering/Playing{w,h}/Ended/Failed{code}) andStreams.remote: BTreeMap<sid, RemoteStream>all match the plan and spec §6.1. Buffering goes throughEffect::Schedule.unwrap/expect/indexing on server data. No secrets: the"status-token-fixture"string is a placeholder.announced()builds each op 4'sviewer_stream_keysthroughkey_valid_in: the key must be sendable, in the target's guild and channel, and its streamer's connection must be present in that channel.sync()compares the wholeAnnounced, so a change to the flags or the keys sends an op 4 that carries both.watchablerejects the own connection's key. During a move or join,send_state(new_target)filters the old channel's keys out beforeprune_watchingruns, so no bad key is ever sent.key_of_other_channel_never_sentcovers the DM, orphan, other-guild and move cases.Findings
fluxer-platform(settings.rs, README, tests), which is outside the task's Files list and a second crate. The plan does not mark the task as serialised. The change is needed for persistence and is backward compatible (#[serde(default)], and keys that do not parse are dropped). Note it in the PR body.VoiceEvent::SubscriptionFailedis new inport.rs, but nothing emits it yet. Task 16/17 must report it, orFailedcan never be reached. Please file afollow-upissue that links Task 16/17.migrateWatchedRemoteStreamConnectionin two ways. First, it fires only when a connection newly shares; the fork also rewrites on any update from an already-sharing second device. Second, like the fork, it needs the old connection still listed as sharing. If the old connection's leave arrives before the new one starts sharing, the key is pruned rather than rewritten, and the viewer has to re-watch. The divergence is reasonable; please mention it in spec §14.SaveSettingsevery 10 min while any stream preference exists. This is harmless.Verdict: approve. No blocking findings and local CI is green.