diff --git a/src/main/mesh.js b/src/main/mesh.js index 29f2c032..8c0809a7 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -768,15 +768,35 @@ function space_init(data) { // fetched Blob wrapped in a File object looks identical to one the user // picked, so no new parsing/import logic is needed here at all. async function cmms_load_from_url(config) { - const response = await fetch(config.loadUrl); - if (!response.ok) { - log(`CMMS load failed: HTTP ${response.status}`).pin({}); - return; + // restore_space() (the normal boot path) is intentionally skipped for a + // CMMS-scoped launch (this loads one specific file, not whatever was + // last open in this browser - see init()'s own comment above) - but its + // finalization tail (hide the loading curtain, enable handles, publish + // app_ready) only ever runs inside restore_space() itself, so skipping + // it meant the curtain never went away even after the file loaded fine + // underneath it (CMMS bug report, 2026-08-27: froze on the loading + // curtain despite attachment.php's fetch succeeding). app_ready + // subscribers never fired either - mesh/history.js's undo-tracking + // enable, mesh/build.js's doc-name label. try/finally so this always + // happens, even if the fetch or file itself fails - a file that can't + // load shouldn't leave the user stuck behind the curtain either. + try { + const response = await fetch(config.loadUrl); + if (!response.ok) { + log(`CMMS load failed: HTTP ${response.status}`).pin({}); + return; + } + const buf = await response.arrayBuffer(); + const name = config.originalName || 'attachment.stl'; + const file = new File([buf], name, { type: 'application/octet-stream' }); + await api.document.restoreOrCreate(); + load_files([file]); + } finally { + boot_done(); + handles.setEnabled(api.prefs.map.space.bounds ?? false); + api.file.set_doc_name(config.originalName || 'Untitled'); + broker.publish("app_ready"); } - const buf = await response.arrayBuffer(); - const name = config.originalName || 'attachment.stl'; - const file = new File([buf], name, { type: 'application/octet-stream' }); - load_files([file]); } function load_files(files) {