LSP-copilot icon indicating copy to clipboard operation
LSP-copilot copied to clipboard

LSP Copilot chat, stops working

Open DJManas opened this issue 1 year ago • 22 comments

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

DJManas avatar Dec 02 '24 14:12 DJManas

TODO: Fix line https://github.com/TerminalFi/LSP-copilot/blob/a0c75e065e362bfbb000d9b4a2c68ceb31c94c8b/plugin/helpers.py#L234

TerminalFi avatar Dec 02 '24 15:12 TerminalFi

TODO: Fix line

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

jfcherng avatar Dec 02 '24 15:12 jfcherng

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.

DJManas avatar Dec 02 '24 15:12 DJManas

Reproduceable steps would help if it's possible.

jfcherng avatar Dec 02 '24 15:12 jfcherng

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.

DJManas avatar Dec 02 '24 15:12 DJManas

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.

jfcherng avatar Dec 02 '24 16:12 jfcherng

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.

DJManas avatar Dec 03 '24 16:12 DJManas

@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 avatar Dec 20 '24 20:12 TerminalFi

@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 avatar Dec 23 '24 15:12 TerminalFi

@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 https://github.com/TerminalFi/LSP-copilot/blob/530359c6184592c77cb1f996a1b6eeb32430fa44/plugin/commands.py#L276

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?

TerminalFi avatar Dec 23 '24 15:12 TerminalFi

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

jfcherng avatar Dec 23 '24 17:12 jfcherng

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?

StephenPTxEng avatar Jan 22 '25 20:01 StephenPTxEng

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?

StephenPTxEng avatar Jan 22 '25 20:01 StephenPTxEng

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.

jfcherng avatar Jan 23 '25 08:01 jfcherng

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

Image

StephenPTxEng avatar Jan 23 '25 19:01 StephenPTxEng

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.

DJManas avatar Jan 24 '25 08:01 DJManas

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

TerminalFi avatar Jan 24 '25 14:01 TerminalFi

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

https://github.com/TerminalFi/LSP-copilot/blob/530359c6184592c77cb1f996a1b6eeb32430fa44/plugin/helpers.py#L199

I will try to find time today to fix this.

TerminalFi avatar Jan 24 '25 14:01 TerminalFi

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?

StephenPTxEng avatar Jan 24 '25 17:01 StephenPTxEng

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.

TerminalFi avatar Jan 24 '25 17:01 TerminalFi

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.

DJManas avatar Jan 27 '25 12:01 DJManas

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.

jfcherng avatar Jan 31 '25 14:01 jfcherng