sourcegraph / cody

Type less, code more: Cody is an AI code assistant that uses advanced search and codebase context to help you write and fix code.
https://cody.dev
Apache License 2.0
2.6k stars 278 forks source link

bug: cody creates unsved files keep showing back after closing #4581

Closed watevadafa closed 2 months ago

watevadafa commented 3 months ago

Version

1.90.0

Describe the bug

Version: 1.90.0 Commit: 89de5a8d4d6205e5b11647eb6a74844ca23d2573 Date: 2024-06-04T19:34:48.028Z Electron: 29.4.0 ElectronBuildId: 9593362 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.5.0

When cody creates files say, test-something.py or any untitled.py, these files if ignored and closed keep showing up after sometime

Expected behavior

Once closed it should be closed, or ignored when user opt-out saving them!

Additional context

No response

waldyrious commented 3 months ago

I've also been experiencing this, and it's so frustrating that I had to disable the extension. What's most annoying is that the files are empty, with no undo history, yet I can't even close them without getting the dialog about losing unsaved changes.

felixfbecker commented 3 months ago

I am also seeing this since last week or so, I didn't realize it was caused by the Cody extension!

recurser commented 3 months ago

Same issue for the last couple of weeks. I've had to disable the extension because of it.

deadband commented 3 months ago

I am experiencing the same issue with Cody AI. Anytime a file is modified a new untitled file will be created. Apparently, there is a very similar issue with Github Copilot here.

JeongJuhyeon commented 3 months ago

I've also been experiencing this, and through "Extension Bisect" confirmed that it only happens with Cody on.

Version: 1.90.2 (Universal) Commit: 5437499feb04f7a586f677b155b039bc2b3669eb Date: 2024-06-18T22:37:41.291Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.5.0

@deadband Currently, your link goes to this issue itself.

justinmilner1 commented 2 months ago

I'm having trouble replicating this - Are any of you aware of a consistent method leading to this behavior?

It appears the only pathway which should create new files is the 'Generate Unit Tests' command - have you been utilizing this command? If not, do you use any other commands?

JeongJuhyeon commented 2 months ago

@justinmilner1

I've even recorded my screen to watch when the files suddenly get opened, because I really enjoy using Cody chat but this bug is making it unusable.

The issue is difficult to pinpoint, but it looks related to one or more of the following:

The video I took shows a new file being opened does not happen upon the user directly interacting with Cody. FWIW I've never used the "Generate Unit Tests" command.

justinmilner1 commented 2 months ago

@JeongJuhyeon Got it, thanks for the info. Do you mind sharing the video?

JeongJuhyeon commented 2 months ago

@JeongJuhyeon Got it, thanks for the info. Do you mind sharing the video?

Unfortunately that's not easy because I spend most of my time writing closed source code, and as such I've already deleted it. Happy to assist with other kinds of debugging if possible.

justinmilner1 commented 2 months ago

@JeongJuhyeon Ah gotcha. Two more questions:

I believe the issue is likely inadvertant calls of openUntitledDocument, but there are a lot of reasons that could be happening. Created this pr to maybe get some more info.

JeongJuhyeon commented 2 months ago

@justinmilner1

Are the unexpected files always untitled and empty for you?

Yes, they are always untitled and empty.

Does this happen often? Or only occasionally?

It seems to get worse the more I use chat (or possibly the more chat windows I have open, or the more files I have @ mentioned in chat) in a given session. When I've used chat quite a bit it can be pretty bad, with a good number of new files having opened after an hour of coding. For me it's often enough that the distraction of having to close random files makes me disable Cody, despite finding it a much better product than competitors' offerings.

What I'll try and do is have the Cody extension activated but not use any of its functionality, and see if it still happens. So far it looks like it won't.

worm2fed commented 2 months ago

For me this happening even If I do not open a chat Also seems related - I might create an empty file and make some drafts and later - close this file, and after that Cody will create empty files.

Also, at the moment of file creation in Output tab there is two regular records that autocompletion was made (and two files was created)

JeongJuhyeon commented 2 months ago

For me this happening even If I do not open a chat Also seems related - I might create an empty file and make some drafts and later - close this file, and after that Cody will create empty files.

This could very well be related - I also often open empty files, make drafts and then close them.

c0dification commented 2 months ago

I disabled the extension, switched to Release version in the config, restarted VS Code, and re-enabled the extension. I haven't had the issue and it's been a full day of use with many new and existing files. Maybe related to pre-release version?

c0dification commented 2 months ago

nope. it's started again for me. i have not used cody chat or any other features except the code completion suggestions.

JeongJuhyeon commented 2 months ago

nope. it's started again for me. i have not used cody chat or any other features except the code completion suggestions.

