[REPLCompletions] Asynchronous tab completion (#61409)
In #57192, we moved hint generation to a worker thread, so it doesn't
block typing. This commit moves manual completion (triggered by either
TAB or the right arrow) to a worker thread, too. I consolidated the code
that kicks off a completion Task into async_get_completions to clean
things up.
The way this works is you get a "…" indicator when completions are
generating, but are taking a long time. If you hit any other key, the
completions are "cancelled" (we can't actually cancel the task at the
moment, but we'll ignore the result), and you can type again without
delay. Unlike hints, we don't limit the number of manual completion
Tasks, since we never want to have the REPL lock up and refuse to accept
input.
This supersedes #52847.
Here's a demo of how it looks, where I've added a 1s sleep to
completions to slow it down:
[demo.webm](https://github.com/user-attachments/assets/a597ef39-8975-4a2e-a75f-768f403379a3)
---------
Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>