Skip to content

fix(ui): Unique Values shows its Expression box as soon as it is chosen (#2784) - #2792

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/2784-unique-expression-row
Nov 23, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/2784-unique-expression-row

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Choosing Unique Values in the Symbology pane showed the Field selector and Apply (#738), but not the Expression box: that box was drawn only once the renderer was Unique Values (crates/ui-egui/src/panes.rs, the Renderer::Unique arm). To class by an expression, you first applied a field you didn't want, then typed the expression, which also left an extra undo step.

The same expression_box, with the same id, is now drawn under the field choice as soon as Unique Values is chosen. An expression that reads applies Unique Values by that expression when the box loses focus (layer.symbology with expression), in one undo step, and ends the field choice (symbology_pending). The pane then looks as it does today after applying: Field shows "(expression)" and the box keeps the text. A blank box applies nothing, and one that doesn't read shows why, both as the box already does, and the field choice stays open. Field + Apply, and the choice following its context (#738's tests in tests/smoke.rs), are unchanged.

Surfaces: the Symbology pane lives in rustgis-ui-egui, which the desktop app and the browser build share. The phone layout (ui-touch) has no Symbology pane. Nothing here is a new command: it runs layer.symbology as the box under the applied field does, so the CLI, Python, scripts and the Assistant/MCP are unaffected. No new user-visible strings: "Expression" is the existing label.

Not in this PR (noted for a follow-up): while the field choice is open, the controls of the layer's current renderer (for example Graduated Colors' field, method and classes) are still drawn under it, as before this change.

Testing

  • New test panes::tests::unique_values_offer_their_expression_before_a_field_is_applied, written first; before the change it failed because no Expression box was found while the field choice was open. It checks a blank box, an expression that doesn't read ("Invalid:", nothing applied, the choice still open), one that reads (classes by it, one undo step, the choice ended, Field shows "(expression)"), and undo (the earlier renderer back, no choice reopened).
  • fix(ui): allow selecting a field before applying unique symbology #738's unique_symbology_lets_the_user_choose_a_text_field_before_applying and unique_symbology_pending_choice_follows_its_context, and unique_values_are_classed_by_the_expression_typed: pass.
  • cargo nextest run --workspace: 9115 passed. cargo clippy -p rustgis-ui-egui --all-targets -- -D warnings, cargo fmt --all --check, doctests, cargo xtask layers, cargo xtask schema --check: pass.
  • ui_shot replay, before and after: Countries (Graduated Colors) in the Symbology pane, Unique Values clicked; after, pop_est > 100000000 typed in the Expression box and Enter.

UI evidence

Unique Values just chosen. Before (left): Field and Apply only. After (right): the Expression box under them.

2784-chosen-before-after.png

After typing pop_est > 100000000 and pressing Enter: classed by the expression, the field choice gone.

2784-applied.png

Related issue

Closes #2784

Summary by CodeRabbit

  • New Features
    • Added an expression editor to the Symbology pane while selecting a field for Unique Values rendering. Valid expressions apply the renderer and clear the pending field choice; blank or invalid expressions leave the selection unchanged.

