Repository navigation
Show world name on Start Generation button and clean up on fetch failure - #951
Conversation
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).
There was a problem hiding this comment.
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-updateGUI 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
Resultfromgenerate_world_with_options(...)is discarded, butcleanup_guardis 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 onOk.
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, butcleanup_guardis disarmed and a "Done!" message is emitted unconditionally. If world generation fails (this function returnsErr), the UI will still report success and the newly created world directory will be kept. Handle theResultand 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.
|
⏱️ Benchmark run finished in 0m 37s 📈 Compared against baseline: 20s 🟢 Generation time is unchanged. 📅 Last benchmark: 2026-04-19 22:15:37 UTC You can retrigger the benchmark by commenting |
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-updateevent 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.