Skip to content

feat(react): feed the MarkdownContext renderer to web_core's basic catalog - #2910

Merged
josemontespg merged 1 commit into
mainfrom
react-markdown-renderer-bridge
Oct 1, 2026
Merged

josemontespg merged 1 commit into
mainfrom
react-markdown-renderer-bridge

Conversation

@josemontespg

@josemontespg josemontespg commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A2uiSurface hands the renderer from MarkdownContext to web_core's setMarkdownRenderer, the same way the Angular renderer does. Once the renderer hosts universal Web Components (#2849), web_core's Text renders markdown with the renderer the application already provides to React components; nothing in the React tree changes today. MarkdownContext moves out of the basic catalog folder to src/v0_9/markdown-context.tsx; its export from @a2ui/react/v0_9 does not change.

The slot is set in a layout effect, during commit, so it is in place before any Lit element in the surface updates. A surface without a MarkdownContext renderer leaves the slot untouched, so a renderer the host registered directly keeps working. Nothing here parses markdown: web_core has no markdown dependency and @a2ui/markdown-it stays opt-in.

Changes

  • A2uiSurface.tsx: useMarkdownRenderer() + useLayoutEffect calling setMarkdownRenderer(renderer) when the context provides one.
  • markdown-context.tsx: moved from catalog/basic/context/MarkdownContext.tsx; the basic catalog's two imports updated.
  • tests/v0_9/markdown-bridge.test.tsx: the context renderer reaches getMarkdownRenderer(); no renderer anywhere registers nothing; a host-registered renderer survives a surface without context. refactor(react)!: delete the React basic catalog implementation #2630 extends it to render web_core's Text through the context renderer.

Verification

  • yarn --cwd renderers/react test passes (479 vitest tests).

@github-project-automation github-project-automation Bot moved this to Todo in A2UI Sep 30, 2026
@josemontespg
josemontespg force-pushed the react-markdown-renderer-bridge branch from c8fde76 to 0997cb7 Compare September 30, 2026 19:47

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates A2uiSurface to register the markdown renderer from MarkdownContext with web_core's basic catalog, ensuring consistent markdown rendering across universal Web Components. It also moves MarkdownContext to a shared location and adds a test suite for the markdown bridge. The review feedback suggests replacing useLayoutEffect with an isomorphic layout effect (useIsomorphicLayoutEffect) to prevent potential React SSR warnings in server-side rendering environments.

@josemontespg
josemontespg force-pushed the react-markdown-renderer-bridge branch from 0997cb7 to 549a734 Compare September 30, 2026 20:43
@josemontespg
josemontespg removed this pull request from stack #2911 September 30, 2026 20:52
@josemontespg
josemontespg force-pushed the react-markdown-renderer-bridge branch from 549a734 to b558597 Compare September 30, 2026 20:52
@josemontespg
josemontespg changed the base branch from react-portal-hosts-node to react-implementation-types September 30, 2026 20:52
@josemontespg
josemontespg removed this pull request from stack #2913 September 30, 2026 21:07
@josemontespg
josemontespg force-pushed the react-markdown-renderer-bridge branch from b558597 to bd85ea4 Compare October 1, 2026 17:25
@josemontespg
josemontespg force-pushed the react-markdown-renderer-bridge branch from bd85ea4 to 42fa87d Compare October 1, 2026 18:25
@josemontespg
josemontespg marked this pull request as ready for review October 1, 2026 18:27
@josemontespg
josemontespg force-pushed the react-markdown-renderer-bridge branch from 42fa87d to 68e2552 Compare October 1, 2026 20:07

@andrewkolos andrewkolos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@josemontespg
josemontespg force-pushed the react-markdown-renderer-bridge branch 2 times, most recently from c4aaf4c to 0ad9a89 Compare October 1, 2026 20:29
@josemontespg
josemontespg removed this pull request from stack #2915 October 1, 2026 20:30
@josemontespg
josemontespg added this pull request to stack #2941 October 1, 2026 20:31
@josemontespg
josemontespg force-pushed the react-markdown-renderer-bridge branch from 0ad9a89 to b8d3b32 Compare October 1, 2026 20:43
@josemontespg
josemontespg removed this pull request from stack #2941 October 1, 2026 20:53
@josemontespg
josemontespg added this pull request to stack #2942 October 1, 2026 20:53
Base automatically changed from react-implementation-types to main October 1, 2026 21:28
…talog

`A2uiSurface` hands the renderer from `MarkdownContext` to web_core's
`setMarkdownRenderer`, the same way the Angular renderer does, so universal
Web Components in a surface render markdown with the renderer the
application already provides to React components. The slot is set in a
layout effect, during commit.

`MarkdownContext` moves out of the basic catalog folder to
`src/v0_9/markdown-context.tsx`; its export from `@a2ui/react/v0_9` does not
change.
@josemontespg
josemontespg force-pushed the react-markdown-renderer-bridge branch from b8d3b32 to d6ae4d8 Compare October 1, 2026 21:28
@josemontespg
josemontespg removed this pull request from stack #2942 October 1, 2026 21:41
@josemontespg
josemontespg added this pull request to stack #2943 October 1, 2026 21:42
@josemontespg
josemontespg merged commit 753cb7a into main Oct 1, 2026
40 checks passed
@josemontespg
josemontespg deleted the react-markdown-renderer-bridge branch October 1, 2026 21:43
@github-project-automation github-project-automation Bot moved this from Todo to Done in A2UI Oct 1, 2026
josemontespg added a commit that referenced this pull request Oct 5, 2026
The v0_9 React renderer renders the basic catalog through the Web Components in `@a2ui/web_core/v0_9/basic_catalog`, so the 23 duplicated React implementations are removed along with their unit tests.

## What changes for consumers

Import the catalog and the individual components from web_core:

```diff
-import {A2uiSurface, basicCatalog} from '@a2ui/react/v0_9';
+import {A2uiSurface} from '@a2ui/react/v0_9';
+import {basicCatalog} from '@a2ui/web_core/v0_9/basic_catalog';
```

`MarkdownContext` and `useMarkdownRenderer` keep their names, their behaviour, and their import path. `A2uiSurface` already feeds the context value to web_core's basic catalog (#2910), so markdown wiring in consumer code does not change.

Custom React components are unaffected: `createComponentImplementation` still returns a React implementation, and the renderer still renders it through React.

## Breaking

- `@a2ui/react/v0_9` no longer exports `basicCatalog`, `Text`, `Button`, `Card`, or the other basic components.
- The basic catalog no longer server-renders, since custom elements produce no markup outside a browser. An application that needs SSR for these components needs a React-SSR renderer.

## Testing

- `renderers/react` unit tests pass; `integration-scenarios.test.tsx` now drives the web_core catalog end to end and waits for Lit's update cycle.
- The explorer's Karma suite passes against the web component catalog.
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