Skip to content

feat(core)!: hooks as pre-commit consultation, events as announcement; drop legacy hook aliases - #19

Merged
jherr merged 4 commits into
mainfrom
cursor/hooks-events-framing-7523
Nov 6, 2026
Merged

jherr merged 4 commits into
mainfrom
cursor/hooks-events-framing-7523

Conversation

@jherr

@jherr jherr commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Implements cms-refactor-plan.md § Phase 1c (item 11, part).

Stack: S1 #20 → S2 #21 → 1c (this PR). It's based on cursor/collections-array-0f74, so merge #21 first. Two core tests clashed with S2: readiness.test.ts, and the new slow-hooks.test.ts, which still used the name-keyed collections object. Stacking this PR on S2 fixes both.

What

  • Docs reframe. Hooks are "we're about to go into the game: anything you want to make us aware of before we do?", a pre-commit consultation. Events are "we won the game!", a post-commit announcement. Commit-firewall semantics are unchanged.
    • docs/architecture/events-and-hooks.md leads with this framing.
    • Hook descriptions are also updated in collections-and-fields, cms-core, cms-core-server, building-pages, review-queue, overview and from-payload.
    • The Payload migration skill and the redirects-and-broken-links cms-skill are updated too.
  • Legacy hook aliases removed from CollectionHooks and the store runners. The only uses were in core tests and app/prm/src/collections.ts, both migrated.
  • Slow-hook warning in development. Every hook runs through one runHook timer. When NODE_ENV !== 'production', a hook slower than 50 ms (the SLOW_HOOK_MS constant) logs one warning per collection and stage per process, even when the hook throws. Tests are in packages/core/tests/slow-hooks.test.ts.
  • afterChange / afterDelete are @deprecated. They point to defineEventHandler on document.created, document.updated and document.deleted, and they still run. The docs include a before/after.
  • Changesets. .changeset/hooks-events-framing.md (@tanstack/cms-core minor) lists the mapping and the deprecations. The unreleased .changeset/events-and-hooks.md no longer promises the aliases stay.

Breaking changes

Removed Use
beforeValidate preValidate
beforeChange postValidate
beforeDelete preDelete
afterRead postRead

Each alias ran in the same slot as its replacement.

How verified

  • On S2: nx affected --base=origin/cursor/collections-array-0f74 with the test:pr targets, plus pnpm test:dts. The only failure is the @tanstack/cms-api oxlint error that main already has.
  • Before the rebase onto S2, NX_BASE=origin/main pnpm test:pr across 39 affected projects showed the same result.
  • pnpm format is clean.

Notes for review

  • app/base/src/model.ts still uses the deprecated afterChange / afterDelete for its admin audit. It reads the request's currentSession(), which an event handler doesn't have. 1e(ii) feat(core)!: split plugins and app configs into a definition and a runtime #25 moves these hooks into the runtime config, and phase 2b replaces them.
  • Left for later phases: unifying the event vocabulary, the review.* events, and separating postRead.

Divergence from plan

None.

Open in Web Open in Cursor 

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: TanStack/cms
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 233d907
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Free
  • Run ID: a95aa0c8-3b2a-4d1e-9cb5-1f071bc0ada7
Commits

Reviewing files that changed from the base of the PR and between 233d907 and 663eb51.

Files selected for processing: 27

  • .changeset/events-and-hooks.md
  • .changeset/hooks-events-framing.md
  • .claude/skills/payload-to-tanstack-cms/SKILL.md
  • app/prm/src/collections.ts
  • docs/agents/review-queue.md
  • docs/api/cms-core-server.md
  • docs/api/cms-core.md
  • docs/architecture/events-and-hooks.md
  • docs/architecture/overview.md
  • docs/migration/from-payload.md
  • docs/schema/building-pages.md
  • docs/schema/collections-and-fields.md
  • packages/cms-skills/src/registry/redirects-and-broken-links.ts
  • packages/core/src/schema.ts
  • packages/core/src/server/store/internal.ts
  • packages/core/src/server/store/query.ts
  • packages/core/src/server/store/read.ts
  • packages/core/src/server/store/review.ts
  • packages/core/src/server/store/scheduling.ts
  • packages/core/src/server/store/write.ts
  • packages/core/tests/field-access.test.ts
  • packages/core/tests/fields.test.ts
  • packages/core/tests/readiness.test.ts
  • packages/core/tests/slow-hooks.test.ts
  • packages/core/tests/store-index.test.ts
  • packages/core/tests/store.test.ts
  • packages/ui-react/tests/interface-view.test.tsx

TanStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.

  • Ask an admin to upgrade

Open in CodeRabbit

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 663eb51

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@tanstack/cms-store-postgres Minor
@tanstack/cms-core Minor
@tanstack/cms-api Minor
@tanstack/cms-cli Minor
@tanstack/cms-client Minor
@tanstack/cms-connect-atproto Patch
@tanstack/cms-migrate-wp Patch
@tanstack/cms-skills Patch
@tanstack/cms-media-s3 Minor
@tanstack/search-cms Patch
@tanstack/cms-store-libsql Minor
@tanstack/cms-ui-dom Patch
@tanstack/cms-ui-react Minor

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

@cursor
cursor Bot force-pushed the cursor/hooks-events-framing-7523 branch 2 times, most recently from 21bf531 to 0b17ec3 Compare November 6, 2026 02:09
@cursor
cursor Bot changed the base branch from main to cursor/collections-array-0f74 November 6, 2026 02:09
@jherr
jherr force-pushed the cursor/collections-array-0f74 branch from 4c9af65 to b6447c1 Compare November 6, 2026 02:24
@jherr
jherr changed the base branch from cursor/collections-array-0f74 to main November 6, 2026 02:38
cursoragent and others added 4 commits November 5, 2026 18:39
…recate afterChange/afterDelete

Remove beforeValidate/beforeChange/beforeDelete/afterRead from CollectionHooks
and the store runners (use preValidate/postValidate/preDelete/postRead).
Outside production, a hook slower than the 50ms guideline logs one warning
per collection.stage per process. Mark afterChange/afterDelete @deprecated in
favour of durable defineEventHandler handlers.

Co-authored-by: jherr <jherr@pobox.com>
…mit announcement

Lead events-and-hooks with the before/after-the-game model, document the
dev slow-hook warning, the afterChange/afterDelete deprecation and its
event-handler replacement, and migrate docs, the Payload skill, and the
redirects cms-skill off the removed alias names. Add the cms-core changeset.

Co-authored-by: jherr <jherr@pobox.com>
InterfaceView opens its EventSource in a passive effect keyed on the loaded
view, which can run after the heading is found; the test then read an unset
Stream.current (about 1 in 10 runs).

Co-authored-by: jherr <jherr@pobox.com>
Co-authored-by: jherr <jherr@pobox.com>
@jherr
jherr force-pushed the cursor/hooks-events-framing-7523 branch from 0b17ec3 to 663eb51 Compare November 6, 2026 02:39
@jherr
jherr merged commit e568873 into main Nov 6, 2026
7 of 11 checks passed
@jherr
jherr deleted the cursor/hooks-events-framing-7523 branch November 8, 2026 01:55
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