Skip to content

Feat/web markdown UI updates#14214

Open
xjq123456 wants to merge 6 commits intoinfiniflow:mainfrom
xjq123456:feat/web-markdown-ui-updates
Open

Feat/web markdown UI updates#14214
xjq123456 wants to merge 6 commits intoinfiniflow:mainfrom
xjq123456:feat/web-markdown-ui-updates

Conversation

@xjq123456
Copy link
Copy Markdown

@xjq123456 xjq123456 commented Apr 19, 2026

What problem does this PR solve?

LLM/chat and search UIs render Markdown in several places (document preview, floating chat widget, next-search, etc.). Plugin lists and behavior were duplicated or inconsistent, and single newlines in model output were not always rendered as visible line breaks, which hurts readability for chat-style content.

This PR centralizes shared remark/rehype configuration (including remark-breaks for newline handling) and wires the main Markdown surfaces to use it, so behavior is consistent and easier to maintain.

**中文摘要:**统一多处 Markdown 的 remark/rehype 插件配置(含 remark-breaks 处理换行),并更新文档预览、悬浮对话、检索等入口的渲染逻辑,提升一致性与可维护性。

Type of change

  • Refactoring

Refactor markdown-related components and centralize remark/rehype
plugin setup for document preview, chat widget, and search pages.

Made-with: Cursor
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 19, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 19, 2026

📝 Walkthrough

Walkthrough

Centralizes Markdown remark plugins into new shared constants, adds remark-breaks dependency, updates multiple Markdown-rendering components to use the shared plugin arrays, and adds typography styles for rendered Markdown elements.

Changes

Cohort / File(s) Summary
Dependency
web/package.json
Added remark-breaks (^4.0.0) to dependencies.
Shared plugin constants
web/src/constants/markdown-remark-plugins.ts
New module exporting MarkdownRemarkPluginsLite ([remarkGfm, remarkBreaks]) and MarkdownRemarkPlugins ([remarkGfm, remarkMath, remarkBreaks]).
Markdown components (plugin usage)
web/src/components/document-preview/md/index.tsx, web/src/components/floating-chat-widget-markdown.tsx, web/src/components/highlight-markdown/index.tsx, web/src/components/markdown-content/index.tsx, web/src/components/next-markdown-content/index.tsx, web/src/pages/next-search/markdown-content/index.tsx
Replaced inline remark plugin imports with imports of the shared MarkdownRemarkPlugins or MarkdownRemarkPluginsLite and passed them to react-markdown via remarkPlugins={...}.
Markdown styling
web/src/components/markdown-content/index.module.less, web/src/components/next-markdown-content/index.module.less
Added typography and spacing rules for rendered Markdown elements (headings h1–h6, p, ul/ol/li, table).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • JinHai-CN

Poem

🐰 I hopped through plugins, snug and bright,
I stitched breaks and math to tidy each line,
Headings pranced in freshly styled light,
Constants shared to keep the flow fine.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Feat/web markdown UI updates' is vague and overly broad, using generic phrasing that doesn't clearly convey the main technical change (centralizing remark/rehype configuration and adding remark-breaks). Use a more specific title that highlights the core change, such as 'Refactor: centralize markdown remark/rehype plugin configuration' or 'Add remark-breaks and centralize markdown plugin configuration'.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description includes the required section 'What problem does this PR solve?' with clear context, and specifies the type of change as 'Refactoring' with proper explanation.

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


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

Copy link
Copy Markdown
Contributor

@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

🧹 Nitpick comments (2)
web/src/components/markdown-content/index.tsx (1)

13-13: Rename shared constant to PascalCase for guideline compliance.

markdownRemarkPlugins does not follow the repo’s constant naming rule. Please rename/export it as MarkdownRemarkPlugins and update call sites in this PR batch.

As per coding guidelines, web/**/*.{ts,tsx,js,jsx}: Use PascalCase for constants and component names in TypeScript/JavaScript.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/markdown-content/index.tsx` at line 13, Import uses the
shared constant named markdownRemarkPlugins which violates the repo constant
naming rule; rename and export the constant as MarkdownRemarkPlugins and update
all call sites in this PR batch (including the import in
web/src/components/markdown-content/index.tsx) to use the new PascalCase name.
Locate the original constant definition (export of markdownRemarkPlugins),
change its export identifier to MarkdownRemarkPlugins, update any named
imports/usages across the changed files to import/use MarkdownRemarkPlugins, and
run a quick search to ensure no remaining references to markdownRemarkPlugins
remain.
web/src/components/next-markdown-content/index.module.less (1)

2-41: Consider extracting shared markdown typography rules to a reusable LESS mixin.

This block duplicates the same heading/list/table rhythm rules used in web/src/components/markdown-content/index.module.less and may drift over time.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/next-markdown-content/index.module.less` around lines 2 -
41, Extract the duplicated heading/list/table rhythm into a reusable LESS mixin
(e.g., .markdownTypography()) in a shared LESS file and replace the duplicated
blocks in this file by including that mixin; specifically, move the shared rules
for :global(h1), :global(h2), :global(h3), :global(h4)/:global(h5)/:global(h6),
:global(p), :global(ul)/:global(ol), :global(li), and :global(table) into the
mixin (parameterize spacing/font-size/line-height if needed) and then call the
mixin from this module (and update the other module that currently duplicates
the same rules to also include the mixin) so both components use the single
source of truth for markdown typography.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/components/document-preview/md/index.tsx`:
- Around line 7-8: The document preview importer currently uses local plugins
(remarkGfm, remarkBreaks) while a shared constant markdownRemarkPlugins includes
remarkMath; decide whether this preview should render math and then implement
one of the three options: (1) create a new math-free constant (e.g.,
markdownRemarkPluginsBase = [remarkGfm, remarkBreaks]) and replace the local
imports with that constant, (2) leave the component's local plugins and add a
short comment in the document-preview index.tsx explaining the intentional
divergence from markdownRemarkPlugins, or (3) add remarkMath to this component
(by using markdownRemarkPlugins) if math rendering is required—ensure you
reference remarkGfm, remarkBreaks, remarkMath and the shared
markdownRemarkPlugins constant when making the change.

In `@web/src/constants/markdown-remark-plugins.ts`:
- Line 11: Rename the exported constant markdownRemarkPlugins to PascalCase
(e.g., MarkdownRemarkPlugins) and update all references and imports to use the
new name; change the export declaration (export const markdownRemarkPlugins =
[...]) to export const MarkdownRemarkPlugins = [...] and then search for and
update every usage/import of markdownRemarkPlugins to MarkdownRemarkPlugins
(including any default or named imports in components, pages, or plugin
registries) to keep types and tooling happy.

---

Nitpick comments:
In `@web/src/components/markdown-content/index.tsx`:
- Line 13: Import uses the shared constant named markdownRemarkPlugins which
violates the repo constant naming rule; rename and export the constant as
MarkdownRemarkPlugins and update all call sites in this PR batch (including the
import in web/src/components/markdown-content/index.tsx) to use the new
PascalCase name. Locate the original constant definition (export of
markdownRemarkPlugins), change its export identifier to MarkdownRemarkPlugins,
update any named imports/usages across the changed files to import/use
MarkdownRemarkPlugins, and run a quick search to ensure no remaining references
to markdownRemarkPlugins remain.

In `@web/src/components/next-markdown-content/index.module.less`:
- Around line 2-41: Extract the duplicated heading/list/table rhythm into a
reusable LESS mixin (e.g., .markdownTypography()) in a shared LESS file and
replace the duplicated blocks in this file by including that mixin;
specifically, move the shared rules for :global(h1), :global(h2), :global(h3),
:global(h4)/:global(h5)/:global(h6), :global(p), :global(ul)/:global(ol),
:global(li), and :global(table) into the mixin (parameterize
spacing/font-size/line-height if needed) and then call the mixin from this
module (and update the other module that currently duplicates the same rules to
also include the mixin) so both components use the single source of truth for
markdown typography.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05b878cb-f2a2-4087-90c8-98ada2c7df92

📥 Commits

Reviewing files that changed from the base of the PR and between 6712b50 and b9b7ecc.

⛔ Files ignored due to path filters (1)
  • web/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • web/package.json
  • web/src/components/document-preview/md/index.tsx
  • web/src/components/floating-chat-widget-markdown.tsx
  • web/src/components/highlight-markdown/index.tsx
  • web/src/components/markdown-content/index.module.less
  • web/src/components/markdown-content/index.tsx
  • web/src/components/next-markdown-content/index.module.less
  • web/src/components/next-markdown-content/index.tsx
  • web/src/constants/markdown-remark-plugins.ts
  • web/src/pages/next-search/markdown-content/index.tsx

Comment thread web/src/components/document-preview/md/index.tsx Outdated
Comment thread web/src/constants/markdown-remark-plugins.ts Outdated
…without math

Addresses CodeRabbit: document preview stays GFM+breaks only; avoids pulling
remark-math where rehype-katex is not configured.

Made-with: Cursor
…DE.md

Rename markdownRemarkPlugins* to MarkdownRemarkPlugins* and update imports.

Made-with: Cursor
@JinHai-CN JinHai-CN requested a review from cike8899 April 20, 2026 08:00
@xjq123456 xjq123456 requested a review from cike8899 April 30, 2026 12:09
@xjq123456
Copy link
Copy Markdown
Author

@cike8899 @JinHai-CN

Conflicts resolved. Ready for merge. Appreciate your review!

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

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants