ai-chatbot icon indicating copy to clipboard operation
ai-chatbot copied to clipboard

Updated markdown libraries and fixed breaking changes and type issues

Open jb-dev1 opened this issue 1 year ago • 2 comments

Summary:

This PR updates the markdown-related libraries (react-markdown, remark-gfm, and remark-math) and addresses the resulting breaking changes caused by the upgrades. Fixes #414.

Changes:

  1. Inline vs Block Code Handling:

    • The inline prop is no longer passed by react-markdown (v9.x+). We now determine whether a code block is inline by checking for the absence of a className attribute.
    • Added a fallback class "inline-code" for inline code blocks to maintain consistent styling.
  2. Safe Access to children Prop:

    • Added safety checks to ensure that children is defined, is an array, and handled correctly (e.g., checking children.length or replacing its first element). This avoids potential runtime errors where children could be null or undefined.
    • Adjusted the handling of children and other props to conform to strict type checking, ensuring that we account for possible null or undefined values in rendering components.
  3. Special Character Handling:

    • Retained logic to replace occurrences of with a pulse animation for custom rendering, ensuring compatibility with the updated react-markdown behavior.
    • Safeguarded this replacement logic by first checking that children[0] exists and is a string.

Affected Files:

  • components/stocks/message.tsx: Fixed handling of inline vs block code and added null checks for children.
  • components/chat-message.tsx (although unused): Applied similar fixes to handle breaking changes from react-markdown and ensure type safety so that build would not fail since this file is included.

Testing:

  • Successfully built the project after applying changes.
  • Verified correct rendering of both inline and block code snippets in user and bot messages.

jb-dev1 avatar Sep 08 '24 11:09 jb-dev1

Someone is attempting to deploy a commit to the Uncurated Tests Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Sep 08 '24 11:09 vercel[bot]

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] Transitive: environment +80 2.61 MB wooorm
npm/[email protected] Transitive: environment +67 2.34 MB wooorm
npm/[email protected] Transitive: environment, filesystem, shell +55 6 MB wooorm

🚮 Removed packages: npm/[email protected]), npm/[email protected]), npm/[email protected])

View full report↗︎

socket-security[bot] avatar Sep 08 '24 11:09 socket-security[bot]

Should be resolved by implementation of Streamdown

haydenbleasel avatar Nov 01 '25 01:11 haydenbleasel