Bug: Don't select items that are created externally
Description
I've mainly encountered this with Minecraft servers trying to save the world and failing because Files has select the level.dat file used when made outside of Files, the terminal will report that the file was in use. I've also had this happen with Visual Studio sometimes making a temp file instead. The preview pane isn't open.
Steps To Reproduce
- Download Minecraft sever (https://papermc.io/downloads/all)
- Start server in terminal (java -jar
.jar) - Open world folder
- Select level.dat
- Wait a bit
- See in console failed to rename, file in use error.
Requirements
- Don't select the file if made outside of files.
Files Version
3.0.9.0
Windows Version
10.0.22621.2506
Log File
What happens if you try deleting the same item from File Explorer?
The file delete fine in Windows File Explorer, renaming too
This can be done by moving HandleChangesOccurredAsync out of the file watcher and only calling it when using an internal action (eg rename, paste, delete etc).
related: https://github.com/files-community/Files/issues/4214#issuecomment-2010572187
Adding #15611 for reference
I wrote an automated reproduction for this, in case it's useful for whoever picks it up.
Branch (on my own fork, not a merge request): https://github.com/mangokingTW/Files/tree/wintegrate-repro-issue-14011 CI run these numbers come from: https://github.com/mangokingTW/Files/actions/runs/33638254396 Screen recordings (run artifacts, 14-day retention): x64 · arm64
It doesn't need a Minecraft server — any second process creating a file in the open folder does it, and the test is that second process. About 20 seconds.
step existing_a.txt existing_b.txt external_new.txt
after_navigation False False -
after_click True False -
after_external_create False False True
Still present on main (63111abb5, 4.2.26.0 sideload build) as well as 4.2.9.0.
Note the second column: as well as the new item being selected, the selection
the user was holding is taken away. Only externally created items are asserted
against, following the note here about HandleChangesOccurredAsync being called
from the file watcher.
Two of the four tests are controls that pass (selection is readable and not
simply True; the watcher did see the file), so a red result isn't just a broken
harness.
Not a proposal to add a second test framework — this lives in tests/ui-repro/
and nothing in the solution picks it up. The measurement is the useful part;
porting it to the existing Appium tests would be a small job.
Driven with wintegrate, a library
I'm building to make Windows GUI testing actually work on hosted CI runners.
Files is one of four real applications it drives as its own release gate, and it
is the reason the library can focus a WinUI 3 content island at all — a
DesktopChildSiteBridge will happily be foreground while every keystroke goes
nowhere.
It has only been run on Windows 11 / Server 2025. It closes any running
Files.exe and sets a few startup settings in
LocalState/settings/user_settings.json so the launch is deterministic, putting
the original file back afterwards.
I plan to investigate this. I will use the reproduction from the thread to check whether Files still selects items created by another process.