Skip to content

Conversation

@JorkeyLiu
Copy link

@JorkeyLiu JorkeyLiu commented Apr 12, 2025

Context

The Markdown rendering previously used for chat messages (primarily via ChatRow.tsx) was incomplete and failed to render several standard Markdown elements correctly. Notably, list markers (both unordered bullets and ordered numbers) were not displayed, and GFM elements like tables appeared as unformatted plain text.

After switching to a more standard-compliant Markdown renderer (@/components/ui/markdown/Markdown.tsx) to address these fundamental rendering issues, further visual inconsistencies were observed compared to the previous implementation. These included differences in list indentation depth, bold text weight, and the styling (background, font, padding, border, alignment) of inline code blocks.

The primary root cause was the use of an incomplete and non-standard Markdown renderer (MarkdownBlock.tsx) in the main chat message rendering path. Secondary styling issues arose from the inherent visual differences between the old styled-components -based styling and the new Tailwind CSS-based styling after switching to the standard renderer.

Implementation

  • Identified two distinct Markdown rendering implementations:
    • @/components/common/MarkdownBlock.tsx: Used react-remark and styled-components. This implementation lacked complete CommonMark support (missing list markers) and GFM support (no tables). It had custom styling, auto-URL linking, and Mermaid support.
    • @/components/ui/markdown/Markdown.tsx: Uses react-markdown with remark-gfm and Tailwind CSS. Provides more robust and standard-compliant Markdown rendering, including GFM features.
  • Determined that ChatRow.tsx, responsible for rendering many chat messages, was incorrectly relying on the limited MarkdownBlock.tsx implementation.
  • Solution Part 1 (Core Fix): Refactored ChatRow.tsx to consistently use the shared, standard-compliant @/components/ui/markdown/Markdown.tsx component. This resolved the fundamental rendering issues for lists, tables, and other standard elements.
  • Solution Part 2 (Styling Adjustments): Fine-tuned the Tailwind CSS classes within the shared @/components/ui/markdown/Markdown.tsx component to address visual discrepancies introduced by the renderer switch. Adjustments included list indentation (pl-[2.5em]), bold weight (font-semibold), inline code styling (background, color, padding, border, font, alignment), and ensuring the base font size uses var(--vscode-font-size).
  • Solution Part 3 (UI Feature Restoration): Re-implemented the hover-to-copy functionality and specific negative vertical margins (originally present in ChatRow.tsx 's local wrapper) by creating a new wrapper component (MarkdownWithCopy) within ChatRow.tsx around the shared <Markdown /> component. This restored specific UI interactions and layout nuances desired for chat messages.

The solution involved replacing the deficient renderer with a standard-compliant one (react-markdown + remark-gfm), unifying the Markdown implementation used by ChatRow.tsx. Subsequently, styles were adjusted in the shared component, and specific UI features/layout wrappers were reintroduced in the calling component (ChatRow.tsx) to achieve functional and visual consistency with the intended design.

Screenshots

before:
image

after:
image

before:
image

after:
image

How to Test

To Reproduce
Steps to reproduce the behavior:

  1. Send a message to the Roo Code assistant containing a Markdown table (e.g., using pipe syntax).
  2. Observe the message rendered in the chat view (likely via ChatRow.tsx).
  3. Notice the table is not formatted.
  4. (After initial fix attempts) Observe other Markdown elements like lists, bold text, and inline code blocks and compare their styling to previous versions or other parts of the UI.

Expected behavior

  • Markdown tables should render as structured tables with appropriate borders and padding.
  • List indentation should be consistent and sufficiently deep for readability.
  • Bold text should have a standard, readable weight (e.g., font-semibold).
  • Inline code blocks should have a distinct background color (matching --vscode-textCodeBlock-background), appropriate padding, border, font, and alignment consistent with the surrounding text.

Get in Touch

[email protected]


Important

Refactor chat message Markdown rendering to use a unified component with GFM support, adjust styles for consistency, and restore specific UI features.

  • Behavior:
    • Refactored ChatRow.tsx to use @/components/ui/markdown/Markdown.tsx for consistent Markdown rendering with GFM table support.
    • Adjusted styles in Markdown.tsx for list indentation, bold text, and inline code blocks.
    • Restored hover-to-copy functionality in ChatRow.tsx using MarkdownWithCopy wrapper.
  • State Management:
    • Added hiddenBuiltInModes state to ExtensionStateContext.tsx and related files to manage visibility of built-in modes.
  • Testing:
    • Updated tests in ChatTextArea.test.tsx and PromptsView.test.tsx to reflect changes in Markdown rendering and state management.
  • Localization:
    • Updated localization files for multiple languages to include new strings related to mode visibility.

This description was created by Ellipsis for ae6b5754192d17a0a6cfa03bc7a1ebd4362c3a96. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Apr 12, 2025

⚠️ No Changeset found

Latest commit: 3aee27f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Apr 12, 2025
@ellipsis-dev
Copy link
Contributor

ellipsis-dev bot commented Apr 12, 2025

The pull request includes changes across 37 files, with 387 lines added and 138 lines removed. It seems to encompass several distinct themes:

  1. Hidden Built-In Modes Feature: This involves adding the 'hiddenBuiltInModes' property across various components and contexts.
  2. Localization Updates: Multiple localization files have been updated with new translation keys related to built-in modes.
  3. Markdown Styling Enhancements: Updates to Markdown styling and table support.

If these changes are not interdependent, it might be beneficial to split them into separate pull requests:

  • One for the 'hiddenBuiltInModes' feature implementation.
  • Another for the localization updates.
  • A third for the Markdown styling enhancements.

This could help in reviewing and testing each aspect more thoroughly. Please consider if these changes can be logically separated and if so, splitting them into smaller pull requests.

@JorkeyLiu JorkeyLiu changed the title Markdown Tables and Styling Inconsistencies in Chat Messages Incomplete Markdown Rendering and Styling Issues in Chat Messages Apr 12, 2025
@JorkeyLiu JorkeyLiu changed the title Incomplete Markdown Rendering and Styling Issues in Chat Messages Fix Incomplete Markdown Rendering and Styling Issues in Chat Messages Apr 13, 2025
@JorkeyLiu JorkeyLiu closed this Apr 13, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Apr 13, 2025
@JorkeyLiu JorkeyLiu reopened this Apr 13, 2025
@github-project-automation github-project-automation bot moved this from Done to New in Roo Code Roadmap Apr 13, 2025
Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Could you please separate out these changes from the hiddenBuiltInModes changes?

JorkeyLiu and others added 8 commits April 13, 2025 13:27
…y or another symbolic link (RooCodeInc#2513)

* read symbolic linked dir and files recursively

* add symlinked dir and nested symlink test case for custom-instructions

* enhance comments

* add changeset
* changeset version bump

* Updating CHANGELOG.md format

* Update CHANGELOG.md

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: R00-B0T <[email protected]>
Co-authored-by: Matt Rubens <[email protected]>
@JorkeyLiu JorkeyLiu force-pushed the improvement/table-css branch from cd64f70 to 64d0a72 Compare April 13, 2025 05:53
@JorkeyLiu JorkeyLiu closed this Apr 13, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Apr 13, 2025
@JorkeyLiu JorkeyLiu reopened this Apr 13, 2025
@github-project-automation github-project-automation bot moved this from Done to New in Roo Code Roadmap Apr 13, 2025
@JorkeyLiu
Copy link
Author

Thanks for the PR! Could you please separate out these changes from the hiddenBuiltInModes changes?

Fixed that.

@JorkeyLiu JorkeyLiu closed this Apr 13, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants