Repository navigation
feat(grid): View reads the selected rows as records (#21102) - #21132
Conversation
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.
|
Thank you, @Mittalnew, and welcome! This is a careful first PR. It follows #21102 closely and keeps The red Next: once #21126 is in 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
left a comment
There was a problem hiding this comment.
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
selectedRowsas it is and removed the one hand-rolled lookup inCellEditing.
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 ofView#selectedRows), The Fix, the Contract Ledger and the ACs; - on
dev:src/grid/View.mjs'rowSelectionModel,selectedCellsandselectedRowsgetters,BaseModel#getRowRecord, andCellEditing#editSelectedCell; - the "Selection Models" section of
Grids.md.
- #21102: its
- Expected Solution Shape: A getter beside
selectedRowsmaps the row model's ids throughgetRowRecord, leaves unresolvable ids out, and returns[]when no row model is active. Two JSDoc lines name the id kind,CellEditingreads the getter, and the guide gets one paragraph. Which kind of id the grid holds is left togetRowRecord, never hardcoded. Specs cover bothuseInternalIdarms, the empty cases and an unresolvable id, each on a fresh grid and store. - Patch Verdict: Matches.
selectedRecordsreturnsrowSelectionModel.selectedRows.map(id => rowSelectionModel.getRowRecord(id)).filter(Boolean), and[]whenrowSelectionModelisnull.rowSelectionModelalready folds cell, column and no model intonullthroughselectsRows.CellEditingdestructures[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
0resolution 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,selectedRecordsinheritsgetRowRecord's reading of a key0as no id. A probe at this head heldselectedRows[0]and returnedselectedRecords[]. 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 ofViewOwnedSelectionModel.spec.mjs, so whichever merges second needs a branch update. That PR can also add a key-0arm forselectedRecords(#21133's AC-5). - The cell- and column-model arms cannot catch a getter that ignores the model's kind, because both models keep
selectedRowsempty. ACellRowModelarm, a row selection inside a cell model, would be the positive case. Neither point blocks.
- Under
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 redunitcheck was inherited fromdev(#21125). #21126 fixed it, and this branch was updated fromdev(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 notepic-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:
selectedRecordsreturnsNeo.data.Record[]inselectedRowsorder, a new array on every read, with no config or event, and[]without a row model;- the JSDoc of
View#selectedRowsnames 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 Evidencerow survives the body's own## Test Evidenceand## Post-Merge Validationsections (noCI-coveredrow contradicted byOutside-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
0underuseInternalId: false. A probe at164294f3c2held[0]and resolved[], which is inherited fromgetRowRecordand 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 -@summaryon the getter, the id kind named in both JSDoc lines, and a short, accurate guide paragraph.[EXECUTION_QUALITY]: 90 - Correct for bothuseInternalIdarms, an unresolvable id and the three empty cases, with a mutation-checked spec. Deductions: the inherited key-0drop (#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
|
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: 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. |
Resolves #21102
Adds a
selectedRecordsgetter onNeo.grid.View, next toselectedRows, so "which records are selected?" is one call:grid.view.selectedRecords. Each selected row id is resolved through the model'sgetRowRecord(); 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 ofView#selectedRowsandBaseModel#selectedRows_now says which ids they hold (the store's internal ids whileuseInternalIdistrue, record keys otherwise) and points to the new getter.CellEditing#editSelectedCellnow reads the row's record through the getter instead of callinggetRowRecorditself, 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
selectedRecordsunderRowModel,useInternalIdtrue and false, plus cell model / column model /selectionModel: nullempty casestest/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 passed3, 99, 1, expects records3, 1)src/grid/View.mjs(selectedRows),src/selection/grid/BaseModel.mjs(selectedRows_)CellEditing#editSelectedCellhas nogetRowRecordcall; CellEditingPooling passes uneditedsrc/grid/plugin/CellEditing.mjs;npm run test-e2e -- test/playwright/e2e/grid/CellEditingPooling.spec.mjs-> 48 passed, no spec editsgrid.view.selectedRecords[0]examples/timeline/basic/Viewport.mjsarrives with #21044, which is still open, so this box stays unchecked as the ticket sayslearn/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.store.get(id)and not drop missing ones, the unresolved-id test failed.Post-Merge Validation
None required.
Authored by @Mittalnew