Skip to content

feat(layout): expose layout.publication defaults and text limit to the wizard (#2874) - #3041

Merged
Mavrick-F merged 1 commit into
opengeos:mainfrom
ninhhaidang:feat/2874-publication-defaults
Nov 26, 2026
Merged

Mavrick-F merged 1 commit into
opengeos:mainfrom
ninhhaidang:feat/2874-publication-defaults

Conversation

@ninhhaidang

@ninhhaidang ninhhaidang commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Expose layout.publication's defaults and text limit from rustgis-engine and use them in the Publication Layout Wizard so the UI stays in sync with the engine instead of hard-coding copies or falling back to the app accent:

  • crates/engine/src/cmd/layout.rs:
    • Export PUBLICATION_DEFAULT_CREDIT ("Made with RustGIS · {date}"), MAX_PUBLICATION_TEXT (2000), and publication_style_accent(style: &str) -> Option<Rgba> beside PUBLICATION_STYLES.
    • Share Style::parse between publication_style_accent and layout.publication, and use PUBLICATION_DEFAULT_CREDIT when "author" is omitted.
  • crates/ui-egui/src/publicationwizard.rs:
    • Start the Accent step's colour picker from publication_style_accent(&d.style) (falling back to the app accent only for unknown style ids), and update the checkbox hover text. Unticking without changing away from the style's own accent leaves no stale custom colour remembered so switching styles starts from the new style's accent.
    • Build default_credit() from i18n::fmt(PUBLICATION_DEFAULT_CREDIT, &[("date", tl_raw!("today's date"))]) for both the Texts hint and the Review row.
    • Cap all five text inputs (Title, Subtitle, Note, Sources, Credit line) with .char_limit(MAX_PUBLICATION_TEXT) and show a weak notice (Each field takes at most 2000 characters.) when any active field reaches the limit.

Reach every surface

  • Desktop app & browser: both share rustgis-ui-egui's Publication Layout Wizard (wasm32-unknown-unknown checked cleanly).
  • CLI, Python, Assistant, MCP, plugins: unaffected — no command, parameter, or project schema changes (layout.publication already enforced these defaults and limits).
  • Phone (ui-touch): does not expose the desktop Publication Layout Wizard.
  • The way back: unticking "Pick a colour of your own" returns to the style's own accent; creating a layout from the wizard remains undoable via edit.undo.

Testing

  • cargo test -p rustgis-engine --lib publication_defaults_match_the_command — verifies every style in PUBLICATION_STYLES returns an opaque accent (unknown returns None), omitted author writes PUBLICATION_DEFAULT_CREDIT, and MAX_PUBLICATION_TEXT matches the exact acceptance/rejection boundary.
  • cargo test -p rustgis-ui-egui --lib publicationwizard::tests (18/18 passed), including 3 new tests:
    • accent_starts_from_the_chosen_styles_own_colour
    • texts_enforce_the_engines_character_limit_and_say_so
    • default_credit_matches_the_engines_constant
  • cargo test -p rustgis-engine --lib command_surface_matches_the_snapshot & hostile_params_never_panic (8/8 passed)
  • cargo test -p rustgis-ui-egui --test command_ids (2/2 passed)
  • cargo fmt --all --check, cargo clippy --all-targets -- -D warnings (all 9 changed/dependent packages), cargo xtask layers, cargo xtask attribution, cargo xtask rows (768/768), cargo xtask test-hygiene
  • RUSTFLAGS='-D warnings' cargo check --locked --target wasm32-unknown-unknown -p rustgis-web
  • Rendered headless screenshots of Step 3 (Texts), Step 4 (Accent with Banner selected), and Step 5 (Review) via ui_shot.

UI evidence

Verified with headless ui_shot screenshots of the Publication Layout Wizard:

  • Step 3 (Texts): Credit line hint renders Made with RustGIS · today's date from PUBLICATION_DEFAULT_CREDIT; clean fields show no extra limit text, while reaching 2000 characters caps input and displays Each field takes at most 2000 characters..
  • Step 4 (Accent): With Banner selected, ticking Pick a colour of your own initializes the colour swatch to Banner's deep brown (#4A3426) instead of the app's blue accent (#2563EB).
  • Step 5 (Review): Shows Credit line: Made with RustGIS · today's date and Accent: #4A3426.

Related issue

Closes #2874

Summary by CodeRabbit

  • New Features
    • Publication styles now provide their own default accent color in the wizard. Custom accent choices are retained when changed, while switching styles uses the new style’s accent by default.
    • Publication text fields show a notice when they reach the character limit.
    • The default credit line now includes the current date.
  • Bug Fixes
    • Publication text limits and default credit details are consistent between the wizard and publication creation.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 18:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@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 engine now exposes publication defaults and style accents. The publication wizard uses the shared text limit and credit, and starts custom accent selection from the selected style’s accent when available.

Changes: Publication wizard updates

Layer / File(s) Summary
Engine publication defaults and command behavior
crates/engine/src/cmd/layout.rs, crates/engine/src/tests.rs
The engine exposes the default credit, maximum text length, and style accent lookup. The publication command uses the shared credit and parses style names with Style::parse. Tests cover style accents, default credit, and the text-length boundary.
Wizard text, credit, and accent behavior
crates/ui-egui/src/publicationwizard.rs
The wizard applies the engine’s text limit and default credit. It shows a limit notice and initializes custom accent selection from the selected style when an accent is available. Tests cover these behaviors.

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

Change: Feature · Severity of issue fixed: Medium

Possibly related issues

  • opengeos/RustGIS#2850 — This PR updates the publication wizard’s credit, accent, and text-limit behavior described in the issue.

Possibly related PRs

Suggested reviewers: jgregoriorincon, giswqs

Merge Risk: Minimal · up to 26b57

The publication wizard now takes its defaults and text limits from the engine, with no command or schema changes. No actionable merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(layout): expose layout.publication defaults and text limit to the wizard (#2874)" matches the main change. The PR exports PUBLICATION_DEFAULT_CREDIT, MAX_PUBLICATION_TEXT and publicati…
Description check Passed The description follows the repository template. It has Summary, Testing, UI evidence and Related issue sections. The Summary explains the engine exports and the wizard changes, and gives the reasons …
Linked Issues check Passed [#2874] requests three engine-side exposures and their wizard use. (1) Accent: the PR adds pub fn publication_style_accent(style: &str) -> Option<Rgba> beside PUBLICATION_STYLES. The wizard starts…
Out of Scope Changes check Passed All changes map to #2874 objectives. The engine constants and accent function are the requested exposures. The wizard changes use them. The new engine test and wizard tests support those objectives. T…
Full details: Title check

Explanation

The title "feat(layout): expose layout.publication defaults and text limit to the wizard (#2874)" matches the main change. The PR exports PUBLICATION_DEFAULT_CREDIT, MAX_PUBLICATION_TEXT and publication_style_accent from the engine and uses them in the Publication Layout Wizard. The title is specific and uses a conventional commit prefix. It is a little long at 85 characters, but it is clear.

Full details: Description check

Explanation

The description follows the repository template. It has Summary, Testing, UI evidence and Related issue sections. The Summary explains the engine exports and the wizard changes, and gives the reasons for them. Testing lists specific commands and new tests. UI evidence gives before-and-after style details for Steps 3 to 5 with screenshot results, and the template asks for screenshots to be attached. The description states the screenshots were rendered headless and describes them in text, but it does not show embedded images. The Related issue section says Closes #2874.

Full details: Linked Issues check

Explanation

[#2874] requests three engine-side exposures and their wizard use. (1) Accent: the PR adds pub fn publication_style_accent(style: &amp;str) -&gt; Option&lt;Rgba&gt; beside PUBLICATION_STYLES. The wizard starts the colour picker from it and falls back to the app accent only for unknown style ids. Unticking 'Pick a colour of your own' returns to the style's accent. (2) Credit line: pub const PUBLICATION_DEFAULT_CREDIT is used for the omitted-author default in layout.publication. The wizard builds default_credit() from it for the Texts hint and Review row. (3) Text limit: MAX_PUBLICATION_TEXT becomes pub. All five text inputs use .char_limit(MAX_PUBLICATION_TEXT), with a notice when an active field reaches the limit. The engine test publication_defaults_match_the_command covers the accent, credit, and limit boundary. The wizard tests cover accent start, limit notice, and credit match. Basis: PR summary, raw diff summary, and PR description. The layout.rs diff and the publicationwizard.rs hunks could not be read directly (diff and file reads were unavailable or truncated), so this verdict relies on the summaries and the reported test results.

Full details: Out of Scope Changes check

Explanation

All changes map to #2874 objectives. The engine constants and accent function are the requested exposures. The wizard changes use them. The new engine test and wizard tests support those objectives. The PR reports no changes to command IDs, parameters, or project schema, and the command surface snapshot test was reported passing. One detail needs note: the summary says layout.publication now trims surrounding whitespace in the style value for parsing and error reporting, because it shares Style::parse. This is a minor side effect of the shared parser. It does not add a parameter or change the documented schema. The diff for that hunk could not be read directly, so this is based on the summary. It does not appear unrelated to the issue.

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 color swatch,
Then sets the text to fit the notch.
The credit line now shares its source,
And styles provide the accent course.
The wizard’s ready, neat and bright,
Says “Hop along,” and ends the night.

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: eacf5201-5945-403d-bb15-3ae442f6321b
Commits

Reviewing files that changed from the base of the PR and between e185e02 and 26b57a0.

Files selected for processing: 3

  • crates/engine/src/cmd/layout.rs
  • crates/engine/src/tests.rs
  • crates/ui-egui/src/publicationwizard.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.

let default = style_accent(&d.style, app_accent);
if !ticked {
d.picked = d.accent;
d.picked = d.accent.filter(|&c| c != default);

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.

Stale colour remembered after a style change while the box is ticked (about 70% confident).

style_step changes d.style but leaves d.accent alone. So with Banner selected, ticking the box sets accent to Banner's brown. If the user then picks Poster while the box is still ticked, accent stays Banner's brown. Unticking then runs d.picked = d.accent.filter(|&c| c != default) with Poster's default, which keeps Banner's brown as a "custom" colour. The next time the box is ticked, d.picked.unwrap_or(default) gives Banner's colour rather than the new style's accent. That is the stale-colour case this PR says it fixes, and the new test accent_starts_from_the_chosen_styles_own_colour does not cover a style change while ticked.

A possible fix is to re-seed accent when the style changes, for example if accent equals the previous style's default, set it to the new style's default. Also add a test for that path.

Category: bug

}

/// The accent step: the style's own colour, or one picked.
fn accent_step(ui: &mut egui::Ui, d: &mut Draft, app_accent: egui::Color32) {

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.

The credit line's English template is no longer a wrapped literal.

The old code was tl!("Made with RustGIS · today's date"), so the whole line could be translated. Now "Made with RustGIS · {date}" comes from a const in the engine and reaches i18n::fmt unwrapped. The catalog extraction (see docs/i18n.md) only sees tl!/tl_raw! literals, so this key never gets a catalog entry and the line stays English in every language. The wizard should keep the template wrapped in its own tl_raw!, with a test (the existing default_credit_matches_the_engines_constant) tying it to PUBLICATION_DEFAULT_CREDIT, so the translator can see the wording.

Category: agents-md

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff, the base-branch AGENTS.md, and the surrounding code (the Style enum, i18n::fmt, cmd::within, the style_step and accent_step functions). I did not build or run the tests, since I have no shell here. There were no earlier review threads, so there were no prior concerns to skip.

Bugs

  • Stale accent remembered after a style change while the box is ticked (publicationwizard.rs:265, about 70% confidence). style_step changes the style but leaves d.accent alone. If the user ticks "Pick a colour of your own" on Banner, switches to Poster, then unticks, Banner's brown is saved as a custom colour. The next tick then gives Banner's colour instead of the new style's accent. This is the stale-colour case the PR says it fixes, and the new tests don't cover it.

Security

  • None found.

Performance

  • None found. The default_credit() allocation runs once per frame, which is negligible.

Quality

  • Nits, not posted inline, left for the release quality pass:
    • Unticking drops a custom colour equal to the style's default, so a deliberately picked default colour is forgotten.
    • The engine's Style::parse trims the input, which matches the old .map(str::trim) behaviour, so the change in behaviour is nil.

AGENTS.md

  • Credit-line template no longer wrapped in tl! (publicationwizard.rs:252, about 65% confidence). The old tl!("Made with RustGIS · today's date") could be translated. The English template now lives in an engine const, so no catalog entry is generated and the line stays English in every language. The wizard should keep the template wrapped in tl_raw!, tied to the constant by the existing test.

Checked and not raised

  • Engine layout.publication: the style parse, the error text and the empty-string case behave as before. The MAX_PUBLICATION_TEXT check uses chars().count() in cmd::within, which matches the wizard's char_limit.
  • Twins: this PR touches only layout.publication and the wizard. It changes no read route, no overlay tool, no project.open* or layer.add* command, and no #[cfg(target_arch = "wasm32")] branch. So there are no twins to check.
  • Command surface and project schema: neither changes, so command-surface.txt and the schema need no update.
  • Accent test: accent_starts_from_the_chosen_styles_own_colour covers the untick-then-switch path but not the style-change-while-ticked path in the bug above.

Change size

Compared with main (merge base e185e02 to PR head 26b57a0). Sizes are file sizes, not line counts.

Measure Value
Files changed 3 (0 added, 3 modified, 0 removed, 0 renamed)
Size before 4.04 MB
Size after 4.05 MB
Total size change +7.3 KB
File Before After Change
crates/ui-egui/src/publicationwizard.rs 32.1 KB 36.7 KB +4.7 KB
crates/engine/src/tests.rs 3.62 MB 3.62 MB +2.0 KB
crates/engine/src/cmd/layout.rs 401.3 KB 401.9 KB +623 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Commit 26b57a0 from a fork built, but isn't published until a maintainer adds the preview label (once per commit).

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.

layout.publication: expose its defaults and text limit (each style's accent, the credit line, the 2000-character limit) to the UI

3 participants