…en (opengeos#2784)

Choosing Unique Values showed only the Field selector and Apply (opengeos#738);
the Expression box appeared once a field was applied, so classing by an
expression took a field first and an extra undo step. The same box now
sits under the field choice, and an expression that reads classes by it
in one step and ends the choice.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Symbology pane now shows an Expression editor while Unique Values field selection is pending. Valid input applies Unique Values by expression and clears the pending choice. Blank or invalid input leaves the renderer and pending choice unchanged.

Changes: Unique Values expression

Layer / File(s) Summary
Pending expression flow
crates/ui-egui/src/panes.rs
The pane accepts an expression while field selection is pending. Tests cover blank and invalid input, applying a valid expression in one undo step, and undo behavior.

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

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested reviewers: giswqs, deniial00

Merge Risk: Minimal · up to 0cb07

Unique Values now shows its Expression box as soon as it is chosen, and a readable expression applies on focus loss. No concrete merge-blocking risk was established.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the Expression box for Unique Values now appears as soon as Unique Values is chosen in the Symbology pane. It matches the raw summary and the linked issue #2784, and i…
Description check Passed The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the change and the reason for it. Testing lists a new test, the existing tests tha…
Linked Issues check Passed Directly linked issue #2784 has three coding requirements. (1) The Expression box appears under the Field selector when Unique Values is chosen. The raw summary states that the Symbology pane now show…
Out of Scope Changes check Passed The reported change set is confined to crates/ui-egui/src/panes.rs, with about +59 lines and one new test in the same module. The Symbology pane is the surface named in #2784. The PR description state…
Full details: Title check

Explanation

The title names the main change: the Expression box for Unique Values now appears as soon as Unique Values is chosen in the Symbology pane. It matches the raw summary and the linked issue #2784, and it follows the conventional commit style. The title is a single sentence and concise.

Full details: Description check

Explanation

The description follows the template sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the change and the reason for it. Testing lists a new test, the existing tests that still pass, and the workspace checks. UI evidence has before and after screenshots, which the template requires for visible UI changes. The Related issue section says Closes #2784. The template's Related issue placeholder is replaced, and the description does not include the template's comment text. The description is thorough and mostly complete. One point to note: the template's UI evidence section says 'No visible UI change', but the author correctly replaced it with screenshots because this PR changes visible UI.

Full details: Linked Issues check

Explanation

Directly linked issue #2784 has three coding requirements. (1) The Expression box appears under the Field selector when Unique Values is chosen. The raw summary states that the Symbology pane now shows an Expression editor while a Unique Values renderer awaits field selection, and the PR description states that the same expression_box, with the same id, is drawn under the field choice. (2) A reading expression applies Unique Values by that expression when the box loses focus, in one undo step. The raw summary states that a valid expression applies Unique Values with that expression and clears the pending field choice. The PR description states that this runs as layer.symbology with expression. (3) Field + Apply keeps working. The PR description states that #738's tests are unchanged and pass. The new test panes::tests::unique_values_offer_their_expression_before_a_field_is_applied covers blank, unreadable, and readable expressions, and undo. Basis and limit: the repository diff could not be read because changed blobs are missing from the checkout. This verdict rests on the raw summary and PR description, not on direct code inspection. The author-reported test results were not independently re-run.

Full details: Out of Scope Changes check

Explanation

The reported change set is confined to crates/ui-egui/src/panes.rs, with about +59 lines and one new test in the same module. The Symbology pane is the surface named in #2784. The PR description states that no new command is added, no CLI, Python, script, or MCP behavior changes, and no new user-visible strings are added beyond the existing 'Expression' label. The deferred item (current renderer controls remain visible while the field choice is open) is disclosed and is not included in this PR. Basis and limit: the diff could not be read directly, so this verdict relies on the raw summary and PR description. No unrelated file changes are reported.

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 taps an expression in,
While field selection waits to begin.
A valid line sets values right,
A blank one leaves the choice in sight.
Then undo hops the state back in.

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: fb90095d-8247-4850-a88a-b1c0bbb3f9f9
Commits

Reviewing files that changed from the base of the PR and between 519ad84 and 0cb0765.

Files selected for processing: 1

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

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

Comment thread crates/ui-egui/src/panes.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

None found. I checked the new pending-choice expression box against the existing Unique arm: they share the id, and kind_label makes it impossible for both to be live at once. The blank, parse-error and apply paths behave as the PR describes. Confidence: high.

Security

None found. The change is UI-only and adds no new command, parameter, or input path. Confidence: high.

Performance

None found. The box runs as before, and the parse only runs when the text changes. Confidence: high.

Quality

  • Typed text is lost when the engine rejects an expression (inline comment on crates/ui-egui/src/panes.rs:4683). The error is notified, but the text reverts to blank because only parse errors keep it. This is reachable: layer.symbology validates area measures on ambiguous-CRS datasets, and the box doesn't check that while typing. The new test does not cover this path. Confidence: medium-high.
  • Pre-existing, outside the diff: the Unique arm's own box (panes.rs:4742) discards the layer.symbology error with let _ = app.run(...), so the same rejection is silent there. The new path notifies, so the two paths now differ. Worth a follow-up. Confidence: high.

AGENTS.md

No violations found. The panel uses tl!("Expression") for its label, has no new user-visible strings, and the PR states which surfaces it reaches. Test code uses unwrap/panic!, which clippy.toml allows. Confidence: high.

I left no earlier concerns alone because there were no prior review threads.

Change size

Compared with the base branch: the whole PR against main (merge base dd3d011 to PR head 0cb0765).

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

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2792/
Web app https://preview.rustgis.app/pr-2792/app/
Commit 0cb0765

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 November 23, 2026 18:38
Comment thread crates/ui-egui/src/panes.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • None confirmed. I checked the pending path's blank and invalid handling in expression_box (panes.rs:6454-6527), the pending lifetime (PendingUniqueSymbology::is_current, lib.rs:843), and the duplicate-id case. The pending box only exists while the renderer is not Unique, so it never draws alongside the applied box under the same id.

Security

  • None.

Performance

  • None new. The per-frame parse_fields call is the existing box's behaviour.

Quality

  • Stale invalid draft carries over to the field-applied box (panes.rs:4680, posted inline). Confidence medium-high, from reading the code. A draft that doesn't read in the pending box survives Apply with a field, because both boxes have cur = "" and share an id. The field-applied renderer then shows that draft with Invalid:, though nothing from it was applied. It is newly reachable with this PR.
  • Nit: duplicated id expression. egui::Id::unique(("unique_expression", crate::labelpane::layer_key(app, &l))) appears at panes.rs:4679 and 4739. A small helper would keep the two in step.

AGENTS.md

  • None. The Err arm uses notify, the label is translatable, the change runs through layer.symbology with no new command, one undo step is tested, and the PR description covers surfaces and UI screenshots.

Already raised, left alone

  • 1 earlier concern: text typed in the box is lost when the engine refuses an expression that parses (the Err arm). It is already raised in a resolved thread, the author answered it, and the code is unchanged. I did not repeat it.

Change size

Compared: the whole PR against main (merge base dd3d011 to PR head 0cb0765).

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

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 23, 2026
Merged via the queue into opengeos:main with commit 3119075 Nov 23, 2026
28 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/2784-unique-expression-row branch November 23, 2026 18:51
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.

Unique Values shows its Expression box only after a field is applied

1 participant