Skip to content

Tests: the second folder drop waits for the Missing Photos count (#3822) - #4027

Merged
dylanmtaylor merged 2 commits into
storytold:mainfrom
THEtheChad:fix/3822-folder-drop-windows-move
Nov 15, 2026
Merged

dylanmtaylor merged 2 commits into
storytold:mainfrom
THEtheChad:fix/3822-folder-drop-windows-move

Conversation

@THEtheChad

@THEtheChad THEtheChad commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3822

What

tests::folder_drop::dont_ask_again_moves_the_next_drop_at_once now 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.moveToFolder within the frame. When home/dunes.png was missing, no move to home had 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_count in panels/left/sections.rs):

  • A count already running when beach.png moved finds its old path empty, so the "Missing Photos" row appears.
  • The recount takes the row away again.

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:

  • usually it went to the folder above, and dunes.png was moved into the parent folder (the CI failure);
  • once it went to trip ("Already in “trip”").

A Windows sharing violation in rename_no_replace was 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).
  • The test runs with a 1 s count (missing_count_test_delay, set before the first frame through a new app_prepared helper), 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.
  • The drag checks the drop hint ("Move 1 photo to “home”") before it releases. It steps one extra frame first, because synthetic pointer events reach the app one per frame and press queues two.
  • The 20 s step_until is 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-egui suites running at once at --test-threads=4 to load the machine like the 4-vCPU runner:

full suites the test looped beside them
before 2 of 12 failed 10 of 1,200 failed
after 0 of 6 failed 0 of 600 failed
  • One "before" failure was exactly CI's: 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.
  • With no load the test never failed (0 of 920 runs), which is why it only shows on CI.
  • Fails without the fix: on Linux, with the settle swapped back for one 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 12 folder_drop tests pass.
  • cargo xtask ci --quick on Linux (WSL2, with craft-fonts): passed (fmt, clippy, tests, parity, layers, assets, roots, wasm). It skipped one GPU test: no hardware adapter there.
  • Windows: cargo clippy -p lightcraft-engine -p lightcraft-ui-egui --all-targets -- -D warnings is clean.
  • Not run: the full 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_rest failed 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

  • Tests
    • Expanded coverage for moving photos into folders when sidebar counts update slowly and the “Don’t ask again” preference is enabled.
    • Verified that the destination folder stays in place and remains the drop target while its count updates.
    • Confirmed that a subsequent drop completes immediately, moves the photo, and does not show a confirmation dialog.

…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.
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The test app helper can configure the app before its first frame. The “Don’t ask again” folder-drop test adds a delayed Missing Photos count and checks sidebar row stability and immediate file movement.

Changes: Folder drop test

Layer / File(s) Summary
Prepared app and drop assertions
crates/ui-egui/src/tests/folder_drop.rs
The app helper accepts a preparation callback before the first frame. The test sets a one-second Missing Photos count delay, checks that the target row stays in place, and verifies that the second drop moves the file without a confirmation dialog.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other · Severity of issue fixed: Low

Possibly related issues

  • Issue 4028 describes a Missing Photos row shifting folder rows and causing a later drop to target the wrong folder. This test now checks that the intended row remains the drop target.

Suggested reviewers: nledford

Merge Risk: Minimal · up to c1fa9

This is a test-only change that makes a flaky folder-drop test more deterministic. It does not change product behavior, and no merge-blocking risk is evident.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the test change: the second folder drop waits for the Missing Photos count.
Linked Issues check Passed [#3822] The test now sets a one-second Missing Photos count delay before the first frame. After the first move, it settles the sidebar before reading the home row and verifies that the row remains i…
Out of Scope Changes check Passed The diff changes only crates/ui-egui/src/tests/folder_drop.rs. The preparation helper enables test-specific count timing, and the remaining changes reproduce and verify the #3822 scenario. No unrela…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

[#3822] The test now sets a one-second Missing Photos count delay before the first frame. After the first move, it settles the sidebar before reading the home row and verifies that the row remains in place while the count runs. It checks the drop hint before release and checks the moved file immediately after the drop, with the toast in the failure message. These changes address the stale-target failure and the issue's timing concern. The issue's quarantine condition does not apply to this fix.

Full details: Out of Scope Changes check

Explanation

The diff changes only crates/ui-egui/src/tests/folder_drop.rs. The preparation helper enables test-specific count timing, and the remaining changes reproduce and verify the #3822 scenario. No unrelated product changes are present.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 96c0ca4 and c1fa91c.

Files selected for processing: 1

  • crates/ui-egui/src/tests/folder_drop.rs
Files skipped from review as they are similar to previous changes: 1

  • crates/ui-egui/src/tests/folder_drop.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@THEtheChad

Copy link
Copy Markdown
Contributor Author

The test only failed on the Windows gate, and this PR touches no path in ci-windows.yml, so gate-windows skipped here. Could a maintainer add the full-ci label so it runs on Windows too? I can't add labels myself.

@AlexChambers AlexChambers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

  1. 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.
  2. 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 a full-ci run before merging would confirm it on the hosted runner.

…rop test catches

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@THEtheChad

Copy link
Copy Markdown
Contributor Author

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 home stays put once the sidebar settled (c1fa91c, comment only). For note 2, the full-ci label is still needed for gate-windows to run here; I can't add labels myself.

@THEtheChad

Copy link
Copy Markdown
Contributor Author

I ran it on Windows locally (Windows 11, x86_64, 32 cores, MSVC toolchain). "Load" means four full lightcraft-ui-egui lib suites running alongside at --test-threads=8 each. Each run is folder_drop (12 tests).

Build Change Load Runs Failures
PR head (c1fa91c) none yes 200 0
PR base (f6b57b0) none yes 200 11
PR head settle replaced by h.step() no 20 20
PR head 25 ms count no 40 0
PR head 25 ms count, settle replaced by h.step() no 40 0
  • On Windows, load is enough to reproduce the race on the base. All 11 failures are dont_ask_again_moves_the_next_drop_at_once at "moved without a question", the CI message. The PR head passed 200 of 200 under the same load.
  • Without the settle, the PR's test fails every time on Windows too, at "home stays where the drop aims".
  • The 25 ms variant without the settle passed here. The observation window lasts as long as the count, so with 25 ms it can end before the recount moves the rows. That variant isn't the PR's test.

This doesn't replace a full-ci run on the hosted runner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run the Windows CI leg (ci-windows.yml) on this PR whatever it changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: folder_drop::dont_ask_again_moves_the_next_drop_at_once fails on Windows ("moved at once")

3 participants