Skip to content

Copilot integration departs from the copilot-language-server protocol #19618

Open

Description

@gtritchie

Our Copilot integration departs from the copilot-language-server documentation in several places. Checked against copilot-language-server 1.570.0 (both its bundled main.js and a live stdio session). Line links are to 14c97a7.

Acceptance telemetry is never delivered

assistantDidAcceptCompletion sends workspace/executeCommand through sendNotification, so the message has no id (SessionAssistant.cpp#L2809). The server registers the method only as a request (onRequest(ExecuteCommandRequest.type, ...)), and has no notification handler for it.

In a live session, sending github.copilot.didAcceptCompletionItem with invalid arguments as a request returned a schema-validation error; the same message as a notification produced no response and no log output, so the handler never ran. No acceptance of an inline completion or next edit suggestion reaches Copilot.

window/showMessageRequest is never answered

The README calls support for these requests essential, since they carry account and billing notices. Our handler shows the message text and continues (SessionAssistant.cpp#L2087-L2138); nothing in the module writes a response to a server-initiated request. The actions are dropped, and the server's request stays pending. One example in the bundle: the certificate-error warning offers a "Learn more" action that opens a help page.

Next edit suggestions are reported as shown with the wrong method

Every display branch of showEditSuggestionImpl reports through assistantDidShowCompletion → textDocument/didShowCompletion (TextEditingTargetAssistantHelper.java#L497-L595), including for items returned by textDocument/copilotInlineEdit. The server's didShowCompletion handler looks the id up only in its inline-completion cache and ignores misses; next edit items must be reported with textDocument/didShowInlineEdit.

Discarded next edits are also never reported to Copilot (github.copilot.didIgnoreNextEditSuggestionItem); our dismiss feedback is sent only for Posit AI (TextEditingTargetAssistantHelper.java#L1281-L1294).

Next edit suggestions are reachable with Copilot: assistant_nes_enabled defaults to true and isn't limited to Posit AI.

Open documents are opened twice, the second time from disk

Two mechanisms announce the documents open at agent startup:

  1. After initialize, syncOpenDocuments() sends didOpen with each document's editor contents (SessionAssistant.cpp#L1652, added in ensure documents synced when switching agents #16853).
  2. When the agent first reports Running, the frontend calls assistantRegisterOpenFiles with every open file path (SourceColumnManager.java#L1459, added in Tell Copilot about source files loaded in the IDE before Copilot has started up #16081). On idle, indexFile sends another didOpen for the same URI and version, with the contents read from disk (SessionAssistant.cpp#L1883-L1913).

LSP doesn't allow a second didOpen without a didClose, and the server's TextDocuments store replaces the document on a repeat open. When a session starts with unsaved edits, the server holds the saved file instead of the buffer, and later incremental didChange ranges apply to the wrong text until the document is closed. (Confirmed from the code paths and the server's handler; not reproduced end to end, which needs a signed-in account.)

Save As leaves the old document open and never opens the new one

Line links in this section and the next are to 360bc5c. Both sections are confirmed from our code paths only; how the server treats the resulting messages was not checked. The code is shared, so they apply to Posit AI as well as Copilot.

The LSP module tracks open documents by URI and doesn't listen for onDocRenamed (SessionLSP.cpp#L419-L424). When a document is saved under a new name:

  • No didClose is sent for the old URI, so the server keeps that document, with its contents from before the save, until the agent stops.
  • No didOpen is sent for the new URI. The save reports its change before writing the document to the source database (SessionSource.cpp#L788-L792), and onDocChanged starts tracking the new URI as it sends didChange (SessionLSP.cpp#L156-L160). The onDocUpdated that follows then finds the URI tracked and skips the didOpen (SessionLSP.cpp#L205-L214).

didChange, didFocus and completion requests are then sent for a URI the server was never given, and closing the tab sends a didClose for it.

The startup sync and a live open disagree on some R documents

syncOpenDocuments() takes the language ID of a saved R, R Markdown or Quarto document from its extension, and skips the document if the extension isn't in the map (SessionAssistant.cpp#L1901-L1916). The didOpen sent when a document opens while the agent runs uses languageIdFromDocument(), which returns r for all of them (SessionLSP.cpp#L293-L303).

  • An R document with an unmapped extension (e.g. model.q, or a file with no extension set to R) gets no didOpen from the sync after an agent restart, but still gets didFocus, didChange and completion requests.
  • A .qmd document is sent as quarto by the sync (SessionLSP.cpp#L90) and as r when opened live, so its language depends on whether the agent started before or after it was opened.

Lower priority

Activity

  1. added
    copilot
    on Nov 13, 2026
  2. added theissue type on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcopilot

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions