From ab2f6761ee9fe593073c182aef5265898b434335 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 16 Dec 2024 20:12:29 -0800 Subject: [PATCH] fix codeblock error --- core/commands/util.ts | 3 +-- gui/src/components/mainInput/TipTapEditor.tsx | 18 ++++++++++++++++++ gui/src/components/mainInput/resolveInput.ts | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/core/commands/util.ts b/core/commands/util.ts index 7921c2b51..2d0c8257e 100644 --- a/core/commands/util.ts +++ b/core/commands/util.ts @@ -12,10 +12,9 @@ export function rifWithContentsToContextItem( ); const rangeStr = `(${rif.range.start.line + 1}-${rif.range.end.line + 1})`; - const itemName = `${basename} ${rangeStr}`; return { content: rif.contents, - name: itemName, + name: `${basename} ${rangeStr}`, description: `${relativePathOrBasename} ${rangeStr}`, // This is passed to the LLM - do not pass full URI id: { providerTitle: "code", diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index 3ffa249d0..b4e6616d7 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -746,9 +746,27 @@ function TipTapEditor(props: TipTapEditorProps) { if (!props.isMainInput || !editor) { return; } + + // const rif: RangeInFile & { contents: string } = + // data.rangeInFileWithContents; + // const basename = getBasename(rif.filepath); + // const relativePath = getRelativePath( + // rif.filepath, + // await ideMessenger.ide.getWorkspaceDirs(), + // const rangeStr = `(${rif.range.start.line + 1}-${ + // rif.range.end.line + 1 + // })`; + + // const itemName = `${basename} ${rangeStr}`; + // const item: ContextItemWithId = { + // content: rif.contents, + // name: itemName + // } + const contextItem = rifWithContentsToContextItem( data.rangeInFileWithContents, ); + console.log(contextItem); let index = 0; for (const el of editor.getJSON()?.content ?? []) { if (el.attrs?.item?.name === contextItem.name) { diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index 8f8cbb6f9..190dfbc80 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -71,7 +71,7 @@ async function resolveEditorContent({ } } else if (p.type === "codeBlock") { if (p.attrs?.item) { - const contextItem = p.atts.item as ContextItemWithId; + const contextItem = p.attrs.item as ContextItemWithId; const rif = ctxItemToRifWithContents(contextItem); // If not editing, include codeblocks in the prompt // If editing is handled by selectedCode below