Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

The remend library (used by streamdown for parseIncompleteMarkdown) has a bug where content like $__timeFilter causes trailing __ to be added to the output. This happens because remend counts all __ in the entire string without respecting code block boundaries.

Fix

Only enable parseIncompleteMarkdown during actual streaming, not for completed/historical content. This prevents the bug while still providing the streaming UX benefit.

Root Cause

remend@1.0.1 counts markdown emphasis markers (__) globally rather than excluding fenced code blocks, causing false 'repairs'.

Example buggy input:

```sql
SELECT * WHERE $__timeFilter(x)

Would incorrectly render as:
```markdown
```sql
SELECT * WHERE $__timeFilter(x)
```__

Testing

  • Added storybook story to reproduce the bug
  • Verified fix works by disabling parseIncompleteMarkdown for completed content

Generated with mux

The remend library (used by streamdown for 'parseIncompleteMarkdown')
has a bug where content like $__timeFilter causes trailing '__' to be
added to the output. This happens because remend counts all '__' in the
entire string without respecting code block boundaries.

Fix: Only enable parseIncompleteMarkdown during actual streaming, not
for completed/historical content. This prevents the bug while still
providing the streaming UX benefit.

Root cause: remend@1.0.1 counts markdown emphasis markers (__) globally
rather than excluding fenced code blocks, causing false 'repairs'.

_Generated with `mux`_
@ammario ammario merged commit 3a84ef4 into main Dec 4, 2025
25 of 26 checks passed
@ammario ammario deleted the there-s-a-bug-where-there-is-e branch December 4, 2025 19:15
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.

2 participants