Skip to content

feat(web_core): add universal markdown fallback in text component - #2272

Draft
josemontespg wants to merge 1 commit into
basic-catalog-universal-componentsfrom
web-core-universal-markdown
Draft

feat(web_core): add universal markdown fallback in text component#2272
josemontespg wants to merge 1 commit into
basic-catalog-universal-componentsfrom
web-core-universal-markdown

Conversation

@josemontespg

Copy link
Copy Markdown
Collaborator

Description

Implements universal markdown fallback support in @a2ui/web_core basic catalog text component.

Key Changes

  1. Dynamic Optional Markdown Renderer:

    • Added optional dynamic import('@a2ui/markdown-it') fallback when no custom markdownRenderer is provided via @lit/context or component properties.
    • If @a2ui/markdown-it is available in consumer bundles, text components asynchronously render rich Markdown into contextual DOM fragments.
    • If @a2ui/markdown-it is not installed or fails to load, text components gracefully fallback to plain text rendering without runtime errors or console spam.
  2. Race Condition Prevention:

    • Added stale-render guards (if (value !== this.lastValue) return;) in MarkdownDirective for both custom renderers and dynamic default renderer resolutions to prevent out-of-order renders during rapid text updates (e.g. streaming LLM responses).
  3. Peer Dependency & Documentation:

    • Registered @a2ui/markdown-it in peerDependencies (marked optional) and devDependencies in web_core/package.json.
    • Added changelog entry in renderers/web_core/CHANGELOG.md.
  4. Testing:

    • Added unit test suite in renderers/web_core/src/v0_9/basic_catalog/directives/markdown.test.ts verifying fallback rendering, custom renderers, and out-of-order promise resolution protection.

Pre-launch Checklist

  • I read the [Contributors Guide].
  • I read the [Style Guide].
  • My code changes (if any) have tests.

@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 introduces @a2ui/markdown-it as an optional peer dependency to @a2ui/web_core to enable automatic Markdown rendering for text components, alongside adding unit tests for the MarkdownDirective. Feedback on these changes suggests improving the directive's robustness against race conditions by using an auto-incrementing renderId counter instead of simple value comparison. Additionally, the reviewer recommends caching the resolved renderer state synchronously to avoid unnecessary microtask overhead on subsequent renders, and removing the console warning when the optional peer dependency is not installed to prevent console clutter.

Comment thread renderers/web_core/src/v0_9/basic_catalog/directives/markdown.ts
Comment thread renderers/web_core/src/v0_9/basic_catalog/directives/markdown.ts
@josemontespg
josemontespg force-pushed the web-core-universal-markdown branch from 9d695e6 to 5737a58 Compare August 14, 2026 19:17
@josemontespg
josemontespg marked this pull request as draft August 14, 2026 19:22
@josemontespg
josemontespg force-pushed the web-core-universal-markdown branch 7 times, most recently from 362589a to 565018c Compare August 17, 2026 19:33
@josemontespg
josemontespg force-pushed the web-core-universal-markdown branch from 565018c to a6e29ba Compare August 17, 2026 20:31
@josemontespg
josemontespg force-pushed the web-core-universal-markdown branch 2 times, most recently from d4d8c50 to d54e001 Compare August 17, 2026 20:57
@josemontespg
josemontespg force-pushed the web-core-universal-markdown branch from d54e001 to 167476d Compare August 17, 2026 21:27
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