Skip to content

fix(ui): marked v18 parseSync removal#141

Merged
thebtf merged 2 commits into
mainfrom
fix/marked-parse-sync
Apr 12, 2026
Merged

fix(ui): marked v18 parseSync removal#141
thebtf merged 2 commits into
mainfrom
fix/marked-parse-sync

Conversation

@thebtf
Copy link
Copy Markdown
Owner

@thebtf thebtf commented Apr 12, 2026

Summary

  • marked.parseSync(text)marked.parse(text) as string
  • marked v18 removed parseSync (sync is default since v13)
  • Fixes CI build failure on all branches

Test plan

  • npm run build passes locally

Summary by CodeRabbit

  • Chores
    • Обновлена обработка Markdown: переход на неблокирующий парсер с сохранением поведения очистки и обработки пустого ввода.
    • Обновлена сборка клиентского образа: изменён целевой исполняемый файл, который собирается и копируется в контейнер, для согласования с текущими артефактами сборки.

marked v13+ removed parseSync(). The parse() method is synchronous
by default (unless async: true is passed). Fixes CI build failure.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

Caution

Review failed

Pull request was closed or merged during review

Обзор

Заменён синхронный вызов парсера Markdown: renderMarkdown теперь использует marked.parse(text) и явно приводит результат к string перед передачей в DOMPurify.sanitize. В Dockerfile изменён целевой исполняемый файл сборки: вместо /out/mcp-stdio-proxy теперь собирается и копируется /out/engram в stage client.

Изменения

Когорта / Файл(ы) Описание
Парсинг Markdown
ui/src/composables/useMarkdown.ts
Синхронный marked.parseSync() заменён на marked.parse(); результат кастуется в string перед DOMPurify.sanitize. Поведение при пустом вводе и санитизация не изменились.
Сборка клиента (Dockerfile)
Dockerfile
В builder и client стадиях изменён артефакт: теперь билдит /out/engram и копирует его в образ клиента как /app/engram вместо ранее используемого /out/mcp-stdio-proxy/app/mcp-stdio-proxy. Остальные артефакты (/out/engram-mcp) не тронуты.

Оценка сложности код-ревью

🎯 2 (Simple) | ⏱️ ~10 минут

Стихотворение

🐰 Я — кролик кодовый, прыгну в строку,
Заменил sync на parse, взмахнул ушком.
Байтами мчится текст в чистую реку,
И в Docker-е новый путь для бина впрок.
Ура, сборка и HTML в порядке! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(ui): marked v18 parseSync removal' clearly and specifically describes the main change: replacing the removed parseSync API with the parse method in the UI module.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/marked-parse-sync

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

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the markdown rendering logic in useMarkdown.ts by replacing marked.parseSync with marked.parse. A review comment points out that the current type assertion is unsafe because marked.parse can return a Promise if async extensions are used, and suggests using a type guard instead to ensure the output is a string.

export function renderMarkdown(text: string): string {
if (!text) return ''
const html = marked.parseSync(text)
const html = marked.parse(text) as string
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The type assertion as string is potentially unsafe. While marked.parse is synchronous by default, it returns a Promise if any async extensions or hooks are registered globally. Since marked is a global singleton, this could cause DOMPurify.sanitize to receive a Promise object (resulting in [object Promise] being rendered in the UI) if the configuration is modified elsewhere in the application. Using a type guard ensures the result is a string as expected by the rest of the function and the TypeScript compiler.

Suggested change
const html = marked.parse(text) as string
const html = marked.parse(text)
if (typeof html !== 'string') return ''

…arseSync

- Dockerfile: update build path after cmd/mcp-stdio-proxy was renamed to cmd/engram in PR #140
- useMarkdown.ts: marked.parseSync → marked.parse (parseSync removed in marked v13+)
@thebtf thebtf merged commit 1718b06 into main Apr 12, 2026
1 of 2 checks passed
@thebtf thebtf deleted the fix/marked-parse-sync branch April 12, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant