Skip to content

feat(angular-lang): run on lang-core's renderer runtime - #1803

Open
Aditya-thesys wants to merge 31 commits into
surfaces/web-corefrom
surfaces/web-angular
Open

Aditya-thesys wants to merge 31 commits into
surfaces/web-corefrom
surfaces/web-angular

Conversation

@Aditya-thesys

Copy link
Copy Markdown
Contributor

Stacked on #1800: this PR targets surfaces/web-core, so it shows only the angular-lang changes. After #1800 merges, GitHub retargets it to main.

What

Rebuilds angular-lang as a thin view layer over @openuidev/lang-core/runtime. It reaches react-lang's feature set: $state, queries and mutations, action plans, custom actions, library functions, form validation, structured errors through (error), projected renderer slots and an element error boundary that keeps the last valid render. It renders on the server without calling tools.

Changes

  • One renderer runtime per renderer (renderer-runtime.ts). Elements are views of their render node's ViewContainerRef; the first instance is created in place, so server HTML can hydrate.
  • Children keyed by statement id, as in 0.4: a statement streamed in above an input keeps it. List placement is linear.
  • Projected openui-renderer-* slots and an element boundary.
  • A new library renders new element instances and starts a new message: its state resets and its queries run again.
  • API changes: injectSetDefaultValue replaces setDefaultValue; OpenUiToolProvider is now ToolProviderInput (the old name stays for one minor); injectFormName() returns a signal. parse, resolveStateField, stripReactiveAssign, OpenUIErrorCode, ValidationErrorCode and the lang-core types react-lang does not export are no longer re-exported; import them from @openuidev/lang-core.
  • A server render spec (server-render.ssr.ts, run by vitest.ssr.config.ts; test runs both suites). Adds @angular/platform-server as a dev dependency.
  • Depends on the workspace lang-core (published as ~1.3.0) instead of 0.4.
  • Adds angular-lang to the lang-core / react-lang changeset fixed group, so it releases as 1.3.0.
  • README: "Migration from 0.4" and "Known differences from react-lang".

Test Plan

  • typecheck, test typecheck, 69 tests plus 2 server render tests, lint, format, build, verify-peer-windows; lang-core (371) and react-lang (92) tests pass on this branch.
  • Differential fuzz against react-lang: 5,000 random streamed, rendered and interacted cases. Remaining known differences are listed under Follow-ups.

Checklist

Notes

  • pnpm-lock.yaml and .changeset/config.json conflict with the Svelte and Vue PRs once one of them is merged. Regenerate the lockfile with pnpm install --lockfile-only and keep every port in the fixed group.

Follow-ups

  • Known differences from react-lang found by the fuzz: the number of library function calls per update (accepted: library functions must be pure), a commit that lands one tick later than react-lang's, and two same-named fields both writing a default.
  • Not ported from react-lang yet: provenance (readSourceTarget), useDataSources, WithPreviewRenderer / useRendererPreview.
  • button[openuiRendererRetry] retries even when the app's own (click) calls preventDefault().
  • A component that throws while Angular refreshes it for one of its own signals reaches Angular's ErrorHandler, not (error).

@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
openui-docs Ready Ready Preview Dec 4, 2026 5:28pm UTC

Request Review

An Angular view layer over @openuidev/lang-core/runtime: one message
runtime per Renderer, elements as views of their RenderNode's
ViewContainerRef with the first instance created in place (so server
rendered HTML can hydrate), an element boundary that keeps the last
valid render, projected openui-renderer-* slots. injectSetDefaultValue
replaces setDefaultValue; OpenUiToolProvider is now ToolProviderInput
(the old name stays for one minor). Adds a server-render spec
(server-render.ssr.ts, run by vitest.ssr.config.ts).

As in 0.4: rendered elements are keyed by statement id and occurrence
(else index path), [library]="null" renders nothing, and a form name
passed as the signal injectFormName() returns is read.
defineComponent takes the schema as its only type argument.

