Summary
Typing a mention prefix and pressing Tab quickly can autocomplete the wrong user, often the current user. Example reported flow: type @timp, press Tab, and the composer inserts @chotchkies instead of @Timpani.
Root cause
Mention detection is debounced, but the Tab/Enter commit path reads the last settled suggestion list from React state:
- A bare
@ produces an empty mention query ("").
- The empty query ranks all channel members as matches.
- If the user pauses long enough for that debounce to settle, the dropdown contains the full member list with
mentionSelectedIndex = 0.
- If the user then types the intended prefix quickly and presses Tab before the next debounce fires, Tab commits the stale
suggestions[0] instead of the fresh prefix match.
This explains the intermittent behavior: it depends on typing rhythm and member ordering.
Reproduction
- Open a channel where you and Timpani are both members.
- Focus the message composer.
- Type
@ and wait slightly longer than the mention debounce interval.
- Quickly type
timp and immediately press Tab.
- Expected: composer inserts
@Timpani.
- Actual: composer may insert the first member from the stale full-member suggestion list, commonly the current user.
Proposed fix
On Tab/Enter, if a mention debounce timer is pending, cancel it and synchronously re-run mention detection against the latest stashed editor value/cursor. Then rank candidates inline using the live query and commit the top matching suggestion in the same keypress.
A candidate implementation exists in the fork branch:
cameronhotchkies/buzz: fork/fix/mention-autocomplete-debounce-race
Notes
This was investigated in Buzz thread c7a45b263917da46c020dd47cb153cd2c2a1020f688c4795cbedc006eb1d46c4 in channel chotchkies-buzz-bombing.
Summary
Typing a mention prefix and pressing Tab quickly can autocomplete the wrong user, often the current user. Example reported flow: type
@timp, press Tab, and the composer inserts@chotchkiesinstead of@Timpani.Root cause
Mention detection is debounced, but the Tab/Enter commit path reads the last settled suggestion list from React state:
@produces an empty mention query ("").mentionSelectedIndex = 0.suggestions[0]instead of the fresh prefix match.This explains the intermittent behavior: it depends on typing rhythm and member ordering.
Reproduction
@and wait slightly longer than the mention debounce interval.timpand immediately press Tab.@Timpani.Proposed fix
On Tab/Enter, if a mention debounce timer is pending, cancel it and synchronously re-run mention detection against the latest stashed editor value/cursor. Then rank candidates inline using the live query and commit the top matching suggestion in the same keypress.
A candidate implementation exists in the fork branch:
cameronhotchkies/buzz:fork/fix/mention-autocomplete-debounce-raceNotes
This was investigated in Buzz thread
c7a45b263917da46c020dd47cb153cd2c2a1020f688c4795cbedc006eb1d46c4in channelchotchkies-buzz-bombing.