From 6a31ea7360e9a7e0c0cd4aed0eb6e4ca85301304 Mon Sep 17 00:00:00 2001 From: Denis Gomes <6731020+denisg0mes@users.noreply.github.com> Date: Fri, 6 Nov 2026 02:53:58 -0500 Subject: [PATCH] M3: Go to main component names a library copy with no link A file imported from another app can hold library copies in its library store with no record of the library they came from. On an instance of one, the command took the local path and failed in selecting it with "isn't on a page (it is a library component)", which says nothing about what to do. It now says the copy has no link to its library and that enabling the library reaches it. Found on a real imported file, where copies of the same library set were cached more than once and only one of them could be linked. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/assets/library/tests.rs | 5 +++++ crates/engine/src/cmd/component.rs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/crates/engine/src/assets/library/tests.rs b/crates/engine/src/assets/library/tests.rs index e9b6009ca..733c3ba8c 100644 --- a/crates/engine/src/assets/library/tests.rs +++ b/crates/engine/src/assets/library/tests.rs @@ -458,6 +458,11 @@ fn going_to_a_library_main_opens_the_library_file() { let e = s.execute("component.goToMain", &json!({"id": card})).unwrap_err(); assert!(e.to_string().contains("isn't at"), "{e}"); assert_eq!(s.docs.len(), 1); + + let NodeKind::Instance { component: copy, .. } = node(&s, card).kind else { panic!("not an instance") }; + s.doc_mut().unwrap().libraries_mut().components.retain(|r| r.root != copy); + let e = s.execute("component.goToMain", &json!({"id": card})).unwrap_err(); + assert!(e.to_string().contains("no link to its library"), "an imported copy without its record: {e}"); let _ = std::fs::remove_dir_all(&d); } diff --git a/crates/engine/src/cmd/component.rs b/crates/engine/src/cmd/component.rs index 7288045ad..e0b2e02f4 100644 --- a/crates/engine/src/cmd/component.rs +++ b/crates/engine/src/cmd/component.rs @@ -207,6 +207,13 @@ pub fn specs() -> Vec { let library = library.to_string(); return go_to_library_main(s, &library, &name, key); } + if doc.is_remote(component) { + return Err(EngineError::Disabled( + cmd.into(), + "the main component is a library copy with no link to its library (it came with an imported file): enable that library to reach it" + .into(), + )); + } super::edit::select_and_page(s, vec![component])?; let ds = s.ds_mut()?; if let Some(b) = ds.doc.world_bounds(component) {