Repository navigation
feat(positron): presence re-publish cue for late subscribers (#118) - #1741
Merged
Merged
Conversation
The presence emitter (`positron_presence::run_presence_loop`) publishes `presence:updated` only when the roster *changes* — an idle re-render is a wasted revision bump. On a stable roster it fires once, then goes silent. A projector (chat/wall/kanban) that (re)starts *after* that one-and-only publish never receives presence, so it holds a roster-empty view until the roster next happens to change: card/message authors render provisionally forever (#118). Fix = a re-publish cue that keeps the single-emitter-owns-roster compression: - A booting presence CONSUMER calls `request_presence_resync(bus)` on boot, publishing a `presence:resync` cue (realtime `presence:` prefix → never coalesced). - `run_presence_loop` now `select!`s over its 2s ticker AND the bus receiver; a resync cue force-re-publishes the current roster (bypassing the change-dedup). Read+project+publish is factored into `emit_once` (shared by the tick and cue paths). Bus-closed disables the cue arm (no busy-loop) while the ticker keeps owning the roster read. - All three projectors (chat, wall, kanban — each folds `presence:updated` for author resolution) cue on boot, right after subscribing `rx` so the emitter's re-publish lands in their buffer. The cue is room-agnostic: the chat projection is room-following (it does not know its room at boot), each per-room emitter re-asserts only its own roster, and consumers already filter presence by room — so a broadcast cue is correct and precise per-room routing is a premature optimization for the single-room reality. Tests (positron_presence): a resync force-re-publishes an unchanged roster (the idle path dedups it); `request_presence_resync` emits the cue event. Wall (8) + kanban (9) projector suites stay green through the insertions. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…w D1) The adversarial review of #1741 caught that the "why room-agnostic" comment justified the broadcast cue with "every consumer already filters presence by room" — which is FALSE for the chat projector. Its `apply_presence` calls `switch_room(update.room_id)`, adopting the update's room and wiping the previously-focused room's messages + roster (room-FOLLOWING, not room-filtering). Under today's single emitter this is harmless (every `presence:updated` names the same room). But the comment green-lit the multi-room case it would actually break: a second room's emitter re-publishing on a broadcast cue would yank the chat projector off the focused room. Correct the comment to state the real invariant — safe only while ≤1 room has a live emitter — and name the two multi-room fixes (room_id on the cue, or a room guard in `apply_presence`) so the landmine is documented, not hidden. Comment-only; no behavior change. `cargo check` clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the late-subscriber presence gap (#118). The presence emitter (
positron_presence::run_presence_loop) publishespresence:updatedonly on a roster change (change-dedup — an idle re-render is a wasted revision bump). On a stable roster it fires once, then goes silent. Any projector (chat / wall / kanban) that (re)starts after that one-and-only publish never receives presence → it holds a roster-empty view until the roster next happens to change, so message/card authors render provisionally forever.Fix — a presence re-publish cue (keeps single-emitter-owns-roster compression)
request_presence_resync(bus)on boot → publishes apresence:resynccue.presence:-prefixed, so the bus treats it as realtime and never coalesces it.run_presence_loopnowselect!s over its 2s ticker and the bus receiver. A matching cue force-re-publishes the current roster (bypassing the change-dedup). Read+project+publish is factored into oneemit_oncehelper shared by the tick (force=false) and cue (force=true) paths. Bus-closed disables the cue arm (if bus_openguard — no busy-loop) while the ticker keeps owning the roster read.positron_source::spawn), wall (run_wall_loop), kanban (run_kanban_loop), each of which foldspresence:updatedfor author/creator/assignee resolution — cue on boot, right after subscribingrx, so the emitter's re-publish lands in their buffer.Why room-agnostic
The cue carries no
room_id: the chat projection is room-following (it doesn't know its room at boot), each per-room emitter re-asserts only its own roster on any cue, and every consumer already filters presence by room. So a broadcast cue is correct; precise per-room routing is a premature optimization for the single-room reality (add aroom_idwhen multi-room emitters make the idle re-reads matter, not before).Doctrine
Null(a resync requests a roster, it doesn't carry one — no fabricated payload); a roster read error inemit_onceskips the emit and keeps the last roster (reader owns reconnection), never substitutes fabricated data.request_presence_resynchelper.Tests (one
mod tests, each// what this catches:)resync_forces_republish_of_unchanged_roster— the idle path dedups an unchanged roster; a resyncforces a re-publish anyway (the actual Build(deps-dev): Bump eslint from 9.24.0 to 9.35.0 #118 gap).request_presence_resync_publishes_the_cue— the consumer-side half actually emitspresence:resync.Validated:
cargo check+ scopedcargo test(--features metal,accelerate), disk swept.🤖 Generated with Claude Code