LearnNewsExamplesServices
Frontmatter
id9539
titleAdd TreeStore override for updateKey()
stateClosed
labels
enhancementaicore
assigneestobiu
createdAtMar 24, 2026, 9:49 AM
updatedAtMar 27, 2026, 10:26 AM
githubUrlhttps://github.com/neomjs/neo/issues/9539
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMar 27, 2026, 10:26 AM

Add TreeStore override for updateKey()

Closed v12.1.0 enhancementaicore
tobiu
tobiu commented on Mar 24, 2026, 9:49 AM

Objective

The newly added updateKey(item, newKey) method in Neo.collection.Base (introduced via PR #9536) does not currently support Neo.data.TreeStore.

TreeStore extends Store (which extends Collection) but manages its own "Structural Layer" via two private maps: #allRecordsMap and #childrenMap.

If updateKey is called on a TreeStore, the base collection map is updated, but the private structural maps are not, which will cause the tree hierarchy to break (split-brain state).

Proposal

Implement an override for updateKey(item, newKey) inside src/data/TreeStore.mjs.

  1. Call super.updateKey(item, newKey) to handle the base collection maps.
  2. Update #allRecordsMap to reflect the new key.
  3. If the item is a parent node, its key might be used as the parentId for other nodes in #childrenMap. The override needs to ensure that #childrenMap remains structurally sound (this might require re-mapping the children array to the new key).
tobiu added the enhancement label on Mar 24, 2026, 9:49 AM
tobiu added the ai label on Mar 24, 2026, 9:49 AM
tobiu added the core label on Mar 24, 2026, 9:49 AM
tobiu cross-referenced by PR #9536 on Mar 24, 2026, 9:52 AM
tobiu
tobiu Mar 27, 2026, 10:25 AM

Input from Gemini 3.1 Pro (Antigravity):

✦ Implementation for Neo.data.TreeStore.updateKey() override has been completed.

Summary of Changes:

  1. Intercepted updateKey(item, newKey) on TreeStore.
  2. Guaranteed the base layer (Projection maps) receives the update via super.updateKey.
  3. Safely re-mapped the node in #allRecordsMap to ensure O(1) fetch integrity.
  4. If the item was a parent node, correctly renamed its key inside #childrenMap and recursively iterated over its children to update their parentId references inline.
  5. Added unit tests for TreeStore updates covering active projection mapping and Turbo Mode records.

The changes have been pushed to remote and the ticket is now closed.

tobiu referenced in commit 17d3ff4 - "feat(TreeStore): add updateKey override (#9539)" on Mar 27, 2026, 10:26 AM
tobiu assigned to @tobiu on Mar 27, 2026, 10:26 AM
tobiu closed this issue on Mar 27, 2026, 10:26 AM