Skip to content

feat(line-items): expose net changeset inspection - #743

Draft
IzumiSy wants to merge 1 commit into
feat/line-items-2427from
feat/line-items-net-changeset
Draft

IzumiSy wants to merge 1 commit into
feat/line-items-2427from
feat/line-items-net-changeset

Conversation

@IzumiSy

@IzumiSy IzumiSy commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Motivation

LineItems already owns local editing and dirty-state detection, but consumers still need to calculate their own persistence differences. A dirty boolean alone cannot identify added lines, changed fields, removals, or the final document order, and it cannot distinguish an untouched field from an explicit clear.

This is an incremental PR into the LineItems integration branch (#710), covering LI-08, LI-09, LI-10, LI-11, LI-41, and LI-43 from the initial milestone checklist. Persistence and document-wide validation remain consumer responsibilities.

Design Decision

Inspect committed net state

Expose getChanges() and LineItemsChangeset<TRow> with added, updated, removed, and order results. Compare the saved baseline with current committed rows rather than retaining an operation history. Creation rows retain their complete current data; removals retain their baseline data; updates contain only changed accessor-owned fields, including own undefined keys for explicit clears.

Inspection does not confirm drafts, run validation, persist data, clear changes, or advance the baseline. Unconfirmed and rejected drafts are excluded without preventing inspection of other committed changes.

Share comparison rules without normalizing values

Property columns may supply equals(baseline, current), defaulting to Object.is. Both isDirty and changeset inspection use the same comparison, without changing adopted values. Duplicate displays inherit one explicit equality function per property; conflicting functions are rejected rather than letting column order choose the result.

A getter retains its render's comparison configuration while reading current committed rows, so suspended renders do not mutate shared configuration. order is the complete final line-key sequence whenever ordered membership differs, including additions/removals; null means unchanged and [] represents an emptied collection.

Summary

  • Add typed, side-effect-free net changeset inspection through the public hook.
  • Share property-level equality between dirty detection and changeset generation.
  • Cover cancellation, explicit clears, complete row data, ordering, draft exclusion, and suspended-render behavior with regression tests and public/published type fixtures.
  • Keep save preparation, baseline replacement, documentation, and release changesets outside this focused PR.

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the LineItems changeset inspection API.

No open issues 🎉

What changed in this PR

Adds net changeset inspection to LineItems, extending its local editing API so consumers can prepare persistence changes without maintaining their own diff logic. Inspection excludes unconfirmed drafts and does not validate, save, or advance the baseline.

Changes:

  • Exposes getChanges() and LineItemsChangeset for additions, field updates, removals, and final ordering.
  • Shares property-level equality rules between changeset inspection and dirty detection.
  • Adds runtime and type coverage for explicit clears, cancellation, draft exclusion, and render-local equality.
File Description
packages/​core/​tests/​dts/​line-items-changes/​check.tsx Verifies published changeset and equality types.
packages/​core/​src/​index.ts Exports the public changeset type.
packages/​core/​src/​components/​line-items/​use-line-items.ts Exposes inspection with render-local equality.
packages/​core/​src/​components/​line-items/​types.ts Adds the hook’s changeset contract.
packages/​core/​src/​components/​line-items/​index.ts Re-exports the changeset type.
packages/​core/​src/​components/​line-items/​document/​types.ts Defines changeset results and property equality.
packages/​core/​src/​components/​line-items/​document/​store.ts Exposes document inspection through the store.
packages/​core/​src/​components/​line-items/​document/​model.ts Computes net changes and shares dirty-state comparison.
packages/​core/​src/​components/​line-items/​document/​changes.test.ts Covers net changes, ordering, clears, and equality rules.
packages/​core/​src/​components/​line-items/​changes.test.tsx Covers retained getters, suspended renders, and draft exclusion.
packages/​core/​src/​components/​line-items/​changes.test-d.ts Checks public changeset and equality type constraints.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (e4b5616) #743 (ce20452) +/-
Coverage 62.9% 62.8% -0.1%
Test Execution Time 4m29s 4m51s +22s
Details
  |                     | main (e4b5616) | #743 (ce20452) |  +/-  |
  |---------------------|----------------|----------------|-------|
- | Coverage            |          62.9% |          62.8% | -0.1% |
  |   Files             |            294 |            317 |   +23 |
  |   Lines             |          13513 |          14339 |  +826 |
+ |   Covered           |           8505 |           9017 |  +512 |
- | Test Execution Time |          4m29s |          4m51s |  +22s |

Code coverage of files in pull request scope (19.0% → 26.0%, patch 100.0%)

Details
Files Coverage +/- Patch Coverage Status
packages/core/dist/app-shell.js 8.2% -0.4% - affected
packages/core/src/components/data-table/cell-renderers.tsx 100.0% +4.4% - affected
packages/core/src/components/data-table/editing/cell/choice.tsx 100.0% +6.2% - affected
packages/core/src/components/data-table/editing/cell/date.tsx 100.0% +20.2% - affected
packages/core/src/components/data-table/editing/cell/shared.tsx 86.6% -8.7% - affected
packages/core/src/components/data-table/editing/cell/typing.tsx 100.0% +2.1% - affected
packages/core/src/components/data-table/pagination.tsx 95.0% -0.5% - affected
packages/core/src/components/internals/table-core/cell-renderers.ts 100.0% +100.0% - affected
packages/core/src/components/internals/table-core/cell-session.ts 98.0% +98.0% - affected
packages/core/src/components/internals/table-core/display-cell-adapters.tsx 100.0% +100.0% - affected
packages/core/src/components/internals/table-core/editing/cell.tsx 100.0% +100.0% - affected
packages/core/src/components/internals/table-core/editing/choice.tsx 94.0% +94.0% - affected
packages/core/src/components/internals/table-core/editing/date.tsx 82.0% +82.0% - affected
packages/core/src/components/internals/table-core/editing/shared.tsx 96.5% +96.5% - affected
packages/core/src/components/internals/table-core/editing/typing.tsx 98.0% +98.0% - affected
packages/core/src/components/internals/table-core/editing/use-session.ts 100.0% +2.0% - affected
packages/core/src/components/internals/table-core/input-values.ts 100.0% +100.0% - affected
packages/core/src/components/line-items/document/identity.ts 100.0% +100.0% - affected
packages/core/src/components/line-items/document/model.ts 98.8% +98.8% 100.0% modified
packages/core/src/components/line-items/document/snapshot.ts 100.0% +100.0% - affected
packages/core/src/components/line-items/document/store.ts 100.0% +100.0% - modified
packages/core/src/components/line-items/editing.ts 98.9% +98.9% - affected
packages/core/src/components/line-items/editor-factory.ts 100.0% +100.0% - affected
packages/core/src/components/line-items/i18n.ts 100.0% +100.0% - affected
packages/core/src/components/line-items/index.ts 0.0% 0.0% - modified
packages/core/src/components/line-items/line-items-cell.tsx 100.0% +100.0% - affected
packages/core/src/components/line-items/line-items-context.ts 100.0% +100.0% - affected
packages/core/src/components/line-items/line-items.tsx 100.0% +100.0% - affected
packages/core/src/components/line-items/use-line-items-reorder.ts 100.0% +100.0% - affected
packages/core/src/components/line-items/use-line-items.ts 100.0% +100.0% 100.0% modified
packages/core/src/index.ts 0.0% 0.0% - modified

Reported by octocov

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.

2 participants