From 9eb89b8a12448ed987b3b88983e6f0da02c6bb34 Mon Sep 17 00:00:00 2001 From: Harry Yep Date: Tue, 30 Jun 2026 17:24:58 +0800 Subject: [PATCH] docs(desktop): correct streaming-repair comments after the defer/smooth swap the parseIncompleteMarkdown comment implied the reveal frontier is repaired; repair runs on the full accumulated text, so reword it to say that. drop the now-dead "multiple surfaces render the same content" clause from the block-cache comment (the smooth and defer wrappers that caused it were removed), and trim the math-preprocess comment to the load-bearing prose-only constraint. --- .../src/components/assistant-ui/markdown-text.tsx | 12 ++++++------ apps/desktop/src/lib/markdown-preprocess.ts | 6 ++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/apps/desktop/src/components/assistant-ui/markdown-text.tsx b/apps/desktop/src/components/assistant-ui/markdown-text.tsx index d6ee2a433..f9eeae55b 100644 --- a/apps/desktop/src/components/assistant-ui/markdown-text.tsx +++ b/apps/desktop/src/components/assistant-ui/markdown-text.tsx @@ -62,8 +62,7 @@ function preprocessWithTailRepair(text: string): string { // Memoized block splitter. Streamdown calls `parseMarkdownIntoBlocks` (a full // `marked` lex of the entire message, ~1.6ms per 28KB) inside a useMemo keyed // on the text — but the same text is re-lexed every time a message REMOUNTS -// (virtualizer scroll, session switch) and whenever multiple surfaces render -// the same content (remount, session switch). A small module-level +// (virtualizer scroll, session switch). A small module-level // LRU keyed by the exact source string removes all of those repeat parses // with zero correctness risk (same input → same output). Streaming tail // growth misses the cache by design (every flush is a new string) — that @@ -523,10 +522,11 @@ function MarkdownTextSurface({ containerClassName, containerProps, defer, smooth defer={defer} lineNumbers={false} mode="streaming" - // The built-in tail-bounded remend is disabled when a custom - // parseMarkdownIntoBlocksFn is supplied, so repair runs in - // preprocessWithTailRepair instead. parseIncompleteMarkdown stays - // false to avoid a second full-text remend pass. + // Incomplete-markdown repair runs in preprocessWithTailRepair on the + // full accumulated text; the built-in tail-bounded remend is disabled + // because a custom parseMarkdownIntoBlocksFn is supplied, and + // parseIncompleteMarkdown stays false to avoid a second full-text + // remend pass. parseIncompleteMarkdown={false} parseMarkdownIntoBlocksFn={parseMarkdownIntoBlocksCached} plugins={plugins} diff --git a/apps/desktop/src/lib/markdown-preprocess.ts b/apps/desktop/src/lib/markdown-preprocess.ts index 6137a7d61..63768a710 100644 --- a/apps/desktop/src/lib/markdown-preprocess.ts +++ b/apps/desktop/src/lib/markdown-preprocess.ts @@ -344,10 +344,8 @@ export function preprocessMarkdown(text: string): string { const leading = part.match(/^\s*/)?.[0] ?? '' const trailing = part.match(/\s*$/)?.[0] ?? '' - // normalizeMathDelimiters rewrites LaTeX bracket delimiters and - // custom math tags to dollar form. escapeCurrencyDollars escapes - // `$` so currency isn't eaten as math. Both run only on - // prose segments so code blocks stay untouched. + // Run only on prose segments so `$5` literals and `\(` inside code + // blocks stay intact. const transformed = normalizeVisibleProse( stripPreviewTargets(normalizeMathDelimiters(escapeCurrencyDollars(part))) )