feat(scene): add node serialization and batch restoration - #934
feat(scene): add node serialization and batch restoration#934YuchenWell wants to merge 5 commits into
Conversation
- Add Node.serialize and Node.createBySerializedData APIs - Preserve internal references and handle prefab and external references - Support atomic batch creation and grouped Undo/Redo - Update public types and add rollback and real-engine tests
c29127f to
8b6a2e1
Compare
c7f59a0 to
b5e271e
Compare
knoxHuang
left a comment
There was a problem hiding this comment.
Three-axis review of head b5e271e9 (merge-base ee94053): repo standards, PR spec, and module design.
Overall the implementation is faithful to the PR description — all five Changes items are verified in code, all four Test Plan bullets have real coverage, the out-of-scope boundary (PinK clipboard / paste UI) is respected, and CI is green.
Findings anchored inline: 1 documented-rule violation (undo snapshot lacks the path fallback required by docs/dev/scene/core/undo-redo.md), 1 file-style inconsistency (the two new API methods miss the bilingual JSDoc used by every sibling), plus judgement-level notes: seam placement (mountSerializedNodes living in the undo-command module), duplicated guard/cleanup code, boolean control coupling (preservePrefab/preserveIdentity), the $nodeReference magic string, SerializedNodeData naming, an exported internal seam with no external consumer, and a redundant double-destroy after rollback.
The changes are available in 6e644e4. Each of the 14 inline comments has a separate reply. Changes made:
Validation: TypeScript checking, compilation, and MCP type generation pass. All 46 outer tests across six relevant suites pass, including a subprocess with 31 passing real-engine checks. ESLint reports no new diagnostics compared with the previous head; the existing one error and two warnings remain. No UI or manual editor acceptance testing was performed. |
|
Re-review at head Confirmed
Withdrawn (see thread replies): the double-destroy redundancy (engine's Remaining nits
(Note: I could not mark the four remaining threads resolved — no permission on this repo; the acceptance replies are posted in-thread.) |
knoxHuang
left a comment
There was a problem hiding this comment.
Approving at head 6e644e46 (re-verified: OPEN, MERGEABLE/CLEAN, all four checks — check-changes, check-dts, pr-test macOS + windows — completed successfully on this exact head).
Everything raised in my initial 14-comment review is now either fixed and verified in the incremental diff (b5e271e...6e644e4), withdrawn with evidence, or turned into a documented, regression-tested deviation:
- mount/rollback seam moved to
service/node/serialized-node-mount.tswith the dependency direction corrected, tests and mocks updated consistently; - type drift, magic string, exported internal seam, schema invariant, JSDoc, and
undo-redo.mdsync all addressed; - the uuid-only structural snapshot now has an explicit documented exception plus two real-engine regressions proving same-name replacement is rejected on both undo and redo.
Remaining nits are non-blocking and can be handled in follow-ups:
- The two new Chinese
it()names in the otherwise-Englishserialized-node-data.engine-test.ts. - The
undo-redo.mdstandards amendment (l.424 exception + rule 12 revision) — rationale and tests are sound; flagging for explicit maintainer visibility since it changes a previously documented rule.
Background
Provide the cocos-cli foundation for cross-scene node copying by exporting selected node hierarchies as transferable data and restoring them in a target scene.
Changes
Node.serializeandNode.createBySerializedData, serializing all selected roots together to preserve internal node and component referencesvalueReplacerhandling parent links, prefab metadata, and external references without modifying source nodesScope
Test Plan