feat(realtime): live sidebar room list on enclave room add/remove (LC-174) #219
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-174-live-sidebar-rooms"
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?
Closes LC-174. Continuation of LC-170.
EnclaveRoom{Added,Removed}already updated the/enclave/{id}landing room list (#lc-enclave-rooms) for landing viewers, but a member sitting in one of the enclave's rooms saw a newly-added public room in their sidebar only after a reload.Approach: enclave-keyed sidebar nav
The scrollable sidebar nav body is extracted into
partials/sidebar_nav.html(shared bypartials/sidebar.htmland the live fragment). The<nav>wrapper now carriesid="sidebar-nav-{enclave_id}"when viewing an enclave (plainsidebar-navotherwise). OnEnclaveRoom{Added,Removed}the WS send task additionally rendersws/sidebar_nav_live.htmlper recipient viaload_sidebar(viewer, Some(enclave_id))and OOB-swaps#sidebar-nav-{enclave_id}.The enclave-keyed id is the crux of correctness: htmx applies the swap only on a connection whose current page is that enclave (its landing, settings, or a room in it). A connection on Home, on a different enclave, or a stale topic subscriber (a user who left the enclave's pages but whose hub subscription has not been cleaned up - see LC-176) all have a different nav id and silently drop the swap. So this does not depend on per-connection page tracking, nor on LC-176 landing first. Per-recipient rendering via
load_sidebarkeeps unread / mention / active-room state correct.Delivery to room viewers
room/page.htmlnow addsdata-lc-live-topic="enclave:{eid}"alongside its existingdata-lc-live-roomwhen the room belongs to an enclave (live.js subscribes both from the one element). Landing / settings pages already subscribe (LC-170/172). TheEnclaveRoomarm emits both fragments in one frame - the landing#lc-enclave-roomslist and the#sidebar-nav-{eid}swap - and each connection applies whichever id its page has.Verification
just testandjust test-saasboth green (106test result: okeach, zero failures);cargo clippy/cargo fmtclean. Regression test (routes_enclave_nav::room_page_subscribes_to_enclave_topic_and_keys_sidebar_nav) asserts a room page in an enclave subscribes to the enclave topic and carries the enclave-keyed sidebar-nav id. The nav extraction intopartials/sidebar_nav.htmlis markup-preserving (verified by the existing sidebar-rendering tests still passing).Continuation of LC-170. EnclaveRoom{Added,Removed} already updated the /enclave/{id} landing room list (#lc-enclave-rooms) for landing viewers, but a member sitting in one of the enclave's rooms saw a newly-added public room in their sidebar only after a reload. Approach: an enclave-keyed sidebar nav. The scrollable nav body is extracted into partials/sidebar_nav.html (shared by the sidebar and the live fragment); the <nav> wrapper carries id="sidebar-nav-{enclave_id}" when viewing an enclave (plain "sidebar-nav" otherwise). On EnclaveRoom{Added,Removed} the WS send task now ALSO renders ws/sidebar_nav_live.html per recipient via load_sidebar(viewer, Some(enclave_id)) and OOB-swaps #sidebar-nav-{enclave_id}. The enclave-keyed id is the crux: htmx applies the swap only on a connection whose current page is that enclave (its landing, settings, or a room in it); a connection on Home, on a different enclave, or a stale topic subscriber (a user who left the enclave's pages but whose hub subscription has not been cleaned up yet - see LC-176) all have a different nav id and silently drop the swap. So correctness does not depend on per-connection page tracking or on LC-176 landing first. Rendering per recipient via load_sidebar keeps unread / mention / active-room state correct. To make room-page viewers actually receive the event, room/page.html now adds data-lc-live-topic="enclave:{eid}" alongside its existing data-lc-live-room when the room belongs to an enclave (live.js subscribes both from the one element). Landing/settings pages already subscribe (LC-170/172). The EnclaveRoom arm emits both fragments in one frame: the landing #lc-enclave-rooms list and the #sidebar-nav-{eid} swap; each connection applies whichever id its page has. Regression test: a room page in an enclave subscribes to the enclave topic and carries the enclave-keyed sidebar-nav id. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>