Skip to content

fix(engine): project.openText and project.fromTemplate steps require layout-legend-counts and layout-legend-subtitle - #3611

Closed
jgregoriorincon wants to merge 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3598-open-text-legend-counts-subtitle
Closed

jgregoriorincon wants to merge 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3598-open-text-legend-counts-subtitle

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

command_uses_legend_counts and command_uses_legend_subtitle had no project.openText arm, unlike command_uses_legend_one_row and command_uses_legend_patch_size, and no project.fromTemplate arm either. A step that opened a project text holding a legend with show_counts or a subtitle required neither layout-legend-counts nor layout-legend-subtitle, so an older release opened it and dropped those fields without refusing.

Both checks now read the opened text the way the one-row and patch-size checks do: a text reader that parses only when the text names the key (or may hide it, or holds a step's data), then asks the project what it requires. project.fromTemplate with inline text gets the same arm, since it opens the same text.

Testing

  • New a_saved_step_that_counts_or_subtitles_a_legend_is_found_in_text_a_project_opens; layout-legend-counts and layout-legend-subtitle added to the_checks_of_an_inline_project_read_nothing_it_names (open text, no header, nested step, template, script; no raster read). Both fail without the fix, on showCounts.
  • checks.sh: fmt, clippy, doctests, layers and schema pass. Nextest: 8 failures, in rustgis-geolibre (runner not installed) and ui-egui line_strokes_editor_edits_one_class; all 8 fail the same way on main.

UI evidence

No visible UI change.

Related issue

Closes #3598.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected legend count and subtitle capability checks for projects opened from inline text or templates. Checks now recognize supported settings in alternate naming styles, escaped text, and base64-encoded project data.
    • These checks also work alongside other inline-project capability checks and correctly handle missing or empty options.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The legend-count and legend-subtitle capability checks now inspect inline project text supplied to project.openText and project.fromTemplate. Tests cover enabled values, empty or default options, escaped keys, and the expanded inline-project checks.

Changes: Inline legend capabilities

Layer / File(s) Summary
Inline capability checks and tests
crates/engine/src/project_capabilities.rs
Legend-count and legend-subtitle checks now inspect inline project text. Tests cover enabled values, escaped keys, and both capabilities in the inline-project checks.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • opengeos/RustGIS#3462 — The issue covers other layout capabilities not checked for inline project.openText projects.
  • opengeos/RustGIS#3476 — The issue describes missing inline-text checks for additional layout capabilities in project.openText and project.fromTemplate.
  • opengeos/RustGIS#3324 — The PR adds the legend-subtitle capability check for inline project text.

Possibly related PRs

  • opengeos/RustGIS#3608 — It changes the same inline-project capability-check paths by replacing per-capability reads.
  • opengeos/RustGIS#3533 — It changes inline project reading in the same file and establishes the reader contract used by these checks.

Suggested reviewers: elpidioassinaturas, mavrick-f, m-hollis-1

Merge Risk: Minimal · up to 7f0d4

The change makes older releases refuse projects that use legend counts or subtitles when those projects are opened from inline text. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the legend-counts and legend-subtitle capability checks now cover project.openText and project.fromTemplate. The title is specific and matches the changeset, though it…
Description check Passed The description follows the template. It has Summary, Testing, UI evidence, and Related issue sections. The UI evidence section states no visible UI change, which the template allows. The Summary expl…
Linked Issues check Passed [#3598] The issue asks for a project.openText arm in command_uses_legend_counts and command_uses_legend_subtitle, a text_… reader like the one-row check, and one test per capability. The PR su…
Out of Scope Changes check Passed All reported changes are in crates/engine/src/project_capabilities.rs (+63/-1) and serve the issue. The legend counts and subtitle checks gain the project.openText handling the issue requests, and…
Full details: Title check

Explanation

The title names the main change: the legend-counts and legend-subtitle capability checks now cover project.openText and project.fromTemplate. The title is specific and matches the changeset, though it is long (116 characters) and includes a conventional-commit prefix.

Full details: Description check

Explanation

The description follows the template. It has Summary, Testing, UI evidence, and Related issue sections. The UI evidence section states no visible UI change, which the template allows. The Summary explains the problem and fix. Testing lists new tests and check results. The Related issue section links #3598 with a closing keyword.

Full details: Linked Issues check

Explanation

[#3598] The issue asks for a project.openText arm in command_uses_legend_counts and command_uses_legend_subtitle, a text_… reader like the one-row check, and one test per capability. The PR summary states that both checks now inspect inline project text for project.openText, parse it when the relevant key appears (either naming style, escaped, or in base64 data), and test the parsed project's required capabilities. The PR adds a_saved_step_that_counts_or_subtitles_a_legend_is_found_in_text_a_project_opens and adds layout-legend-counts and layout-legend-subtitle to the_checks_of_an_inline_project_read_nothing_it_names. Both tests reportedly fail without the fix. Limitation: the whole-PR diff could not be read (changed blobs unavailable), so this verdict rests on the file at head and the PR summary, not on a direct read of the new hunks.

Full details: Out of Scope Changes check

Explanation

All reported changes are in crates/engine/src/project_capabilities.rs (+63/-1) and serve the issue. The legend counts and subtitle checks gain the project.openText handling the issue requests, and the reader mirrors the existing one-row and patch-size readers. The project.fromTemplate inline-text arm applies the same handling to text that the template opens, which is the same defect class; it is a small, closely related extension. The added tests cover these checks only. No unrelated code change is reported. Limitation: the diff could not be read directly, so this verdict relies on the PR summary.

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 legend’s count,
And asks if subtitles are there.
Escaped keys and text go through,
With empty options checked too.
Two new checks join the project’s path,
The rabbit hops away at last.

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: 3e88d223-0281-42c4-bc32-d78665c87651
Commits

Reviewing files that changed from the base of the PR and between b89fd11 and 7f0d4f4.

Files selected for processing: 1

  • crates/engine/src/project_capabilities.rs

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

}
"layout.import" | "report.existingTemplate" => imported_layout_uses(id, params, &["\"subtitle\""], legend_subtitle_features),
// It opens its `text` only, whatever else the step holds.
"project.openText" => params.get("text").and_then(Value::as_str).is_some_and(text_gives_legend_subtitle),

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.

Twin gap in the same family: five legend checks in this file still have no project.openText / project.fromTemplate arm, so an openText step holding a legend with any of these fields passes the older-reader check and the older reader drops the field silently:

  • command_uses_legend_fit (layout-legend-fit, around line 680)
  • command_uses_legend_class_labels (layout-legend-class-labels, around line 701)
  • command_uses_legend_order (layout-legend-order, around line 723)
  • command_uses_legend_column_breaks (layout-legend-column-breaks, around line 740)
  • command_uses_legend_nested_sizes (layout-legend-nested-sizes, around line 922)

This PR fixes counts, subtitle and (already) one-row and patch-size, so the same two arms are missing from those five. This PR doesn't have to fix them, but a follow-up should, with a test like the new a_saved_step_that_counts_or_subtitles_... for each. I checked the dispatch table (COMMAND_CAPABILITIES, lines 163–223) and command_uses: nothing else routes an openText step to those checks.

Category: bug

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Code review

Reviewed PR #3611 (fix(engine): project.openText and project.fromTemplate steps require layout-legend-counts and layout-legend-subtitle), one file, crates/engine/src/project_capabilities.rs. The fix itself is correct. The main gap is a twin that the PR leaves open. I could not run the test suite (no shell here), so the test results below are from reading the code.

Bugs

  • Twin gap, not fixed here (posted inline, confidence high). Five legend checks still have no project.openText / project.fromTemplate arm: layout-legend-fit, layout-legend-class-labels, layout-legend-order, layout-legend-column-breaks and layout-legend-nested-sizes. An openText step holding one of these passes the older-reader check, so an older reader drops the field silently. This predates the PR, but it is the same family the PR is fixing.

Security

  • None found. The new text readers are pre-filtered and parse with Project::from_peer_raw, the same path as the existing one-row and patch-size checks.

Performance

  • Low confidence. "subtitle" is a broad pre-filter, so any large project text containing that word now gets a full parse from two more checks. The one-row and patch-size checks already do this, so the cost is consistent with the existing design.

Quality

  • The two new tests repeat the project-building closure. Helper names differ: text_gives_legend_subtitle against text_shows_legend_counts and text_lays_a_legend_in_one_row. Left for the release quality pass.

AGENTS.md

  • Low confidence, a question for the author. required_capabilities feeds the saved requires header, so this changes what gets saved for such projects. The capability names already exist in schema/project.schema.json, so the schema does not need regenerating. No new fixture covers the openText route, which the "change to how a project is read" rule may want. Confirm whether the rule applies.

Checked and fine

  • The key names the pre-filters rely on (show_counts, showCounts, subtitle) match the legend fields and the layout.update parameters.
  • The new project.openText and project.fromTemplate arms match the one-row arms, including the inline_text path.
  • The new tests cover the escaped-key case (\u0073howCounts, \u0073ubtitle) and the test-matrix entry for the_checks_of_an_inline_project_read_nothing_it_names.
  • The PR states that the 8 nextest failures also occur on main. I did not verify that.

Earlier concerns skipped: 0 (no prior review threads).

Change size

Compared: the whole PR against main (merge base 7548c1b to PR head 7f0d4f4).

Measure Value
Files changed 1 (added 0, modified 1, removed 0, renamed 0)
Size before 301.8 KB
Size after 306.1 KB
Total size change +4.4 KB
Path Before After Change
crates/engine/src/project_capabilities.rs 301.8 KB 306.1 KB +4.4 KB

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3611/
Web app https://preview.rustgis.app/pr-3611/app/
Commit 7f0d4f4

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 marked this pull request as ready for review December 2, 2026 15:05
/// or its notebooks. Parsed only when the text names a key, either way it is written, may hide it
/// ([`may_hide_a_key`]), or holds a step's base64 `data` ([`names_data`]).
fn text_shows_legend_counts(text: &str) -> bool {
(["show_counts", "showCounts"].iter().any(|key| text.contains(key)) || may_hide_a_key(text) || names_data(text))

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.

Low-confidence performance note, not a correctness problem. names_data is true for any text with a quoted data key, and may_hide_a_key is true for any \uXXXX escape. When either holds, every project.openText and project.fromTemplate step now gets one more full Project::from_peer_raw parse from this check. The subtitle check (text_gives_legend_subtitle) has the same shape, so a text that passes the pre-filter gets two more full parses per step. The siblings already do this, so the cost follows the existing pattern. If large saved projects with embedded data make this slow, parse once per text and share the result across the capability checks, rather than adding a parse per check.

Category: performance

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Code review

Scope: one file, crates/engine/src/project_capabilities.rs. The PR adds project.openText and project.fromTemplate arms to the layout-legend-counts and layout-legend-subtitle checks, and two tests. I found no correctness, crash, or security problem. I could not build or run the tests in this environment (no shell), so the test results below are from reading the code.

Bugs

  • None found. The new arms match the existing one-row and patch-size arms: openText reads text, fromTemplate uses inline_text, and both defer to inline_project_requires. The key spellings match the serialized and command names (show_counts, showCounts, subtitle).

Security

  • None found. No unsafe input handling is introduced; may_hide_a_key uses text.get(..), so it cannot panic on a char boundary.

Performance (low confidence, inline comment posted)

  • Each openText or fromTemplate step whose text passes the broad pre-filter (names_data, may_hide_a_key) now gets two more full parses. This follows the existing siblings' pattern, so it is consistent but repeated work. See the inline comment at project_capabilities.rs:809.

Quality (release quality pass, not posted inline)

  • text_shows_legend_counts, text_gives_legend_subtitle, text_lays_a_legend_in_one_row and text_gives_legend_patch_size share one shape. A single helper taking the key list and capability would remove the repetition.
  • The test branch in inline_project_with (line 2267) calls layout.update with showCounts: true on a map-template legend and unwraps the result. I could not confirm from reading alone that a legend over a raster scene accepts showCounts without an error. Running the_checks_of_an_inline_project_read_nothing_it_names would settle it.

AGENTS.md (low confidence, process only)

  • The PR body says "No visible UI change" but does not state which surfaces the change reaches (CLI, Python, Assistant and MCP tool descriptions, undo). The rule in "Reach every surface" asks for that statement. The change itself is in the command capability check, which all surfaces share.

Twins checked

  • The other legend checks in this family (fit, class labels, order, column breaks, nested sizes) still lack the project.openText and project.fromTemplate arms. The existing prior thread already raises this, so I left it alone. That is one earlier concern not repeated.
  • Path-based project.open is not gated by these text arms, the same as the sibling checks.
  • project.importQgis and project.importGeolibre read other formats, not RustGIS project text, so they are out of scope.
  • inline_text handles both text and base64 data, so fromTemplate covers the package case too.

Change size

Compared with the base branch: the whole PR against main (merge base 7548c1b to PR head 7f0d4f4).

Measure Value
Files changed 1 (added 0, modified 1, removed 0, renamed 0)
Size before 301.8 KB
Size after 306.2 KB
Total size change +4.4 KB
Path Size before Size after Size change
crates/engine/src/project_capabilities.rs 301.8 KB 306.2 KB +4.4 KB

@jgregoriorincon

Copy link
Copy Markdown
Contributor Author

Closing: #3608 (merged, e1b5334) covers this. A saved step that opens a project from its text now requires every capability that project requires, layout-legend-counts and layout-legend-subtitle included, and it removed the per-capability arms this PR extended.

auto-merge was automatically disabled December 2, 2026 18:24

Pull request was closed

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.

[Bug]: project.openText steps don't require layout-legend-counts or layout-legend-subtitle

1 participant