Repository navigation
feat: make the reference field type merge-ready - #2799
Closed
saariuslystoned wants to merge 47 commits into
Closed
saariuslystoned wants to merge 47 commits into
saariuslystoned wants to merge 47 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`handleContentCreate`/`handleContentUpdate` already accept a `references` body key, but the zod schemas didn't list it, so `parseBody` silently stripped it before it reached the handler.
Creating a reference field now creates its backing relation def transactionally, updating the field's label PATCHes the relation's childLabel, and deleting the field deletes the relation and its edges. The admin no longer has to orchestrate these multi-step writes itself. Also fixes withTransaction to short-circuit when already inside a transaction (db.isTransaction), rather than attempting an illegal nested .transaction() call — required for the field-create/update/ delete handlers to nest their relation writes with SchemaRegistry's own internally-transacted field writes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Type STORAGELESS_FIELD_TYPES as ReadonlySet<string> so membership checks against DB-sourced field types need no cast, resolving the lint diagnostic introduced with stripStoragelessDataKeys. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reference fields are storage-less, so a seed defining one now creates the backing relation (like the schema handler) and writes a $ref value in the field's data as a content-reference edge instead of a table column. Previously applySeed threw "no such column" for any seed using a reference field. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- resolveEntries now attaches a display `title` (entry `title`, then `name`, else null) to every EntryRef, so picked entries and backlinks show a readable label instead of a slug; hydrated through content GET and the admin editor/backlinks sidebar. - Wire the relation and reference-edge API routes into injectCoreRoutes; they existed but were never registered, so /_emdash/api/relations 404'd and the "Referenced by" panel silently hid itself. - Preserve `targetCollection` and `multiple` on reference field validation so the create handler no longer rejects the field for a missing target. - Backlinks sidebar resolves relations by translation_group, not name. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts: # packages/core/src/api/handlers/content.ts
# Conflicts: # packages/admin/src/components/ContentEditor.tsx # packages/admin/src/router.tsx
- Add `title` to entryRefSchema so the response contract matches the runtime EntryRef (no more OpenAPI/generated-type drift). - Validate the target collection in createFieldRelation, rejecting a reference field whose target does not exist (rolls back in-transaction, leaving no orphan field or relation row). Adds a lifecycle test. - Remove the misleading cross-locale badge from the reference list and backlinks sidebar: edges are keyed by translation_group, so labelling a resolved variant's locale implies a per-locale binding that doesn't exist. Titles already resolve at the current entry's locale via pickVariant. Drops the now-dead entryLocale plumbing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…d-admin-ui # Conflicts: # packages/core/src/astro/routes/api/content/[collection]/[id].ts # packages/core/src/seed/apply.ts
This was referenced Sep 11, 2026
9 of 19 tasks
This was referenced Sep 13, 2026
Contributor
|
This PR has been inactive for 14 days. It will be closed automatically in 7 days if there is no further activity. If you're still working on this, please push an update or leave a comment. |
This was referenced Sep 16, 2026
This was referenced Sep 23, 2026
Member
|
Superseded by #1928, which landed relations and reference fields as entry pickers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This is a tested, author-preserving continuation of #1928, opened directly against upstream
mainso the result can run through EmDash's authoritative CI, bot, preview, visual, query-count, security, and review rails.MA2153's work remains the foundation:
808cde87a34fa818a2f29ddafacf5053d3859398, as its first parent and preserves the original commits and authors.mainat1717d31b351164a5f78e95fe004ee582c7c50f40and resolves the three conflicts in the content editor, transaction helper, and route tests.body.datavalidation while the existing top-levelreferencespayload remains accepted.This follows the maintainer direction on #1928 to resolve the current-main conflicts without adding migration scope. It does not automatically close #1928; maintainers can coordinate which PR remains canonical.
Approved feature discussion: #386
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
Exact identities
808cde87a34fa818a2f29ddafacf5053d38593981717d31b351164a5f78e95fe004ee582c7c50f4020bb470b68e143a6b3dc0f16b9a47726b4ca7a62cf146124f939aa5efd23c2e6bf800e14b3fc9534EmDashBot repair cycle 1
The first EmDashBot review found two blocker classes across three inline comments. Current head
cf146124f939addresses all three:FIELD_NOT_INDEXABLE; seed preflight rejects them; admin hides the Indexed toggle and clears stale invalid state.sort_orderis preserved across chunks.The regression proof includes registry create/update/seed rejection, seed preflight, admin visibility/save normalization, SQL parameter shape, and a real Workerd/D1 replacement of an old edge with 17 ordered children.
The D1 test proves the deterministic bind-limit failure is fixed. It does not claim all-or-nothing behavior across an unrelated outage between D1 statements; true atomic replacement would require a separate
D1Database.batch()adapter or generation/pointer design.Current-head verification
tsgo --noEmit: passedAt the requested monitoring cutoff, GitHub reported 42 successful checks, one expected skipped Dependabot check, one still-pending aggregate
CI / Testsjob, and zero failures. This records the exact cutoff rather than claiming that the aggregate or an admin-triggered second review completed.Independent exact-head review
1717d31b351164a5f78e95fe004ee582c7c50f40cf146124f939aa5efd23c2e6bf800e14b3fc9534gpt-5.6-sol, high reasoningImmutable repaired-head proof packet: release, receipt, hashes, and exact-head OpenClaw result
Visual proof provenance
The captures below were made at predecessor head
20bb470b68e1. The repair does not change the picker flow, so they remain useful behavior evidence, but they are deliberately not represented as newly captured atcf146124.The MP4 is a four-state sequence assembled from actual browser states; it is not a continuous screen recording.
The old
CHANGES_REQUESTEDreview is bound to predecessor head20bb470b68e1. The current label isreview/needs-rereview; current headcf146124f939is ready for a maintainer-triggered EmDashBot rereview.