Do you also have a habit of sometimes creating empty files (e.g. to paste stuff into, or to make a draft) and then closing them, like @worm2fed and me?

felixfbecker commented 2 months ago

I might be misremembering but I also think every time I had this issue, I had made some untitled files to paste some stuff into. I think I close them eventually or restart VS Code or something and start noticing how there would still be "untitled" files popping up.

worm2fed commented 2 months ago

Maybe Cody trying to be smart and learning on such behavior (create files for smth)?

worm2fed commented 2 months ago

It's getting worse, now it creates a new file immediately after I close it.

It put's two log messages into output window. First when I'm clicking close on file, and second one when it creates a new file again

█ SimpleChatPanelProvider: postContextStatus [{"displayName":"project","providers":[{"kind":"embeddings","state":"ready","embeddingsAPIProvider":"sourcegraph"},{"kind":"search","type":"local","state":"ready"}]}]
█ SimpleChatPanelProvider: postContextStatus [{"displayName":"project","providers":[{"kind":"embeddings","state":"ready","embeddingsAPIProvider":"sourcegraph"},{"kind":"search","type":"local","state":"ready"}]}]
abs-angularminds commented 2 months ago

Maybe Cody trying to be smart and learning on such behavior (create files for smth)?

No, it is creating untitled files at the root location. These files are not like regular new files that we can easily close. When prompted to save, it asks for confirmation. What should someone do by saving these files?

abs-angularminds commented 2 months ago

It's getting worse, now it creates a new file immediately after I close it.

It put's two log messages into output window. First when I'm clicking close on file, and second one when it creates a new file again

█ SimpleChatPanelProvider: postContextStatus [{"displayName":"project","providers":[{"kind":"embeddings","state":"ready","embeddingsAPIProvider":"sourcegraph"},{"kind":"search","type":"local","state":"ready"}]}]
█ SimpleChatPanelProvider: postContextStatus [{"displayName":"project","providers":[{"kind":"embeddings","state":"ready","embeddingsAPIProvider":"sourcegraph"},{"kind":"search","type":"local","state":"ready"}]}]

This is indeed becoming worse. I have disabled the extension. It was creating multiple files. Started with creating one, then kept on increasing 5-6 files. And it won't let me close. Opens more as soon as I close one.

JeongJuhyeon commented 2 months ago

@worm2fed @abs-angularminds It seems like not leaving any more unsaved files open has fixed it for me. I now just keep a separate VSCode window open to paste/draft random stuff when I want to.

sbuttgereit commented 2 months ago

I'm seeing this as well. I made a video where I see this with a project that I'm working on. Before the video, I closed all tabs and then exited so that the next launch would have no files open. Then I open a file and unwanted tabs are opened next. Next steps are not in the video, I close the unwanted tabs and answer the prompt "do I want to save?" : "no". As soon as I finish answering the last modal yes/no prompt, new tabs open up.

https://github.com/user-attachments/assets/be1b0a57-e266-417e-a2ec-e08ea1eec018

In this case then, the only thing I did in the session was select a file in the file browser and then close the unwanted tabs. The one complication is that I'm connecting to a WSL session.

The version of the VS Code extension I made the video with is: image

Though I have been experiencing this prior to updating.

shawncook commented 2 months ago

I am seeing this as well. The issue goes away after deactivating the VSCode extension.

caspark commented 2 months ago

I am also having this issue of untitled tabs being created/sticking around.

Recording

Screencast_20240718_093718.webm

Here's a proper bug report with repro steps etc (note these steps are slightly different from what's visible in my text editor in the video - I couldn't be bothered doing another take):

Repro steps

  1. Disable all installed extensions (does not seem to be strictly necessary for me, but I include this to show it's not an interaction with another third party extension)
  2. Create a new workspace with a main.py in it
  3. Press Ctrl+N to create a new untitled tab
  4. Close the untitled tab, and notice that it stays closed as expected
  5. Enable Cody
  6. Press Ctrl+N to create a new untitled tab
  7. Close the untitled tab, and notice that it stays closed
  8. Type something in the main.py file to trigger an inline autocomplete suggestion (no need to accept it)
  9. Press Ctrl+N to create a new untitled tab
  10. Close the untitled tab

Observed

The untitled tab gets auto-reopened each time it's closed, and attempting to close the re-opened tab prompts to save its contents.

Expected

The untitled tab should stay closed.

Workaround

To remove "stuck open" untitled tabs:

  1. Disable Cody extension
  2. Restarting extensions as prompted by vscode
  3. Close all open untitled (i.e. unsaved new file) tabs
  4. Re-enable Cody extension

Then avoid ever creating any new untitled tabs, otherwise the issue will recur.

Other notes

And yes, it is super annoying.