Skip to content

feat(react): run spec actions and write state from RenderSpec - #1605

Merged
blove merged 3 commits into
mainfrom
blove/react-interactive-render
Nov 16, 2026
Merged

blove merged 3 commits into
mainfrom
blove/react-interactive-render

Conversation

@blove

@blove blove commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Summary

React RenderSpec could only display a spec. Angular's <render-spec> takes handlers, a writable store and an events output. This closes that gap, and everything stays opt-in.

Actions from on bindings

  • Registered views now receive emit(event, payload?). It runs the element's on[event] bindings, one or several in order, through the handlers the application passes to RenderSpec.
  • If a spec names an action the application did not supply, nothing runs.
  • params resolve the same way element props do, inside the view's own repeat row. A view's payload is merged over them and wins on key collisions.
  • confirm asks through window.confirm and skips the action when the user declines.
  • onSuccess can set store values, run another action, or navigate. Navigation only goes to http, https or relative addresses.
  • onError can set store values ('$error.message' becomes the error's message) or run another action. Without onError, a thrown error reaches the view.
  • Handlers always come from the latest render, so passing a new map doesn't remount views.

Writable state

  • store (structurally createRenderState's owner) is an alternative to read-only state. Passing both throws, and the types reject it.
  • RenderSpec reads the store through useSyncExternalStore, and views get set(path, value). Bound inputs write to the path in their bindings.
  • Without a store, views get no set, so the tree stays read-only, as it is today.

Observing

  • onEvent receives the same event shapes as Angular: handler (with the action's result, or what its promise resolved to), stateChange (path, value and the whole snapshot) and result (a view's result(value) plus its element key).

Boundaries

  • Payloads and written values must be plain data; anything else throws a TypeError. A view calls event.preventDefault() itself.
  • Readiness fallbacks get no emit, set or result.
  • After the tree unmounts, a late promise no longer writes the store, runs follow-ups or reports events.
  • Not included: lifecycle events, watch effects, and the preventDefault binding field.

Docs and parity

  • The React render Events guide is rewritten around the new API. Its compiled example is checked by react-doc-examples.
  • The introduction, quickstart, registry and state-store guides are updated to match.
  • The type tests and the installed-consumer fixture no longer pin "no actions". Eight disposition rows are added.

Test plan

  • nx test react: 77 files, 1,353 tests. The new interaction.spec.tsx has 18 tests.
  • Mutation checks: removing confirm, the URL policy, the unmount guard, payload precedence, latest-handler reads, the writer gate, or stateChange each fails a test.
  • react:type-tests, lint (0 errors), and the React build
  • Website docs-content-rules and react-doc-examples
  • Parity: inventory exits 0; boundaries (source and built), verify-packages, verify-render-state, verify-a2ui-surfaces and verify-markdown pass. Node specs pass: packages 102, render-state 13, readiness 23, boundaries 544, inventory 37.
  • verify-react-readiness passes. Locally it needed TMPDIR set to the real path, because Vite fails on the macOS /var symlink.
  • All six React render cockpit examples build and their tests pass. The shared render specs pass, 58 tests. cockpit-render-state-management-react e2e passes 8 of 8.

🤖 Generated with Claude Code

RenderSpec views can now act. A spec names actions in an element's `on`
bindings, and a view's `emit` runs them through `handlers` the
application supplies, with resolved params (in the view's own repeat
row), `confirm`, and `onSuccess`/`onError` follow-ups. A spec naming an
action the application did not supply does nothing.

A writable `store` (such as `createRenderState`) replaces read-only
`state`: RenderSpec reads its snapshot, and views get `set` so bound
inputs write back. `onEvent` reports handler, stateChange and result
events. Payloads and written values must be plain data, `navigate`
follows only http(s) or relative addresses, readiness fallbacks get no
emit, and late async work is dropped after unmount.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadplane Ignored Ignored Preview Nov 15, 2026 7:47pm UTC

Request Review

The docs catalog pins each guide's frontmatter description, and the React
render Events guide now describes actions, the store and onEvent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@blove
blove added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit b95c558 Nov 16, 2026
90 checks passed
@blove
blove deleted the blove/react-interactive-render branch November 16, 2026 00:44
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