publish-a-snapshot-on-taking-the-role
Installation
SKILL.md
Edge-triggered publishers have nothing to say about the past
A source-of-truth participant publishes by watching its own state and reacting to changes: an item
transition, a play/pause, a seek, a queue edit. Each of those is a collector over a flow with
distinctUntilChanged on it, and that is the right shape — it is also why the group can start
completely empty.
Someone who was already playing when they opened the session produces no change at all. Nothing transitions, nothing toggles, so none of the watchers fire, and every follower waits for a command that only arrives if the source happens to touch its transport. Two level-triggered publishers close the gap:
// adapted — names generalized
private suspend fun publishOnTakingTheRole() {
room.map { it.inRoom && it.isSource }.distinctUntilChanged()
.collect { isSource -> if (isSource) publishSnapshot() }
}