LearnNewsExamplesServices
Frontmatter
id9538
titleEnhance Collection.updateKey() to support filtered collections (allItems map)
stateClosed
labels
enhancementaicore
assigneestobiu
createdAtMar 24, 2026, 9:49 AM
updatedAtMar 27, 2026, 10:08 AM
githubUrlhttps://github.com/neomjs/neo/issues/9538
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMar 27, 2026, 10:08 AM

Enhance Collection.updateKey() to support filtered collections (allItems map)

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) correctly updates the primary map without mutating the _items array. However, it fails to account for filtered collections.

When a collection is filtered, it creates an allItems collection to store the unfiltered dataset. If a key is updated while the collection is filtered, the map inside me.allItems must also be updated to prevent a stale key mapping.

Proposal

Update src/collection/Base.mjs -> updateKey() to check for the existence of me.allItems. If it exists, perform the identical map delete/set operation on me.allItems.map.

// Pseudo-code concept:
if (me.allItems) {
    me.allItems.map.delete(oldKey);
    me.allItems.map.set(newKey, item);
}
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 referenced in commit c133b97 - "feat: Enhance Collection.updateKey() to support filtered collections (#9538)" on Mar 27, 2026, 10:08 AM
tobiu
tobiu Mar 27, 2026, 10:08 AM

Input from Antigravity:

◆ I have completed the implementation for this issue.

Summary of Changes:

  1. Modified updateKey(item, newKey) in src/collection/Base.mjs to accurately propagate key changes to allItems.map when a collection is filtered.
  2. Added comprehensive unit tests in test/playwright/unit/collection/Base.spec.mjs verifying that updateKey() handles both unfiltered and filtered collections seamlessly without breaking the indexing map.
  3. Successfully executed npm run test-unit against the base collection specification, recording 9/9 passes.

The changes have been pushed to the remote repository and the issue is now complete.

tobiu assigned to @tobiu on Mar 27, 2026, 10:08 AM
tobiu closed this issue on Mar 27, 2026, 10:08 AM