continuedev / continuedev/continue

Selected code is not provided in getContextItems input when using edit mode

Open
#4,014 0 comments 0 reactions 1 assignee View on GitHub

@RomneyDa is already working on this.

Since Feb 7, 2025.

area:context-providers ide:vscode kind:bug needs-triage
Dominant language
TypeScript
Stars
36k
Forks
5.4k
PR merge metrics
No merged PRs in 30d

Description

Before submitting your bug report
Relevant environment info
- OS: Windows 11 Home | Ubuntu 20.04.6 LTS (Focal Fossa)
- Continue version: 0.8.66
- IDE version: Visual Studio Code 1.97.0
- Model: Anyone 
- config.ts:
  

export function modifyConfig(config: Config): Config {
  if (!config.contextProviders) {
    config.contextProviders = [];
  }
  config.contextProviders.push(CustomContext);
  return config;
}

const CustomContext: CustomContextProvider = {
  title: "Custom Context",
  displayTitle: "custom-context",
  description:
    "Retrieve snippets from our vector database of internal documents",

  getContextItems: async (
    query: string,
    extras: ContextProviderExtras
  ): Promise<ContextItem[]> => {

    console.log("--- Log extras ---")
    console.log("FullInput: " + extras.fullInput)
    console.log("SelectedCode: " + JSON.stringify(extras.selectedCode))

    
    return [
      {
        content: "Content",
        name: "Content",
        description: "This is a mocked content for testing.",
      }
    ];
}};
Description

Hi there,

I'm using a CustomContextProvider that sends a selected code snippet to a code analysis tool to enrich the context with its report.

To do this, I use an implementation of getContextItens and access information about the selected code in extras.fullInput and extras.selectedCode.

This works fine in Chat mode, but in Edit mode the expected information is not sent to my implementation. The logs below show the difference in behavior in the two cases.

The interface in each mode is a bit different, so it makes sense that they don't behave the same way at the moment. But I'd like my CustomContextProvider to work the same way in both cases anyway, and I couldn't find anything in the reference that says this is an expected limitation or that offers an alternative implementation for Edit mode.

Thanks for your support guys.

To reproduce
  1. Replace your config.ts with my example in Relevant environment information of this post
  2. Type ">Developer: Toggle Developer Tools" in the Visual Studio Code search bar to open the Developer Tools window
  3. In the Developer Tools window, select the console panel and in the filter bar type "Extension Host"
  4. In Visual Studio Code select a piece of code, in my example I selected the entire modfyConfig function from config.ts
  5. Open Continue in chat mode (ctrl+L), type "@" and "custom-context", send the request
  6. Open Continue in edit mode (ctrl+I), type "@" and "custom-context", send the request
Log output
[Extension Host] --- Log extras ---
console.ts:137 [Extension Host] FullInput: 

 config.ts (1-7)
export function modifyConfig(config: Config): Config {
  if (!config.contextProviders) {
    config.contextProviders = [];
  }
  config.contextProviders.push(CustomContext);
  return config;
}

custom-context 
console.ts:137 [Extension Host] SelectedCode: [{"filepath":"config.ts (1-7)","range":{"start":{"line":0,"character":0},"end":{"line":6,"character":0}}}]
console.ts:137 [Extension Host] --- Log extras ---
console.ts:137 [Extension Host] FullInput: custom-context 
console.ts:137 [Extension Host] SelectedCode: []

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.