Skip to content

Tell Copilot about source files loaded in the IDE before Copilot has started up - #16081

Merged
gtritchie merged 7 commits into
mainfrom
copilot-register-initial-files
May 29, 2025
Merged

gtritchie merged 7 commits into
mainfrom
copilot-register-initial-files

Conversation

@gtritchie

@gtritchie gtritchie commented May 29, 2025 •

Copy link
Copy Markdown
Member

Intent

Addresses #15895

Approach

When Copilot starts up tell the front-end UI to register any open documents with Copilot (one time). This ultimately uses the same code as the "project file indexing" feature.

This will typically be files that were left opened when the session closed, and thus get reloaded early in startup before Copilot has started up.

Automated Tests

None

QA Notes

  • Add RS_LOG_LEVEL=3 to ~/.Renviron
  • Ensure signed in to Copilot in RStudio
  • open some source files in the IDE (no project)
    • for my example I opened a.R and hello.R
  • Close RStudio and then restart
  • Examine Copilot logging output and make sure you see the following for previously opened files at startup
[indexFile]: Indexing document: ~/aaa/aaa/a.R
[indexFile]: Indexing document: ~/aaa/ppp/R/hello.R

REQUEST
----------------
Content-Length: 204
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/gary/aaa/aaa/a.R","languageId":"r","version":0,"text":"...contents of file..."}}}
----------------

REQUEST
----------------
Content-Length: 622
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/gary/aaa/ppp/R/hello.R","languageId":"r","version":0,"text":"...contents of file..."}}}
----------------

A second test case is to ensure project indexing is still working:

  • open an RStudio project
  • enable "Index project files with GitHub Copilot" in Global Options / Copilot
  • open some files that are part of the project (and some that are not, if you want), then exit RStudio
  • restart RStudio
  • you should see every file in the project get indexed, then the opened files will get indexed
  • there is some duplicated effort here; files that are part of the project AND previously left open will get registered twice; could do some work to eliminate this if we think it's worth it

Documentation

None

Checklist

  • If this PR adds a new feature, or fixes a bug in a previously released version, it includes an entry in NEWS.md
  • If this PR adds or changes UI, the updated UI meets accessibility standards
  • A reviewer is assigned to this PR (if unsure who to assign, check Area Owners list)
  • This PR passes all local unit tests

@gtritchie gtritchie added this to the Cucumberleaf Sunflower milestone May 29, 2025
@gtritchie
gtritchie requested a review from kevinushey May 29, 2025 01:34
@gtritchie
gtritchie marked this pull request as ready for review May 29, 2025 15:50

@kevinushey kevinushey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gtritchie
gtritchie merged commit 0435e4c into main May 29, 2025
@gtritchie
gtritchie deleted the copilot-register-initial-files branch May 29, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants