From f4e5b103f782be211f6c7a57c97d965c8a0d8beb Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 7 Nov 2024 17:05:56 -0800 Subject: [PATCH] prevent duplicate code blocks --- gui/src/components/mainInput/TipTapEditor.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 01ee8dea6..49fe9d547 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -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 {