fix(xiaoyi): allow slot-skeleton scope switches on bound template canvases

This commit is contained in:
WuYongJie 2026-12-03 19:05:29 +08:00
parent 26503bd6cc
commit 011109f188

View File

@ -1326,10 +1326,12 @@ impl Workspace {
return Err(SINGLE_PROJECT_IN_PROGRESS.into());
}
// A draft read can assign a provisional local ID to an imported file.
let has_canvas_workspace = self.template_workflow["workspaceId"].is_string()
&& st.doc.metadata.text.iter().any(|(key, _)| key == "jiansun.slot-mapping.v1");
let standalone_file = st.path.as_deref().is_some_and(|path| {
!std::path::Path::new(path).extension().is_some_and(|extension| extension.eq_ignore_ascii_case("pcraft"))
}) && !self.project_files.contains_key(&doc) && !self.template_workflow["workspaceId"].is_string();
if (self.owned_project_key(doc).is_none() || standalone_file) && !first_project_save {
}) && !self.project_files.contains_key(&doc) && !has_canvas_workspace;
if ((self.owned_project_key(doc).is_none() && !has_canvas_workspace) || standalone_file) && !first_project_save {
return Err("请先打开或新建产品项目,再读取模板".into());
}
}
@ -1485,16 +1487,18 @@ impl Workspace {
self.busy = None;
}
let production_save = pending["continueProduct"] == true || method == "slot-product-export";
let active = app.session.active().filter(|state| state.doc.id.0 == id);
let has_canvas_workspace = self.template_workflow["workspaceId"].is_string()
&& active.is_some_and(|state| state.doc.metadata.text.iter().any(|(key, _)| key == "jiansun.slot-mapping.v1"));
let same_scope = waiting
&& (method == "slot-product-export" && self.production_can_use_scoped_pending()
|| slot_action_allowed(&self.template_workflow, self.unknown, &method))
&& pending["accountId"] == self.account["id"] && pending["origin"] == self.origin
&& pending["slotRevision"].as_u64() == Some(self.template_workflow["revision"].as_u64().unwrap_or(0))
&& (method != "slot-skeleton" || self.owned_project_key(id).is_some())
&& (method != "slot-skeleton" || self.owned_project_key(id).is_some() || has_canvas_workspace)
&& (method != "slot-skeleton" || pending["draftGuard"] == json!({"brief":self.creation_brief,"width":self.creation_width}))
&& (!production_save || self.product_production.is_some())
&& ((pending["generateProduct"] != true && pending["resumeProduct"] != true) || self.product_start_queued);
let active = app.session.active().filter(|state| state.doc.id.0 == id);
if same_scope && production_save && active.is_some_and(|state| state.revision > revision) {
self.canvas_workspace.scope_switch_in_flight = false;
if live_handoff {