fix(sidebar): live category change uses enclave-keyed nav fragment (LC-331) #342

Merged
nrupard merged 1 commit from fix/lc-331-sidebar-categories-live into main 2026-06-17 20:48:20 +02:00
Owner

What

Fix the WS handler for ChatEvent::SidebarCategoriesChanged so live sidebar category updates render the enclave-keyed nav fragment instead of the whole-sidebar DM-only shape.

Why

render_sidebar hardcodes current_enclave = None, producing the DM-only Home shape (no categories, no enclave rooms), and the category-change arm OOB-swapped that over #sidebar. For a member viewing the enclave this caused two bugs (LC-331): adding or deleting a category blanked the chat list until a manual refresh, and moving a chat into a category reverted a couple seconds later when the broadcast landed (the DB write via set_room_positions / assign_room upsert persists correctly; only the live render was wrong).

Fix

Route the event through the existing LC-174 render_enclave_sidebar_nav(state, viewer, enclave_id), which renders #sidebar-nav-{enclave_id} via load_sidebar(.., Some(enclave_id)). The id-keyed target is self-limiting: a connection on Home, a different enclave, or a stale subscription lacks the target and htmx drops the swap. No template, DB, or client-JS change. render_sidebar is retained for its remaining DM-creation / mute callers.

Test

just test and just test-saas both green; just fmt clean. Manual: add/delete a category and drag a chat across categories while viewing an enclave; the list updates in place and the move sticks.

#LC-331

## What Fix the WS handler for `ChatEvent::SidebarCategoriesChanged` so live sidebar category updates render the enclave-keyed nav fragment instead of the whole-sidebar DM-only shape. ## Why `render_sidebar` hardcodes `current_enclave = None`, producing the DM-only Home shape (no categories, no enclave rooms), and the category-change arm OOB-swapped that over `#sidebar`. For a member viewing the enclave this caused two bugs (LC-331): adding or deleting a category blanked the chat list until a manual refresh, and moving a chat into a category reverted a couple seconds later when the broadcast landed (the DB write via `set_room_positions` / `assign_room` upsert persists correctly; only the live render was wrong). ## Fix Route the event through the existing LC-174 `render_enclave_sidebar_nav(state, viewer, enclave_id)`, which renders `#sidebar-nav-{enclave_id}` via `load_sidebar(.., Some(enclave_id))`. The id-keyed target is self-limiting: a connection on Home, a different enclave, or a stale subscription lacks the target and htmx drops the swap. No template, DB, or client-JS change. `render_sidebar` is retained for its remaining DM-creation / mute callers. ## Test `just test` and `just test-saas` both green; `just fmt` clean. Manual: add/delete a category and drag a chat across categories while viewing an enclave; the list updates in place and the move sticks. #LC-331
fix(sidebar): live category change uses enclave-keyed nav fragment
All checks were successful
check-secrets / Nosey parker (push) Successful in 7s
check-secrets / TruffleHog (push) Successful in 7s
check-secrets / Kingfisher (push) Successful in 10s
check-secrets / Nosey parker (pull_request) Successful in 3s
check-secrets / TruffleHog (pull_request) Successful in 7s
check-secrets / Kingfisher (pull_request) Successful in 10s
Check / clippy + fmt + tests (pull_request) Successful in 4m48s
Create release / Create release from merged PR (pull_request) Has been skipped
f5b7b4dfdb
The WS handler for `SidebarCategoriesChanged` rendered the whole-sidebar DM-only shape via `render_sidebar` (which hardcodes `current_enclave = None`) and OOB-swapped it over `#sidebar`. The DM-only shape has no categories and no enclave rooms, so for a member viewing the enclave the live broadcast blanked the chat list on category add/delete, and reverted a just-completed chat-move a beat after the correct PATCH response (the DB write persists; only the live render was wrong). Route the event through the existing LC-174 `render_enclave_sidebar_nav`, which renders the enclave-keyed `#sidebar-nav-{enclave_id}` fragment with `load_sidebar(.., Some(enclave_id))`. The id-keyed target is self-limiting: connections on Home, a different enclave, or a stale subscription drop the swap.

#LC-331

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
nrupard deleted branch fix/lc-331-sidebar-categories-live 2026-06-17 20:48:20 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/lets-chat!342
No description provided.