You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(ui): search boundary countries and show available levels - #3233
The Boundaries country list now filters by name or ISO code. Levels use neutral division labels and, when geoBoundaries' catalogue is available, show unit counts and disable missing levels with a reason. Failed availability requests leave levels offered with an explanation, and typed ISO codes retain their normalization. Country and level metadata requests are each capped at 4 MiB.
This reaches the shared desktop/browser Web Data pane. The phone does not offer this pane. Ribbon and command search still open the same pane; CLI, Python, Assistant, MCP and plugins keep the unchanged boundaries.add command. Added layers retain existing Undo/removal behavior. No dependency, project format or layer storage changes.
Testing
Focused metadata parsing and portal tests pass (4 tests). The picker regression fails at the intended assertion with ISO normalization removed. The portal group takes 0.26 s locally; the parser case is below 0.01 s. The failed-catalogue real-frame case also passes (0.26 s), and fails when its displayed explanation is removed.
Fork CI passed on 2203c6a, including lint, workspace tests, wasm build/smoke, schema, GDAL/DuckDB and licences.
UI evidence
Before
After
Country filtering:
Catalogue failure, captured from the actual pane with a simulated service error. Availability stays unknown and the level remains offered:
The boundaries picker now lets you search countries by name or ISO code.
Availability information loads for each administrative level. Once it arrives, level choices show unit counts, and unavailable levels are disabled with an explanation. If availability can’t be checked, level choices remain selectable and availability is reported as unknown.
Documentation
Updated the boundaries guide to describe country search and level availability, and clarified the description of first-level divisions.
No actionable comments were generated in the recent review.
Walkthrough
The Boundaries dialog filters countries by name or ISO code and loads geoBoundaries catalogues for ADM1–ADM5. It shows known unit counts, disables levels absent for the selected country, and leaves availability unknown when catalogue requests fail. New tests cover catalogue parsing and dialog behavior.
Changes: Boundaries country and level selection
Layer / File(s)
Summary
Catalogue URL and availability parsing crates/tiles/src/boundaries.rs
Adds a validated level URL builder and a parser for country codes and optional unit counts. Tests cover URL validation, parsing, and invalid entries.
Catalogue loading and availability state crates/ui-egui/src/portalsui.rs
Tracks pending catalogue requests and parsed availability. The dialog requests ADM1–ADM5 catalogues, and polling stores valid results while leaving failed or invalid results unknown.
Country search and level choices crates/ui-egui/src/portalsui.rs, docs/user-guide/web-data.md
Filters country names and codes. Displays known unit counts, disables unavailable levels, and disables Add when the selected level is unavailable. Tests and documentation cover the updated behavior.
sequenceDiagram
participant User
participant BoundariesDialog
participant GeoBoundariesCatalogue
participant StatePoll
participant ParseAvailability
BoundariesDialog->>GeoBoundariesCatalogue: Request ADM1–ADM5 catalogues
GeoBoundariesCatalogue-->>StatePoll: Return catalogue responses
StatePoll->>ParseAvailability: Parse successful responses
ParseAvailability-->>StatePoll: Return country counts or an error
StatePoll-->>BoundariesDialog: Update catalogue availability
User->>BoundariesDialog: Search and select a country
BoundariesDialog-->>User: Show counts and unavailable levels
Loading
Suggested reviewers:giswqs
Merge Risk: Minimal · up to 2203c
The Boundaries dialog gains country search and per-level availability hints, and failed availability lookups leave all levels selectable as before. No merge-blocking risk is evident, and the change is easy to revert.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "feat(ui): search boundary countries and show available levels" matches the main change. The PR adds a country filter by name or ISO code in the Boundaries picker. It also shows per-level un…
Linked Issues check
Issue #2947 has four coding requirements. The whole-PR diff (merge base to reviewed head) shows each one implemented at head 2203c6a.
1. Searchable country list by name or ISO code, with the same scr…
Out of Scope Changes check
All changes in the whole-PR diff support the objectives of #2947 or are tests and documentation for them.
- crates/ui-egui/src/portalsui.rs: the picker filter, level labels, availability state, pol…
Description check
The description covers the Summary, Testing, and Related issue sections well. It explains the country filtering, neutral level labels, catalogue-driven unit counts and disabled levels, the 4 MiB cap, …
Full details: Title check
Explanation
The title "feat(ui): search boundary countries and show available levels" matches the main change. The PR adds a country filter by name or ISO code in the Boundaries picker. It also shows per-level unit counts and disables unavailable levels when geoBoundaries catalogue data exists. The title is concise and specific, and it follows conventional commit style.
Full details: Linked Issues check
Explanation
Issue #2947 has four coding requirements. The whole-PR diff (merge base to reviewed head) shows each one implemented at head 2203c6a.
Searchable country list by name or ISO code, with the same screen-reader label [#2947]: portalsui.rs adds country_filter and a search TextEdit inside the gb_country combo box. The filter matches name iso case-insensitively. The search field and the combo box both call .labelled_by(input_label.id). The test boundary_picker_filters_and_keeps_typed_codes_available types "pol" and checks that Peru is hidden and Poland is shown.
Levels a country lacks are greyed out with a reason [#2947]: level_info reads the per-level catalogue. ui.add_enabled disables unavailable levels, and missing_level gives the hover text "geoBoundaries has no {level} for {country}". The Add button is also disabled for an unavailable level.
Unit counts when available [#2947]: boundaries::parse_availability in crates/tiles/src/boundaries.rs reads admUnitCount. The level label shows "{level} — {count} units" (or "unit" for one).
Background catalogue loading, with levels kept offered until data arrives or after failure [#2947]: the five ALL/ADMn requests start with the country list. poll stores a successful parse only for its own level. A failure leaves that level None, so level_info returns available. The test availability_lands_independently_of_boundary_downloads covers this.
Neutral hints replace the fixed division names. The boundaryCanonical field is not used as a level name. boundaries.add is unchanged. Typed ISO codes are normalized through boundaries::country.
Limits: the incremental diff from previous reviewed head 1b4fc76 to 2203c6a could not be read because changed blobs were missing. This assessment uses the whole-PR diff at head, which covers the incremental changes. The diff output for portalsui.rs was truncated after the test section, so the last test body was not fully read. Test execution was not verified; the Fork CI result was not used as evidence.
Full details: Out of Scope Changes check
Explanation
All changes in the whole-PR diff support the objectives of #2947 or are tests and documentation for them.
crates/ui-egui/src/portalsui.rs: the picker filter, level labels, availability state, poll handling, close_behavior, and the disabled Add behaviour implement the issue requirements. The "Downloading…" hover text supports the availability gate.
crates/tiles/src/boundaries.rs: level_url, catalogue_url, and parse_availability implement the ALL/ADMn catalogue parsing that the issue names as the source for availability and counts. countries_url now uses the shared builder with the same URL.
docs/user-guide/web-data.md: documents the filter, counts, disabled levels, and neutral wording. This matches the changed behaviour.
Test additions cover the picker, availability, and parser logic.
No change alters the boundaries.add command, dependencies, project format, or layer storage, as the PR description states. The phone pane is not changed. The incremental diff since the previous review was unreadable, so the check relies on the whole-PR diff at head. No unrelated change was found in the portions read.
Full details: Description check
Explanation
The description covers the Summary, Testing, and Related issue sections well. It explains the country filtering, neutral level labels, catalogue-driven unit counts and disabled levels, the 4 MiB cap, and the scope limits (phone excluded, CLI and other entry points unchanged). Testing lists focused tests, a regression check, and Fork CI results. The UI evidence section has before/after screenshots, a country-filter screenshot, and a failure-state screenshot. It closes issue #2947. Two items are missing or unclear: the template asks for a 'Closes' or 'Part of' line, which is present, and the UI evidence section is present. The Fork CI run ID and commit hash differ from those in the PR objectives (1b4fc76 with run 46155389602 versus 2203c6a with run 46169218603). The author should confirm which run and commit the description refers to.
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.
A rabbit checks the country list, And finds a name without a twist. The levels show their counts with care, Missing ones are marked right there. If catalogues fail to arrive, Unknown stays unknown, choices survive. Then off the rabbit hops, content.
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: 0e288d01-46d0-473f-a8a4-449ac49397de
Commits
Reviewing files that changed from the base of the PR and between 1b4fc76 and 2203c6a.
Files selected for processing: 3
crates/tiles/src/boundaries.rs
crates/ui-egui/src/portalsui.rs
docs/user-guide/web-data.md
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
When a level's catalogue fails to download or to parse, the error is discarded here (result.ok().and_then(... .ok())). The level then falls back to "offered" with no notice, so the user cannot tell that the unit counts and disabled levels are unknown. The docs describe this fallback, and it is a reasonable one, but AGENTS.md "Never silent" asks that an approximation say what happened. Suggest keeping a per-level note (for example, a small line under the Level picker such as "Unit counts for ADM2 couldn't be read: all levels stay offered", with the parse error text) and showing it only while the current level's catalogue is in the failed state. A test for the failed-catalogue case would then assert the note.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 2203c6a: download and parse errors are retained per level. The selected failed level shows the reason and explains that it remains offered without unit counts. The real-frame regression covers network failure, malformed data, and an unaffected level; removing the displayed note makes it fail. The fork gate passed on this commit.
The reason will be displayed to describe this comment to others. Learn more.
parse_availability fails the whole catalogue on one malformed row (collect() into Result). parse_countries in the same file skips bad rows with filter_map. The two readers handle the same kind of list differently. One bad entry here removes every count and every disabled level for that level, silently (see the note on portalsui.rs). Please pick one policy. If rows are skipped, report how many, following the notice rule. If the whole list is rejected, say so in the doc comment, which already says "Reject malformed entries", and leave the rest as it is.
The reason will be displayed to describe this comment to others. Learn more.
Kept whole-catalogue rejection and documented the reason in 2203c6a: skipping a malformed country row could incorrectly disable that country's level. A failed catalogue now shows the selected-level explanation while keeping choices offered.
The reason will be displayed to describe this comment to others. Learn more.
Minor nits, grouped:
The filter lowercases each country's name and code on every frame while the popup is open. Lowercasing the country list once when it arrives (or caching the lowercase needle) avoids about 500 allocations per frame.
Line 80 indexes availability[*level]. The levels are constants 1 to 5 here, so it can't panic today, but get_mut would match the get() style AGENTS.md asks for.
level_url in boundaries.rs repeats the countries_url pattern. A shared helper would make the two catalogue addresses easy to see together.
These are quality points and can wait for the release quality pass.
The reason will be displayed to describe this comment to others. Learn more.
Included all three in 2203c6a: country search text is cached when the list arrives, level results land through get_mut, and country/level catalogue URLs share one helper.
Reviewed the full diff (3 files) against pr-context/AGENTS.md. No prior review threads exist, so no earlier concerns were left alone. I posted 5 inline comments.
Bugs
Absence treated as "no such level" (portalsui.rs:107). A country missing from ALL/ADMn disables that level and Add. This is only correct if the endpoint lists every country. I could not check the live API, so the concern is unverified. Confidence: low.
Security
None found. The new parser bounds its keys to three ASCII letters, reads no URLs from the catalogue, and uses no unwrap or indexing on hostile input. The only indexing is availability[*level] with internal constants 1 to 5.
Performance
Five eager downloads on first dialog open (portalsui.rs:129). Each uses the 512 MB MAX_DOWNLOAD cap, so a misbehaving server could buffer up to about 2.5 GB. A catalogue-sized cap or on-demand fetching would fix it. Confidence: medium.
Quality
Strict versus lenient parsing (boundaries.rs:54). parse_availability rejects a whole catalogue on one bad row, while parse_countries skips bad rows. Confidence: medium.
Nits, grouped (portalsui.rs:264). These are per-frame lowercasing in the filter, get_mut in place of indexing, and a possible shared helper for level_url. They can wait for the release quality pass. Confidence: high.
AGENTS.md
Silent fallback on a failed catalogue (portalsui.rs:80). Download and parse errors are discarded with .ok(), so levels are offered with no notice. The docs describe the fallback, but "Never silent" asks that an approximation say what happened. Confidence: medium.
What I checked
Twins: the CLI, Assistant and MCP boundaries.add path is unchanged, as the PR says. It has no availability check, so an unavailable level there fails through the existing fetch error. No overlay, layer.add* or project.open* paths are touched.
Wasm:portalsui.rs is shared with the browser. The only new std::time use is a Duration type, which is fine. No cfg branches were added or changed.
Tests: the new tests use no timer waits and no identical assert_eq! sides. They cover the malformed-catalogue and failed-catalogue cases, and both picker behaviours.
Docs:web-data.md matches the new behaviour.
Change size
Compared with the base branch (merge base 5cdcf5b to PR head 1b4fc76).
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).
The geoBoundaries API contract defines ALL as listing available boundaries across countries. Absence is authoritative only after a catalogue parses successfully; failed or malformed catalogues leave choices offered and show the selected-level explanation.
2203c6a also caps each country/level catalogue at 4 MiB. The six initial metadata requests therefore have a combined 24 MiB payload allowance. Boundary feature downloads retain their existing limit.
The reason will be displayed to describe this comment to others. Learn more.
The picker test sets countries directly, so country_search (the cache that poll fills when the list arrives, line 138) stays empty. Only the fallback format!(...).to_lowercase() path is exercised. The cached path, including its filter(|(original, _)| original == name) guard, that real sessions take on every frame has no test. Suggest one setter that both poll and tests call, so the cache is always built with the list, and an assertion on a match through the cached path (e.g. filtering "per" finds Peru through the cache).
Confidence: high that the cached path is untested; the risk is a regression that the current tests would not catch.
The reason will be displayed to describe this comment to others. Learn more.
Cached-path coverage is a useful addition. The current fallback also supports callers that supply or change the public country list directly. I’m leaving the additional cache-path test for the release quality pass.
The reason will be displayed to describe this comment to others. Learn more.
admUnitCount values that aren't a non-negative integer (a float like 26.0, a negative number, a non-numeric string) become None, so the level shows its plain label with no count and no note. The unit count is optional, so this is not a crash or a wrong answer, but it is a field dropped without a word, which the "Never silent" rule asks to be said. Either accept the float form (n.as_f64() with a whole-number check) or leave it as is and say in the doc comment that a count that isn't a whole number is treated as absent. The test at line 137 covers the string and missing forms but not a malformed count.
Confidence: medium (depends on whether geoBoundaries ever sends non-integer counts).
The reason will be displayed to describe this comment to others. Learn more.
The count is optional display metadata: unsupported count forms leave the level offered without a count, while downloaded features and level availability are unchanged. I’m leaving the explicit documentation and malformed-count case for the release quality pass.
The reason will be displayed to describe this comment to others. Learn more.
Minor nits, grouped:
The loop at line 260 uses if let Ok(url) = boundaries::level_url(...). level_url can't fail for 1..=5, so the Err arm is dead. Building the URL from catalogue_url through a loop over ["ADM1", …, "ADM5"] or stating the expectation with expect isn't allowed here, so the simplest is a filter_map with a comment, or just boundaries::level_url(&level.to_string()) mapped with a clear reason.
The same disabled reason is shown twice for the selected level: the ui.small(missing_level(...)) note here and the Add button's disabled hover text at line 363. One is enough.
These are quality points and can wait for the release quality pass.
The reason will be displayed to describe this comment to others. Learn more.
Keeping the inline reason makes it available without hovering a disabled control, including to keyboard and screen-reader users; the hover also explains the button state in context. The guarded call to the shared fallible URL helper handles the fixed range without a panic. I’ll retain both choices.
Verdict: I found no bugs, crash paths, silent data loss or security problems. Three quality points are posted inline. I reviewed by reading the diff and the surrounding code (cache.rs, lib.rs, i18n/mod.rs, the engine's portals.rs). I did not build or run the tests.
Bugs
None found. I checked the poll ordering (the level answers are handled before the early return on waiting), the level_info and Add gating for an invalid or unknown country, the get/get_mut indexing, and the ui.close() and ComboBox behaviour. Confidence: high.
Security
None found. Catalogue URLs are built only from validated levels or the fixed ADM0 level. The fetch goes through the existing fetch_within with Reach::Local and a 4 MiB cap. Confidence: high.
Performance
Low: first open of the pane starts six requests to the geoBoundaries API (the countries list plus five catalogues), each capped at 4 MiB. Per-frame lowercasing is now cached when the list arrives, so the earlier per-frame allocation concern is mostly gone. The fallback path still allocates per frame, but it only runs when the cache is empty, which doesn't happen in real sessions. Confidence: medium.
Quality
Inline:portalsui.rs:410. The picker test sets countries directly, so the country_search cache is never exercised. Only the fallback matching path is tested. Confidence: high.
Inline:boundaries.rs:62. A non-integer or negative admUnitCount is dropped to None with no notice. It's a minor loss of an optional field rather than a wrong result. Confidence: medium.
Inline:portalsui.rs:359. Nits. The if let Ok around level_url for 1..=5 is a dead branch, and the disabled reason is shown twice for the selected level.
Informational, not posted: the PR changes two English source strings (the ADM0 description and the ADM1 label). That leaves the existing translations in about 20 .tsv catalogues stale, so those locales show English until the maintainer translates before a release. The AGENTS rules allow this.
Informational: a failed catalogue is never retried until restart, the same as the countries list. The note says the level stays offered but doesn't say how to recover.
AGENTS.md
None found. User-visible literals use tl! or i18n::fmt. There are no unwrap, expect or panic calls in non-test code. No command was added or changed, so the command surface and schema are unaffected. The docs were updated. The phone and the Assistant/MCP surfaces are correctly left out, as the PR says.
Earlier review threads
Three threads from the github-actions reviewer are on this PR, all outdated. I left them alone because the code addresses them:
A discarded catalogue error. The error is now stored and shown for the selected level.
The parse policy mismatch. The doc comment now states the whole-catalogue rejection and why.
The nits. The per-frame lowercase is cached, get_mut is used, and catalogue_url is shared.
Change size
Compared with the base branch (merge base 5cdcf5b to PR head 2203c6a).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Boundaries country list now filters by name or ISO code. Levels use neutral division labels and, when geoBoundaries' catalogue is available, show unit counts and disable missing levels with a reason. Failed availability requests leave levels offered with an explanation, and typed ISO codes retain their normalization. Country and level metadata requests are each capped at 4 MiB.
This reaches the shared desktop/browser Web Data pane. The phone does not offer this pane. Ribbon and command search still open the same pane; CLI, Python, Assistant, MCP and plugins keep the unchanged boundaries.add command. Added layers retain existing Undo/removal behavior. No dependency, project format or layer storage changes.
Testing
Focused metadata parsing and portal tests pass (4 tests). The picker regression fails at the intended assertion with ISO normalization removed. The portal group takes 0.26 s locally; the parser case is below 0.01 s. The failed-catalogue real-frame case also passes (0.26 s), and fails when its displayed explanation is removed.
Fork CI passed on 2203c6a, including lint, workspace tests, wasm build/smoke, schema, GDAL/DuckDB and licences.
UI evidence
Country filtering:
Catalogue failure, captured from the actual pane with a simulated service error. Availability stays unknown and the level remains offered:
Related issue
Closes #2947
Summary by CodeRabbit