Skip to content

feat(grid): View reads the selected rows as records (#21102) - #21132

Merged
tobiu merged 2 commits into
neomjs:devfrom
Mittalnew:feat/grid-selected-records-21102
Nov 16, 2026
Merged

tobiu merged 2 commits into
neomjs:devfrom
Mittalnew:feat/grid-selected-records-21102

Conversation

@Mittalnew

Copy link
Copy Markdown
Contributor

Resolves #21102

Adds a selectedRecords getter on Neo.grid.View, next to selectedRows, so "which records are selected?" is one call: grid.view.selectedRecords. Each selected row id is resolved through the model's getRowRecord(); an id that resolves to no record is left out, and the getter returns [] under a cell or column model or when there is no model. The JSDoc of View#selectedRows and BaseModel#selectedRows_ now says which ids they hold (the store's internal ids while useInternalId is true, record keys otherwise) and points to the new getter. CellEditing#editSelectedCell now reads the row's record through the getter instead of calling getRowRecord itself, and the Grids guide's "Selection Models" section has a short paragraph on reading a selection. Additive only: no public behavior changes and nothing to migrate.

Evidence: L2 (new unit specs + grid/selection unit suites + CellEditingPooling e2e run locally) -> L2 required (#21102 ACs: unit spec, e2e passing unchanged).

AC Evidence

AC Proof
AC-1 selectedRecords under RowModel, useInternalId true and false, plus cell model / column model / selectionModel: null empty cases test/playwright/unit/grid/ViewOwnedSelectionModel.spec.mjs, describe "the View reads the selected rows as records (#21102)"; npm run test-unit -- test/playwright/unit/grid/ViewOwnedSelectionModel.spec.mjs -> 24 passed
AC-2 an unresolvable id is left out, the others keep their order same describe, "an id that resolves to no record is left out..." (selects 3, 99, 1, expects records 3, 1)
AC-3 both JSDoc lines name the id kind src/grid/View.mjs (selectedRows), src/selection/grid/BaseModel.mjs (selectedRows_)
AC-4 CellEditing#editSelectedCell has no getRowRecord call; CellEditingPooling passes unedited src/grid/plugin/CellEditing.mjs; npm run test-e2e -- test/playwright/e2e/grid/CellEditingPooling.spec.mjs -> 48 passed, no spec edits
AC-5 timeline example reads grid.view.selectedRecords[0] Not done: examples/timeline/basic/Viewport.mjs arrives with #21044, which is still open, so this box stays unchecked as the ticket says
AC-6 Grids guide paragraph learn/guides/datahandling/Grids.md, "Selection Models"

Deltas from ticket

The timeline example change (AC-5) is left out because #21044 is not merged yet. Once it lands, the example can switch to grid.view.selectedRecords[0]; I'm happy to do that in a follow-up.

Test Evidence

  • npm run test-unit -- test/playwright/unit/grid/ViewOwnedSelectionModel.spec.mjs: 24 passed (3 new).
  • npm run test-unit -- test/playwright/unit/grid test/playwright/unit/selection: 524 passed.
  • npm run test-e2e -- test/playwright/e2e/grid/CellEditingPooling.spec.mjs: 48 passed.
  • I checked that the new spec catches a broken getter: when I changed it to resolve ids with store.get(id) and not drop missing ones, the unresolved-id test failed.

Post-Merge Validation

None required.

Authored by @Mittalnew

Adds `Neo.grid.View#selectedRecords` beside `selectedRows`: the records of
the selected rows, each resolved through the model's `getRowRecord()`,
leaving out ids that resolve to no record, and `[]` under a cell or column
model or none. The JSDoc of `View#selectedRows` and `BaseModel#selectedRows_`
now names the id kind (internal ids while `useInternalId` is true, record
keys otherwise). `CellEditing#editSelectedCell` reads the row's record
through the getter, and the Grids guide says how to read a selection.
@neo-opus-grace

Copy link
Copy Markdown
Contributor

Thank you, @Mittalnew, and welcome! This is a careful first PR. It follows #21102 closely and keeps selectedRows as it is. It also removes the hand-rolled lookup in CellEditing and leaves AC-5 open while #21044 is unmerged, as the ticket asks. You also checked that your spec catches a broken getter, which is exactly the evidence we look for.

The red unit check is not caused by your change. Its only failure is test/playwright/unit/buildScripts/util/claimResponse.spec.mjs:1667, which fails on dev itself (#21125). Your other 7,481 unit tests pass, and so does every other check, including all eleven e2e shards. The fix, #21126, is approved and waiting to merge.

Next: once #21126 is in dev, I'll merge dev into your branch so CI runs again; thanks for allowing maintainer edits. Then I'll review the PR in full. Until then, there's nothing you need to do.

Questions are welcome here at any time. In this codebase, asking is quicker than guessing.

🖖 Grace (Claude Opus 5.5, Claude Code) · session 9d2c0742-5c77-402e-82c9-3294b03a4062

@neo-opus-grace neo-opus-grace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary

Status: Approved

🪜 Strategic-Fit Decision

Per §9 Strategic-Fit Step-Back:

  • Decision: Approve
  • Rationale: No §0 row fires. #21102 is current: the View has owned the selection model since #18626, and nothing newer reads selected records. The diff is the ticket's prescription, additive, with no correctness gap of its own. AC-5 is deferred by the ticket's own clause, and its pointer lives on #21044 (see the Close-Target Audit).

Peer-Review Opening: Thank you, @Mittalnew, and congratulations on a first PR that needs no changes. Two things stand out:

  • You checked that your spec has teeth. Resolving the ids with store.get(id) and keeping misses made the unresolved-id test fail, and that is exactly how we tell a test from a decoration.
  • You kept selectedRows as it is and removed the one hand-rolled lookup in CellEditing.

Some orientation:

  • Neo runs your app's components in a worker, which is why a grid's selection is state on the View, read through getters, rather than something read from the DOM.
  • Grids.md, which you just extended, and #18626 explain who owns the selection model.
  • The open good first issues nobody holds are a good place to look next. #21133, a related one, is already taken.

🧭 Patch-Blind Premise Snapshot

  • Inputs Read Before Patch:
    • #21102: its Design authority: line (the JSDoc of View#selectedRows), The Fix, the Contract Ledger and the ACs;
    • on dev: src/grid/View.mjs' rowSelectionModel, selectedCells and selectedRows getters, BaseModel#getRowRecord, and CellEditing#editSelectedCell;
    • the "Selection Models" section of Grids.md.
  • Expected Solution Shape: A getter beside selectedRows maps the row model's ids through getRowRecord, leaves unresolvable ids out, and returns [] when no row model is active. Two JSDoc lines name the id kind, CellEditing reads the getter, and the guide gets one paragraph. Which kind of id the grid holds is left to getRowRecord, never hardcoded. Specs cover both useInternalId arms, the empty cases and an unresolvable id, each on a fresh grid and store.
  • Patch Verdict: Matches. selectedRecords returns rowSelectionModel.selectedRows.map(id => rowSelectionModel.getRowRecord(id)).filter(Boolean), and [] when rowSelectionModel is null. rowSelectionModel already folds cell, column and no model into null through selectsRows. CellEditing destructures [rowRecord] from the getter.
  • Premise Coherence: Coheres with friction → gold. Two silent wrong reads on #21044 become one documented getter, and the id kind is now written down where it confused people.

🕸️ Context & Graph Linking

  • Target Epic / Issue ID: Resolves #21102
  • Related Graph Nodes: #18626 (the View owns the selection model), #21044 (the AC-5 file), #21133 / #21134 (the key 0 resolution this getter inherits)
  • Origin Session ID: e2fce289-4792-4a80-b70a-8ca212277ce7
  • PR body attribution: Authored by … is the only attribution; no harness-appended backlink (e.g. 🤖 Generated with [Claude Code]).

🔬 Depth Floor

Challenge OR documented search (per guide §7.1):

  • Challenge:
    • Under useInternalId: false, selectedRecords inherits getRowRecord's reading of a key 0 as no id. A probe at this head held selectedRows [0] and returned selectedRecords []. That is not this PR's defect: I filed it as #21133, and #21134 (approved) fixes it. Both PRs append a block to the end of ViewOwnedSelectionModel.spec.mjs, so whichever merges second needs a branch update. That PR can also add a key-0 arm for selectedRecords (#21133's AC-5).
    • The cell- and column-model arms cannot catch a getter that ignores the model's kind, because both models keep selectedRows empty. A CellRowModel arm, a row selection inside a cell model, would be the positive case. Neither point blocks.

Rhetorical-Drift Audit (per guide §7.4):

  • PR description: framing matches what the diff substantiates (no overshoot)
  • Anchor & Echo summaries: precise codebase terminology, no metaphor or source-code snapshot anchor (ticket/PR/lane/AC/cycle/line number) that overshoots durable intent
  • [RETROSPECTIVE] tag: accurately characterizes what shipped (no inflation of architectural significance) (N/A: none in the PR)
  • Linked anchors: cited tickets/PRs actually establish the claimed pattern (no borrowed authority)

Findings: Pass.


🧠 Graph Ingestion Notes

  • [KB_GAP]: "Record ids" in a grid meant the grid's row ids, which are internal ids by default, not the model's keys. That gap cost #21044 two rounds, and this PR closes it in both JSDoc lines and the guide.
  • [TOOLING_GAP]: The red unit check was inherited from dev (#21125). #21126 fixed it, and this branch was updated from dev (164294f3c2 → 946c8b9194).
  • [RETROSPECTIVE]: "Which records are selected?" is now one read, grid.view.selectedRecords, beside the View's other selection readers.

N/A Audits — 🪜 📡 🔗

N/A across listed dimensions: unit and e2e specs cover the ACs in CI; no OpenAPI surface, skill or convention change.


🎯 Close-Target Audit

  • Close-targets identified: #21102
  • For each #N: confirmed not epic-labeled (or flagged as Required Action below)

Findings: Pass. AC-5 is open by the ticket's own clause, because the timeline example arrives with #21044, which is still open. So that closing #21102 does not drop the only pointer, I put AC-5 on #21044 (#21044 (comment)).


📑 Contract Completeness Audit

  • Originating ticket (or parent epic) contains a Contract Ledger matrix
  • Implemented PR diff matches the Contract Ledger exactly (no drift)

Findings: Pass on all three rows:

  • selectedRecords returns Neo.data.Record[] in selectedRows order, a new array on every read, with no config or event, and [] without a row model;
  • the JSDoc of View#selectedRows names the id kind and points to the getter;
  • the JSDoc of BaseModel#selectedRows_ names the id kind.

🧪 Test-Evidence & Location Audit

  • Execution evidence: exact-head required CI green at 946c8b9194 + author per-surface non-CI receipt present and current-head-appropriate
  • AC-table cross-read: each ## AC Evidence row survives the body's own ## Test Evidence and ## Post-Merge Validation sections (no CI-covered row contradicted by Outside-CI / an unrun job; no blocking pre-merge gate filed as post-merge follow-up)
  • Reviewer falsifier: the named concern was a selected record keyed 0 under useInternalId: false. A probe at 164294f3c2 held [0] and resolved [], which is inherited from getRowRecord and routed to #21133.
  • Test location: pass, the sibling spec #21102 named.

Findings: Pass.


📋 Required Actions

No required actions — eligible for human merge.


📊 Evaluation Metrics

Verdict weights: 30% premise / right thing, 30% architecture + placement, 30% diff correctness, 10% AC/audit sanity. These are importance-to-verdict weights, not effort budgets.

  • [ARCH_ALIGNMENT]: 95 - The getter sits beside the View's other selection readers and leaves resolution to the model. Deduction: none of substance; checked that it adds no config, event or reactive state. owner: src/grid/View.mjs · primitive: View#rowSelectionModel + BaseModel#getRowRecord · retired: CellEditing's hand-rolled two-step lookup.
  • [CONTENT_COMPLETENESS]: 95 - @summary on the getter, the id kind named in both JSDoc lines, and a short, accurate guide paragraph.
  • [EXECUTION_QUALITY]: 90 - Correct for both useInternalId arms, an unresolvable id and the three empty cases, with a mutation-checked spec. Deductions: the inherited key-0 drop (#21133) and the two empty arms that cannot fail on a wrong reader.
  • [PRODUCTIVITY]: 90 - Five of six ACs; AC-5 is deferred by the ticket's own clause, and its pointer moved to #21044.
  • [IMPACT]: 40 - A small public read API on the grid, and the answer two review rounds needed.
  • [COMPLEXITY]: 20 - Five files, additive, one consumer moved.
  • [EFFORT_PROFILE]: Quick Win - One getter and two doc lines remove a recurring silent misread.

Thanks again, @Mittalnew. This is ready for a maintainer to merge.

🖖 Grace (Claude Opus 5.5, Claude Code) · session e2fce289-4792-4a80-b70a-8ca212277ce7

@tobiu
tobiu merged commit 459371e into neomjs:dev Nov 16, 2026
43 of 45 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Merged. Thank you: this is your first merged pull request in Neo.mjs.

Standing: Contributor (1 merged). 4 more reach Returning Contributor.

Your badge, if you would like to show it, is written by a scheduled run that has not counted this merge yet. From then on it is at https://neomjs.com/badges/mittalnew-111978266/ in three forms to choose from, and the card's line shows it:
<a href="https://neomjs.com/badges/mittalnew-111978266/"><img src="https://neomjs.com/badges/mittalnew-111978266/card.svg" alt="Neo.mjs contributor"></a>

Next, if you want one: #20735 and #20883 are open and unclaimed; a comment on either claims it. The full list has more if both are taken by then.

See it run: the engine you changed runs live in the browser: https://neomjs.com/examples

A star helps others find the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A grid has no one-call answer to which records are selected

3 participants