[BUG] InlineDiffManager auto-rejects and reverts all agent edits after 1s when files.autoSave is "afterDelay"

When VS Code is configured with "files.autoSave": "afterDelay" (the default 1000ms delay) and "antigravity.enableInlineDiff": true (default in v1.5.0), all edits made by the Antigravity agent are automatically rejected and reverted to originalText after exactly 1 second before the user can accept or review them.

Environment & Versions

  • Extension: google.google-antigravity (v1.5.0)
  • CLI / Sidecar: agy.exe (v1.2.12)
  • Host IDE: Microsoft VS Code (win32-x64)
  • Key Settings: "files.autoSave": "afterDelay", "antigravity.enableInlineDiff": true

Steps to Reproduce

  1. In VS Code settings (settings.json), set:
"files.autoSave": "afterDelay",
"antigravity.enableInlineDiff": true

2.Prompt the Antigravity agent to make changes to one or more files.

3.Observe the editor when the agent finishes applying changes.

Expected Behavior

Inline diff decorations and Accept / Reject buttons remain visible until the user explicitly accepts or rejects the changes.

Actual Behavior:

The agent finishes editing the file.

The Accept / Reject action appears for < 1 second and disappears.

All file changes are automatically reverted on disk back to their pre-edit state.

Root Cause Analysis (extension.js)

  1. registerDiff() leaves the document dirty:
    In InlineDiffManager.prototype.registerDiff, this.applyContentReplacement(document, activeDiff.combinedText) replaces the buffer with combinedText without saving, marking document.isDirty = true and starting VS Code’s 1000ms auto-save timer.

  2. handleDocumentWillSave() intercepts auto-save and reverts to originalText:
    At 1000ms, VS Code fires onWillSaveTextDocument with
    reason = vscode.TextDocumentSaveReason.AfterDelay (value 2):

if (event.reason != null && event.reason !== vscode.TextDocumentSaveReason.Manual) {
this.pendingAutoSaveUris.add(normalizedKey);
event.waitUntil(Promise.resolve([
vscode.TextEdit.replace(fullRange, activeDiff.originalText),
]));
return;
}

  1. handleDocumentDidSave() finalizes with accepted = false:
    After writing originalText to disk, onDidSaveTextDocument triggers:

const isManualSave = this.pendingManualSaveUris.delete(normalizedKey); // false
this.finalizeFile(key, isManualSave); // passes false!

Calling finalizeFile(key, false) destroys the diff session and marks the hunk as rejected (SetFileDiffs: ).

Workaround

Add the following to VS Code’s settings.json to fall back to the side-by-side diff renderer:

“antigravity.enableInlineDiff”: false

I ran into this issue too, but I tried rolling back to version 1.4.0 and it works fine. I’m not sure if there were any major updates between 1.4.0 and the subsequent versions; if not, I might just stick with this version for the long haul :grinning_face_with_smiling_eyes:

Hi @Shubham_Giri,

Could you please share the Operating System you are using?

Hi @Ambati_Rajendra,

I am running on Windows 11 (64-bit) — VS Code win32-x64.

Hi @imorius,

You don’t actually need to downgrade to v1.4.0!

The root issue in v1.5.0 is the new default inline diff renderer colliding with VS Code’s auto-save timer. You can stay on v1.5.0 and simply disable inline diffs by adding this to your settings.json:

“antigravity.enableInlineDiff”: false

This falls back to the side-by-side diff renderer, completely bypassing the 1-second auto-revert bug while keeping all the latest v1.5.0 features.