From 471ca9eae5e1f82e04b2d6d600631bf24876ec06 Mon Sep 17 00:00:00 2001 From: Ben Force Date: Fri, 15 Mar 2024 12:43:33 -0500 Subject: [PATCH] feat: enable comment filtering --- .../context/providers/GitLabMergeRequestContextProvider.ts | 7 +++++++ docs/docs/customization/context-providers.md | 4 ++++ docs/static/schemas/config.json | 4 ++++ extensions/intellij/src/main/resources/config_schema.json | 4 ++++ extensions/vscode/config_schema.json | 4 ++++ extensions/vscode/continue_rc_schema.json | 4 ++++ 6 files changed, 27 insertions(+) diff --git a/core/context/providers/GitLabMergeRequestContextProvider.ts b/core/context/providers/GitLabMergeRequestContextProvider.ts index c845c959c..d1b3da8eb 100644 --- a/core/context/providers/GitLabMergeRequestContextProvider.ts +++ b/core/context/providers/GitLabMergeRequestContextProvider.ts @@ -186,6 +186,13 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider { locations[filename].push(comment); } + + if (extras.selectedCode.length && this.options.filterComments) { + const toRemove = Object.keys(locations).filter(filename => !extras.selectedCode.find(selection => selection.filepath.endsWith(filename)) && filename !== "general"); + for (const filepath of toRemove) { + delete locations[filepath]; + } + } const commentFormatter = async (comment: GitLabComment) => { const commentLabel = comment.body.includes("```suggestion") ? 'Code Suggestion' : 'Comment'; diff --git a/docs/docs/customization/context-providers.md b/docs/docs/customization/context-providers.md index d17835a3d..94cbcb2ed 100644 --- a/docs/docs/customization/context-providers.md +++ b/docs/docs/customization/context-providers.md @@ -151,6 +151,10 @@ You can specify the domain to communicate with by setting the `domain` parameter } ``` +#### Filtering Comments + +If you select some code to be edited, you can have the context provider filter out comments for other files. To enable this feature, set `filterComments` to `true`. + ### Jira Issues Type '@jira' to reference the conversation in a Jira issue. Make sure to include your own [Atlassian API Token](https://id.atlassian.com/manage-profile/security/api-tokens). diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 439e6c0d5..4d9ff78fd 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1260,6 +1260,10 @@ "token": { "type": "string", "description": "Your private access token." + }, + "filterComments": { + "type": "boolean", + "description": "If you have code selected, filters out comments that aren't related to the selection." } }, "required": ["token"] diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 439e6c0d5..4d9ff78fd 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1260,6 +1260,10 @@ "token": { "type": "string", "description": "Your private access token." + }, + "filterComments": { + "type": "boolean", + "description": "If you have code selected, filters out comments that aren't related to the selection." } }, "required": ["token"] diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 439e6c0d5..4d9ff78fd 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1260,6 +1260,10 @@ "token": { "type": "string", "description": "Your private access token." + }, + "filterComments": { + "type": "boolean", + "description": "If you have code selected, filters out comments that aren't related to the selection." } }, "required": ["token"] diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 7fdd0279b..277388a9e 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1411,6 +1411,10 @@ "token": { "type": "string", "description": "Your private access token." + }, + "filterComments": { + "type": "boolean", + "description": "If you have code selected, filters out comments that aren't related to the selection." } }, "required": [