rubberduck-ai / rubberduck-vscode

Use AI-powered code edits, explanations, code generation, error diagnosis, and chat in Visual Studio Code with the official OpenAI API.
https://marketplace.visualstudio.com/items?itemName=Rubberduck.rubberduck-vscode
MIT License
580 stars 70 forks source link

Rubberduck often will hang on generating output #92

Open wilrodriguez opened 1 year ago

wilrodriguez commented 1 year ago

Describe the bug

I've noticed many times when I launch rubberduck from my context menu after selecting a code block for explanation, generating unit tests, or its other options, it will often hang on generating output. Other times, it will simply open the rubberduck sidebar and then not do anything. I've also seen it work with no problem after sending the same command from the context menu a few times. I did notice that if I change my model to GPT-4 and let it fail to connect, then change it back to 3.5-turbo and click the retry button, it'll send the API request with no problem. Notably I don't seem to have any issues with executing new chat questions from the side bar, it's only with context menu operations.

How to reproduce

At the moment, all context menu operations seem to cause this behavior in my environment. However, it's a bit harder to narrow down exactly what is causing the behavior since it seems to be erratic and there's nothing I've noticed in the logs that really gives me a hint as to what's going on, even with debug turned on.

Expected behavior

Should be able to select code and execute rubberduck operations via the context menu.

Additional information

lgrammel commented 1 year ago

Thanks for the bug report!

I have noticed some flakiness after a VS Code restartet. Does this happen always or primarily after a VS Code restart? Does it affect only code generation or also code editing?

wilrodriguez commented 1 year ago

So, I actually just had it explain some code and when I clicked the button in the context menu, it took me to the rubberduck side bar and had a explain code chat, but based on the debug output, it didn't do anything and the UI was just saying "Generating output. But, then, I started a new chat and I can see that in the logs, it added instructions to continue the conversation from the block of code I had submitted initially, so in this way it ended up working out just fine... so there's that at least. But it was certainly weird that it didn't actually kick off the conversation in the first place.

wilrodriguez commented 10 months ago

So, I did eventually determine what was going on here. The code generation does not actually kick off unless the rubberduck pane is in focus when you issue the command from the context menu. The odd behavior I was seeing was caused by the fact that when you choose a generate action, it does actually open the pane, so successive commands will eventually work, but things get extra confusing thanks to #75. So, I'm guessing this is more of a race condition issue where something isn't waiting long enough for the pane to change (or something like that, it's not like I've looked at the source code or know anything about vs code plugin development).

lgrammel commented 10 months ago

Thanks for looking into this. Sadly I won't have time in the foreseeable future to work on Rubberduck. Fortunately there are now many alternative extensions with similar functionality that you could use instead and Copilot has chat functionality as well.