Skip to content

fix: implement markdown rendering in AI chat panel#150

Open
Rakshi2609 wants to merge 1 commit into
piyushdotcomm:mainfrom
Rakshi2609:fix/markdown-rendering-fresh
Open

fix: implement markdown rendering in AI chat panel#150
Rakshi2609 wants to merge 1 commit into
piyushdotcomm:mainfrom
Rakshi2609:fix/markdown-rendering-fresh

Conversation

@Rakshi2609
Copy link
Copy Markdown
Contributor

@Rakshi2609 Rakshi2609 commented May 16, 2026

Summary

  • Added markdown rendering support in the AI chat panel using react-markdown
  • Added GitHub Flavored Markdown (GFM) support with remark-gfm
  • Implemented syntax highlighting for code blocks using react-syntax-highlighter
  • Integrated Tailwind Typography styles for improved markdown formatting
  • Enhanced chat message rendering for both user and AI responses

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Test or CI improvement
  • Starter template change

Related issue

Closes #

Validation

  • npm run lint
  • npm test
  • npm run build

List any additional manual verification you performed:

  • Verified markdown rendering in AI chat messages
  • Tested code block syntax highlighting
  • Checked rendering for lists, headings, tables, and inline code

Screenshots or recordings

Add screenshots demonstrating markdown and code block rendering improvements.

Checklist

  • I kept this PR focused on one primary change
  • I updated documentation if behavior changed
  • I did not commit secrets, local logs, or scratch files
  • I am requesting review on the correct scope

Summary by CodeRabbit

New Features

  • Chat messages now support Markdown rendering, enabling richer text formatting and styling options
  • Code blocks in chat display syntax highlighting with professional color themes for improved readability
  • Enhanced typography styling utilities applied throughout the application for better text presentation

Review Change Stack

@Rakshi2609 Rakshi2609 requested a review from piyushdotcomm as a code owner May 16, 2026 12:48
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions
Copy link
Copy Markdown

👋 Thanks for opening a PR, @Rakshi2609!

Your PR has entered the 🚦 PR Review Pipeline.

Standard PR detected — your PR will follow the standard review pipeline.


What happens next

Stage Reviewer Checks
Stage 1 — Automated Validation 🤖 Bot DCO · Format · AI/Slop · Duplicate
Stage 2 — Human Review 👥 Maintainer Code + Quality Review
Stage 3 — PA / Maintainer Review 🔑 Project Admin Final Merge Decision

A pipeline status comment will appear below and update automatically as your PR progresses.


While you wait

  • Sign all commits (git commit -s)
  • Link your issue (Closes #123)
  • Use a feature branch (not main)
  • Avoid unrelated changes

This comment is posted only once.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Walkthrough

Chat messages in the playground now render as Markdown with syntax-highlighted code blocks. The feature adds dependencies for Markdown parsing and Prism syntax highlighting, enables Tailwind typography styling, and updates the chat component to render user and assistant messages through ReactMarkdown with custom code rendering for language-specific highlighting.

Changes

Markdown Chat Rendering

Layer / File(s) Summary
Dependencies and Tailwind typography plugin
package.json, app/globals.css
Added react-markdown, remark-gfm, react-syntax-highlighter, and type definitions. Enabled @tailwindcss/typography plugin to provide prose-based text styling.
Chat message Markdown rendering with code highlighting
modules/playground/components/ai-chat-panel.tsx
Imported Markdown libraries and syntax highlighter. User messages render via ReactMarkdown with prose styling. Assistant messages render Markdown text and use custom code rendering to detect language from class names, apply Prism highlighting with vscDarkPlus theme for fenced blocks, and plain <code> elements for inline code.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Chat messages bloom with colors so bright,
Markdown syntax now dancing in light,
Code blocks glow with Prism's cheer,
Making the playground crystal clear! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: implementing markdown rendering in the AI chat panel, which aligns with the core modifications across multiple files.
Description check ✅ Passed The description covers the main changes, includes type of change, and lists manual verification performed; however, the related issue reference remains a placeholder and lint/test validation checkboxes are unchecked.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/globals.css`:
- Line 2: The Stylelint config is flagging Tailwind v4 at-rules like
`@plugin/`@custom-variant/@theme used in app/globals.css; update the
.stylelintrc.json to allow these by adding them to the at-rule-no-unknown rule's
ignoreAtRules array (include "plugin", "theme", "custom-variant" along with
existing Tailwind at-rules such as
"tailwind","layer","apply","responsive","screen","import") so stylelint no
longer reports valid Tailwind v4 at-rules as unknown.

In `@modules/playground/components/ai-chat-panel.tsx`:
- Around line 388-389: The regex used to extract the fenced-code language from
className (currently /language-(\w+)/) is too narrow and misses tokens like
"objective-c" or "c++"; update the pattern where match is assigned (the line
with const match = /language-(\w+)/.exec(className || "")) to use a broader
capture such as /language-([^\s]+)/ (or equivalent) so the match variable
captures hyphens, pluses, and other non-whitespace language IDs; keep the
subsequent logic that checks !inline && match unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c2064808-b9f5-4b90-82b7-5df3ea1bdc1e

📥 Commits

Reviewing files that changed from the base of the PR and between d470fd0 and b716feb.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • app/globals.css
  • modules/playground/components/ai-chat-panel.tsx
  • package.json

Comment thread app/globals.css
@@ -1,4 +1,5 @@
@import "tailwindcss";
@plugin "@tailwindcss/typography";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether stylelint config is present and whether Tailwind at-rules are ignored.
fd -i 'stylelint*' .
fd -i '.stylelintrc*' .
rg -n -C3 'at-rule-no-unknown|ignoreAtRules|scss/at-rule-no-unknown|plugin|custom-variant|theme' $(fd -i 'stylelint*|.stylelintrc*' .)

# Inspect CSS files that use Tailwind v4 at-rules.
rg -n -C2 '`@plugin`|`@theme`|`@custom-variant`' app/globals.css

Repository: piyushdotcomm/Editron

Length of output: 50379


🏁 Script executed:

cat -n app/globals.css

Repository: piyushdotcomm/Editron

Length of output: 10386


🏁 Script executed:

find . -name ".stylelintrc*" -o -name "stylelint.config.*" 2>/dev/null | head -20

Repository: piyushdotcomm/Editron

Length of output: 85


🏁 Script executed:

rg "ignoreAtRules" . --type-list | head -5

Repository: piyushdotcomm/Editron

Length of output: 455


🏁 Script executed:

cat -n .stylelintrc.json

Repository: piyushdotcomm/Editron

Length of output: 1691


Configure stylelint to accept Tailwind v4 at-rules (@plugin, @custom-variant, @theme).

The file uses valid Tailwind v4 at-rules that stylelint's at-rule-no-unknown rule flags as errors. Add these to the .stylelintrc.json configuration by setting at-rule-no-unknown rule's ignoreAtRules option to include Tailwind at-rules.

Example configuration
{
  "rules": {
    "at-rule-no-unknown": [
      true,
      {
        "ignoreAtRules": [
          "tailwind",
          "layer",
          "apply",
          "responsive",
          "screen",
          "plugin",
          "theme",
          "custom-variant",
          "import"
        ]
      }
    ]
  }
}
🧰 Tools
🪛 Stylelint (17.11.0)

[error] 2-2: Unexpected unknown at-rule "@plugin" (scss/at-rule-no-unknown)

(scss/at-rule-no-unknown)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/globals.css` at line 2, The Stylelint config is flagging Tailwind v4
at-rules like `@plugin/`@custom-variant/@theme used in app/globals.css; update the
.stylelintrc.json to allow these by adding them to the at-rule-no-unknown rule's
ignoreAtRules array (include "plugin", "theme", "custom-variant" along with
existing Tailwind at-rules such as
"tailwind","layer","apply","responsive","screen","import") so stylelint no
longer reports valid Tailwind v4 at-rules as unknown.

Comment on lines +388 to +389
const match = /language-(\w+)/.exec(className || "");
return !inline && match ? (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Broaden code-block language parsing for fenced blocks.

/language-(\w+)/ is too restrictive and misses valid language IDs like objective-c or c++, so some fenced blocks won’t get highlighted. Prefer a broader capture like /language-([^\s]+)/.

Suggested patch
-const match = /language-(\w+)/.exec(className || "");
+const match = /language-([^\s]+)/.exec(className || "");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const match = /language-(\w+)/.exec(className || "");
return !inline && match ? (
const match = /language-([^\s]+)/.exec(className || "");
return !inline && match ? (
🧰 Tools
🪛 OpenGrep (1.20.0)

[ERROR] 388-388: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.

(coderabbit.command-injection.exec-js)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modules/playground/components/ai-chat-panel.tsx` around lines 388 - 389, The
regex used to extract the fenced-code language from className (currently
/language-(\w+)/) is too narrow and misses tokens like "objective-c" or "c++";
update the pattern where match is assigned (the line with const match =
/language-(\w+)/.exec(className || "")) to use a broader capture such as
/language-([^\s]+)/ (or equivalent) so the match variable captures hyphens,
pluses, and other non-whitespace language IDs; keep the subsequent logic that
checks !inline && match unchanged.

Copy link
Copy Markdown
Owner

@piyushdotcomm piyushdotcomm left a comment

Choose a reason for hiding this comment

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

add screenshot or recording of the improvement and tag the issue number in the description
and address the review of coderabbit also before tagging me

Comment thread package-lock.json
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

again you changed this file?

@Maxd646 Maxd646 self-requested a review May 20, 2026 16:38
Copy link
Copy Markdown
Collaborator

@Maxd646 Maxd646 left a comment

Choose a reason for hiding this comment

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

Hey @Rakshi2609, nice work on this — markdown rendering in the chat panel is a solid improvement. A few things to fix before we can merge:

Needs fixing:

  1. The regex for extracting code block language is too narrow. /language-(\w+)/ misses language IDs like c++, objective-c, shell-session, etc. Change it to /language-([^\s]+)/.

  2. The inline prop on the code component was removed in react-markdown v9+. The any cast is hiding this. Check the node position to detect block vs inline code instead — otherwise this will break silently on upgrade.

  3. Add "plugin", "theme", and "custom-variant" to the ignoreAtRules array in .stylelintrc.json. The @plugin line in globals.css will fail stylelint as-is.

. The prose-invert class on the user message bubble will force light-on-dark colors even in light mode. The AI bubble correctly uses dark:prose-invert — apply the same pattern to the user bubble.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants