fix(xiaoyi): bind published component originals and isolate unavailable outputs
This commit is contained in:
parent
7c478d652b
commit
726b8ba500
@ -126,25 +126,54 @@ export function normalizeTemplateMapping(raw,originals,key,component) {
|
||||
const detail=component==='detail'&&originals.length===1;
|
||||
const expected=raw.source?.assets??(detail?[{asset_id:original.id,ps_sha256:raw.source?.sha256}]:null);
|
||||
if(!Array.isArray(expected)||expected.length!==originals.length||
|
||||
originals.some(a=>!expected.some(source=>source?.asset_id===a.id&&matchesOriginal(source.ps_sha256,a)))||
|
||||
detail&&raw.source?.sha256!==undefined&&!matchesOriginal(raw.source.sha256,original)){
|
||||
throw conflict('字段映射与当前原稿版本不符');
|
||||
}
|
||||
// Resource-map attachment IDs are scoped to the published component. The
|
||||
// field mapping may use its document-local ID for the same pinned original.
|
||||
const bindings=new Map(), used=new Set();
|
||||
for(const source of expected){
|
||||
if(!text(source?.asset_id)||bindings.has(source.asset_id))throw conflict('字段映射的原稿身份缺失或重复');
|
||||
const exact=originals.find(a=>a.id===source.asset_id);
|
||||
const candidates=exact?[exact]:text(source.ps_asset_path)
|
||||
?originals.filter(a=>a.file.path?.endsWith('/template-adapter/'+source.ps_asset_path))
|
||||
:[];
|
||||
const [match]=candidates;
|
||||
if(candidates.length!==1||!matchesOriginal(source.ps_sha256,match)||used.has(match.id)){
|
||||
throw conflict(`原稿「${source.asset_id}」的路径或版本与字段映射不符`);
|
||||
}
|
||||
bindings.set(source.asset_id,match.id);
|
||||
used.add(match.id);
|
||||
}
|
||||
const assetId=id=>{
|
||||
if(id===undefined||id===null)return id;
|
||||
const bound=bindings.get(id);
|
||||
if(!bound)fail(`字段映射引用了未登记的原稿「${id}」`);
|
||||
return bound;
|
||||
};
|
||||
const canvas=detail?(raw.canvas??expected[0].canvas_px):undefined;
|
||||
if(detail&&(!Array.isArray(canvas)||canvas.length!==2||!canvas.every(size=>Number.isSafeInteger(size)&&size>0))){
|
||||
fail('字段映射的原稿尺寸无效');
|
||||
}
|
||||
const screens=raw.screens.map(screen=>{
|
||||
if(!object(screen)||!text(screen.screen_id))fail('字段映射缺少有效的页面编号');
|
||||
return {...screen,bounds:rectangle(screen.bounds,`页面「${screen.screen_id}」`)};
|
||||
return {...screen,asset_id:assetId(screen.asset_id),bounds:rectangle(screen.bounds,`页面「${screen.screen_id}」`)};
|
||||
});
|
||||
const screenIds=new Set(screens.map(screen=>screen.screen_id));
|
||||
if(!screens.length||screenIds.size!==screens.length)fail('字段映射缺少页面或页面编号重复');
|
||||
return {...raw,screens,...(detail?{canvas,source:{...raw.source,sha256:expected[0].ps_sha256.toLowerCase()}}:{}),fields:raw.fields.map(field=>{
|
||||
const source={...raw.source,
|
||||
...(raw.source?.assets?{assets:expected.map(item=>({...item,asset_id:assetId(item.asset_id)}))}:{}),
|
||||
...(detail?{sha256:expected[0].ps_sha256.toLowerCase()}:{}),
|
||||
};
|
||||
return {...raw,screens,source,...(detail?{canvas}:{}),fields:raw.fields.map(field=>{
|
||||
if(!object(field)||!object(field.ps_location)||!text(field.ps_location.path)||!text(field.ps_location.name))fail('字段缺少原稿图层路径或名称');
|
||||
if(!screenIds.has(field.screen_id))fail(`字段「${field.name??field.field_id}」缺少对应页面`);
|
||||
const rect=field.type==='图片'?field.ps_style?.coverage_rect:field.ps_style?.bounds;
|
||||
const coverage_rect=rectangle(rect,`「${field.name??field.field_id}」`);
|
||||
return {...field,asset_id:field.asset_id||field.ps_location.asset_id,ps_style:{...field.ps_style,coverage_rect}};
|
||||
const asset=assetId(field.asset_id||field.ps_location.asset_id);
|
||||
const location=field.ps_location;
|
||||
return {...field,asset_id:asset,
|
||||
ps_location:location.asset_id?{...location,asset_id:assetId(location.asset_id)}:location,
|
||||
ps_style:{...field.ps_style,coverage_rect}};
|
||||
})};
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import fs from 'node:fs/promises';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import {EnterpriseTemplates} from '../src/enterprise-templates.mjs';
|
||||
import {normalizeTemplateMapping} from '../src/template-mapping.mjs';
|
||||
|
||||
const sha='a'.repeat(64), version='b'.repeat(32), setId='c'.repeat(32);
|
||||
const file=(fileId,ext)=>({fileId,name:fileId+ext,path:fileId+ext,revision:version,sha256:sha,size:100});
|
||||
@ -341,3 +342,24 @@ test('resource map reuses complete mappings by file identity and revision after
|
||||
assert.ok((await choose()).items[0].pack);
|
||||
assert.deepEqual(calls.filter(([name])=>name==='read_text').map(([,args])=>args.revision),[version,revision]);
|
||||
});
|
||||
|
||||
test('component-scoped original IDs bind by the published path and digest', () => {
|
||||
const relative = 'assets/fixtures/desk/main/plate.psd';
|
||||
const original = {id:'publication-plate',file:{path:'library/template-adapter/'+relative,sha256:sha}};
|
||||
const mapping = {
|
||||
template_id:'test-desk',component:'main_images',
|
||||
source:{assets:[{asset_id:'plate',ps_asset_path:relative,ps_sha256:sha}]},
|
||||
screens:[{asset_id:'plate',screen_id:'main',bounds:[0,0,100,100]}],
|
||||
fields:[{field_id:'hero',asset_id:'plate',screen_id:'main',type:'图片',
|
||||
ps_location:{asset_id:'plate',path:'Hero',name:'Hero'},ps_style:{coverage_rect:[0,0,100,100]}}],
|
||||
};
|
||||
const bind = a => normalizeTemplateMapping(mapping,[a],'test-desk','main_images');
|
||||
const normalized = bind(original);
|
||||
assert.equal(normalized.source.assets[0].asset_id,original.id);
|
||||
assert.equal(normalized.screens[0].asset_id,original.id);
|
||||
assert.equal(normalized.fields[0].asset_id,original.id);
|
||||
assert.equal(normalized.fields[0].ps_location.asset_id,original.id);
|
||||
assert.equal(mapping.fields[0].asset_id,'plate');
|
||||
assert.throws(() => bind({...original,file:{...original.file,sha256:'c'.repeat(64)}}),/路径或版本/);
|
||||
assert.throws(() => bind({...original,file:{...original.file,path:'elsewhere/plate.psd'}}),/路径或版本/);
|
||||
});
|
||||
|
||||
@ -97,6 +97,19 @@ fn production_stages(state: &Value) -> Vec<Value> {
|
||||
}).collect()
|
||||
}
|
||||
|
||||
fn blocked_production_stages(state: &Value) -> Vec<Value> {
|
||||
production_stages(state).into_iter().filter_map(|mut stage| {
|
||||
let reason = state["productTemplateIssues"].get(stage["outputId"].as_str()?)?.as_str()?;
|
||||
stage["reason"] = json!(reason);
|
||||
Some(stage)
|
||||
}).collect()
|
||||
}
|
||||
|
||||
fn runnable_stages(state: &Value, mut remaining: Vec<Value>) -> Vec<Value> {
|
||||
remaining.retain(|stage| stage["outputId"].as_str().is_some_and(|output| state["productTemplateIssues"][output].is_null()));
|
||||
remaining
|
||||
}
|
||||
|
||||
fn output_variant<'a>(state: &'a Value, component: &str, requested: Option<&'a str>) -> R<&'a str> {
|
||||
if let Some(id) = requested {
|
||||
variant(state, id)?;
|
||||
@ -2206,6 +2219,7 @@ fn approved_structure_guides(recipe: &Value, item: &Value, candidate: &str) -> R
|
||||
fn remaining_stages(dir: &Path, state: &Value, brief_revision: &Value, verify_editable: bool) -> Vec<Value> {
|
||||
production_stages(state).into_iter().filter(|stage| {
|
||||
let (Some(variant), Some(component)) = (stage["variantId"].as_str(), stage["outputId"].as_str()) else { return true };
|
||||
if !state["productTemplateIssues"][component].is_null() { return true; }
|
||||
let receipt = read_json(&receipt_path(dir,variant,component)).unwrap_or(Value::Null);
|
||||
let pack = &state["productTemplates"][component];
|
||||
let pages = pack["outputs"].as_array().into_iter().flatten().filter(|page| page["component"] == component);
|
||||
@ -2596,7 +2610,7 @@ fn export_product_stage_snapshot(dir: &Path, doc: u64, state: &Value, input: &Va
|
||||
{
|
||||
result["goalSyncError"] = json!(error);
|
||||
}
|
||||
result["productionStages"] = json!(remaining);
|
||||
result["productionStages"] = json!(runnable_stages(state, remaining));
|
||||
Ok(result)
|
||||
}
|
||||
// Older projects stored the mapping's combined requirements. Use the original
|
||||
@ -2761,50 +2775,65 @@ fn snapshot_for_view(dir: &Path, view: Option<Value>) -> R<Value> {
|
||||
"productionRoute":pack["productionRoute"],"production":profile.map(production_profile::agent_rules)});
|
||||
let mut workflow = json!({"canvasFirst":true,"revision":state["revision"],"workspaceId":state["id"],"structureHash":state["structureHash"],"templateId":state["template"]["id"],"templateVersion":state["template"]["version"],"templateHash":state["template"]["contentHash"],"templateName":state["template"]["name"],"template":template,"confirmed":true,"confirmationKind":"template-selection","pending":pending,"recoveryCandidateId":recovery_candidates.first(),"recoveryCandidateIds":recovery_candidates,"activeVariantId":active,"variantId":active,"variants":state["variants"],"outputVariantIds":state["brief"]["outputVariantIds"],"outputId":state["activeOutput"],"outputs":outputs,"slots":slots,"capabilities":{"imageDispatchAllowed":ready&&!pending&&active_color_enabled,"copyDispatchAllowed":false,"localApplyAllowed":ready}});
|
||||
if state["productTemplates"].is_object() {
|
||||
workflow["productionStages"] = json!(remaining_stages(dir, &state, ¤t["revision"], false));
|
||||
workflow["productionStages"] = json!(runnable_stages(&state, remaining_stages(dir, &state, ¤t["revision"], false)));
|
||||
workflow["productionBlocks"] = json!(blocked_production_stages(&state));
|
||||
workflow["scopedProductionPending"] = json!(scoped_production_pending);
|
||||
}
|
||||
Ok(workflow)
|
||||
}
|
||||
|
||||
impl Backend {
|
||||
fn product_templates(&self, brief: &Value, selected_pack: Value, width: u64) -> R<Value> {
|
||||
let independent = super::product_layout::from_product(brief, width)?;
|
||||
fn product_templates(&self, brief: &Value, selected_pack: &Value, width: u64) -> R<(Value, Value)> {
|
||||
let selected_set = &selected_pack["enterprise"]["resourceSetId"];
|
||||
let independent = (!selected_set.is_string()).then(|| super::product_layout::from_product(brief, width)).transpose()?;
|
||||
let resource_input = json!({"resourceSetId":selected_set,
|
||||
"brandId":brief["brandId"],"categoryId":brief["categoryId"],
|
||||
"brandName":brief["brandName"],"categoryName":brief["categoryName"]});
|
||||
let catalog = if selected_set.is_string() {
|
||||
let mut request = resource_input.clone();
|
||||
request["action"] = json!("resource-set");
|
||||
self.enterprise_template_request(request)?["items"].clone()
|
||||
} else { Value::Null };
|
||||
self.enterprise_template_request(request).map(|response| response["items"].clone())
|
||||
} else { Ok(Value::Null) };
|
||||
let mut packs = serde_json::Map::new();
|
||||
let mut blocked = serde_json::Map::new();
|
||||
for component in PRODUCTION_OUTPUTS {
|
||||
let mut pack = if selected_pack["outputs"].as_array().is_some_and(|outputs| outputs.iter().any(|output|output["component"] == component)) {
|
||||
selected_pack.clone()
|
||||
} else {
|
||||
let matching: Vec<_> = catalog.as_array().into_iter().flatten().filter(|part|
|
||||
part["kind"] == component).collect();
|
||||
if let [part] = matching.as_slice() {
|
||||
if !part["issues"].as_array().is_some_and(Vec::is_empty) {
|
||||
return Err(format!("企业模板的 {component} 组件资料不完整,请核对原稿与字段映射"));
|
||||
}
|
||||
let pack = (|| -> R<Value> {
|
||||
let mut pack = if selected_pack["outputs"].as_array().is_some_and(|outputs|
|
||||
outputs.iter().any(|output| output["component"] == component))
|
||||
{
|
||||
selected_pack.clone()
|
||||
} else if selected_set.is_string() {
|
||||
let parts = catalog.as_ref().map_err(Clone::clone)?;
|
||||
let matching: Vec<_> = parts.as_array().into_iter().flatten()
|
||||
.filter(|part| part["kind"] == component).collect();
|
||||
let [part] = matching.as_slice() else {
|
||||
return Err(if matching.is_empty() { "所选企业模板未发布该组件" }
|
||||
else { "模板有多份组件,请明确要使用的原稿" }.into());
|
||||
};
|
||||
let mut request = resource_input.clone();
|
||||
request["action"] = json!("resource-component");
|
||||
request["componentId"] = part["id"].clone();
|
||||
let mut pack = self.enterprise_template_request(request)?["items"][0]["pack"].clone();
|
||||
let response = self.enterprise_template_request(request)?;
|
||||
let item = &response["items"][0];
|
||||
let mut pack = item["pack"].as_object().ok_or_else(|| {
|
||||
let issues = item["issues"].as_array().into_iter().flatten()
|
||||
.filter_map(Value::as_str).collect::<Vec<_>>().join("。");
|
||||
if issues.is_empty() { "未取得组件的原稿和字段映射".into() } else { issues }
|
||||
}).map(|pack| Value::Object(pack.clone()))?;
|
||||
pack["contentHash"] = json!(template_slots::pack_hash(&pack)?);
|
||||
template_slots::validate_pack(&pack)?;
|
||||
if pack["enterprise"]["component"] != component { return Err("固定模板组件与输出类型不符".into()); }
|
||||
if pack["enterprise"]["component"] != component { return Err("模板组件与输出类型不符".into()); }
|
||||
pack
|
||||
} else if matching.is_empty() { independent.clone() }
|
||||
else { return Err(format!("企业模板含多组 {component} 组件,无法确定本次使用的原稿")); }
|
||||
};
|
||||
production_profile::add_image_fields(&mut pack, component)?;
|
||||
packs.insert(component.into(),pack);
|
||||
} else { independent.clone().ok_or("缺少产品版式")? };
|
||||
production_profile::add_image_fields(&mut pack, component)?;
|
||||
Ok(pack)
|
||||
})();
|
||||
match pack {
|
||||
Ok(pack) => { packs.insert(component.into(), pack); }
|
||||
Err(reason) => { blocked.insert(component.into(), json!(reason)); }
|
||||
}
|
||||
}
|
||||
Ok(Value::Object(packs))
|
||||
Ok((Value::Object(packs), Value::Object(blocked)))
|
||||
}
|
||||
|
||||
pub(super) fn canvas_workspace_result(&self, doc: u64, dir: &Path) -> R<Value> {
|
||||
@ -2889,10 +2918,12 @@ impl Backend {
|
||||
next["variants"] = json!(variants);
|
||||
next["activeVariantId"] = json!(active);
|
||||
if production {
|
||||
next["productTemplates"] = if pack["productionRoute"] == "from_scratch" {
|
||||
json!({"detail":pack,"main_images":pack,"sku_images":pack})
|
||||
} else { self.product_templates(&common, pack.clone(), width)? };
|
||||
for stage in production_stages(&next) {
|
||||
let (packs, blocked) = if pack["productionRoute"] == "from_scratch" {
|
||||
(json!({"detail":pack,"main_images":pack,"sku_images":pack}), json!({}))
|
||||
} else { self.product_templates(&common, &pack, width)? };
|
||||
next["productTemplates"] = packs;
|
||||
next["productTemplateIssues"] = blocked;
|
||||
for stage in runnable_stages(&next, production_stages(&next)) {
|
||||
generation_references(&dir, &next, stage["variantId"].as_str().ok_or("制作款式缺失")?)?;
|
||||
}
|
||||
}
|
||||
@ -2933,8 +2964,14 @@ impl Backend {
|
||||
!matches!(record["phase"].as_str(), Some("complete" | "failed"))
|
||||
&& (input["resumeProduct"] != true || !product_slot_binding(&state, &record["binding"])));
|
||||
if unrelated { return Err("请先查询原任务结果".into()); }
|
||||
Some(remaining_stages(&dir, &state, &creation::load(&dir)?["revision"], true)
|
||||
.into_iter().next().ok_or("三类制作成品已在项目中保存")?)
|
||||
let remaining = remaining_stages(&dir, &state, &creation::load(&dir)?["revision"], true);
|
||||
Some(runnable_stages(&state, remaining).into_iter().next().ok_or_else(|| {
|
||||
let blocked = blocked_production_stages(&state);
|
||||
if blocked.is_empty() { return "已选成品均已在项目中保存".to_owned(); }
|
||||
let reasons = blocked.iter().filter_map(|stage| stage["reason"].as_str())
|
||||
.collect::<std::collections::BTreeSet<_>>().into_iter().collect::<Vec<_>>().join("。");
|
||||
format!("所选模板暂无可制作的输出。{reasons}。请核对模板资源后选用新版本。")
|
||||
})?)
|
||||
} else { None };
|
||||
let component = initial.as_ref().and_then(|stage|stage["outputId"].as_str())
|
||||
.or_else(||input["outputId"].as_str()).unwrap_or("detail");
|
||||
@ -2943,6 +2980,9 @@ impl Backend {
|
||||
state["template"]["enterprise"]["component"].as_str().ok_or("固定模板组件缺失")?
|
||||
} else { component }.to_owned();
|
||||
let component = component.as_str();
|
||||
if let Some(reason) = state["productTemplateIssues"][component].as_str() {
|
||||
return Err(reason.to_owned());
|
||||
}
|
||||
let variant_id = output_variant(&state, component, initial.as_ref().and_then(|stage|stage["variantId"].as_str())
|
||||
.or_else(||input["variantId"].as_str()))?.to_owned();
|
||||
if let Some(pack) = state["productTemplates"].get(component) {
|
||||
@ -4044,6 +4084,22 @@ mod tests {
|
||||
assert!(blocked["files"].as_array().unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_blocked_output_remains_required_but_does_not_enter_the_runnable_queue() {
|
||||
let fixture = fixture();
|
||||
let mut state = load(&fixture.dir).unwrap();
|
||||
let variant = state["activeVariantId"].clone();
|
||||
state["brief"]["outputVariantIds"] = json!({"detail":[variant],"main_images":[variant],"sku_images":[]});
|
||||
state["productTemplates"] = json!({"detail":state["template"]});
|
||||
state["productTemplateIssues"] = json!({"main_images":"原稿版本与字段映射不符",
|
||||
"sku_images":"没有发布规格组件"});
|
||||
let remaining = remaining_stages(&fixture.dir, &state, &json!(1), false);
|
||||
assert_eq!(remaining.len(), 2);
|
||||
assert_eq!(runnable_stages(&state, remaining), json!([{"outputId":"detail","variantId":variant}]).as_array().unwrap().clone());
|
||||
assert_eq!(blocked_production_stages(&state), json!([{"outputId":"main_images","variantId":variant,
|
||||
"reason":"原稿版本与字段映射不符"}]).as_array().unwrap().clone());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_colors_survive_save_and_only_the_target_image_type_uses_them() {
|
||||
let fixture = fixture();
|
||||
|
||||
@ -334,3 +334,39 @@ fn published_enterprise_page_without_fixed_text_policy() {
|
||||
"newText":text.text,"mapping":"default","reopened":true})).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires independently downloaded enterprise components"]
|
||||
fn published_sibling_components_bind_the_actual_native_layers() {
|
||||
let root = PathBuf::from(std::env::var_os("JIANSUN_COMPONENT_REPAIR_FIXTURES").unwrap());
|
||||
let variant = Uuid::new_v4().to_string();
|
||||
let mut results = Vec::new();
|
||||
for component in ["main_images", "sku_images"] {
|
||||
let mut prepared = read_json(&root.join(format!("{component}-prepared.json"))).unwrap();
|
||||
let mut pack = prepared["pack"].clone();
|
||||
pack["contentHash"] = json!(super::super::template_slots::pack_hash(&pack).unwrap());
|
||||
prepared["pack"] = pack.clone();
|
||||
super::super::template_cache::confirm_prepared_pack(&pack, &prepared).unwrap();
|
||||
for original in prepared["originals"].as_array().unwrap() {
|
||||
let expected = pack["enterprise"]["components"][component]["originals"].as_array().unwrap().iter()
|
||||
.find(|asset| asset["assetId"] == original["assetId"]).unwrap();
|
||||
assert_eq!(file_digest(Path::new(original["originalPath"].as_str().unwrap())).unwrap(), expected["sha256"].as_str().unwrap());
|
||||
}
|
||||
let doc = slot_canvas::enterprise(&pack, &prepared, component, None, &variant).unwrap();
|
||||
let map = mapping(&doc).unwrap();
|
||||
let fields = page_fields(&map).map(|(_, fields)| fields.len()).sum::<usize>();
|
||||
let expected = pack["outputs"].as_array().unwrap().iter()
|
||||
.map(|page| page["slots"].as_array().unwrap().len()).sum::<usize>();
|
||||
assert_eq!(fields, expected);
|
||||
let preview_path = root.join(format!("{component}-canvas.jpg"));
|
||||
let output = &pack["outputs"][0];
|
||||
let region = (output["top"].as_u64().unwrap(), output["width"].as_u64().unwrap(), output["height"].as_u64().unwrap());
|
||||
let preview = export_jpg_region(&doc, region).unwrap();
|
||||
fs::write(&preview_path, preview.bytes).unwrap();
|
||||
assert_eq!(photocraft_codecs::probe_size(&fs::read(&preview_path).unwrap()).unwrap(), (region.1 as u32, region.2 as u32));
|
||||
results.push(json!({"component":component,"version":pack["version"],"fields":fields,
|
||||
"pages":map["outputs"].as_array().unwrap().len(),"draftPreview":preview_path}));
|
||||
}
|
||||
write_json(&root.join("native-components.json"), &json!(results)).unwrap();
|
||||
}
|
||||
|
||||
@ -110,8 +110,8 @@ impl Workspace {
|
||||
self.messages.push(json!({"role":"user","text":text}));
|
||||
self.note("已接续制作,正在核对当前画布和原请求。");
|
||||
self.agent_effects_paused = false;
|
||||
self.product_production = Some(Run::new(doc, project, workspace, stages, Some(text.into()), Phase::AwaitingSave));
|
||||
self.checkpoint_production();
|
||||
let run = Run::new(doc, project, workspace, stages, Some(text.into()), Phase::AwaitingSave);
|
||||
self.begin_prepared_production(run, &self.template_workflow["productionBlocks"].clone());
|
||||
self.production_tick(app);
|
||||
true
|
||||
}
|
||||
@ -708,6 +708,17 @@ impl Run {
|
||||
}
|
||||
|
||||
impl Workspace {
|
||||
fn begin_prepared_production(&mut self, mut run: Run, blocked: &Value) {
|
||||
for draft in blocked.as_array().into_iter().flatten() {
|
||||
let (Some(stage), Some(reason)) = (Stage::read(draft), draft["reason"].as_str()) else { continue; };
|
||||
self.note(format!("{}暂无法制作。{reason}。请核对所选模板的原稿与字段映射。", stage.label()));
|
||||
run.drafts.push(draft.clone());
|
||||
}
|
||||
run.total += run.drafts.len();
|
||||
self.product_production = Some(run);
|
||||
self.checkpoint_production();
|
||||
}
|
||||
|
||||
fn write_production_checkpoint(&self, run: &Run, active: bool) {
|
||||
let Some(project) = run.project.rsplit('|').next() else { return; };
|
||||
let checkpoint = json!({
|
||||
@ -799,8 +810,8 @@ impl Workspace {
|
||||
let goal_user_entry = self.messages.iter().rev().find(|message| message["role"] == "user")
|
||||
.and_then(|message| message["text"].as_str())
|
||||
.filter(|text| matches!(*text, "制作详情、主图和 SKU" | "继续整套制作")).map(str::to_owned);
|
||||
self.product_production = Some(Run::new(doc, project, meta["workspaceId"].clone(), stages, goal_user_entry, Phase::CanvasRequested));
|
||||
self.checkpoint_production();
|
||||
let run = Run::new(doc, project, meta["workspaceId"].clone(), stages, goal_user_entry, Phase::CanvasRequested);
|
||||
self.begin_prepared_production(run, &meta["workflow"]["productionBlocks"]);
|
||||
}
|
||||
if self.product_production.as_ref().is_none_or(|run| !run.current(self, app) || !run.accepts_canvas(meta)) {
|
||||
self.product_production = None;
|
||||
@ -831,7 +842,9 @@ impl Workspace {
|
||||
}
|
||||
let Some(run) = self.product_production.as_mut() else { return };
|
||||
let Some(stage) = run.stages.front() else { return };
|
||||
let text = format!("制作{} · {}/{}", stage.label(), run.total - run.stages.len() + 1, run.total);
|
||||
let blocked = self.template_workflow["productionBlocks"].as_array().map_or(0, Vec::len);
|
||||
let runnable = run.total.saturating_sub(blocked);
|
||||
let text = format!("制作{} · {}/{}", stage.label(), runnable.saturating_sub(run.stages.len()) + 1, runnable);
|
||||
run.phase = Phase::Agent;
|
||||
self.agent_effects_paused = false;
|
||||
self.submit_turn(app, text, true);
|
||||
@ -1124,6 +1137,31 @@ mod tests {
|
||||
use super::*;
|
||||
use std::sync::mpsc;
|
||||
|
||||
#[test]
|
||||
fn a_blocked_template_is_reported_without_adding_a_runnable_stage() {
|
||||
let (tx, requests) = mpsc::channel();
|
||||
let (_, rx) = mpsc::channel();
|
||||
let mut w = Workspace::new(tx, rx);
|
||||
let _ = requests.try_recv().unwrap();
|
||||
let run = Run::new(1, "account|project".into(), json!("workspace"), VecDeque::from([
|
||||
Stage { output:"detail".into(), variant:"wood".into() },
|
||||
]), None, Phase::CanvasRequested);
|
||||
let blocked = json!([{"outputId":"main_images","variantId":"wood","reason":"字段映射版本不一致"}]);
|
||||
w.begin_prepared_production(run, &blocked);
|
||||
let run = w.product_production.take().unwrap();
|
||||
assert_eq!(run.stages.len(), 1);
|
||||
assert_eq!(run.total, 2);
|
||||
assert_eq!(w.messages[0]["text"], "主图暂无法制作。字段映射版本不一致。请核对所选模板的原稿与字段映射。");
|
||||
let mut run = run;
|
||||
run.stages.clear();
|
||||
run.completed = 1;
|
||||
w.note_production_summary(run);
|
||||
let summary = &w.messages.last().unwrap()["productionSummary"];
|
||||
assert_eq!(summary["exported"], 1);
|
||||
assert_eq!(summary["total"], 2);
|
||||
assert_eq!(summary["drafts"], blocked);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn production_deadline_settles_when_the_agent_request_is_still_busy() {
|
||||
let (tx, requests) = mpsc::channel();
|
||||
|
||||
@ -198,3 +198,13 @@ Node 范围回归 162 项通过,另有采纳本轮超时定向回归 9 项通
|
||||
|
||||
实机根因定位在 `apps/detail-photocraft/apps/photocraft/src/jiansun_canvas_workspace.rs` 的 `product_templates`。组件返回具体问题但没有 `pack` 时,空值传给 `pack_hash` 后丢失组件问题。生产文件版本核对按原流程执行。
|
||||
|
||||
### 7. 企业组件原稿绑定与局部阻塞
|
||||
|
||||
对顾家电脑桌正式资源组复核后,确认主图的五个 PSD 和 SKU 的一个 PSD 与字段映射声明的 SHA-256 全部一致。映射使用原稿局部编号,资源组发布使用组件内的附件编号。读取器按原稿路径和摘要核对两种编号并绑定同一发布文件。原稿校验后再加载图层。已保存项目继续使用固定版本。
|
||||
|
||||
组件读取失败时,项目保留详细原因,该组件仍计入必需交付集合。其余具备依赖的组件进入既有执行队列。时间轴说明被阻塞的组件,最终只有通过既有导出门禁的成果计为交付。修正资源后,选择新版本进行制作。
|
||||
|
||||
原始对照和组件证据在 `audit-corrections/desk-template-repair/`。真实企业资料读取已通过,详情 22 页、主图 5 页、SKU 1 页。资源回归 21 项通过,覆盖局部编号、来源路径错误和摘要错误。
|
||||
|
||||
PhotoCraft 用正式文件独立导入了 5 张主图和 1 张 SKU,并按原稿编号、图层名、层级和类型绑定全部 35 个字段。主图首张和 SKU 原稿预览在本机生成并检查。原生回归 3 项与运行状态回归 3 项通过,覆盖组件阻塞、必需交付计数、已有图位审核及到期结算。证据见 `native-components.json`、`native-regression.log`、`ui-regression.log`。本轮验收覆盖正式资源和原稿画布,98K 整套制作另行验证。
|
||||
|
||||
|
||||
@ -25,3 +25,6 @@
|
||||
固定文案许可由组件映射中的 `production_profile` 发布。`staticText` 指定固定文字,`keepTextLayerIds` 允许原文字保留。字段都缺省时,成品回执记录未发布许可并走常规图文交付检查。显式发布空清单表示没有固定文字获许可。编辑稿和导出回执记录所用 profile 的发布来源与版本。
|
||||
|
||||
文案字段可用 `style_roles` 声明需要保持的样式角色,并用 `maxLines` 指定可用行数。未声明样式角色的字段按原稿段落顺序套用样式,额外的行继承最后一段样式,跨样式替换使用起点样式。超出实际排版范围时,缩短对应文字后重新提交。
|
||||
字段映射里的局部原稿编号与企业资源附件编号不同时,`source.assets` 需要声明 `ps_asset_path` 和 `ps_sha256`。客户端按发布路径和摘要一一核对,随后用发布附件的身份固定原稿。页面和字段继续通过映射里的局部编号关联该原稿。
|
||||
|
||||
组件资源错误仅阻塞受影响的输出。项目保留原有交付要求和错误原因,其余资源齐备的输出可以继续制作。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user