Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP Copilot chat, stops working #220

Open
DJManas opened this issue Dec 2, 2024 · 22 comments
Open

LSP Copilot chat, stops working #220

DJManas opened this issue Dec 2, 2024 · 22 comments
Labels
bug Something isn't working

Comments

@DJManas
Copy link

DJManas commented Dec 2, 2024

Hello,

today I used LSP copilot for working and after some time, it stopped working. I use ctrl + shift + p, copilot chat, enter question and nothing generates.

In console I see:

Traceback (most recent call last):
  File "/home/djmanas/.config/sublime-text/Packages/LSP-copilot/plugin/commands.py", line 250, in <lambda>
    wcm.prompt(callback=lambda msg: self._on_prompt(plugin, session, msg), initial_text=message)
  File "/home/djmanas/.config/sublime-text/Packages/LSP-copilot/plugin/commands.py", line 335, in _on_prompt
    if not (request := prepare_conversation_turn_request(wcm.conversation_id, wcm.window.id(), msg, view, views)):
  File "/home/djmanas/.config/sublime-text/Packages/LSP-copilot/plugin/helpers.py", line 234, in prepare_conversation_turn_request
    if not (selection := view_.sel()[0]) or view_.substr(selection).isspace():
  File "/opt/sublime_text/Lib/python38/sublime.py", line 2291, in __getitem__
    raise IndexError()
IndexError

Sublime-Text: 4_4184 (Yes it dev so I dunno if it should not go to them)
Gentoo Linux

Thanks,
Regards,
Petr Sourek

@TerminalFi TerminalFi added the bug Something isn't working label Dec 2, 2024
@TerminalFi
Copy link
Owner

TODO: Fix line

if not (selection := view_.sel()[0]) or view_.substr(selection).isspace():

@jfcherng
Copy link
Collaborator

jfcherng commented Dec 2, 2024

TODO: Fix line

So there is either no cursor (which is supposed not to happen) or view_ is wrong 🤔

@DJManas
Copy link
Author

DJManas commented Dec 2, 2024

If you can point me to what I should look for, I will be able to test it next time it happens.

EDIT: Or maybe I can take a look how to debug it, when it happens.

@jfcherng
Copy link
Collaborator

jfcherng commented Dec 2, 2024

Reproduceable steps would help if it's possible.

@DJManas
Copy link
Author

DJManas commented Dec 2, 2024

Reproduceable steps would help if it's possible.

I will try, but the problem is, that I had been developing python script since morning and suddenly when I got back with cup of coffee the Copilot was not responding and error was in console. We will see if it happens tonight or tomorrow during the day.

@jfcherng
Copy link
Collaborator

jfcherng commented Dec 2, 2024

Reproduceable steps would help if it's possible.

I will try, but the problem is, that I had been developing python script since morning and suddenly when I got back with cup of coffee the Copilot was not responding and error was in console. We will see if it happens tonight or tomorrow during the day.

I see. Sometimes it's just hard to find a stable way to reproduce a bug.

@DJManas
Copy link
Author

DJManas commented Dec 3, 2024

Reproduceable steps would help if it's possible.

I will try, but the problem is, that I had been developing python script since morning and suddenly when I got back with cup of coffee the Copilot was not responding and error was in console. We will see if it happens tonight or tomorrow during the day.

I see. Sometimes it's just hard to find a stable way to reproduce a bug.

It seems the problem occurs everytime I launch Copilot chat from debug. I launch my project (python), debugger is stopped at breakpoint and I press ctrl+shift+p and launch Copilot chat, the window for question opens, but when I write question and hit send to copilot it doesn't answer and error is in the console.

@TerminalFi
Copy link
Owner

@DJManas i am seeing this now as well. I hope to have time this weekend to review both our code and any changes that may have occurred in the upstream copilot.vim that we may have missed

@TerminalFi
Copy link
Owner

@jfcherng

Looks like something changed, and when creating a new conversation and sending an empty turn message. It doesn't like it. We should try and not send an empty message when creating a conversation now

@TerminalFi
Copy link
Owner

@jfcherng

Looks like something changed, and when creating a new conversation and sending an empty turn message. It doesn't like it. We should try and not send an empty message when creating a conversation now

Initial message here can be blank

is_template, msg = preprocess_chat_message(view, initial_message, user_prompts)

So maybe we need a way to send a message Hello if this is a brand new conversation? Or postpone this until user provides first message?

@jfcherng
Copy link
Collaborator

I am not sure what's happening since copilot chat seems to just work on my side.

@StephenPPEng
Copy link

