Typeahead suggestions sometimes freeze on results for incomplete search query
Closed, ResolvedPublic5 Story Points

Description

Due to how the requests are managed in wm-typeahead.js, results often arrive out of order. When that happens, the last one to arrive is also the last one to be applied to the user interface.

As such, I quite frequently experience that the shown results are for outdated query.

E.g. when typing "Amsterdam" I often get results for "Ams" and then it stays that way.

The current implementation does dereference JSONP script elements, but this does not cancel or abort the request. Even if cancelation was possible in browsers for script tags (which isn't possible), I'm not recommending that. Cancelling the previous request on each key stroke would mean that on slow connections no results show up until the user lets go of the keyboard for long enough.

Instead, the response handler should make sure to never apply updates for a response older than the last received response.

This way, when the user types "A", "Ams", "Amsterdam" and results arrive as "Ams", "Amsterdam", "A" the user sees results for "Ams" and then "Amsterdam". The response for "A" must be ignored.

Krinkle created this task.Mar 11 2016, 1:46 AM
Restricted Application added a project: Discovery. · View Herald TranscriptMar 11 2016, 1:46 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@debt , we should prioritize this one.

17:49 <Krinkle> jgirault: Note that "[", "]", 0-9 and _ are allowed
17:49 <Krinkle> so e.g. callbacks[1] would work
17:50 <Krinkle> or callback_1
17:50 <jgirault> Krinkle: interesting!
17:50 <Krinkle> Makes it easier to keep a map internally
17:51 <Krinkle> You'd presumably have a list of queries sent out, and whenever there is a response you drop anything from before that
17:51 <Krinkle> and if a response if for something you didn't ask for (or no longer in the 'needed' list) then you can ignore it

Krinkle updated the task description. (Show Details)Mar 11 2016, 1:58 AM
debt triaged this task as High priority.Mar 11 2016, 3:34 AM
debt moved this task from Backlog to To Discuss on the Discovery-Portal-Sprint board.
debt moved this task from To Discuss to What's Next on the Discovery-Portal-Sprint board.
debt added a subscriber: Jdrewniak.
Jdrewniak claimed this task.
Jdrewniak set the point value for this task to 5.
Krinkle moved this task from Untriaged to Backlog on the Wikimedia-Portals board.Mar 17 2016, 12:49 AM

Change 281983 had a related patch set uploaded (by Jdrewniak):
Guaranteeing the order in which search suggestions appear.

https://gerrit.wikimedia.org/r/281983

I approved the patch, but there are plenty of interesting comments in the gerrit patch regarding the implementation of this (the user experience, the performance...).

The debate was quite active and interesting. Though we didn't go with my approach, I think I brought up various points that are still worth considering.

Change 281983 merged by jenkins-bot:
Guaranteeing the order in which search suggestions appear.

https://gerrit.wikimedia.org/r/281983

debt closed this task as Resolved.Apr 14 2016, 7:40 PM

looks good - tested on http://www.wikipedia.beta.wmflabs.org, it'll be part of this production release: https://phabricator.wikimedia.org/T130755

debt moved this task from Done to Completed on the Discovery-Portal-Sprint board.Apr 14 2016, 11:26 PM