Skip to content

refactor(engine): Add Data's list of formats that ask copy-or-link lives in asks_link (#2976) - #2983

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:feat/2976-asks-link
Nov 25, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:feat/2976-asks-link

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add Data's list of formats that ask copy-or-link now lives in one place. The engine exposes asks_link(path) next to link_choice; link_choice returns None when it says no and decides the rest by it, and the dialog's links() calls it (on the trimmed path, as before) instead of keeping its own list of extensions. A format added to data::source::EXTENSIONS is asked about with no edit in the dialog.

No behaviour change for what the dialog asks about today: .geojson, .shp, .gpkg, .parquet, .geoparquet, .fgb. asks_link keeps the dialog's suffix rule, so the only engine-side difference is for paths no dialog sends: link_choice("data.parquet/") now answers nothing instead of a question.

Surfaces: the desktop Add Data question is unchanged; the browser never asks (links() stays false on wasm32); the command line and Python never ask ("link": true is only sent by the dialog). No command, parameter, saved data or undo step changes, so the command snapshot, the schema and the undo rules don't apply.

Testing

  • New tests: asks_link_names_the_formats_read_in_place (the six extensions ask, in upper case; .json, .las, .laz, .csv, .kml, .tif, no extension, an empty path, a trailing separator and a path with spaces don't), asks_link_follows_the_source_extensions (every non-LiDAR source extension asks), link_choice_asks_where_asks_link_does in crates/engine/src/cmd/layer.rs; the_dialog_asks_by_the_engines_list_of_formats in layerchooser.rs (a typed path with spaces and capitals still asks).
  • checks.sh on rustgis-engine and rustgis-ui-egui: fmt, clippy, nextest, doctests, layers and schema --check.

UI evidence

No visible UI change.

Related issue

Closes #2976.

Summary by CodeRabbit

  • New Features
    • On desktop, link choices are now available for GeoJSON, Shapefile, and other supported source-file formats. File extensions are recognized regardless of letter case, and paths with surrounding whitespace are handled correctly.
  • Bug Fixes
    • LAS and LAZ files remain excluded from link choices, and paths without a recognized extension do not qualify.

…ves in asks_link (opengeos#2976)

link_choice and the dialog's links() both decide by asks_link, so a format added to the sources is asked about and answered with no second edit. asks_link keeps the dialog's suffix rule on the path as given (the dialog trims what was typed); no behaviour change for what the dialog asks about.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The engine now exposes a shared check for whether a path can offer a link choice. The engine’s choice logic and the desktop layer chooser use this check. The layer chooser continues to return false on WebAssembly.

Changes: Add Data link eligibility

Layer / File(s) Summary
Engine eligibility and link choice
crates/engine/src/cmd/layer.rs
The engine adds asks_link and uses it to gate link_choice and its source-table scan. Tests cover recognized and rejected paths, extension case handling, and agreement with link_choice.
Layer chooser integration
crates/ui-egui/src/layerchooser.rs
On desktop, links delegates eligibility to the engine using the trimmed path. On WebAssembly, it returns false. A test covers trimmed, mixed-case paths and excluded extensions.

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

Change: Refactor

Possibly related PRs

  • opengeos/RustGIS#2808: This PR introduces the Add Data copy-or-link prompt that this change centralizes across the engine and layer chooser.

Suggested reviewers: mavrick-f, pick2510

Merge Risk: Minimal · up to eaa2c

This refactor gives Add Data's copy-or-link question a single source of truth in the engine, with no intended change to the dialog's behavior. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the Add Data copy-or-link format list moves into the engine's asks_link(path) helper, which the dialog then uses. It fits the changeset and the linked objectives, thou…
Description check Passed The description follows the template. It includes Summary, Testing, UI evidence ('No visible UI change.'), and Related issue ('Closes #2976.') sections, and each is filled in with specific detail. The…
Linked Issues check Passed Issue #2976 has one coding requirement: one source of truth for the formats that prompt in Add Data. The PR meets it. The AI-generated summary of crates/engine/src/cmd/layer.rs adds desktop-only `pub …
Out of Scope Changes check Passed All changes described in the summaries serve #2976. They are the new asks_link engine function, the link_choice change that uses it, the dialog's links() delegation, and tests for these. No comm…
Full details: Title check

Explanation

The title names the main change: the Add Data copy-or-link format list moves into the engine's asks_link(path) helper, which the dialog then uses. It fits the changeset and the linked objectives, though the title is long at 93 characters and includes the issue number.

Full details: Description check

Explanation

The description follows the template. It includes Summary, Testing, UI evidence ('No visible UI change.'), and Related issue ('Closes #2976.') sections, and each is filled in with specific detail. The Testing section lists new tests and the checks run. The template's placeholder comments were removed, which is acceptable.

Full details: Linked Issues check

Explanation

Issue #2976 has one coding requirement: one source of truth for the formats that prompt in Add Data. The PR meets it. The AI-generated summary of crates/engine/src/cmd/layer.rs adds desktop-only pub fn asks_link(path: &str) -> bool. It states that link_choice uses this helper and returns None when it says no. The summary of crates/ui-egui/src/layerchooser.rs states that links delegates desktop eligibility to rustgis_engine::cmd::layer::asks_link on a trimmed path, and that the local extension allowlist is removed. The reviewed head shows EXTENSIONS in crates/data/src/source/mod.rs as gpkg, parquet, geoparquet, fgb, las, laz. The dialog's six formats are therefore the four source extensions (non-LiDAR) plus .geojson and .shp, which asks_link adds. This matches the stated 'no behaviour change' for the dialog. New tests cover the listed extensions, the source-extension rule, link_choice consistency, and the dialog. Limitation: the text diff for the changed files was unavailable, so the function bodies were not read directly. The verdict rests on the supplied summary and the reviewed-head EXTENSIONS constant. The one deliberate engine-side change, link_choice("data.parquet/") returning None, is disclosed and does not affect the dialog.

Full details: Out of Scope Changes check

Explanation

All changes described in the summaries serve #2976. They are the new asks_link engine function, the link_choice change that uses it, the dialog's links() delegation, and tests for these. No command, parameter, saved data, or schema change is described, which the PR description also states. The text diff was unavailable, so this verdict rests on the supplied summaries and the reviewed-head EXTENSIONS constant, not on a line-level read of the changes.

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 each path in sight,
The engine says if links are right.
The chooser asks one shared routine,
With trimmed paths and cases seen.
On WebAssembly, it answers no,
Then hops along through fields of snow.

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: 5006dfcb-4d7a-4c72-a77c-75e0a35c3b27
Commits

Reviewing files that changed from the base of the PR and between 54d7854 and eaa2c43.

Files selected for processing: 2

  • crates/engine/src/cmd/layer.rs
  • 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; 6 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Scope: 2 files, a refactor that moves Add Data's copy-or-link format list into asks_link in the engine. I checked it against rustgis_data::source::EXTENSIONS (gpkg, parquet, geoparquet, fgb, las, laz). The dialog's old list (geojson, shp, gpkg, parquet, geoparquet, fgb) matches what asks_link now returns, so the stated "no behaviour change for the dialog" holds. The wasm gating is correct, and rustgis_engine is a dependency of ui-egui.

Bugs

  • Untrimmed path reaches the question (crates/ui-egui/src/layerchooser.rs:112), medium confidence. The dialog's links() trims the path, but the listing sent to info.fileLayers uses the raw path. For roads.gpkg (trailing space), the chooser opens but no copy-or-link question is asked. This predates the PR, and the PR text says the dialog trims before it asks, which is not true for this call. The new test covers only links(). An inline suggestion is posted.

Security

  • None found.

Performance

  • None found. asks_link does a single lowercase and a constant-sized suffix scan.

Quality

  • Nothing blocking. Checked and fine: the ends closure requires a . before the extension, so .gpkg (a dotfile name) now asks where Path::extension didn't. link_choice then fails open_path and returns None, so the user sees no change. The PR's claim that only data.parquet/ changes engine-side is therefore slightly incomplete, but no visible behaviour changes.

AGENTS.md

  • No rule breaks found. No commands, parameters, saved data or undo steps change. Command-surface, schema and memory checks don't apply. The wasm, layering and tl! rules are respected.

Prior reviews

  • None on this PR, so no earlier concerns were left alone.

Change size

Compared with the base branch (merge base 7331389 to PR head eaa2c43).

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 470.5 KB
Size after 473.5 KB
Total size change +3.0 KB
Path Before After Change
crates/engine/src/cmd/layer.rs 437.7 KB 440.2 KB +2.6 KB
crates/ui-egui/src/layerchooser.rs 32.8 KB 33.3 KB +452 B

The stats are not truncated.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2983/
Web app https://preview.rustgis.app/pr-2983/app/
Commit eaa2c43

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).

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 25, 2026
Merged via the queue into opengeos:main with commit 70a7520 Nov 25, 2026
28 checks passed
@jgregoriorincon
jgregoriorincon deleted the feat/2976-asks-link branch November 25, 2026 23:56
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]: Add Data's list of formats that ask copy-or-link lives in one place

1 participant