LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-vega
createdAtNov 7, 2026, 6:15 PM
updatedAtNov 7, 2026, 6:48 PM
githubUrlhttps://github.com/neomjs/neo/issues/20568
authorneo-opus-vega
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 7, 2026, 6:48 PM

A re-added tree node stops expanding once the store sorts

neo-opus-vega
neo-opus-vega commented on Nov 7, 2026, 6:15 PM

Context

In Neo Pro's Workstation demo the grouped 100k matrix sorts its states by value (neomjs/neo-pro#10, sorters: [{property: 'status'}]). Since then, clicking a fleet's expand toggle on first load does nothing: 36 rows stay 36. Neo Pro's grouped e2e records it, red on its dev. Measured:

  • With the sorter removed, the same click expands (bisected on the Pro store).
  • A Pro unit arm expanding healthy › Atlas on the store shows the row count unchanged, and the Atlas record no longer in the store (indexOf → -1).

The Problem

In Turbo Mode (autoInitRecords: false), re-adding a key that already exists:

  1. replaces the node in the Structural Layer (#allRecordsMap.set; #addChild() swaps the sibling), while
  2. Collection#splice skips keys already in map, so the visible layer keeps its old object.

The two layers now hold different objects for one key. get() hydrates the visible object, and TreeStore#hydrateRecord() heals #childrenMap by identity only (siblings.indexOf(item)). The structural sibling is a different object, so the heal misses silently.

expand() then marks the hydrated Record expanded and splices its children in. A sorted store re-sorts after every add (Collection#splice → doSort()), and TreeStore#doSort() re-projects _items from the Structural Layer. There it meets the stale raw node, still collapsed: the children vanish and the raw object replaces the Record.

Measured in the engine alone (no Pro code): a re-added root expanded in a sorted Turbo store loses its child. The unsorted control passes.

The Architectural Reality

  • src/data/TreeStore.mjs#hydrateRecord (the identity heal) versus #addChild(), which already falls back to a key scan for "a node whose two map entries have drifted apart".
  • src/data/TreeStore.mjs#doSort re-projects from #childrenMap; src/collection/Base.mjs#splice sorts after an add when autoSort and sorters are set.
  • Neo Pro's GroupingStore re-applies its projected data once construction finishes, which re-adds every group key. That is how the demo reaches the drift.

The Fix

TreeStore#hydrateRecord: when identity misses, find the sibling by key, the same fallback #addChild() uses, and heal it.

Unit test: test/playwright/unit/data/TreeStoreReAddExpand.spec.mjs re-adds a root as a new object and expands it, with sorters and without (control). The sorted arm fails on dev.

Acceptance Criteria

  • AC-1: A re-added node expands in place while the store sorts: the new spec, red on dev, green at the head; the control passes on both.
  • AC-2: unit/data, unit/grid and unit/collection stay green.
  • AC-3: Neo Pro's Workstation matrix expands a fleet on first load: neomjs/neo-pro#23's receipts run against this head.

Out of Scope

  • Making Collection#splice replace the visible object on a re-add. That changes what a re-add means for every store; this ticket only stops the layers from staying split.
  • GroupingStore's construct-time re-apply (neomjs/neo-pro#15 / #16), which is legitimate.

Related

#9432 (TreeStore split-brain on clear()), neomjs/neo-pro#10 (the sorter that exposed it), neomjs/neo-pro#23.

Sweeps: latest open engine issues plus all-state searches ("TreeStore hydrateRecord expand", "TreeStore split-brain childrenMap": #9432, #9539, #9411, #20212, #17839, none on this path), the A2A in-flight sweep and my own assignments, at 2026-11-07T17:1xZ. No equivalent found.

Retrieval Hint: "TreeStore hydrateRecord identity heal re-add sorted expand"

tobiu referenced in commit 6a88a7c - "fix(data): a re-added tree node keeps expanding once the store sorts (#20568) (#20569) on Nov 7, 2026, 6:48 PM
tobiu closed this issue on Nov 7, 2026, 6:48 PM