LearnNewsExamplesServices
Frontmatter
id18668
titleSelection models share their selection arrays per class: selectedRows / selectedColumns (grid) and selectedRowIds / selectedColumnCellIds (table) are static-config defaults, so two grids on one model class select together
stateClosed
labels
bugai
assigneesneo-fable-clio
createdAtSep 13, 2026, 5:14 PM
updatedAtSep 13, 2026, 9:01 PM
githubUrlhttps://github.com/neomjs/neo/issues/18668
authorneo-fable-clio
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 13, 2026, 9:01 PM

Selection models share their selection arrays per class: selectedRows / selectedColumns (grid) and selectedRowIds / selectedColumnCellIds (table) are static-config defaults, so two grids on one model class select together

neo-fable-clio
neo-fable-clio commented on Sep 13, 2026, 5:14 PM

Context

Two grids on the same selection-model class share one selection today. Measured 2026-09-13 in the engine's unit runtime (Playwright unit project, dev-equivalent source at agent/18626-view-owned-selection@8d8799643e, src/selection/grid/BaseModel.mjs unchanged from dev): Neo.create(RowModel).selectedRows === Neo.create(RowModel).selectedRows is true; after modelA.selectedRows.push(3) a fresh Neo.create(RowModel).selectedRows reads [3]; RowModel.config.selectedRows is that same array. CellRowModel, CellModel and ColumnModel each share their own copy per class; the table family declares the same kind of static arrays under its own names. CI surfaced it first: unit job 103741193182 (PR #18661, head 8d8799643e) ran two grid arms in one worker in file order — a RowModel grid selected record 3 and was destroyed, the next RowModel grid adopted records 2 and 4 from its own store and read [3, 2, 4]; the retry ran alone and passed. In an app: a Workstation with two grids on the default RowModel and colliding business ids paints a row in the second grid the moment the first selects it, and the second grid's singleSelect deselects the first's row.

The Problem

src/selection/grid/BaseModel.mjs:21 and :27 declare selectedColumns: [] and selectedRows: [] as NON-reactive static configs. core.Base#mergeConfig (src/core/Base.mjs:764, {...staticConfig, ...config}) copies a static default by reference and setFields assigns it as the instance's own property — so a mutable default is one object per class, and NeoArray.add(me.selectedRows, recordId) / NeoArray.remove (BaseModel.mjs:238, 363) mutate the class's array in place. BaseModel#unregister (:394) assigns the DESTROYED instance a fresh [] and leaves the class array populated for the next instance. The table family repeats the pattern: selectedRowIds: [] (src/selection/table/CellRowModel.mjs:29) and selectedColumnCellIds: [] (src/selection/table/CellColumnModel.mjs:34, src/selection/table/CellColumnRowModel.mjs:34) — five static arrays across the selection family. Neo.selection.Model#items_ (src/selection/Model.mjs) already carries the per-instance descriptor; the subclasses' arrays never got it.

The Architectural Reality

This is the #18198 class — grid.Body's row and column windows were the same static-array default, fixed with config descriptors after the maintainer's ruling there (descriptors are the Neo-native shape; a construct() copy and instance fields were dropped). The config-system side (why a static reference default is not cloned per instance) is D#18195 / #18192 and stays there.

The Fix

The five arrays — grid selectedColumns_ / selectedRows_, table selectedRowIds_ / selectedColumnCellIds_ (twice) — become reactive configs with the Neo.selection.Model#items_ / grid.Body#mountedRows_ descriptor: {[isDescriptor]: true, clone: 'shallow', cloneOnGet: 'none', value: []} — clone makes the default per instance, cloneOnGet: 'none' keeps the in-place NeoArray.add / remove writes landing (the engine's default copies arrays on every read, so a write would land in a discarded copy). Every reader and writer keeps its name (me.selectedRows, me.selectedColumns = [...], me.selectedRowIds, toJSON). The full invariant closes in one commit — a partial fix of a shared-state invariant burns the next review cycle (#14153).

Contract Ledger

Not applicable: no public surface changes shape — all five members keep their names, types and semantics; only their per-instance identity is repaired.

Acceptance Criteria

  • AC-1 Two grids on the same model class hold distinct selectedRows and selectedColumns arrays; a row selected in the first is not held or painted by the second.
  • AC-2 A grid created after another grid on the same model class was destroyed starts with an empty selection.
  • AC-3 Every grid and table selection model instance owns its arrays: an identity arm over the nine model classes (selectedRows, selectedColumns, selectedRowIds, selectedColumnCellIds distinct per instance, an in-place push on one instance invisible to a fresh one) — red on the current source.
  • AC-4 The existing selection arms (unit/grid, unit/selection, e2e SelectionMultiBody, BigDataMultiBodyNL) stay green; unit/grid/ViewOwnedSelectionModel.spec.mjs is deterministic in any worker order (AC-1 / AC-2 are red on the current source too).

Out of Scope

The config-system gap (D#18195 / #18192); Neo.selection.Model#items_ (already a descriptor); the add: [] literals in GalleryModel / HelixModel (method-local update payloads, not defaults).

Avoided Traps

  • Instance fields (selectedRows = []) or a construct() copy — dropped in #18198 by the maintainer; descriptors are the shape.
  • A descriptor without cloneOnGet: 'none' — the default read copy would swallow every in-place write (#18198's second finding).
  • Reading the leak as a test-ordering flake and re-keying the spec's records per arm — that hides the defect the arm just measured.

Related

#18198 (the same class in grid.Body, the ruling) · #18626 / PR #18661 (where the CI-admitted arms surfaced it; the fix ships there) · D#18195 / #18192 (config-system side) · #9839 (the retired Peer State Adoption, which had copied selectedRows between models by reference on purpose).

Live latest-open sweep: the latest 20 open issues at 2026-09-13T15:10Z — none equivalent (#18666 is a benchmark bound, unrelated); search "selectedRows shared" → #18198 (closed, sibling class) and the multi-body tickets. A2A in-flight claim sweep: the grid-selection lane is mine (#18626). Memory Core rationale sweep: no prior decision on per-instance selection arrays; the 2026-06 peer-state-adoption design copied them by reference on purpose, retired with the View-owned model. Own-assignment sweep: #18626, #18604 (different defects). Sweep of src/selection/** for non-reactive array defaults (grep -rn '^\s*[a-zA-Z]\+\s*:\s*\[\]'): the five configs above; the three other hits are the items_ descriptor's value and two method-local add: [] payloads.

Origin Session ID: a1d12cdc-a975-4f69-a14e-50cc28343691 Retrieval Hint: "selection grid BaseModel selectedRows shared across instances static config array clone descriptor"

📜 Clio · @neo-fable-clio · Claude Fable 5.1 · Claude Code · session a1d12cdc-a975-4f69-a14e-50cc28343691