Skip to content

fix(layout): say a preview's bug after the Layout Wizard has gone - #3512

Merged
jgregoriorincon merged 3 commits into
opengeos:mainfrom
jgregoriorincon:fix/3505-preview-bug-after-close
Dec 1, 2026
Merged

jgregoriorincon merged 3 commits into
opengeos:mainfrom
jgregoriorincon:fix/3505-preview-bug-after-close

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Layout Wizard draws its preview on a thread of its own in the desktop app (#3480). The channel's receiver lived only in the wizard, so a bug the drawing met was dropped with it: when the wizard was closed, another dialog took its place, or it was closed on another step before the review step had read the answer. Messages never said it.

Drop for Drawing, which each of those goes through, now keeps the receiver, and a per-frame landing, beside the other land_* calls, says a caught bug in Messages. A drawing that ends well or is only cancelled says nothing, and one the review step already read has nothing left to say, so a bug is said once.

Reach: the desktop app and the phone's desktop interface, which draw the preview on a thread. The browser draws it in place and is unchanged. No command, parameter or project change, so the command line, Python, the ribbon, the Assistant and MCP, plugins and undo are not involved.

Testing

  • New tests in publicationwizard/review.rs: a bug met after the wizard is closed or replaced, one unread when it closes on another step, and drawings left that met no bug; the existing once-only test now closes the wizard too. The new ones failed before the fix.
  • cargo nextest run -p rustgis-ui-egui -E 'test(publicationwizard)': 205 passed; clippy on the crate and fmt --check clean.
  • Full workspace run: fmt, clippy, doctests, layers and schema --check pass; nextest 11749 of 11757. The 8 failures (7 in rustgis-geolibre, and the smoke test line_strokes_editor_edits_one_class) happen on this machine on other branches too and touch nothing changed here.
  • cargo check -p rustgis-web --target wasm32-unknown-unknown passes.

UI evidence

No visible UI change.

Related issue

Closes #3505

Summary by CodeRabbit

  • Bug Fixes
    • Recognized drawing errors in the Layout Wizard now appear as session warnings, even if you close the wizard or leave the review step before the drawing finishes.
    • Each recognized incident is reported only once. Successful drawings and errors that are not recognized as named incidents do not generate these warnings.
    • Warnings are added when a drawing finishes with a recognized error; still-running drawings do not generate premature warnings.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Dropped Layout Wizard preview receivers are retained and polled on desktop. When a completed drawing result contains a named incident, the app adds a session notice, including if the wizard has closed or left the Review step.

Changes: Layout Wizard result reporting

Layer / File(s) Summary
Queue and report drawing results
crates/ui-egui/src/publicationwizard/review.rs
Dropped drawing receivers are queued and polled. Completed or disconnected receivers are removed. The app reports errors with named incidents. Tests cover reporting after the wizard closes or changes steps, and ignoring successes, unnamed errors, and unanswered results.
Wire desktop polling
crates/ui-egui/src/publicationwizard/mod.rs, crates/ui-egui/src/lib.rs
The module re-exports land_left on non-WASM targets. The desktop frame also polls Layout Wizard results.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • opengeos/RustGIS#3480: Adds the Review-step preview thread whose drawing-result reporting this change updates.

Suggested reviewers: mavrick-f, giswqs

Merge Risk: Minimal · up to 26ffe

This change keeps the Layout Wizard's drawing-result receiver alive after the wizard closes, so a drawing bug is reported once in Messages. No concrete merge-blocking risk was found, and the change is narrow and easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names a fix for a Layout Wizard preview bug being reported after the wizard has closed. The change does retain the result receiver after the wizard closes and reports a caught drawing bug in…
Description check Passed The description follows the repository template. It has a Summary that explains the problem and fix, a Testing section with specific tests and command results, and a UI evidence section that states no…
Linked Issues check Passed [#3505] requires a Layout Wizard preview bug to be said once in Messages, whether or not the wizard is still open. At the reviewed head, Drawing::drop (crates/ui-egui/src/publicationwizard/review.rs…
Out of Scope Changes check Passed The changes described are confined to the Layout Wizard preview path: Drawing::drop, the LEFT thread-local, land_left, bug_met, incident, and the preview's cancelled-drawing branch in review…
Full details: Title check

Explanation

The title names a fix for a Layout Wizard preview bug being reported after the wizard has closed. The change does retain the result receiver after the wizard closes and reports a caught drawing bug in Messages, so the title matches the main change. It is short, specific, and follows the conventional-commit style.

Full details: Description check

Explanation

The description follows the repository template. It has a Summary that explains the problem and fix, a Testing section with specific tests and command results, and a UI evidence section that states no visible UI change. The Related issue section links #3505. The description does not include a screenshot, but the template allows the no-visible-change line, which the author kept.

Full details: Linked Issues check

Explanation

[#3505] requires a Layout Wizard preview bug to be said once in Messages, whether or not the wizard is still open. At the reviewed head, Drawing::drop (crates/ui-egui/src/publicationwizard/review.rs) moves the drawing's result receiver into the thread-local LEFT queue instead of dropping it, so the send no longer fails for lack of a receiver. land_left (review.rs, non-WASM) polls that queue. For each answer, bug_met keeps only an error recognised by rustgis_engine::data::incident::named, and app.session.warn(bug) is called once. Empty receivers are kept. Disconnected or successful answers are removed silently. In preview_part, a drawing already read becomes Shown::Drawn, and its later drop pushes only a disconnected receiver, so a bug is not reported twice. A user-cancelled drawing that meets a named bug is still reported through bug_met. mod.rs re-exports review::land_left on non-WASM targets, which matches the code read. The per-frame call in crates/ui-egui/src/lib.rs was not read directly: the diff and hunk reads were unavailable. The AI summary names publicationwizard::land, which differs from the exported land_left. The crate builds and tests pass per the PR, so the call most likely targets land_left. The new tests in review.rs were not read directly; the PR reports 205 passing tests. Residual uncertainty: the per-frame wiring is supported by the PR description and compilation, not by reading lib.rs.

Full details: Out of Scope Changes check

Explanation

The changes described are confined to the Layout Wizard preview path: Drawing::drop, the LEFT thread-local, land_left, bug_met, incident, and the preview's cancelled-drawing branch in review.rs. They also include the per-frame call in ui-egui lib.rs and the non-WASM re-export in publicationwizard/mod.rs. All of these serve #3505. The PR description states that no command, parameter, project, browser-path, or integration change is included. The read review.rs and mod.rs code shows no unrelated behaviour. The lib.rs hunk and the test bodies were not read directly, so this verdict is based on the read code and the PR description.

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 drawing queue,
And keeps each dropped receiver near.
A named incident joins the notes,
Even when the wizard disappears.
The desktop frame polls; all is clear.

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: c5c7cd93-85c9-4756-b326-a992fdd61b4c
Commits

Reviewing files that changed from the base of the PR and between 549fb8f and 26ffe65.

Files selected for processing: 1

  • crates/ui-egui/src/publicationwizard/review.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

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

I read the full diff, the base-branch AGENTS.md, and the surrounding wizard code (review.rs, mod.rs, the incident module, and the other land_* callers). I did not run the tests or clippy, since I have no shell here. The PR's own test list reports them passing, but I have not verified that.

Overall the change is sound. It keeps a dropped drawing's answer, lands a bug from it once through session.warn, and filters with the same incident::named check the existing path uses. Its three new tests cover the cases that matter: closed, replaced, and closed on another step. The wasm gating is consistent: land_left and its use are cfg(not(wasm32)), and bug_met is still used on wasm. No bugs found.

Bugs

  • None found. Confidence: high that the main flow is correct.
  • Not verified: bug_met drops every Err that isn't a named incident, including real failures. Since the wizard is already gone, this looks intentional. Confidence: low.

Security

  • None found.

Performance

  • None found. land_left is a short per-frame scan that only runs while receivers are pending.

Quality

  • review.rs:151: borrow_mut() in Drop can panic on re-entry. Nothing re-enters today, but the AGENTS "Never crash" rule makes try_borrow_mut the safer choice. The same comment also covers a throwaway channel() allocated on every drop, and the reused name made. Confidence: medium. Posted inline with a suggestion.

AGENTS.md

  • None found. The PR adds no command, parameter, or saved-file change, so the schema, snapshot, and fixture rules don't apply. It names its surfaces (desktop, phone, browser unchanged) and has no visible UI change, so no screenshot is needed.

Twins checked

  • Other Drop impls and land_* calls in ui-egui: readjob, exportjob, analysispane, workspacepanes. None keep a dropped job's answer, so the wizard's pattern is the only one of its kind. Not verified: syncmark::Job discards its slot when dropped. I did not check whether a hash bug there is reported. Confidence: low, worth a follow-up.
  • Wasm twin: Drawing is only built when reads_off_frame is set, which is desktop-only, so LEFT is never filled in the browser.

Prior reviews

  • No existing threads on this PR, so there were no earlier concerns to skip.

Change size

Compared with the base branch (merge base 5453f49 to PR head 549fb8f). Files changed: 3 (0 added, 3 modified, 0 removed, 0 renamed).

Measure Value
Files changed 3 (added 0, modified 3, removed 0, renamed 0)
Size before 712.7 KB
Size after 716.8 KB
Total size change +4.1 KB
File Before After Change
crates/ui-egui/src/publicationwizard/review.rs 31.9 KB 35.9 KB +3.9 KB
crates/ui-egui/src/lib.rs 631.6 KB 631.7 KB +85 B
crates/ui-egui/src/publicationwizard/mod.rs 49.1 KB 49.2 KB +70 B

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

PR #3512 makes the Layout Wizard's preview answer reach Messages when the wizard has gone before the drawing finishes. I found no crash paths, no wasm breakage, and no duplicate notices. One minor quality point is posted inline.

Bugs

None found. I traced the cases:

  • Closed or replaced wizard with an answer ready: the receiver is kept, land_left reads it and warns once. Confidence high.
  • Answer read by preview_part and then the wizard closes: the receiver yields Disconnected, so nothing is said twice. Confidence high.
  • Cancelled drawing (Shown::Stopping) with a bug: said once via bug_met and returned to mod.rs, then d.preview = None drops the receiver, so no second notice. Confidence high.
  • Err(Disconnected) and cancel-only answers: answer.ok() yields None, so no notice. Confidence high.
  • lib.rs uses |, so every land_* is evaluated each frame. Confidence high.

Security

None found.

Performance

  • While a dropped drawing finishes its current long step, land_left returns true and the app requests a repaint every 200 ms. This is bounded by the thread's lifetime and cheap. Low severity; not posted.

Quality

  • Inline (review.rs:152): a try_borrow_mut failure would silently drop a bug answer, which the "Never silent" rule forbids. It is unreachable today. A Cell<Vec<…>> take-and-restore avoids the borrow entirely. Confidence medium.
  • Already raised, left alone: the prior thread on review.rs:151 asked for try_borrow_mut (now adopted) and for removing the throwaway channel().1 allocation in Drop. The allocation is still there, so the nit stands. I did not re-post it. Its reply is not an answer from the author or a maintainer, so it stays open.
  • Minor: incident() and bug_met() duplicate the "named bug" check. The Drop comment "with the app" is unclear. The test a_drawing_dropped_while_the_left_ones_are_read_does_not_panic has no assertion and only checks that it doesn't panic. Each is a nit, not posted.

AGENTS.md

  • The change is wired through session.warn, which is the same path the wizard already uses at mod.rs:664.
  • It is desktop-only behind #[cfg(not(target_arch = "wasm32"))], and the wasm build still compiles the Drop and LEFT code. Confidence high.
  • No commands, saved files or layers changed, so the schema, command-surface and row limits do not apply.

Twins checked

  • The other land_* functions (land_summary, land_series, land_trend, land_job, exportjob::land, readjob::land) were not changed. I did not examine whether they share the drop-loss pattern.
  • The overlay-tool, add-data and project-open families are not touched by this diff.

Change size

Compared against main (merge base 5453f49 to PR head 26ffe65). 3 files changed, all modified; 0 added, 0 removed, 0 renamed.

Measure Value
Files changed 3 (added 0, modified 3, removed 0, renamed 0)
Size before 712.7 KB (729,781 B)
Size after 717.1 KB (734,536 B)
Total size change +4.6 KB (+4,755 B)
Path Before After Change
crates/ui-egui/src/publicationwizard/review.rs 31.9 KB 36.4 KB +4.5 KB
crates/ui-egui/src/lib.rs 631.6 KB 631.7 KB +85 B
crates/ui-egui/src/publicationwizard/mod.rs 49.1 KB 49.2 KB +70 B

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3512/
Web app https://preview.rustgis.app/pr-3512/app/
Commit 26ffe65

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 Dec 1, 2026
Merged via the queue into opengeos:main with commit 8f98761 Dec 1, 2026
30 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3505-preview-bug-after-close branch December 1, 2026 10:31
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]: A bug in a Layout Wizard preview isn't said in Messages if the wizard closes while it draws

1 participant