Skip to content

fix(desktop-gpui): tell a same-size replacement from the saved copy on Windows - #4313

Open
richiemcilroy wants to merge 4 commits into
mainfrom
fix/gpui-automation-windows-file-id
Open

richiemcilroy wants to merge 4 commits into
mainfrom
fix/gpui-automation-windows-file-id

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Automations only delete local files after checking that the copy a rule saved is still the file it wrote. On Windows that check could not tell a same-size file put in its place from the real copy.

Cause

FileFingerprint holds length, modified time and, on unix only, (dev, ino). Windows had no file identity. CopyFile keeps the source's modified time, so a different file of the same length swapped in inside one timestamp tick produced an identical fingerprint and the delete went ahead.

This also explains why delete_is_refused_when_the_saved_copy_is_not_the_one_this_run_wrote was flaky on the Windows runner: it panicked with unwrap_err() on Ok in the Build GPUI Desktop (x86_64-pc-windows-msvc) job on #4252, which does not touch automations.

Change

  • Add file_id: (volume serial, NTFS file index) to the Windows fingerprint, read with GetFileInformationByHandle.
  • The handle comes from std::fs::File::open. Std opens with read, write and delete sharing, and the handle drops before the function returns, so it never blocks the later delete.
  • Unix and macOS are unchanged. No new dependency: windows-sys already enables Win32_Storage_FileSystem.

Proof

The Windows GPUI job runs the full automation test suite, including the replacement, edit and unwritten cases.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Adds Windows file identity to the saved-copy check so a same-size replacement cannot pass just by keeping the original modified time.

  • Windows automations check file identity before deleting a local capture.

Reviews (2) · Last reviewed commit: "test(desktop-gpui): pin the replacement'..." · Reviewed by Greptile

…n Windows

The delete guard fingerprints the copy a rule saved by length, modified
time and, on unix, inode. Windows had no file identity in it, and CopyFile
keeps the source's modified time, so a same-length file put in the copy's
place inside one timestamp tick passed the check. That is what made
delete_is_refused_when_the_saved_copy_is_not_the_one_this_run_wrote flaky on
the Windows runner.

Add the volume serial and NTFS file index, read through a short-lived handle
opened with std's full share mode so it never holds up the later delete.
@sandchest-com

sandchest-com Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Sandchest · Sandchest couldn't finish reviewing 43c75d9. Comment /sandchest review to try again; nothing was charged.

Details · earlier results on this pull request no longer apply to the latest commit.

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

Open in Capy

Comment thread apps/desktop-gpui/src/automation.rs Resolved
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Nov 17, 2026 6:50am UTC

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 17, 2026 04:09 Inactive

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 17, 2026 06:50 Inactive

This branch was previously deployed

1 inactive deployment
Preview – cap-status — 43c75d95 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant