Cody generates new files when I click ‘Apply’ instead of applying the changes to the correct file.

I use Cody in VS Code with no tabs and three windows arranged from left to right: file explorer, an open file, and the Cody AI chat window. In the past few days, when I clicked ‘Apply’ in the chat window, the changes were correctly applied to the open file. However, today Cody suddenly started creating new files every time I click ‘Apply.’ Could this be a bug?

@f64c Could you make a screen recording, upload to youtube and add the link here? There are certain conditions for smart apply and it has the ability to create new files especially if you use the right prompt so without a reproducible test case that might be found from the screen recording, there is little chance for this issue to be found.

I am just an user as yourself but I have had issues with smart apply and I have some familiarity with the code as I have fixed an issue for myself where it was creating new files when it shouldn’t have so I might be able to help out if I know how to reproduce the issue.

Thanks for the feedback. A video wouldn’t be a problem but today it works again without any changes on my side. But for further investigation attached is a screenshot. It looked like a problem with the API.

@f64c The screenshot is not very useful as it doesn’t show the full error message and there is no test case or detail on what you’ve tried.
Doing a github search has led me here cody/vscode/src/edit/manager.ts at 5bd253c16261680490d2afb14398ff568334ffbd · sourcegraph/cody · GitHub which mentions that they couldn’t find what selection was needed for the smart apply.

If you can find a reproducible workflow where it fails and can share it, it would make it more likely for an issue with a bug report to be added which can then be checked by the developers.

As mentioned earlier, it’s working again today, so I can’t reproduce the error. I’ve attached the screenshot to show that, as far as I can tell, this isn’t a VS Code issue.

1 Like

I don’t want to open another issue but i have the same problem.

It’s so annoying that I wonder if I’m going to keep my subscription, because I have to copy and paste the changes and delete the files/directories created each time.
Note that on the same project, competitors apply patches without a hitch.

@skrew Sorry for the inconvenience.

Indeed, if Cody is not able to reference the changes to a file it will create a new file instead. You see if it references a file whether at the bottom of the Smart Apply box a file path is showing or it is empty.

This happens, if the file to which changes should be applied are not explicitly mentioned in the prompt with the @-file mention feature.

I hope that helps.