continuedev / continuedev/continue
Selected code is not provided in getContextItems input when using edit mode
@RomneyDa is already working on this.
Since Feb 7, 2025.
- Dominant language
- TypeScript
- Stars
- 36k
- Forks
- 5.4k
- PR merge metrics
- No merged PRs in 30d
Description
Before submitting your bug report
- I believe this is a bug. I'll try to join the Continue Discord for questions
- I'm not able to find an open issue that reports the same bug
- I've seen the troubleshooting guide on the Continue Docs
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
- Replace your config.ts with my example in Relevant environment information of this post
- Type ">Developer: Toggle Developer Tools" in the Visual Studio Code search bar to open the Developer Tools window
- In the Developer Tools window, select the console panel and in the filter bar type "Extension Host"
- In Visual Studio Code select a piece of code, in my example I selected the entire modfyConfig function from config.ts
- Open Continue in chat mode (ctrl+L), type "@" and "custom-context", send the request
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.