Skip to content

Suggestions from project indexing only made if the active file is saved #14051

Open

Description

@ronblum

System details

RStudio Edition : Desktop and Server
RStudio Version : 2023.12.0-363
OS Version      : RHEL 9 and MacOS
R Version       : N/A

Steps to reproduce the problem

  1. Turn on Copilot project indexing.
  2. Write some code in a file that wouldn't likely be available at GitHub.
  3. Save the file and close it.
  4. Open a new file and write some code that should trigger suggestions based on the other file.

Describe the problem in detail

The project-based suggestions aren't happening.

Describe the behavior you expected

Suggestions should be made based on the file without having to open it.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added
    copilot
    on Dec 14, 2023
  2. added this to the Product Backlog milestone on Jan 8, 2024
  3. ronblum commented on Jan 8, 2024

    @ronblum
    ContributorAuthor

    Try this in other comparable tools.

  4. self-assigned this
    on Jan 8, 2024
  5. kevinushey commented on Jan 10, 2024

    @kevinushey
    Collaborator

    It seems to work for me:

    Screenshot 2024-01-10 at 11 34 25 AM

    For posterity, I created a new project with these files:

    script-1.R

    # use variables from script-2.R
    source("script-2.R")
    print(her)
    

    script-2.R

    # define some variables
    heres_a_variable_with_a_unique_name <- 42
    

    In project options, I also made sure to enable Copilot + indexing:

    Screenshot 2024-01-10 at 11 35 46 AM

    Then, I closed all open documents, restarted RStudio, and then opened script-1.R.

    To further verify, if I close all open documents, and then write:

    COPILOT_LOG_LEVEL = 3
    

    to the project .Renviron file, then when I restart the R session, I see:

    [onStarted]: Copilot agent has started [PID = 88129]
    
    RESPONSE
    ------------------
    {"jsonrpc":"2.0","method":"LogMessage","params":{"level":0,"message":"[DEBUG] [agent] [2024-01-10T19:36:27.396Z] Agent service starting","metadataStr":"[DEBUG] [agent] [2024-01-10T19:36:27.396Z]","extra":["Agent service starting"]}}
    ------------------
    
    
    [sendRequest]: Sending request 'initialize' with id 'fe466d81-0fc9-49ea-bd75-c7c81d461d33'.
    
    REQUEST
    ----------------
    Content-Length: 180
    
    {"jsonrpc":"2.0","method":"initialize","params":{"processId":87846,"clientInfo":{"name":"RStudio","version":"1.0.0"},"capabilities":{}},"id":"fe466d81-0fc9-49ea-bd75-c7c81d461d33"}
    ----------------
    
    
    
    RESPONSE
    ------------------
    {"jsonrpc":"2.0","id":"fe466d81-0fc9-49ea-bd75-c7c81d461d33","result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2},"workspace":{"workspaceFolders":{"supported":false,"changeNotifications":false}}}}}
    ------------------
    
    
    [indexFile]: Indexing document: /Users/kevin/scratch/copilot-test
    [indexFile]: Indexing document: /Users/kevin/scratch/copilot-test/copilot-test.Rproj
    [indexFile]: Indexing document: /Users/kevin/scratch/copilot-test/script-1.R
    [indexFile]: Indexing document: /Users/kevin/scratch/copilot-test/script-2.R
    [onBackgroundProcessing]: Invoking continuation with id 'fe466d81-0fc9-49ea-bd75-c7c81d461d33'.
    [sendRequest]: Sending request 'setEditorInfo' with id 'e33a50ae-c825-4dc1-91ea-f6bae1c9a073'.
    
    REQUEST
    ----------------
    Content-Length: 164
    
    {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/kevin/scratch/copilot-test","languageId":"","version":1,"text":""}}}
    ----------------
    
    
    
    REQUEST
    ----------------
    Content-Length: 462
    
    {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/kevin/scratch/copilot-test/copilot-test.Rproj","languageId":"rproj","version":1,"text":"Version: 1.0\n\nRestoreWorkspace: Default\nSaveWorkspace: Default\nAlwaysSaveHistory: Default\n\nEnableCodeIndexing: Yes\nUseSpacesForTab: Yes\nNumSpacesForTab: 2\nEncoding: UTF-8\n\nRnwWeave: Sweave\nLaTeX: pdfLaTeX\n\nAutoAppendNewline: Yes\nStripTrailingWhitespace: Yes\n"}}}
    ----------------
    
    
    
    REQUEST
    ----------------
    Content-Length: 247
    
    {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/kevin/scratch/copilot-test/script-1.R","languageId":"r","version":1,"text":"\n# use variables from script-2.R\nsource(\"script-2.R\")\nprint(her)\n"}}}
    ----------------
    
    
    
    REQUEST
    ----------------
    Content-Length: 246
    
    {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/kevin/scratch/copilot-test/script-2.R","languageId":"r","version":1,"text":"\n# define some variables\nheres_a_variable_with_a_unique_name <- 42\n"}}}
    ----------------
    
    
    
    REQUEST
    ----------------
    Content-Length: 231
    
    {"jsonrpc":"2.0","method":"setEditorInfo","params":{"editorInfo":{"name":"RStudio","version":"2024.01.999-dev+999"},"editorPluginInfo":{"name":"RStudio","version":"2024.01.999-dev+999"}},"id":"e33a50ae-c825-4dc1-91ea-f6bae1c9a073"}
    ----------------
    
    
    
    RESPONSE
    ------------------
    {"jsonrpc":"2.0","method":"LogMessage","params":{"level":0,"message":"[DEBUG] [agent] [2024-01-10T19:36:27.637Z] Telemetry initialized","metadataStr":"[DEBUG] [agent] [2024-01-10T19:36:27.637Z]","extra":["Telemetry initialized"]}}
    ------------------
    
    
    
    RESPONSE
    ------------------
    {"jsonrpc":"2.0","id":"e33a50ae-c825-4dc1-91ea-f6bae1c9a073","result":"OK"}
    ------------------
    
    
    [onBackgroundProcessing]: Invoking continuation with id 'e33a50ae-c825-4dc1-91ea-f6bae1c9a073'.
    

    and you can see in the logs that the files are indeed being indexed by Copilot.

  6. ronblum commented on Jan 10, 2024

    @ronblum
    ContributorAuthor

    Ah! @kevinushey I can see the files getting index (I used RSTUDIO_LOG_LEVEL=1). And your examples work splendidly for me. The issue is occurring for me only if the current file isn't saved. So for a new file (Untitled1 etc.), the only suggestions are from GitHub. As soon as the file is saved, locally-sourced suggestions are made, as well.

  7. changed the title [-]Project indexing isn't working—suggestions from local files are only made if open[/-] [+]Suggestions from project indexing only made if the active file is saved[/+] on Jan 10, 2024
  8. jthomasmock commented on Jan 11, 2024

    @jthomasmock
    Contributor

    Thanks for the reprex Kevin! @ronblum - I think this issue can be closed unless we think the "active file must be saved" is a regression/bug. If the active file just has to be saved 1x to start the indexing/suggestions then I think we're good.

  9. ronblum commented on Jan 11, 2024

    @ronblum
    ContributorAuthor

    It's not a regression—it was like this in the preview (2023.09). I think that it's a bug, or at least a nice to have, but it has a an easy workaround—save the file—so I don't think this is a high priority.

  10. removed their assignment
    on Mar 14, 2024
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

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions