Skip to content

Conversation

@jfperusse
Copy link
Contributor

@jfperusse jfperusse commented Dec 15, 2025

For a user message like this:

Capture d’écran 2025-12-15 114151

By default, Chainlit renders them as markdown:

Capture d’écran 2025-12-15 114407

This can lead to confusion. With the new user_message_markdown option set to false, such messages render as sent by the user:

Capture d’écran 2025-12-15 114203

Summary by cubic

Adds a config option to control markdown rendering for user messages. When disabled, user messages render as plain text to avoid confusing formatting.

  • New Features

    • Added features.user_message_markdown (default true) to config.
    • Frontend respects the setting for user messages; bot outputs, readme, and profile descriptions still render markdown.
    • Updated types to include the new flag.
  • Migration

    • To disable markdown for user messages, set user_message_markdown = false in your Chainlit config and restart.

Written for commit e7ddf30. Summary will update automatically on new commits.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. frontend Pertains to the frontend. labels Dec 15, 2025

const videoExtensions = ['.mp4', '.webm', '.mov', '.avi', '.ogv', '.m4v'];
const isVideo = videoExtensions.some(ext =>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to include this to pass the linter checks.

isLoading
} = useApi<IThread>(
id ? (isSharedRoute ? `/project/share/${id}` : `/project/thread/${id}`) : null,
id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to include this to pass the linter checks.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

4 issues found across 12 files

Prompt for AI agents (all 4 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="frontend/src/components/chat/Messages/Message/Content/index.tsx">

<violation number="1" location="frontend/src/components/chat/Messages/Message/Content/index.tsx:19">
P1: The new `renderMarkdown` prop is not included in the `memo` comparison function. When `renderMarkdown` changes, the component won&#39;t re-render because the custom comparison function doesn&#39;t check this prop. Add `prevProps.renderMarkdown === nextProps.renderMarkdown &amp;&amp;` to the comparison function.</violation>
</file>

<file name="frontend/src/components/Markdown.tsx">

<violation number="1" location="frontend/src/components/Markdown.tsx:102">
P1: Using `!renderMarkdown` will skip markdown rendering when the prop is `undefined` (not passed), breaking backward compatibility. Existing callers that don&#39;t pass this prop will now get plain text instead of rendered markdown.

Use strict equality `renderMarkdown === false` to only skip markdown when explicitly disabled, preserving the default markdown behavior.</violation>
</file>

<file name="frontend/src/components/chat/MessagesContainer/index.tsx">

<violation number="1" location="frontend/src/components/chat/MessagesContainer/index.tsx:127">
P1: Missing `config?.features?.user_message_markdown` in the `useMemo` dependency array. If this config value changes, the memoized context won&#39;t update, causing stale `renderUserMarkdown` values to be passed to children. Add it to the dependency array like `unsafe_allow_html` is handled.</violation>
</file>

<file name="frontend/src/components/ReadOnlyThread.tsx">

<violation number="1" location="frontend/src/components/ReadOnlyThread.tsx:160">
P2: Missing `config?.features?.user_message_markdown` in the `useMemo` dependency array. If this config value changes, the memoized context won&#39;t update, causing stale `renderMarkdown` values to be used.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

}: Props) => {
const apiClient = useContext(ChainlitContext);

if (!renderMarkdown) {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 15, 2025

Choose a reason for hiding this comment

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

P1: Using !renderMarkdown will skip markdown rendering when the prop is undefined (not passed), breaking backward compatibility. Existing callers that don't pass this prop will now get plain text instead of rendered markdown.

Use strict equality renderMarkdown === false to only skip markdown when explicitly disabled, preserving the default markdown behavior.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/components/Markdown.tsx, line 102:

<comment>Using `!renderMarkdown` will skip markdown rendering when the prop is `undefined` (not passed), breaking backward compatibility. Existing callers that don&#39;t pass this prop will now get plain text instead of rendered markdown.

Use strict equality `renderMarkdown === false` to only skip markdown when explicitly disabled, preserving the default markdown behavior.</comment>

<file context>
@@ -91,12 +92,24 @@ const cursorPlugin = () =&gt; {
 }: Props) =&gt; {
   const apiClient = useContext(ChainlitContext);
 
+  if (!renderMarkdown) {
+    return (
+      &lt;pre
</file context>
Suggested change
if (!renderMarkdown) {
if (renderMarkdown === false) {
Fix with Cubic

askUser,
allowHtml: config?.features?.unsafe_allow_html,
latex: config?.features?.latex,
renderUserMarkdown: config?.features?.user_message_markdown,
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 15, 2025

Choose a reason for hiding this comment

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

P1: Missing config?.features?.user_message_markdown in the useMemo dependency array. If this config value changes, the memoized context won't update, causing stale renderUserMarkdown values to be passed to children. Add it to the dependency array like unsafe_allow_html is handled.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/components/chat/MessagesContainer/index.tsx, line 127:

<comment>Missing `config?.features?.user_message_markdown` in the `useMemo` dependency array. If this config value changes, the memoized context won&#39;t update, causing stale `renderUserMarkdown` values to be passed to children. Add it to the dependency array like `unsafe_allow_html` is handled.</comment>

<file context>
@@ -124,6 +124,7 @@ const MessagesContainer = ({ navigate }: Props) =&gt; {
       askUser,
       allowHtml: config?.features?.unsafe_allow_html,
       latex: config?.features?.latex,
+      renderUserMarkdown: config?.features?.user_message_markdown,
       editable: !!config?.features.edit_message,
       loading,
</file context>
Fix with Cubic

return {
allowHtml: config?.features?.unsafe_allow_html,
latex: config?.features?.latex,
renderMarkdown: config?.features?.user_message_markdown,
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 15, 2025

Choose a reason for hiding this comment

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

P2: Missing config?.features?.user_message_markdown in the useMemo dependency array. If this config value changes, the memoized context won't update, causing stale renderMarkdown values to be used.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/components/ReadOnlyThread.tsx, line 160:

<comment>Missing `config?.features?.user_message_markdown` in the `useMemo` dependency array. If this config value changes, the memoized context won&#39;t update, causing stale `renderMarkdown` values to be used.</comment>

<file context>
@@ -153,6 +157,7 @@ const ReadOnlyThread = ({ id }: Props) =&gt; {
     return {
       allowHtml: config?.features?.unsafe_allow_html,
       latex: config?.features?.latex,
+      renderMarkdown: config?.features?.user_message_markdown,
       editable: false,
       loading: false,
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Pertains to the frontend. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant