fix(composer): self-heal a stuck "Sending..." optimistic placeholder (LC-382) #390
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/lc-382-sending-stuck-watchdog"
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-382.
Symptom
After sending a message the row greys out and stays on "Sending..." (the LC-230 optimistic placeholder); it only renders after a manual full refresh. The message is persisted - the POST succeeded - so only the live render is lost.
Root cause
The optimistic-echo reconcile has a single point of failure: the one WS
NewMessagebroadcast that carriesdata-lc-client-id.live.js(htmx:oobBeforeSwap) removes the matching placeholder and htmx appends the canonical row. If that single frame is missed - flaky socket, a reconnect gap between the POST landing and the socket re-subscribing, a dropped/unprocessed OOB swap - the placeholder is never removed or replaced and sits on "Sending..." forever, with no fallback.I traced the whole chain (placeholder builder, server
finalize_message_sendbroadcast,ws.rs::render_new_messageauthor echo, thelive.jsreconcile, htmx 2.0.4, room re-subscription onhtmx:wsOpen) - every piece is individually correct. The defect is the missing fallback, not any one step. (The running dev build is pre-LC-376, so this is unrelated to the room-view epic.)Fix
A WS-miss safety net. On a successful send the composer schedules a ~4s watchdog for the sent
client_id.__lcEchoReconcilechecks whether the placeholder is still pending (findPending) and, if so, reloads the#messagesregion from the current URL viahtmx.ajax(GET, location, {select:'#messages', swap:'outerHTML'})- the manual refresh the user would do, automated - so the real message renders and the stale placeholder is dropped.No effect on:
__lcEchoDropalready removed it),__lcEchoFailedcleareddata-lc-pending),since each leaves
findPending()returning null.Testing
./dev/cargo check,just test,just test-saas- all green. Markup/JS only; server broadcast / reconcile / failure paths unchanged.🤖 Generated with Claude Code