openpencil/apps
Fini f7412cb26c fix(ai): JSONL fallback appends roots in subtask order, not reverses them
`store.addNode` defaults to `index: 0` (prepend) — appropriate for new
shapes a user draws on canvas (topmost in z-order), but wrong for
sub-agent generation where each subtask emits a section that should
appear AFTER the previous subtask's output in document order.

The previous JSONL fallback called `addNode(parentId, root)` without
an explicit index, so every subtask's output prepended to the previous
ones. Result: the last subtask landed first in the root frame's children
and the first subtask was pushed to the bottom. Real-world repro:
a food-app brief with sections [status-bar, header, search, categories,
banner, popular, recommended, bottom-nav] produced [recommended,
popular, banner, header, search, status-bar, categories, "what are
you craving", bottom-nav] — same nodes, reversed order.

Compute the parent's current `children.length` for each insert and
pass it as the explicit index so roots append at the end of the
parent. Order matches subtask iteration order, matches the brief.

The default-prepend behavior of `addNode` is unchanged for other
callers (drawing tools, paste, etc) — only this dispatcher path
overrides it.
2026-05-05 01:52:26 +08:00
..
cli Merge origin/v0.8.0 into feat/rust-ification 2026-05-03 21:00:00 +08:00
desktop Merge origin/v0.8.0 into feat/rust-ification 2026-05-03 21:00:00 +08:00
web fix(ai): JSONL fallback appends roots in subtask order, not reverses them 2026-05-05 01:52:26 +08:00