copilot-emacs / copilot.el

An unofficial Copilot plugin for Emacs.
MIT License
1.74k stars 124 forks source link

Copilot agent started. Copilot error: (:code -32602) #171

Closed benlarsendk closed 10 months ago

benlarsendk commented 10 months ago

When running diagnose on the module, I get the following (from the Messages Buffer) Copilot agent started. Copilot error: (:code -32602 :message "Document for URI could not be found: file:///, URIs of the known document are: ") user-error: Minibuffer window is not active

Can't seem to make it work, but didn't have any other problems on another machine with the same OS.

Any idea what this means?

zerolfx commented 10 months ago

In recent versions, I synced upstream changes without testing.

I just tested the latest version and can confirm that copilot-diagnose is broken. But the code completion feature should work properly. Please examine the *copilot events* buffer to get more information.

Will get it fixed after merging #164.

zerolfx commented 10 months ago

I tried to fix this issue by adding a didOpen request in the copilot-diagnose function.

However, I consistently got a timeout and received the following response:

(:jsonrpc "2.0" :id 3 :result
          (:completions
           []
           :cancellationReason "RequestCancelled"))

Could anyone help with this issue?

emil-vdw commented 10 months ago

@zerolfx I will see if I can look into it this weekend.

emil-vdw commented 10 months ago

So the problem is that copilot-diagnose resets the mode's state but then runs 'getCompletions request to test the connection. The request is for URI "" (empty string).

Before #164 any non-file buffer (like *scratch*) would have a URI of empty string but now it would be buffer://<buffer-name> (buffer://*scratch* for example).

An easy fix would be to trigger copilot--on-doc-focus to trigger didOpen for the current buffer then use the current buffer's URI in the test request by doing (copilot--get-uri).

I will whip up a PR to resolve this.