UCSD-PL / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
0 stars 7 forks source link

Handle race condition when triggering LEAP multiple times #32

Closed KasraF closed 1 year ago

KasraF commented 1 year ago

Right now, if we hit Ctrl/Cmd+Enter repeatedly, there's a race condition between the many promises trying to get a list of completions and drawing the panel. Similarly, if we cancel out by pressing Esc before requests are finished, it will show and draw the panel anyway.

We need to actually cancel previous promises, not just hide the panel.

Related to #3.

KasraF commented 1 year ago

The 65684ae327a910c1c422a9b87771132e5ffdda9b commit (fixed further in 140cb52af02214291dc7fe7f89ce3211f04b2b4f) should reduce the risks for now, though it still doesn't fully address it.

Basically, the user can't cancel out/restart in the middle of drawing the panel. But if they are doing it while waiting for the OpenAI request (i.e. most of time) we gracefully handle it.

If they cancel out, Leap remains closed. If they use Ctrl/Cmd+Enter we automatically restart the Leap request with a new prompt instead.

KasraF commented 1 year ago

@rlisahuang What do you think of this interaction flow? If it looks good (and it works for you as well) please close the issue. :)

rlisahuang commented 1 year ago

Works nicely for me. Closing as completed.