Skip to content

Mention autocomplete can commit stale suggestion on Tab #1660

Description

@cameronhotchkies

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

  1. Open a channel where you and Timpani are both members.
  2. Focus the message composer.
  3. Type @ and wait slightly longer than the mention debounce interval.
  4. Quickly type timp and immediately press Tab.
  5. Expected: composer inserts @Timpani.
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions