Skip to content

test(ui): a listing told to stop makes no question (#2978) - #3004

Merged
jgregoriorincon merged 3 commits into
opengeos:mainfrom
jgregoriorincon:test/2978-listing-cancel-wiring
Nov 26, 2026
Merged

jgregoriorincon merged 3 commits into
opengeos:mainfrom
jgregoriorincon:test/2978-listing-cancel-wiring

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

add_file's line also_stop_when(stopped) (the one that lets Cancel on Add Data's chooser stop its listing, #2827) was pinned by no test: cancel_stops_the_listing_on_its_way and its sibling build the chooser by hand, so deleting the line kept every test green.

The listing moves into two functions add_file calls: list_in_background (the thread) and list_layers (what the thread runs: info.fileLayers under also_stop_when). A new test goes through list_in_background. No behaviour change.

list_in_background takes the function that starts the thread (as work_off_frame_with does), so the test runs the work where it stands: no thread and no waits, which test_hygiene forbids. One hop is not tested: that add_file hands its own stop flag (the one the chooser's Cancel sets) to list_in_background. It goes through a real thread, so it could only be tested with waits.

Testing

  • New test layerchooser::tests::a_listing_told_to_stop_makes_no_question: through list_in_background, on a GeoPackage of two tables, a flag already set lands the listing with no question made; a flag still clear lands it with one. With also_stop_when removed from list_layers it fails with "stopped: no question made".
  • checks.sh 2978: fmt, clippy, nextest (9651 passed), doctests, layers and schema --check all exit 0.

UI evidence

None: no visible change.

Related issue

Closes #2978.

Summary by CodeRabbit

  • Bug Fixes
    • Layer listing now respects cancellation state when checking for linked layers, while still displaying available layers.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The layer chooser now delegates layer discovery to an injectable background-listing helper. A desktop-only test verifies that a set stop flag suppresses the GeoPackage link question while preserving both listed layers, and that an unset flag returns the question. GeoPackage fixture creation is shared by a helper.

Changes: Layer listing and cancellation

Layer / File(s) Summary
Background listing and cancellation test path
crates/ui-egui/src/layerchooser.rs
add_file uses a background-listing helper that accepts an injectable start function. A desktop-only test checks listing results and the link question for set and clear stop flags. A shared helper creates the two-table GeoPackage fixture.

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

Change: Other

Possibly related PRs

Suggested reviewers: pick2510, mavrick-f

Merge Risk: Minimal · up to 70628

This change moves layer listing into a helper and adds a test for stop-flag cancellation, with no intended behavior change. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names a test added for the cancellation wiring of a listing. The changeset adds the test a_listing_told_to_stop_makes_no_question and moves the listing into list_in_background and `list_…
Description check Passed The description follows the repository template. The Summary section explains the refactor into list_in_background and list_layers and the new test. The Testing section names the new test, the fai…
Linked Issues check Passed Issue #2978 asks for three things: (1) move the listing into a function that add_file calls, (2) a test that gives that function an already-set flag on a two-table GeoPackage and checks that no ques…
Out of Scope Changes check Passed All changes sit in crates/ui-egui/src/layerchooser.rs. They are the extraction of list_in_background and list_layers, the injectable start function, the two_table_gpkg test helper, and the n…
Full details: Title check

Explanation

The title names a test added for the cancellation wiring of a listing. The changeset adds the test a_listing_told_to_stop_makes_no_question and moves the listing into list_in_background and list_layers. The title is specific to the main change. The conventional type prefix test(ui): matches the test-only intent, and the issue number matches the linked issue. The title is 58 characters, which fits the concise style.

Full details: Description check

Explanation

The description follows the repository template. The Summary section explains the refactor into list_in_background and list_layers and the new test. The Testing section names the new test, the failing-without-fix check, and the checks.sh 2978 results. The UI evidence section states 'None: no visible change', which the template allows when there is no visible UI change. The Related issue section says 'Closes #2978.' The description also notes one untested hop, which gives reviewers useful context.

Full details: Linked Issues check

Explanation

Issue #2978 asks for three things: (1) move the listing into a function that add_file calls, (2) a test that gives that function an already-set flag on a two-table GeoPackage and checks that no question is made, and (3) no behaviour change. At head, add_file calls list_in_background(path, stop.clone(), start), which runs list_layers on the thread. list_layers wraps info.fileLayers (with "link": true) in also_stop_when(stop). The start parameter lets a test run the work directly, so no thread or waits are needed. The PR summary and the AI-generated summary both describe the test layerchooser::tests::a_listing_told_to_stop_makes_no_question. It covers a set flag (no question) and a clear flag (one question) on a two-table GeoPackage. The PR reports that removing also_stop_when makes it fail. Limit: the file read was truncated at 16000 bytes, so the test body was not read directly. The test's existence and assertions rest on the PR description and summary. The unread hop (add_file passing its own stop to list_in_background) is not tested, as the PR states. The issue does not require that hop to be tested.

Full details: Out of Scope Changes check

Explanation

All changes sit in crates/ui-egui/src/layerchooser.rs. They are the extraction of list_in_background and list_layers, the injectable start function, the two_table_gpkg test helper, and the new test. Each change serves issue #2978. The PR states that no behaviour change is intended, and the head code keeps the same cancellation flag path. No unrelated change is evident in the reviewed evidence. The test body was not read in full because of truncation, so this verdict covers the code shown and the PR's description of the test.

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

A rabbit checks the layers in a row,
Two GeoPackage tables come and go.
A set flag quiets the question’s sound,
An unset flag lets it come around.
The chooser lists, then hops away.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c9ddd609-40e1-44fd-8739-fb2f7d36706b
Commits

Reviewing files that changed from the base of the PR and between 21853a7 and 70628b0.

Files selected for processing: 1

  • crates/ui-egui/src/layerchooser.rs

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

@github-actions

Copy link
Copy Markdown
Contributor

Code review

PR #3004 moves the Add Data listing in add_file into list_in_background and list_layers so a new test can drive the stop flag without a real thread. I found no bugs, security issues, performance problems, or AGENTS.md breaks. I did not post any inline comments. I can't compile or run tests here (no shell), so everything below is checked by reading the code.

Bugs: None found.

  • The refactor is behaviour-preserving. The also_stop_when guard is still installed inside the thread closure, before Session::new, as before. Session::run on this path installs no probe that would replace it, so the stop flag reaches progress::check() in link_choice.
  • With the flag already set on a two-table GeoPackage, the first check() fails, link_choice returns None, and no link key is written. That matches the new test's assertion. With the flag clear, the result is {"linked": false, "copy": true}, also matching. Confidence: high.
  • named_thread captures an owned String, so the lifetime change from work_off_frame is harmless. Confidence: high.

Security: None found. No new input handling or external data.

Performance: None found. The change adds no copies or work.

Quality: Nothing worth an inline comment. list_in_background is a thin wrapper, but it exists to give the test a place to inject the spawner and a path to the slot, so I'd keep it. The list_layers doc says the listing "still runs to the end" on stop. That is accurate, since listed_layers does not check the stop flag. Confidence: high.

AGENTS.md: No breaks found.

  • Wasm: list_in_background, list_layers and named_thread are ungated, and they use only the ungated progress module, Session and std::thread::Builder. The old work_off_frame already used the same calls unconditionally, so the browser build should be unaffected.
  • The new test is gated on not(wasm32) and its assert_eq! sides differ. It uses tempfile and two_table_gpkg, which the existing tests in this module use too.
  • The PR body says it adds no new command or parameter, so command-surface.txt is not affected.
  • Test-only .unwrap() calls follow the existing module style.

Twins checked:

  • crates/ui-egui/src/repairsource.rs:97 also runs info.fileLayers off the frame, but without "link": true and without a stop flag. No question is asked there, so it has no cancel-question twin to change.
  • link_choice's checks and the link tests in crates/engine/tests/integration/link_choice.rs already cover the question logic. This PR does not change them.
  • crates/ui-egui/src/layerchooser.rs:525 calls info.fileLayers with link: true synchronously in a test. It is unaffected.
  • The other work_off_frame callers keep the same spawn behaviour, since work_off_frame now delegates to named_thread.

Prior review threads: none exist on this PR, so there were no earlier concerns to leave alone.

Limits: The one hop the PR says is untested is add_file handing its own stop flag to list_in_background. Reading the code, that hop is correct, since Chooser.stop is the same Arc clone.

Change size

Compared with the base branch (merge base 36b8e7c to PR head 21853a7).

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 593.7 KB
Size after 596.5 KB
Total size change +2.8 KB
Path Before After Change
crates/ui-egui/src/lib.rs 560.4 KB 560.6 KB +226 B
crates/ui-egui/src/layerchooser.rs 33.3 KB 35.9 KB +2.6 KB

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3004/
Web app https://preview.rustgis.app/pr-3004/app/
Commit 70628b0

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the diff, the base-branch AGENTS.md, and the surrounding code in layerchooser.rs, ui-egui/src/lib.rs (work_off_frame), data/src/progress.rs (also_stop_when, Installed), and engine/src/cmd/layer.rs (file_layers, link_choice). I could not compile or run the tests here (no shell), so the author's test results are unverified by me.

Bugs: None found.

  • The refactor preserves behaviour. list_layers holds the also_stop_when guard in a named binding (_stop), so it lives until the listing returns, as before.
  • Box<dyn FnOnce() + Send> captures only String, Arc<AtomicBool> and Slot, so it is Send + 'static and fits work_off_frame.
  • A refused spawn still fills the slot with an error, as work_off_frame_with does.
  • The new test is two-sided. The stopped case expects layers without link, and link_choice returns None at progress::check(). The free case expects link to be present, so the test can't pass just because link_choice always returns None.

Security: None found.

Performance: None found. The change adds one Arc clone and one Box.

Quality: None worth an inline comment. The only observations are optional:

  • add_file's line 110 is long but under the 140-column limit in rustfmt.toml.
  • The start closure parameter exists only as a test seam. Its doc comment says so.

AGENTS.md: No breaks found.

  • Long-running work stays on work_off_frame, and the new test does no timer waits.
  • The test uses fixed expected values, and assert_eq! sides differ.
  • The test is gated #[cfg(not(target_arch = "wasm32"))].
  • The wasm build is unaffected. list_in_background and list_layers are not desktop-only, and add_file already used the same calls.

Twins checked:

  • Other listing callers (dialogs.rs:2503, repairsource.rs:99, layerchooser.rs:445) call info.fileLayers without a stop flag. The diff doesn't change them and they aren't part of the Add Data question, so I did not raise them.
  • Browser path: on wasm, lists_layers and links return false, so add_file never reaches the listing. There is no browser twin to update.
  • Add-data read routes: the diff changes no read route.

Limits of this review: The PR body says the add_file → list_in_background hop with the Chooser's own stop flag is untested. I agree this is a gap, but a test of it would need waits, so I'm not asking for one.

Prior reviews: prior-reviews.json has no threads, so no earlier concerns were left alone.

Change size

Compared with main (merge base 36b8e7c to PR head 70628b0).

Measure Value
Files changed 1 (modified 1, added 0, removed 0, renamed 0)
Size before 33.3 KB
Size after 35.9 KB
Total size change +2.7 KB
Path Before After Change
crates/ui-egui/src/layerchooser.rs 33.3 KB 35.9 KB +2.7 KB

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 26, 2026
Merged via the queue into opengeos:main with commit 519c390 Nov 26, 2026
30 checks passed
@jgregoriorincon
jgregoriorincon deleted the test/2978-listing-cancel-wiring branch November 26, 2026 09:24
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.

[Feature]: A test that Cancel on Add Data's listing reaches the thread that lists

1 participant