perf(ui): debounce mention popover refresh 200ms (LC-227) #271
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-227-mention-popover-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
Pre-LC-227
composer.html's mention-popoverrefresh()firedhtmx.ajax('GET', '/users/mentions?...')directly on every input event. Typing@alicestacked 6 in-flight requests on a 100ms-latency network; the popover flickered as each landed.Wrap
refresh()in a 200mssetTimeout+clearTimeout-on-each-keystroke pattern, mirroring the existing 300msrefreshBroadcastCountdebounce one line away. Picked 200ms vs 300ms because the mention popover should feel close to keystroke-immediate; broadcast count is a count-only HUD where 300ms is invisible.activeToken()+close()calls move inside the timer callback so the popover does not flicker-close-then-reopen on rapid typing through a token boundary.Defensive
clearTimeoutadded to the existingteardown()function so a swap-out during the debounce window cannot fire an htmx.ajax targeting a detached#lc-mention-popoverslot.Test plan
cargo check -p lets-chat-serverclean.@alicerapidly. DevTools Network panel shows ONE request to/users/mentions(not six).@a, pause 250ms — popover opens withacandidates.Related
LC-228 / LC-229 / LC-230 cover the rest of the typing/sending-feel-clunky analysis surfaced from the same staging report.
`composer.html`'s mention-popover `refresh()` fired `htmx.ajax('GET', '/users/mentions?...')` directly on every input event. Typing `@alice` stacked 6 in-flight requests on a 100ms-latency connection; each response triggered a fresh `htmx:afterSwap` cycle and the popover flickered as each landed. Perceived as typing-feels-laggy-when-typing-@. Mirror the same `setTimeout` + `clearTimeout` shape `refreshBroadcastCount` already uses for the broadcast-count probe (300ms debounce, L188-207). Picked 200ms instead of 300ms: a mention popover should feel close to keystroke-immediate; broadcast count is a count-only HUD where 300ms is invisible. 200ms swallows the rapid-typist N-keystroke burst without delaying the natural-pause popover open. Defensive cleanup added to the existing `teardown()` function so a swap-out during the debounce window cannot fire an htmx.ajax targeting a detached `#lc-mention-popover` slot. Mirrors LC-216 / LC-227's same shape for `__lcComposerErrTimer` / `bcastTimer`. Verified: `cargo check -p lets-chat-server` clean. Combobox semantics unchanged: arrow-key navigation, Enter-to-insert, Escape-to-close, blur-to-close, click-to-select all still fire through the same paths. #LC-227