Repository navigation
Tests: the second folder drop waits for the Missing Photos count (#3822) - #4027
Conversation
…ssing Photos count
dont_ask_again_moves_the_next_drop_at_once read the home row's rect one
frame after the first move. The move changes the Missing Photos count,
which a worker takes: a count already running when beach.png moved finds
its old path empty and adds the Missing Photos row, and the recount takes
it away. Each shifts every folder row below it by one row, so on a busy
machine the second drop, aimed at the rect read before the count landed,
went to the folder above (dunes.png moved into the parent folder) or to
trip ("Already in"). Waiting longer for home/dunes.png could not help.
The test now settles the sidebar before reading the row, as other
sidebar tests do, and runs with a slow count so the race happens on
every run: it checks that the row stays put for longer than the count
takes. Without the settle it fails every time ("home stays where the
drop aims"). The move is synchronous, so the 20 s wait from storytold#3834 is
replaced by an immediate check that prints the toast, and the drag
checks the drop hint before releasing.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
The test only failed on the Windows gate, and this PR touches no path in |
AlexChambers
left a comment
There was a problem hiding this comment.
Approve. The diagnosis is right, the fix is in the right place, and the new test fails every time without the settle. I have two small notes below. Neither blocks the merge.
What I checked
The cause is in the code, as described. missing_count (crates/ui-egui/src/panels/left/sections.rs:391) collects its candidate paths when it starts and checks them on a worker thread. A count already running when beach.png moves finds the old path empty and stores 1. The left panel then draws the "Missing Photos" row above Folders (crates/ui-egui/src/panels/left.rs:99), and the recount takes it away again. Either change shifts every folder row.
Settling covers that recount. A catalog change during a running count increments fs_running_counter and sets owed (sections.rs:408). Headless::busy checks that counter, so settle waits for the recount. That's the same mechanism settling_waits_for_the_missing_photos_count in tests/panels.rs relies on.
The move is synchronous, so dropping step_until is safe. folder_drop_target calls move_photos_here, which goes through app.run("photo.moveToFolder", ..) in the same frame (panels/left/folders.rs:425, :464). If the file isn't in home right after the drop, waiting longer won't put it there. The new assert also prints the toast, which helps.
The extra h.step() before the hint check is correct. Synthetic pointer events reach the app one per frame (app/input.rs:191). The press queues two events and steps once, so one event is still queued when the glide ends.
AGENTS.md is followed. The diff touches only the test file. The unwraps are in test code. The settle waits on a condition. The 1 s loop is an observation window, not a wait, and it uses the same pattern as the existing panels test. The doc comment says why the test is shaped this way and names the issue.
What I ran
All runs were on macOS (aarch64, 14 cores). "Load" means three full lightcraft-ui-egui lib suites running alongside at --test-threads=4 each.
| Build | Change | Runs | Failures |
|---|---|---|---|
| main (e9c29e2) | none, under load | 400 | 0 |
| main | slow count only, 1 s | 20 | 0 |
| main | slow count only, 20 ms and 25 ms | 20 | 7 |
| PR head | none, under load | 400 | 0 |
| PR head | settle replaced by h.step(), 1 s count |
20 | 20 |
| PR head | settle kept, 20 ms and 25 ms count | 40 | 0 |
| PR head | settle replaced by h.step(), 20 ms and 25 ms count |
40 | 30 |
Load alone didn't trigger the race on this machine. Main passed 400 of 400.
A short count reproduces the CI failure on main. With a 20 to 25 ms count, the count lands during the second drag. The test then fails with the exact CI message, "moved without a question". In every failed run, dunes.png ended up in the parent folder, one row above home, which matches the diagnosis.
Without the settle, the PR's test fails every time. It fails at "home stays where the drop aims" (line 360). With the settle, it passed every run, including the short counts that break main.
The other checks passed on the PR head:
cargo test -p lightcraft-ui-egui --lib folder_drop: 12 passed.cargo clippy -p lightcraft-ui-egui --all-targets -- -D warnings: clean.cargo xtask ci --quick: all 8 steps passed.
I could not run anything on Windows.
Notes (non-blocking)
crates/ui-egui/src/tests/folder_drop.rs:331: the doc comment says "(here, a slow count)". On its own, the 1 s count doesn't make the drop miss. On main it passes 20 of 20, because the drop finishes long before the count lands. What catches the bug is the check at line 360 that the row stays put. Maybe say that in the comment, for example: "a slow count makes the row move after the first move on every run, and the test checks that it stays put once settled". Up to you.- The Windows leg (
gate-windows) was skipped on this PR, and Windows is where the flake was seen. The local numbers above make me fairly confident, but afull-cirun before merging would confirm it on the hosted runner.
…rop test catches Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the thorough check. I took note 1: the doc comment now says the slow count doesn't make the drop miss by itself, and that the test checks |
|
I ran it on Windows locally (Windows 11, x86_64, 32 cores, MSVC toolchain). "Load" means four full
This doesn't replace a |
Fixes #3822
What
tests::folder_drop::dont_ask_again_moves_the_next_drop_at_oncenow settles the sidebar before it reads the folder row for its second drop, so the drop can't land on the row above.Why it failed
The move itself is synchronous: a drop with "ask before move" off calls
photo.moveToFolderwithin the frame. Whenhome/dunes.pngwas missing, no move tohomehad happened, and #3834's 20 s wait could never help.The test read the home row's rect one frame after the first move. The move changes the Missing Photos count, which a worker thread takes (
missing_countinpanels/left/sections.rs):beach.pngmoved finds its old path empty, so the "Missing Photos" row appears.Each change moves every folder row below it by 29 px. On a busy machine, the second drop was aimed at a rect read before the count landed:
dunes.pngwas moved into the parent folder (the CI failure);trip("Already in “trip”").A Windows sharing violation in
rename_no_replacewas my first guess. Holding the file open without delete sharing does produce this symptom (os error 32). But 5,000 moves of freshly written files with Defender on gave no error, and the drop diagnostics below show the rows shifting instead.Change (test only)
h.settle(...)before reading the row. Settling already waits for this count (LRC-LIB-MISSING: settling waits for the Missing Photos count, which can't panic on spawn #3392,settling_waits_for_the_missing_photos_count).missing_count_test_delay, set before the first frame through a newapp_preparedhelper), so a count straddles the first move on every run. It then checks that the home row stays put for longer than the count takes.pressqueues two.step_untilis replaced by an immediate check, whose message includes the toast, so a refused move says why.No product code changes.
How it was checked
On Windows 11 (MSVC, native), with three full
lightcraft-ui-eguisuites running at once at--test-threads=4to load the machine like the 4-vCPU runner:moved without a question (toast: "Moved 1 photo to “lc-folder-drop-dont-ask-22788”. …"). The rest showed the Missing Photos row having moved the folder rows.h.step(), the new test fails 5 of 5 runs ("home stays where the drop aims", home's rect moves from y 374 to 403). With it, the 12folder_droptests pass.cargo xtask ci --quickon Linux (WSL2, with craft-fonts): passed (fmt, clippy, tests, parity, layers, assets, roots, wasm). It skipped one GPU test: no hardware adapter there.cargo clippy -p lightcraft-engine -p lightcraft-ui-egui --all-targets -- -D warningsis clean.cargo xtask ci(only--quick), and macOS.The test now takes about 3 s instead of under 1 s, for the slow count.
Unrelated: in the loaded Windows runs,
find_similar::stopping_leaves_the_view_alone_and_the_next_search_reads_only_the_restfailed once (already tracked in #3823 / #3799).The brief Missing Photos row after a move is visible in the app too, and can send a quick second drop to the wrong folder. That's a product bug, which I'm filing and fixing separately; this PR doesn't depend on it.
Summary by CodeRabbit