fix(ui): debounce composer "Could not send" banner (LC-216) #258
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/lc-216-composer-error-debounce"
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?
Summary
Rapid successive message submits showed the "Could not send." banner for ~a second even when the post ultimately succeeded. Reported on staging: typing several messages back-to-back at ~200 ms apart flashes the banner on one of them while the message itself lands.
Root cause: when the user submits a second message before the first's response lands, htmx cancels the first request (or it times out for other reasons) and fires
htmx:afterRequestwithevent.detail.successful === false. Both composers'hx-on::after-requesthandlers immediately revealed the failure banner, then the actual-successful response hid it again ~a moment later. Reads as flaky chat.Wrap the failure-reveal in a 2 s
setTimeoutwhose handle is stashed onwindow. Each handler clears the matching timer at the top, then either runs the success branch (which already hides the banner) or schedules the failure-reveal. A rapid follow-up success arrives within 2 s, clears the timer, and the false flash never paints. A real failure leaves the timer to fire on schedule.Distinct timer keys (
__lcComposerErrTimerfor the main composer,__lcThreadErrTimerfor the thread panel composer) so the two surfaces do not fight when both are active simultaneously.Test plan
cargo check -p lets-chat-serverclean.role="alert"is announced.Related
LC-217 (deferred follow-up the user flagged): per-enclave admin-controllable message send rate-limit ("anti-spam by policy"). Separate ticket; not in this PR.