I am having the same issue.
Used to work great until about November of '24. Then it started not responding to chat messages, but would respond to pre-defined commands (/fix, /explain).
Now, it doesn't respond to anything. It opens the chat that has been running but doesn't post the new query.
If i delete the running chat, nothing changes.

I removed the package, then re-added it. I then sent a "Hello" message, to which it responded.
I then asked it a question about my code, but was already broken again.

I tried signing out then signing back in, but no change.

Is there a way to get error messages for you?

@StephenPPEng
Copy link

right after i submitted that message, i tried again and it worked this time.
I realized i was attempting to reference temporary code (not code saved in a file).
Turns out that the plugin does not reference code from the editor; it references code from the file (which is open in the editor).

The plugin cannot reference unsaved code (code which only exists in the editor, but not in a file)
Is this correct?

@jfcherng
Copy link
Collaborator

right after i submitted that message, i tried again and it worked this time. I realized i was attempting to reference temporary code (not code saved in a file). Turns out that the plugin does not reference code from the editor; it references code from the file (which is open in the editor).

The plugin cannot reference unsaved code (code which only exists in the editor, but not in a file) Is this correct?

On my side, if you select those codes, it works.

@StephenPPEng
Copy link

strange.
I highlight code, run the "Copilot: Chat" command, and the window remains blank.
This problem only happens with code that is unsaved.

Image

@DJManas
Copy link
Author

DJManas commented Jan 24, 2025

The plugin cannot reference unsaved code (code which only exists in the editor, but not in a file) Is this correct?

I agree that this might be problem, but in my first post I didn't referenced anything, still learning how to use Copilot so most of my prompts are mostly questions, not referencing my code yet. But its good point.

@TerminalFi
Copy link
Owner

Just confirming I am able to reproduce this issue. I am looking into it.

@TerminalFi
Copy link
Owner

I've identified the issue. This line below fails if the view does not have a file on disk.

if not view.file_name():

I will try to find time today to fix this.

@StephenPPEng
Copy link

today I used LSP copilot for working and after some time, it stopped working. I use ctrl + shift + p, copilot chat, enter question and nothing generates.

I misunderstood your original question then; sorry for hijacking the thread!
I agree with @TerminalFi for the reason why.
An invalid "hello" message could corrupt future questions for that session.

@DJManas are you able to find steps that let you use CoPilot again? (e.g. Close and Reopen Sublime | Sign Out -> Sign back in to CoPilot | Copilot: Destroy Conversation | Remove package then re-add package)? Or is it permanently broken right now?

@TerminalFi
Copy link
Owner

today I used LSP copilot for working and after some time, it stopped working. I use ctrl + shift + p, copilot chat, enter question and nothing generates.

I misunderstood your original question then; sorry for hijacking the thread!
I agree with @TerminalFi for the reason why.
An invalid "hello" message could corrupt future questions for that session.

@DJManas are you able to find steps that let you use CoPilot again? (e.g. Close and Reopen Sublime | Sign Out -> Sign back in to CoPilot | Copilot: Destroy Conversation | Remove package then re-add package)? Or is it permanently broken right now?

It will work on files that are actually saved to disk currently.

We think we also found a bug in LSP for unsaved views.

@DJManas
Copy link
Author

DJManas commented Jan 27, 2025

today I used LSP copilot for working and after some time, it stopped working. I use ctrl + shift + p, copilot chat, enter question and nothing generates.

I misunderstood your original question then; sorry for hijacking the thread! I agree with @TerminalFi for the reason why. An invalid "hello" message could corrupt future questions for that session.

@DJManas are you able to find steps that let you use CoPilot again? (e.g. Close and Reopen Sublime | Sign Out -> Sign back in to CoPilot | Copilot: Destroy Conversation | Remove package then re-add package)? Or is it permanently broken right now?

Seems that copilot is working today, I will continue to use it. As stated in my first comment. I have problems, that it stops working after some time (not sure why), but before it its working normally (talking about chat).

And I had written, that I am not using it on unsaved files, but in the same sentence I had written, that its good point. Now thinking about it, and working, when I see there is problem (in source) I will save first and try again. I guess this is thing, that would not get into my mind, when I have problems in source code usage.

jfcherng added a commit that referenced this issue Jan 31, 2025
#220 (comment)

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
@jfcherng
Copy link
Collaborator

jfcherng commented Jan 31, 2025

I've identified the issue. This line below fails if the view does not have a file on disk.

LSP-copilot/plugin/helpers.py

Line 199 in 530359c

if not view.file_name():
I will try to find time today to fix this.

I have fixed and pushed that line. But another issue related to LSP (wrong buffer ID in payloads) is still required to be addressed in order to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants