File keeps reverting and losing all my work

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Files are being automatically reverted to previous versions after changes are accepted in the IDE. The file appears correct in the editor view, but when code is executed, it fails because the actual file on disk has been reverted to an older version. This causes code breakage, data loss, and requires manual restoration of changes.

Specific Example:

  • Modified trident/src/trident/marketdata/beam_watch.py with upgraded implementation (223 lines)
  • Accepted changes in IDE - file appeared correct
  • Ran python scripts/run_hl_realtime_3m_ha.py
  • Received error: TypeError: BeamWatch.__init__() got an unexpected keyword argument 'momentum_threshold'
  • Checked file on disk - had reverted to old version (142 lines, missing new parameters)

Steps to Reproduce

  1. Open a file in Cursor IDE (e.g., trident/src/trident/marketdata/beam_watch.py)
  2. Make significant changes to the file (add new methods, parameters, or substantial code)
  3. Accept the changes in the IDE (file shows as updated in editor)
  4. Verify the file appears correct when viewed in the editor
  5. Run code that depends on the changes (e.g., python scripts/run_hl_realtime_3m_ha.py)
  6. Observe failure due to missing changes
  7. Check the actual file on disk - changes are gone, file has reverted to previous version
    Note: This has occurred multiple times during development sessions, particularly when making substantial changes to files.

Expected Behavior

  • Files should persist all changes after being accepted in the IDE
  • No automatic reversion should occur
  • The file content on disk should match what is displayed in the IDE editor
  • Git status should accurately reflect file state
  • If a file cannot be saved, the IDE should show an error or warning

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Important: Accessing the workspace via SSH into Windows server environment. This may be relevant to file persistence/sync issues.

Version: 2.3.21
VSCode Version: 1.105.1
Commit: 68e0a0385b87408d050869ea543e3778ad53f780
Date: 2026-01-02T23:46:13.381Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Darwin arm64 25.0.0

For AI issues: which model did you use?

Auto (Sonnet 4) - This issue occurs regardless of AI model used, as it’s a file persistence problem

For AI issues: add Request ID with privacy disabled

[Not applicable - this is a file system/IDE issue, not an AI generation issue]

Additional Information

File in Question:

  • Path: trident/src/trident/marketdata/beam_watch.py
  • Expected after changes: 223 lines with momentum tracking, proper BREAK detection
  • Actual after reversion: 142 lines, old implementation

Key Changes Lost:

  • Missing momentum_threshold and momentum_window_ms parameters
  • Missing _post_break tracking dictionary
  • Missing _maybe_emit_momentum() method
  • Missing info field in BeamEvent dataclass
  • Using now_ms() instead of tick ts_ms for timing

Git Status:

  • Repository shows “working tree clean” even when file is incorrect
  • No uncommitted changes detected
  • File appears to be in sync with last commit, but content doesn’t match IDE view

Workspace Configuration:

  • Multiple workspace paths: C:\TRIDENT_ZERO and /trident
  • Active Git repository on develop branch
  • PowerShell 5.1 shell

Pattern Observed:

  • Changes appear accepted in IDE but don’t persist to disk
  • No warning or notification when reversion occurs
  • File appears correct in editor but actual disk content differs
  • This has happened multiple times during the session
  • User has resorted to “aggressively committing” changes immediately to prevent loss

Workaround:

  • Manually re-apply changes after each reversion
  • Immediately commit changes after making them
  • Verify file content on disk matches IDE view before running code

Potential Root Causes to Investigate:

  1. File watcher or sync process reverting files
  2. Multiple workspace paths causing sync conflicts
  3. Git hook or auto-format process interfering
  4. IDE file caching vs actual disk state mismatch
  5. Background processes restoring files
  • Can still use Cursor for development, but must work around the issue
  • Requires constant vigilance and immediate commits
  • Causes significant productivity loss and confusion
  • Risk of losing work if not caught immediately
  • Makes development workflow unreliable

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey, thanks for the report.

This looks like a known sync issue when using Remote SSH, and the team is already working on it.

A couple quick questions:

  1. About shows Darwin arm64 (macOS), but you mentioned Windows 10/11. Are you connecting from a Mac via SSH to a Windows server?
  2. There are two different workspace paths (C:\TRIDENT_ZERO and /trident). Are these mounted folders, or different directories?

For debugging, could you please collect:

  • The Request ID from Chat menu > Copy Request ID when the issue happens again
  • Console logs: Help > Toggle Developer Tools > Console, plus screenshots of any errors
  • Whether you have any file watchers, sync tools, or antivirus running (besides Defender)

The temporary workaround you’re using, committing right away, is still the best option for now. Also try saving the file manually after accepting changes CMD/Ctrl+S, then run cat <filepath> in the terminal to confirm what’s on disk.

Let me know what you find and I’ll pass it to the team.

# Cursor Support - File Reversion Issue - Final Report

**Date:** January 7, 2026

**Issue:** Files reverting to previous state after accepting AI changes in Cursor via Remote SSH

**Status:** :white_check_mark: **RESOLVED**

## Executive Summary

The file reversion issue was caused by a race condition between Cursor’s Remote SSH file writes and Microsoft OneDrive’s sync process. Files were being written correctly to the Windows server, but OneDrive was overwriting them with older cloud versions within milliseconds. After excluding the repository folder from OneDrive sync, the issue is completely resolved.

## Problem Description

### Symptoms

- Files would revert to previous state after accepting AI changes in Cursor

- Changes appeared saved in the editor, but would disappear seconds later

- Git status showed files as “deleted” when they should have been modified

- Issue occurred consistently when using Remote SSH from Mac to Windows Server

### Impact

- Lost development time due to reverted changes

- Required aggressive commit-and-push protocol after every file change

- Reduced confidence in Cursor’s file saving mechanism

- Workflow disruption requiring constant verification

## Environment Details

### Client Machine (Mac)

- **OS:** Darwin arm64 (macOS)

- **Connection:** Remote SSH to Windows server

- **Cursor Version:** [Current version - to be filled]

### Server Machine (Windows)

- **OS:** Windows Server 2019 (Windows 10.0.17763)

- **PowerShell:** 5.1.17763.8146

- **Computer:** CRYPT0GH0ST

- **User:** administrator

### Workspace Configuration

- **Primary Path:** `C:\trident` (Windows)

- **SSH Path:** `/trident` (Unix-style, mapped to `C:\trident`)

- **Alternative Path:** `C:\TRIDENT_ZERO` (appears to be same directory, different mount point)

**Note:** Both `C:\TRIDENT_ZERO` and `/trident` map to the same physical directory `C:\trident`.

## Root Cause Analysis

### The Race Condition

When editing files via Remote SSH, the following sequence occurred:

T+0ms: Cursor writes file to C:\trident\file.py :white_check_mark:

T+50ms: OneDrive file watcher detects change

T+150ms: OneDrive checks cloud, finds older version

T+200ms: OneDrive overwrites file with old version :cross_mark:

T+250ms: Cursor detects external change, shows as reverted

### Contributing Factors

1. **OneDrive Sync Process**

- OneDrive was actively running (Process ID: 5544)

- OneDrive sync folder: `C:\OneDrive`

- Repository was outside OneDrive folder but still being synced

- OneDrive had Desktop/Documents backup enabled

2. **File System Timing**

- Cursor’s Remote SSH extension writes files correctly

- Windows file system confirms write completion

- OneDrive sync happens asynchronously, not instantly

- When OneDrive syncs, it may have an older cloud version cached

3. **SSH File Watching**

- Cursor’s file watcher detects the OneDrive overwrite

- Cursor interprets this as “external modification”

- Git sees unexpected content change, shows as “deleted”

**

Why Git Showed “Deleted” Files**

Git tracks files via SHA-1 content hashes:

- Original file: `SHA1: abc123` (old content)

- After Cursor write: `SHA1: def456` (new content)

- After OneDrive revert: `SHA1: abc123` (old content restored)

Git interprets this as: “File was deleted (abc123 → def456), then recreated (def456 → abc123)”

Hence the “D” (deleted) status in `git status`.

## Solution Implemented

### Action Taken

Excluded `C:\trident` from OneDrive sync via OneDrive Settings GUI:

1. Right-clicked OneDrive icon in system tray

2. Opened Settings > Account tab

3. Clicked “Choose folders”

4. Unchecked `trident` folder (or navigated to `C:\trident` and excluded it)

5. Clicked OK

### Verification

Created and ran test script `scripts/test_onedrive_exclusion.ps1`:

- Writes test file with timestamp

- Waits 5 seconds (simulating OneDrive sync delay)

- Reads file back and compares content

- **Result: :white_check_mark: SUCCESS - File content unchanged, no reversion detected**

## Debugging Information Collected

### System Information

- **OS:** Windows Server 2019 (10.0.17763)

- **PowerShell:** 5.1.17763.8146

- **Python:** 3.11.8 (Windows)

- **Computer:** CRYPT0GH0ST

- **User:** administrator

### Running Processes

- **OneDrive:** Running (PID: 5544, started Dec 13, 2025)

- **OneDrive.Sync.Service:** Running (PID: 7308)

- **SSH Daemon:** Multiple processes (7 sshd.exe instances

### File Watchers / Sync Tools

- :white_check_mark: **OneDrive** - Active (now excluded from repository folder)

- :cross_mark: No Dropbox, Google Drive, or other sync tools detected

### Antivirus

- :white_check_mark: Windows Defender only (default, no third-party AV)

### Services

- Offline Files: Stopped (Disabled)

- User Profile Service: Running (Automatic)

- Hyper-V Time Synchronization: Running (Manual)

### OneDrive Configuration

- **OneDrive Root:** `C:\OneDrive`

- **Repository Location:** `C:\trident` (outside OneDrive folder)

- **Backup Settings:** Desktop/Documents backup was enabled

- **Sync Status:** Repository folder now excluded from sync

### Git Repository Status

- **Repository:** `C:\trident`

- **Branch:** `develop`

- **Status:** Clean working tree

- **Total Files:** 45,410

- **Last Commit:** `72ccea6` - “feat: add test script to verify OneDrive exclusion”

## Request ID & Console Logs

**Note:** Issue resolved before console logs could be captured during active reversion.

## Testing & Verification
### Test Script Results

```

Test File: C:\trident\test_onedrive_exclusion.txt

Written: Test content written at 2026-01-07 17:18:59.495

Wait Time: 5 seconds

Read Back: Test content written at 2026-01-07 17:18:59.495

Result: :white_check_mark: SUCCESS - File content unchanged!

    OneDrive exclusion appears to be working.

    No file reversion detected.

### Real-World Testing

- Made changes to multiple files via Cursor Remote SSH

- Waited 5+ seconds after each change

- Verified changes persisted (no reversion)

- Git status shows normal modified files (not “deleted”)

## Recommendations for Cursor Team

### 1. Detection & Warning

Consider adding a detection mechanism for common sync tools (OneDrive, Dropbox, Google Drive) that could cause file conflicts:

- Detect when sync tools are active in the workspace directory

- Warn users about potential conflicts

- Suggest excluding workspace from sync tools

### 2. File Write Verification

Implement a post-write verification step:

- After writing file, wait a short delay (e.g., 100ms)

- Re-read file from disk

- Compare with expected content

- If mismatch detected, warn user about potential sync conflict

### 3. Documentation

Add to Remote SSH documentation:

- Warning about sync tool conflicts

- Best practices for excluding workspace folders

- Troubleshooting guide for file reversion issues

### 4. Error Reporting

When file reversion is detected:

- Log detailed information (sync tools, file paths, timestamps)

- Provide actionable error message to user

- Suggest excluding folder from sync tools

## Temporary Workarounds Used (Before Resolution)

1. **Aggressive Commit Protocol**

- Save file (CMD+S)

- Immediately: `git add file.py && git commit -m “…” && git push`

- Git locks content before OneDrive can revert

2. **Manual Verification**

- After saving, run `cat ` in terminal

- Verify disk contents match editor contents

- Re-save if mismatch detected

3. **OneDrive Process Stop** (temporary)

- `Stop-Process -Name “OneDrive” -Force`

- Note: OneDrive restarts on next login

## Conclusion

The file reversion issue was **not a bug in Cursor**, but rather a conflict between Cursor’s Remote SSH file writes and Microsoft OneDrive’s sync process. The issue is **completely resolved** by excluding the repository folder from OneDrive sync.

### Key Takeaways

1. :white_check_mark: Files ARE being saved correctly by Cursor

2. :white_check_mark: OneDrive was overwriting files with older cloud versions

3. :white_check_mark: Excluding folder from OneDrive sync resolves the issue

4. :white_check_mark: No changes needed to Cursor itself

### Status

**RESOLVED** - Issue no longer occurs after OneDrive exclusion.

**Report Prepared By:** Dan and his AI Assistant

**Date:** January 7, 2026

**Issue Status:** :white_check_mark: RESOLVED

1 Like

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