package.json: lang-core is a workspace dependency (workspace:~), catalog
versions where openui uses them, exports under publishConfig, and
@angular/platform-server pinned to 22.1.7, the Angular version the
lockfile resolves (a range resolves it to 22.3.0 against core 22.1.7).
The README has a migration section from 0.4.
As in angular-lang 0.4, an element is reused only when its typeName is
unchanged: two library components rendered by one Angular class no
longer share an instance (and its typed text) when one replaces the
other.
Each element is placed right after the views placed before it, counted
as the reconciliation goes, instead of scanning the entries for every
item; a kept view is compared with the container's view at its index.
Prepending to 4,000 items takes about 5 ms instead of growing with the
square of the list, as in angular-lang 0.4.
A component declaring `@Input() props?: {...}` compiles again: the props
type is read from an optional input too (it resolved to never), as
angular-lang 0.4 accepted it.
Content projected into <openui-renderer-query-loading> or
<openui-renderer-query-error> inside an <ng-template> is created only
while the slot shows, as react-lang renders a slot's children; plain
projected content keeps working.
They describe the current renderer inputs (library may be null, toolProvider is
ToolProviderInput) with each output as a callback. A type check in
renderer.spec.ts keeps them in step with the component's inputs.
0.4 emitted both from ngOnChanges, which also runs on the server. The
runtime glue only mounted and committed in afterNextRender, a no-op on the
server, so neither output fired there. On the server the glue now calls
the runtime's reportOnServer once, as vue-lang does.
…iles

The copied reactive() and the hand-built render-error (with its message helper) go. The
unreferenced tsconfig.spec.json and the ActionConfig re-export in context.ts nothing imported are
deleted. README and the renderNode JSDoc say injectRenderNode() returns its argument unchanged;
children nest with <openui-render-node [value]>.
triggerAction, setFieldValue, evaluationContext and queryManager were only
ever read through untracked(...), so their computeds added nothing:
untracked(view) reads the same value.
…down

- Entry is TextEntry | ElementEntry instead of one type with nine optional
  fields, which drops the non-null assertions on type and node
- ngOnChanges passes the container index it is placing at down to render,
  create and place, instead of a placing field that slotIndex special-cased
  (still linear time)
- render decides once whether the instance is healthy
…ist test

The test timed a prepend at two sizes and compared the ratio, which is
flaky on a busy machine (and a failure there skipped the server render
suite). It now counts view lookups, container scans and moves for a
prepend to 100 and to 1,000 items: lookups grow with the list, scans do
not, and nothing moves. The 0.4 placement fails it (about n squared / 2
lookups).
…faults

State is initialized after mount, as in react-lang, and the server render
test asserts the defaults are not in the server HTML.
The runtime lives in a computed over the library input, created once there is a library: a new
library starts a new message and a null library renders nothing (no NO_LIBRARY runtime, no early
onError([])). An effect per runtime subscribes, mounts after the next render and unmounts on
cleanup; the render output is a computed over the epoch, committed after each render. The context
reads the current runtime and view; boundaries call setRenderError through it; retry and
getParseResult call the runtime. ResponseMetadata is no longer re-exported.
…svelte-lang and vue-lang; a server-render comment names render
…oes not export

parse, resolveStateField, stripReactiveAssign, OpenUIErrorCode, ValidationErrorCode,
InferStateFieldValue and isElementNode are no longer re-exported (import them from
@openuidev/lang-core); AcceptsSchema and PropsOf stay internal. README migration
section and changeset say so.
…Schema, TriggerAction, DefaultValueRequest and FieldErrors, as react-lang
A new library starts a new message, and react-lang remounts the tree. The render node reused an
instance when the component class, type name and context matched, so a library reset kept the
old instances and the props they last rendered (including `partial` flags from streaming). An
instance is now reused only for the library it was rendered from.
…fecycle methods, the removed exports and upgrading lang-core alongside
- Migration notes: the host is display: contents (was block) and the 0.4 renderer classes are
  gone; a custom queryLoader renders in flow; library is a required input; OpenUiContextValue
  drops the report*/clearError members and requires storeSnapshot, revision, applyDefault,
  getParseResult and queryManager (for code that builds its own [context]); a form-name signal
  is always truthy
- The deprecated setDefaultValue takes the injectFormName() signal as formName, with a test
- README: zod/v4 in samples; the lang-core link points at the migration section
- @angular/platform-server comes from the catalog like the other @angular packages
…ads, trim the new exports

- RenderNode keeps the context and library its entries rendered with on the component, not per entry
- inline report() and componentOf(); setRenderError goes through the rendered context everywhere
- the context reads getFieldValue/applyDefault off the view directly instead of through computeds
- OPENUI_RENDERER, RendererSlotContext and OPENUI_FORM are no longer exported (new since 0.4.2;
  injectRendererQuery and injectOpenUiForm/provideOpenUiForm cover them)
- rxjs is no longer a peer dependency: nothing imports it
…he other ports and aligned to 1.2.1 so this release lands at 1.3.0
…rror only if it still fails once the query is registered

This branch was successfully deployed

1 active deployment
Preview — e8308280 Deployed Dec 4, 2026 by vercel[bot]
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