feat(wiki): live wiki-editing presence banner (LC-498) #495
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/LC-498-wiki-editing-presence"
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?
LC-498: Live wiki editing presence (the viable slice)
The ticket flags TRUE collaborative co-editing (CRDT/OT, per-keystroke shared state) as
[DEFER]- it fights the server-render + OOB-fragment model. The ticket's own recommendation is the presence-only compromise, and that's what this ships: a live "X is editing the wiki" banner on the room About page, reusing the typing-indicator infrastructure. True co-edit stays deferred.What a user sees
While someone has the room wiki editor open, everyone else viewing that room's About page sees a live " is editing the wiki..." banner under the Wiki heading. It appears as soon as they focus the editor and clears a few seconds after they blur, save, or navigate away. Last-writer-wins on save is unchanged - this is awareness, not locking.
How it works (mirrors the typing indicator)
ws/hub.rs): awiki_editingDashMap parallel totyping, withnotify_wiki_editing/stop_wiki_editing. A heartbeat broadcastsWikiEditingto the room except the editor's own connection, then a 5s idle-eviction task broadcastsWikiStoppedEditing. Ephemeral, no DB.ChatEvent::WikiEditing/WikiStoppedEditing(transient, likeUserTyping).ClientFrame::WikiEditing { room_id }, handled exactly liketyping(gated on room subscription).render_eventarms +ws/wiki_editing.html/ws/wiki_stopped_editing.html, OOB-swapping#wiki-editing. Recipient-independent (the typing fragment is too, so like typing the banner text is not localized).data-lc-live-room) and has a#wiki-editingslot outside#wiki-content(survives the edit/view fragment swaps). The wiki editor fragment heartbeats{type:'wiki_editing'}on focus + every 3s + on input via the existingwindow.__lcWS; the 3s heartbeat keeps the banner up through reading/thinking pauses, and the 5s server eviction clears it after the editor leaves.Scope
Presence only. No new dependency, no DB change, no schema migration; reuses the WebSocket hub, the typing pattern, and the existing wiki edit/view fragments. No saas gating needed (room-scoped, not admin-only). True concurrent co-editing remains deferred per the ticket.
Tests
just check(clippy standalone + saas + desktop + fmt),just test,just test-saasall pass. New hub unit testwiki_editing_presence_excludes_editor_and_clears(banner goes to viewers not the editor, no duplicate mid-session broadcast, idempotent stop).Manual smoke test (recommend before merge)
Two browsers, same room: open the wiki editor in one, confirm the other's About page shows "X is editing the wiki..." and that it clears a few seconds after save / blur.