diff --git a/core/edit/lazy/deterministic.ts b/core/edit/lazy/deterministic.ts index 99d5c9a01e..1e3a0ec4e3 100644 --- a/core/edit/lazy/deterministic.ts +++ b/core/edit/lazy/deterministic.ts @@ -172,7 +172,7 @@ export async function deterministicApplyLazyEdit( oldText.slice(endIndex); } else { console.warn("No matching node found for lazy block"); - return []; + return undefined; } } } diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index a3a7f651fd..4d8a99020d 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -359,7 +359,7 @@ export class VerticalDiffHandler implements vscode.Disposable { // Clear deletion buffer await this.insertDeletionBuffer(); - this.reapplyWithMeyersDiff(diffLines); + await this.reapplyWithMeyersDiff(diffLines); this.options.onStatusUpdate( "done", @@ -386,6 +386,7 @@ export class VerticalDiffHandler implements vscode.Disposable { startLine: number, numGreen: number, numRed: number, + skipStatusUpdate?: boolean, ) { if (numGreen > 0) { // Delete the editor decoration @@ -415,15 +416,18 @@ export class VerticalDiffHandler implements vscode.Disposable { // Shift the codelens objects this.shiftCodeLensObjects(startLine, offset); - const numDiffs = - this.editorToVerticalDiffCodeLens.get(this.fileUri)?.length ?? 0; + if (!skipStatusUpdate) { + const numDiffs = + this.editorToVerticalDiffCodeLens.get(this.fileUri)?.length ?? 0; - const status = numDiffs === 0 ? "closed" : undefined; - this.options.onStatusUpdate( - status, - numDiffs, - this.editor.document.getText(), - ); + const status = numDiffs === 0 ? "closed" : undefined; + + this.options.onStatusUpdate( + status, + numDiffs, + this.editor.document.getText(), + ); + } } private shiftCodeLensObjects(startLine: number, offset: number) { @@ -482,11 +486,15 @@ export class VerticalDiffHandler implements vscode.Disposable { * we have received all of the diff lines. */ async reapplyWithMeyersDiff(diffLines: DiffLine[]) { - // First, we reset the original diff by deleting any new lines and clearing decorations - for (const range of this.greenDecorationManager.getRanges()) { - await this.deleteLinesAt( - range.start.line, - range.end.line - range.start.line + 1, + // First, we reset the original diff by rejecting all pending diff blocks + for (const block of this.editorToVerticalDiffCodeLens.get(this.fileUri) ?? + []) { + await this.acceptRejectBlock( + false, + block.start, + block.numGreen, + block.numRed, + true, ); } diff --git a/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx b/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx index f915f27d73..3d59ac2394 100644 --- a/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx +++ b/gui/src/components/CodeToEditCard/CodeToEditListItem.tsx @@ -98,7 +98,7 @@ export default function CodeToEditListItem({ -
+
{showCodeSnippet ? ( { setShowApplied(false); - }, 2_000); + }, 5_000); return () => clearTimeout(timer); } }, [isClosed, isSuccessful]); diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index 45b55f10b7..6ccedc74aa 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -131,18 +131,19 @@ export default function StepContainerPreToolbar( } }, [props.children, codeBlockContent]); - useEffect(() => { - const hasCompletedGenerating = - wasGeneratingRef.current && !isGeneratingCodeBlock; + // Temporarily disabling auto apply for Edit mode + // useEffect(() => { + // const hasCompletedGenerating = + // wasGeneratingRef.current && !isGeneratingCodeBlock; - const shouldAutoApply = hasCompletedGenerating && isInEditMode; + // const shouldAutoApply = hasCompletedGenerating && isInEditMode; - if (shouldAutoApply) { - onClickApply(); - } + // if (shouldAutoApply) { + // onClickApply(); + // } - wasGeneratingRef.current = isGeneratingCodeBlock; - }, [isGeneratingCodeBlock]); + // wasGeneratingRef.current = isGeneratingCodeBlock; + // }, [isGeneratingCodeBlock]); async function onClickAcceptApply() { const fileUri = await inferResolvedUriFromRelativePath(