Skip to content

Show world name on Start Generation button and clean up on fetch failure - #951

Merged
louis-e merged 3 commits into
mainfrom
gui/world-name-button
Apr 20, 2026
Merged

louis-e merged 3 commits into
mainfrom
gui/world-name-button

Conversation

@louis-e

@louis-e louis-e commented Apr 19, 2026

Copy link
Copy Markdown
Owner

Adds a yellow subtitle span to the Start Generation button showing the generated world name (localized "No world generated yet" when idle). The backend emits a world-name-update event so Java worlds can update the label to include the localized area suffix (e.g. "Arnis World 1: Berlin") after the Nominatim lookup, and Bedrock worlds show the location-derived level name.

Also removes a freshly created Java world directory if the Overpass fetch fails, so repeated failures don't leave empty "Arnis World N" folders behind. Session lock is dropped first so the folder can be removed on Windows.

louis-e added 3 commits April 20, 2026 00:00
Adds a yellow subtitle span to the Start Generation button showing the
generated world name (localized "No world generated yet" when idle).
The backend emits a `world-name-update` event so Java worlds can update
the label to include the localized area suffix (e.g. "Arnis World 1:
Berlin") after the Nominatim lookup, and Bedrock worlds show the
location-derived level name.

Also removes a freshly created Java world directory if the Overpass
fetch fails, so repeated failures don't leave empty "Arnis World N"
folders behind. Session lock is dropped first so the folder can be
removed on Windows.
Previously cleanup only ran when the Overpass fetch errored, leaving
orphan "Arnis World N" folders behind for disk-space, session-lock,
bbox-parse, coord-transformer, and rotation failures.

Pre-spawn validation is now wrapped in a single IIFE so all four error
paths share one cleanup + error-emit site. Inside the blocking task a
NewWorldCleanup RAII guard removes the world on any early return and
is disarmed only at the two success sites. Declaration order ensures
the SessionLock's file handle is released before the folder is removed
(Windows otherwise blocks the rmdir).
Copilot AI review requested due to automatic review settings April 19, 2026 22:11

Copilot AI left a comment

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.

Pull request overview

Adds UI support for displaying the generated world’s name under the “Start Generation” button (with localization and backend-driven updates), and introduces cleanup logic to remove newly created Java world folders when generation aborts early.

Changes:

  • Added a world-name-update GUI event to push finalized world names from Rust to the frontend.
  • Updated the GUI (HTML/CSS/JS) to show a localized “no world generated yet” placeholder and to update/reset the label during generation lifecycle.
  • Added RAII-based cleanup to delete freshly created Java world directories when generation fails (notably on Overpass fetch failure), ensuring Windows session locks don’t block deletion.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/progress.rs Adds emit_world_name_update event emitter for frontend world-name label updates.
src/gui.rs Adds Java world cleanup guard and emits world-name updates (Java localized suffix / Bedrock level name).
src/gui/js/main.js Adds localized placeholder + label update/reset logic; listens for world-name-update.
src/gui/index.html Splits Start Generation button into title + subtitle span for world name display.
src/gui/css/styles.css Adds styling for the new .world-name-label subtitle (yellow, ellipsis).
src/gui/locales/ar.json Adds no_world_generated_yet localization key.
src/gui/locales/de.json Adds no_world_generated_yet localization key.
src/gui/locales/en-US.json Adds no_world_generated_yet localization key.
src/gui/locales/es.json Adds no_world_generated_yet localization key.
src/gui/locales/fi.json Adds no_world_generated_yet localization key.
src/gui/locales/fr-FR.json Adds no_world_generated_yet localization key.
src/gui/locales/hu.json Adds no_world_generated_yet localization key.
src/gui/locales/ja.json Adds no_world_generated_yet localization key.
src/gui/locales/ko.json Adds no_world_generated_yet localization key.
src/gui/locales/lt.json Adds no_world_generated_yet localization key.
src/gui/locales/lv.json Adds no_world_generated_yet localization key.
src/gui/locales/pl.json Adds no_world_generated_yet localization key.
src/gui/locales/pt-BR.json Adds no_world_generated_yet localization key.
src/gui/locales/ru.json Adds no_world_generated_yet localization key.
src/gui/locales/sl.json Adds no_world_generated_yet localization key.
src/gui/locales/sv.json Adds no_world_generated_yet localization key.
src/gui/locales/ua.json Adds no_world_generated_yet localization key.
src/gui/locales/zh-CN.json Adds no_world_generated_yet localization key.
Comments suppressed due to low confidence (2)

src/gui.rs:1079

  • Same issue as terrain-only branch: the Result from generate_world_with_options(...) is discarded, but cleanup_guard is disarmed and the success path continues. If generation fails during saving/writing, this will still emit the Done message and prevent cleanup of the newly created world. Propagate/handle the error and only disarm/emit Done on Ok.
                    let _ = data_processing::generate_world_with_options(
                        parsed_elements,
                        xzbbox.clone(),
                        args.bbox,
                        ground,
                        &args,
                        generation_options.clone(),
                    );
                    if let Some(g) = cleanup_guard.as_mut() {
                        g.disarm();
                    }
                    // Explicitly release session lock before showing Done message
                    // so Minecraft can open the world immediately
                    drop(_session_lock);
                    emit_gui_progress_update(100.0, "Done! World generation completed.");

src/gui.rs:999

  • The return value from data_processing::generate_world_with_options(...) is ignored here, but cleanup_guard is disarmed and a "Done!" message is emitted unconditionally. If world generation fails (this function returns Err), the UI will still report success and the newly created world directory will be kept. Handle the Result and only disarm/emit Done after a successful generation; on error, emit the error and keep cleanup armed so the empty world is removed.
                let _ = data_processing::generate_world_with_options(
                    parsed_elements,
                    xzbbox.clone(),
                    args.bbox,
                    ground,
                    &args,
                    generation_options.clone(),
                );
                if let Some(g) = cleanup_guard.as_mut() {
                    g.disarm();
                }
                // Explicitly release session lock before showing Done message
                // so Minecraft can open the world immediately
                drop(_session_lock);
                emit_gui_progress_update(100.0, "Done! World generation completed.");
                println!("{}", "Done! World generation completed.".green().bold());

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

⏱️ Benchmark run finished in 0m 37s
🏗️ Generation time: 20s (excl. data fetching)
🧠 Peak memory usage: 1727 MB

📈 Compared against baseline: 20s
🧮 Delta: 17s
🔢 Commit: 37c6b08

🟢 Generation time is unchanged.

📅 Last benchmark: 2026-04-19 22:15:37 UTC

You can retrigger the benchmark by commenting retrigger-benchmark.

@louis-e
louis-e merged commit a8ee09c into main Apr 20, 2026
7 checks passed
@louis-e
louis-e deleted the gui/world-name-button branch April 20, 2026 15:02
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.

2 participants