Skip to content

Commit

Permalink
Merge pull request #3666 from continuedev/pe/edit-apply-short-circuit…
Browse files Browse the repository at this point in the history
…-bugfix

fix: comment out auto apply on MFE
  • Loading branch information
Patrick-Erichsen authored Jan 10, 2025
2 parents 89a1517 + f61476a commit 462ded1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
2 changes: 1 addition & 1 deletion core/edit/lazy/deterministic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export async function deterministicApplyLazyEdit(
oldText.slice(endIndex);
} else {
console.warn("No matching node found for lazy block");
return [];
return undefined;
}
}
}
Expand Down
36 changes: 22 additions & 14 deletions extensions/vscode/src/diff/vertical/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
);
}

Expand Down
2 changes: 1 addition & 1 deletion gui/src/components/CodeToEditCard/CodeToEditListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function CodeToEditListItem({
</div>
</div>

<div className="invisible flex items-center gap-1.5 group-hover:visible">
<div className="invisible flex items-center group-hover:visible">
<div className={`flex items-center ${isInsertion ? "hidden" : ""}`}>
{showCodeSnippet ? (
<ChevronDownIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function ApplyActions(props: ApplyActionsProps) {
setShowApplied(true);
const timer = setTimeout(() => {
setShowApplied(false);
}, 2_000);
}, 5_000);
return () => clearTimeout(timer);
}
}, [isClosed, isSuccessful]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 462ded1

Please sign in to comment.