Skip to content

Move row writes to core-data - #406

Draft
priethor wants to merge 9 commits into
mainfrom
priethor/add/row-writes-core-data
Draft

Move row writes to core-data#406
priethor wants to merge 9 commits into
mainfrom
priethor/add/row-writes-core-data

Conversation

@priethor

@priethor priethor commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

What

Part of #298.

Row edits and row creation now use core-data. Duplicate, trash, and restore also add the canonical response record to the entity cache. The grid still reads full rows from /cortext/v1/rows and keeps its existing refresh path, so this PR does not change how collections load.

Why

Rows are crtxt_document records, the same entities shown in the grid and opened in the side peek or full editor. Direct REST writes bypass core-data, so its cached copy can fall behind the server and Cortext has to keep each surface in sync by hand. Writing through core-data keeps the saved record in the entity store, which is required before the grid can read from it.

How

Field saves send only the changed title or field and use throwOnError so the existing UI can report failures. The duplicate response now includes a canonical post without changing the rest of its envelope, and lifecycle actions cache only canonical records returned by the server.

Testing Instructions

  1. Edit a text cell inline and a relation from the row properties. Reload and confirm both values persisted.
  2. Create a row with a simple filter active, then create another from a relation picker. Confirm the filter value is prefilled and the related row is selected.
  3. Duplicate a row with populated fields. Reload and confirm the copied values are still present.
  4. Open a row in the side peek and change the same property twice quickly. Confirm the last value wins after reloading.
  5. Block a row save request in browser developer tools. Confirm the error appears and a reload restores the previous server value.
  6. Trash and restore a row, then bulk-trash several selected rows. Confirm the grid and sidebar update.

Base automatically changed from priethor/add/rows-ids-shape to main July 30, 2026 17:33
@priethor
priethor force-pushed the priethor/add/row-writes-core-data branch from 333d63b to 7b68a8d Compare July 30, 2026 17:37
priethor added 2 commits July 31, 2026 11:59
The subregistry makes it look like row saves are split across two stores,
so the previous note claimed property saves and grid saves ended up in
different queues. They do not. EditorProvider builds that subregistry with
only core/block-editor and core/editor and falls back to the root registry,
so core-data resolves to the root from either side and every row save shares
the same per-record lock.

Left the reasoning in the doc rather than just deleting the claim, since the
subregistry really does suggest the opposite and the next person reading it
would wonder.
Preparing the record runs an internal REST request with the full row
enrichment behind it, so the cost is worth stating next to the call rather
than leaving someone to find it. Also explains why a null there still leaves
the duplicate successful, which was deliberate and not obvious.
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.

1 participant