fix(dm): send WS subscribe when page mounts on an already-open socket #141

Merged
nrupard merged 1 commit from fix/dm-subscribe-on-open-socket into main 2026-05-18 19:59:33 +02:00
Owner
No description provided.
fix(dm): send WS subscribe when page mounts on an already-open socket
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 1m2s
204fe6851f
User reported DMs don't autoscroll on send. Most likely failure mode:
the DM page's `htmx:wsOpen` handler registers a subscribe-on-open hook,
but on a reconnect-soft-refresh (or any navigation that swaps #main
without tearing the WebSocket down), wsOpen has already fired for this
connection - so no subscribe message is sent for the new DM's room_id.
The sender's own NewMessage event then falls into the "not subscribed"
branch on render_new_message_or_bump, returns None, and no OOB swap
into #messages happens. UI looks like "doesn't autoscroll" because the
message never arrives in the DOM for the sender.

Fixes both `room/page.html` and `dm/page.html` symmetrically: in
addition to the wsOpen hook, if `window.__lcWS` is already set when the
inline script runs, fire the subscribe frame directly. Defensive and
safe to do twice (the server `Subscribe` handler is idempotent).

If the symptom persists, the root cause is elsewhere - need user's
DevTools network tab to see whether the NewMessage frame arrives at
the sender's WS.
nrupard deleted branch fix/dm-subscribe-on-open-socket 2026-05-18 19:59:33 +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!141
No description provided.