Merge pull request #2842 from continuedev/dallin/duplicate-code-blocks

Prevent duplicate code blocks per chat
This commit is contained in:
Nate Sesti 2024-11-08 15:56:54 -08:00 • committed by GitHub
commit 04ff08ec37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -700,9 +700,11 @@ function TipTapEditor(props: TipTapEditorProps) {
);
const rangeStr = `(${rif.range.start.line + 1}-${rif.range.end.line + 1
})`;
const itemName = `${basename} ${rangeStr}`;
const item: ContextItemWithId = {
content: rif.contents,
name: `${basename} ${rangeStr}`,
name: itemName,
// Description is passed on to the LLM to give more context on file path
description: `${relativePath} ${rangeStr}`,
id: {
@ -717,6 +719,9 @@ function TipTapEditor(props: TipTapEditorProps) {
let index = 0;
for (const el of editor.getJSON().content) {
if (el.attrs?.item?.name === itemName) {
return; // Prevent duplicate code blocks
}
if (el.type === "codeBlock") {
index += 2;
} else {