Context
I found this while fixing #19187 and promoted it from defect-note 2f45fa099d0c29d5 on a triage decision: I own the adjacent lane, and the fix is a single index translation. In the Workstation film, the tear-out vessel's Metrics tab reads "⠿Metrics", with the stack handle before the text, while its vdom orders [text, handle]. The freshly rendered Commits tab reads "Commits⠿", which is correct.
The Problem
- Captured in the film. This was at the vessel's
DeltaUpdates#update, #19182 head e7f95d9043. The text span was first inserted as <!-- neo-vtext-2 -->Metrics<!-- /neo-vtext -->, followed by {action: 'moveNode', id: 'neo-dock-stack-handle-metrics', index: 1, parentId: <that span>}. DOM index 1 is the text node inside the vtext's comment wrapper, so the handle lands inside the wrapper.
- Reproduced with pure
VdomHelper.
- The old tree holds the handle in another span. The new tree inserts
span#new-label with [vtext, handle].
- The deltas are
insertNode new-label (markup without the handle) and then moveNode handle {index: 1, parentId: 'new-label'}.
- The physical index is 3.
- Beyond the order.
DeltaUpdates#updateVtext writes startComment.nextSibling.nodeValue. With the handle trapped behind the opening comment, that sibling is the handle element, and setting nodeValue on an element does nothing. Later text updates for that label are therefore silently dropped.
The Architectural Reality
Helper#insertNode builds the inserted subtree's markup or pruned vnode without the moved nodes. It then pushes one moveNode per moved node with index: details.index, which is the logical index within the new parent.
Helper#moveNode, the standalone path, translates the logical index with getPhysicalIndex(parentNode, index). A text child counts as three DOM nodes, and a fragment counts as its anchors plus its children.
DeltaUpdates#moveNode inserts before parentNode.childNodes[index], which is a DOM index.
The Fix
- Translate the index. In
Helper#insertNode's moved-node loop, emit index: me.getPhysicalIndex(details.parentNode, details.index). Moves apply in order, so sibling moved nodes see the DOM that the earlier moves built.
- Red-first test. Add a unit case to
Helper.spec.mjs: a node moved into a freshly inserted subtree after a text child gets index 3.
Acceptance Criteria
Out of Scope
- The
removeAll that erased the label after the compose: #19187, PR #19189.
- Which tab carries the stack handle.
Related
#19187 · #19189 · #19182 · #15252
Sweeps (at filing):
- Live latest-open: latest 20 open issues, none equivalent.
- A2A: the 30 latest messages hold no claim on this scope.
- MC: no prior decision on moved-node indices inside inserted subtrees.
- Own assignments: #19186–#19188 are adjacent, not equivalent.
- Structure map: not applicable, since this is not
ai/.
Origin Session ID: 101d2ce9-9f43-4f5a-9ae2-3c75bf8f6fcf
Retrieval Hint: "vdom moveNode logical index inserted subtree vtext comment wrapper stack handle"
Context
I found this while fixing #19187 and promoted it from defect-note
2f45fa099d0c29d5on a triage decision: I own the adjacent lane, and the fix is a single index translation. In the Workstation film, the tear-out vessel's Metrics tab reads "⠿Metrics", with the stack handle before the text, while its vdom orders[text, handle]. The freshly rendered Commits tab reads "Commits⠿", which is correct.The Problem
DeltaUpdates#update, #19182 heade7f95d9043. The text span was first inserted as<!-- neo-vtext-2 -->Metrics<!-- /neo-vtext -->, followed by{action: 'moveNode', id: 'neo-dock-stack-handle-metrics', index: 1, parentId: <that span>}. DOM index 1 is the text node inside the vtext's comment wrapper, so the handle lands inside the wrapper.VdomHelper.span#new-labelwith[vtext, handle].insertNode new-label(markup without the handle) and thenmoveNode handle {index: 1, parentId: 'new-label'}.DeltaUpdates#updateVtextwritesstartComment.nextSibling.nodeValue. With the handle trapped behind the opening comment, that sibling is the handle element, and settingnodeValueon an element does nothing. Later text updates for that label are therefore silently dropped.The Architectural Reality
Helper#insertNodebuilds the inserted subtree's markup or pruned vnode without the moved nodes. It then pushes onemoveNodeper moved node withindex: details.index, which is the logical index within the new parent.Helper#moveNode, the standalone path, translates the logical index withgetPhysicalIndex(parentNode, index). A text child counts as three DOM nodes, and a fragment counts as its anchors plus its children.DeltaUpdates#moveNodeinserts beforeparentNode.childNodes[index], which is a DOM index.The Fix
Helper#insertNode's moved-node loop, emitindex: me.getPhysicalIndex(details.parentNode, details.index). Moves apply in order, so sibling moved nodes see the DOM that the earlier moves built.Helper.spec.mjs: a node moved into a freshly inserted subtree after a text child gets index 3.Acceptance Criteria
dev.Out of Scope
removeAllthat erased the label after the compose: #19187, PR #19189.Related
#19187 · #19189 · #19182 · #15252
Sweeps (at filing):
ai/.Origin Session ID: 101d2ce9-9f43-4f5a-9ae2-3c75bf8f6fcf Retrieval Hint: "vdom moveNode logical index inserted subtree vtext comment wrapper stack handle"