fix(ppt-live): tolerate bad project JSON and degrade unexportable elements#1617
Merged
bobleer merged 1 commit intoJul 18, 2026
Conversation
…ments Generation: - Parse agent-written project.json tolerantly: strip markdown fences, JS comments and trailing commas, and repair truncated documents, instead of aborting the whole generation on invalid_project_json. - Retry recoverable file-contract failures (bad/missing project.json, missing slides, unreadable deck) with more bounded continuation attempts so the agent finishes the deck in the same session. Export: - Add an export degradation layer (export-degrade.js): unsupported styles (box-shadow, text-shadow, filter, mask, animation, background images, inline margins) are stripped, unrepresentable SVG constructs are simplified or removed, unexportable elements are removed, and a slide that still fails is replaced with a simplified editable scene. - Map multi-layer and negative/soft-spread box-shadows to the first usable native outer shadow layer instead of blocking. - Guard OOXML serialization per slide: a scene that fails to serialize is replaced with a blank slide instead of failing the whole deck. - Report every degradation in the export summary (new 'degraded' count and phase, localized reasons for all degrade codes). - Update the ppt-design authoring contract to describe degradation and drop the retired fail-closed preflight audit from the export path. Bump builtin-ppt-live to version 232.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
PPT Live 的两个高频可用性问题:
project.json一旦出现 markdown 围栏、JS 注释、尾随逗号或写入截断,严格JSON.parse直接抛出invalid_project_json,一次续跑失败就"生成未完成"异常结束。pptx-source-NN的多层/inset/spread box-shadow、text-shadow、filter、SVG paint server 等),整个 deck 导出直接失败。修改
生成链路:容错 + 让 agent 把活做完
deck-project-contract.js新增容错 JSON 解析链:剥离围栏/注释/尾随逗号 → 截断文档修复(闭合字符串与括号、丢弃不完整尾部片段);仅在全部修复失败后才报invalid_project_json(仍带定向续跑提示)。导出链路:降级而不是阻断
export-degrade.js降级层:parseBoxShadow优化:多层 shadow 取首个可用非 inset 层映射为原生 outer shadow;负/柔 spread 按 0 近似;纯 ring 仍走既有的同心 shape 重写。options.onDegrade汇入导出摘要:新增degraded计数与"降级处理"阶段标签,所有降级码均有中英文案。preflight-slide-audit(其阻断项要么被 sanitizer 中和,要么由降级循环处理)。验证
node --test src/crates/contracts/product-domains/src/miniapp/builtin/assets/ppt-live/test/*.test.mjs:181/181 通过(含新增的多层 shadow、负 spread、inset 剥离、text-shadow 剥离、元素跳过、简化场景、容错 JSON 等用例)。cargo check -p bitfun-product-domains通过。