diff --git a/apps/detail-photocraft/crates/ui-egui/src/jiansun.rs b/apps/detail-photocraft/crates/ui-egui/src/jiansun.rs index 3279b9ba..d9be1f94 100644 --- a/apps/detail-photocraft/crates/ui-egui/src/jiansun.rs +++ b/apps/detail-photocraft/crates/ui-egui/src/jiansun.rs @@ -4412,18 +4412,21 @@ mod agent_daemon_control_tests { let mut opened = (*app.session.active().unwrap().doc).clone(); let mapping = json!({"version":1,"canvasFirst":true,"workspaceId":"product", "component":"sku_images","variantId":"wood","templateId":"fixture", - "templateVersion":"1","templateHash":"fixture-hash","outputs":[]}); + "templateVersion":"1","templateHash":"fixture-hash", + "outputs":[{"documentId":"sku-01","mapping":{"fields":[]}}]}); opened.metadata.text.push(("jiansun.slot-mapping.v1".into(), mapping.to_string())); let mut workflow = w.template_workflow.clone(); for (key, value) in [("outputId",json!("sku_images")),("templateId",json!("fixture")), ("templateVersion",json!("1")),("templateHash",json!("fixture-hash"))] { workflow[key] = value; } + workflow["outputs"] = json!([{"outputId":"sku_images","documentId":"sku-01"}]); w.continue_product_canvas(&mut app, Box::new(opened), json!({ "doc":doc,"baseRevision":revision,"workspaceId":"product","accountId":w.account["id"], "origin":w.origin,"outputId":"sku_images","variantId":"wood", "canvasFirst":true,"continueProduct":true,"workflow":workflow })); + assert!(!w.product_view_detached(), "the first mapped canvas replaces the placeholder"); w.with_product_target(&mut app, |w, app| { assert!(w.production_canvas_receipt(app).is_null(), "wait for the real save receipt"); let rev = app.session.active().unwrap().revision; @@ -4434,6 +4437,9 @@ mod agent_daemon_control_tests { assert_eq!(w.production_canvas_receipt(app)["revision"], rev); assert_eq!(w.pi_run.as_deref(), Some(run)); }); + assert!(w.enforce_canvas_scope(&app)); + assert!(!w.agent_native.cancelled(run)); + assert!(w.product_production.is_some()); assert!(matches!(requests.try_recv().unwrap(), Request::Action(method, input) if method == "product-run-checkpoint" && input["checkpoint"]["outputSelected"] == true)); assert!(requests.try_recv().is_err(), "the bound canvas stays in the original Pi turn"); diff --git a/apps/detail-photocraft/crates/ui-egui/src/jiansun/product_production.rs b/apps/detail-photocraft/crates/ui-egui/src/jiansun/product_production.rs index 2bfb97c0..0d53267b 100644 --- a/apps/detail-photocraft/crates/ui-egui/src/jiansun/product_production.rs +++ b/apps/detail-photocraft/crates/ui-egui/src/jiansun/product_production.rs @@ -415,6 +415,11 @@ impl Workspace { if !run.current(self, app) || !run.accepts_canvas(&meta) || meta["accountId"] != self.account["id"] || meta["origin"] != self.origin { return; } let Some(active) = app.session.active_mut().filter(|state| state.doc.id == doc.id) else { return; }; + // A new project has no mapped editor canvas to preserve in the viewer. + if !run.output_selected && canvas_workspace::document_mapping(&active.doc).is_none() { + self.receive_slot_canvas(app, doc, meta); + return; + } if Stage::read(&meta) == Stage::read(&self.template_workflow) { self.template_workflow = meta["workflow"].clone(); self.canvas_workspace.scope_switch_in_flight = false;