Undo deletes file created by Agent after multiple edits

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When creating a new file using Cursor’s agent and then performing multiple operations, pressing Undo sometimes causes the entire file to be deleted.

For example:

A new file is created.

Several modifications are made through the agent (steps 2, 3, 4, 5).

When I press Undo to revert the changes from step 5, the entire source file disappears and cannot be found.

To clarify, this does not happen when undoing all changes.
The issue occurs when undoing a specific edit or statement within the file.
Even though only a partial undo is performed, the entire file gets deleted instead of reverting just that change.

This issue has occurred several times recently.
Is there any way to prevent this behavior?

Steps to Reproduce

  1. Open Cursor and start a new project or workspace.
  2. Use the Agent to create a new source file.
  3. Make several edits to the file through the Agent (e.g., multiple code changes or additions).
  4. Place the cursor on a specific statement introduced in the latest edit.
  5. Press Undo (Ctrl+Z) to revert only that specific change.
  6. Observe that the entire file is deleted instead of reverting just the last edit.

Operating System

Windows 10/11

Version Information

Version: 2.4.31 (user setup)
VSCode Version: 1.105.1
Commit: 3578107fdf149b00059ddad37048220e41681000
Date: 2026-02-08T07:42:24.999Z
Build Type: Stable
Release Track: Default
Electron: 39.2.7
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Windows_NT x64 10.0.26200

For AI issues: which model did you use?

auto

For AI issues: add Request ID with privacy disabled

46191ddd-5755-48e9-b412-eafb8c236261

Does this stop you from using Cursor

No - Cursor works, but with this issue

3 Likes

Hey, thanks for the report. This is a known bug: Undo on files created by the agent deletes the entire file instead of undoing the last change. The team has already confirmed and logged it.

The same bug is discussed here: Undo suggestion deletes entire file after accepting a created file

For now, the workaround is to avoid using Ctrl+Z on files the agent just created. If you need to roll back changes, it’s better to use Restore Checkpoint in chat (the button in the agent message context menu).

Your report helps with prioritization.

please solve this… its been like 2 weeks

1 Like

Hey all.

This will be fixed in the next update of 2.5. Appreciate the reports.

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.