Repository navigation
feat(ui-react): rebuild the admin edit route on DocForm and core's editor store (closes S1) (5b(ii)) - #42
Merged
Conversation
🦋 Changeset detectedLatest commit: a0a6d16 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 59 minutes. View limit details
TanStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.
|
This was referenced Nov 6, 2026
cursor
Bot
force-pushed
the
cursor/write-actions-02f8
branch
from
November 6, 2026 14:50
013cd74 to
3dbbd75
Compare
cursor
Bot
force-pushed
the
cursor/admin-edit-route-d21e
branch
from
November 6, 2026 14:50
26cdeaf to
2767e37
Compare
jherr
force-pushed
the
cursor/admin-edit-route-d21e
branch
from
November 6, 2026 15:10
2767e37 to
a0a6d16
Compare
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.
Implements the second half of cms-refactor-plan.md § Phase 5, 5b: "the admin edit route rebuilt on it (closes the S1 leak)". It also wires 5a's
save/actinto the editor.Merge chain: step 22 of 24. Base:
main. Merge it right after #43. The branch ismain3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit2767e37(treeaa470aa).Before the merge chain, this PR's diff against 5a also showed R1a's squash and the whole A stack. This was the first branch to hold both the A stack (1e/1d/R2/5b(i)) and the B/C stack (2b/2c/3a/4a–4d/5a). Every conflict is recorded below so the merges can be replayed.
What
The admin edit route (
edit.$collection.$id.tsx) is now composition and no longer renders fields itself.DocForm, viauseDocForm, owns field state: read and write access,showWhen, field errors, the proposal highlight and relation titles.published,publishAt,unpublishAt,locale) write throughform.setValue.form.submit({ publish, overwrite }), so every save goes through TanStack Form'shandleSubmit.createDocEditorStoreowns everything else: the baseline, optimistic concurrency, conflict reload and overwrite, busy/status, and 5a'sstateandavailableActions.onSubmit(patch)callsed.save, which calls 5a'ssave({ collection, id, doc: patch, expectedRevision, expectedPendingVersion, publish }).docbecomes the baseline.availableActionsthat carry no document (approve, reject, discard, publish an approved change, custom steps) are buttons with the strategy's label and tone. They runed.act, which calls 5a'sact.discardaction.availableActions:edit→ Save, or Publish changes whendraftis offered too.submit→ Submit for review.draft, for publishers, adds Save draft.state.labelappears next to the revision.Diffapprove;Core (
lib/doc-editor.ts). Every change here is additive.baseline,writeStateandavailableActions.transport.savereceivespatch, and the store adopts any result that hasstate. The status comes from the change set before and after the save.act(action, input?),change(doc)andtransport.load.docPatchmoves here from ui-react, which re-exports it.API.
getDocEditorMetaalso returnsstateandavailableActions, so the editor has them before its first save.S1, closed.
s1-primitives-boundary.test.tsnow:FieldInputin every admin route;<DocFormin the edit route;canReadField,canWriteFieldorisFieldVisible.The old route fails all three.
The seam for 5c. Every save goes through
form.submitand thenhandleSubmit. So validators that 5c attaches toDocForm's fields will gate every save with no change to the route.Docs:
cms-ui-react.mdhas a new section, "With the core editor store", with a type-checked example.getDocEditorMetarows are updated.review-queue.md.Changesets:
doc-editor-write-results.md(core minor);doc-editor-meta-state.md(api minor);admin-edit-route-doc-form.md(ui-react minor).Breaking changes
None in published APIs. These admin changes are visible:
availableActions. UnderdirectStrategy, a non-publisher withcontent.writenow sees Save, because their save commits. It used to say "Submit for review".Merge record (for replay)
12e9e68:origin/main(R1a #22) into 5a. The one conflict wasscripts/codemods/index.ts; both codemods were kept.86198f9: 5b(i) #33 into 5b(ii).Conflicts caused only by squash merges, in files the B/C stack didn't touch. Each took #33's side:
docs/tutorials/blog-cms.mdpackage.jsonpackages/ui-react/src/routes/index.tsxcms.config.tsin eight examples and three startersReal conflicts between the A and B/C stacks:
.claude/skills/payload-to-tanstack-cms/SKILL.mdreadDocumentAsapp/base/src/model.tscollection-runtime.ts.app/base/src/collection-runtime.ts(semantic)baseHooksusedcurrentSession(), which 2c removed. They're ported to the args:afterChange({ id, operation, session }),afterDelete({ id, session }),postRead({ doc, access }).app/prm/src/cms.config.tsdefineCms(definition, { …, documentState: ownerDirectAgentReview({ autoApprove }) })docs/api/cms-core.mddefinePlugin({ definition, runtime })example with B/C'sdocument.publishedcheckdocs/deployment/upgrading.mddocs/migration/from-sanity.mddocs/schema/building-pages.md(frontmatter)packages/core/src/schema.ts,packages/core/tests/plugins.test.ts,packages/ui-react/src/routes/review.tsxscripts/codemods/index.tscms.config.tsin seven starterscms.definition.ts), with imports unionedAfter the merge, no stale
currentSession,runWithSessionorcmsVirtualRoutesremained.355f800: 5a's013cd74into 5b(ii). The one conflict wasupgrading.md.How verified
GitHub Actions is out of billing, so everything ran locally.
pnpm install --frozen-lockfiletest:ci(173 tasks)@tanstack/cms-api:test:oxlint. Twono-non-null-assertionerrors in the new store code are fixed in26cdeaf.test:dtstest:dialectstest:definitionstest:scriptsdoc-editor.test.ts46 (15 new); a new apigetDocEditorMetatest; ui-react 124, including the tightened S1 testThe new E2E test,
examples/blog/e2e/editor.spec.ts, walks through:Assumptions (tasks 8–12 defaults)
getDocEditorMeta, becausedocumentWriteStateis server-only.schedule. They use the strategy's labels.actreplaces the document and baseline, dropping unsaved edits, as discard did.pendingVersioninto the store.canWriteand an offered save action.runSavedrafts only for them.Divergence from plan
@tanstack/form-coreis not in core. Where Q23 said the store should wrap the form, the store composes with it instead.DocForm's API, with no added capability.save()can be called from a timer.saveDocordiscardDraftops. They stay, deprecated in 5a.Merge chain (local verification, CI down)
This PR's commits are squashed into one commit on the linear merge chain. That commit holds this PR's own changes, resolved against every PR before it, with the integration rehearsal's fixes for this PR applied. Five conflicts, all where 5a's
staged: falsecommits are already on the chain. The commit was replayed from86198f9.The chain tip's tree is exactly the integration rehearsal plus #46 (
c4e6d7c), and the tip passes the full local suite. I simulated merging every PR in order, with a merge commit or a fast-forward at each step, and every step is clean. A plain squash of the next PR would conflict, because the squash commit isn't an ancestor of the next branch. To squash instead, first rebase the branch's one commit onto the newmain; that rebase is always clean.