deerflow2/frontend/tests/unit/core
AochenShen99 11dd5b0683
fix(frontend): strip unclosed <think> tags from streaming AI content (#3218)
* fix(frontend): strip unclosed <think> tags from streaming AI content

During streaming, an opening <think> tag may arrive in one chunk
while the matching </think> arrives in a later chunk. The existing
splitInlineReasoning regex only matched fully closed pairs, so the
mid-flight reasoning was left in message.content and rendered into
the chat bubble via the markdown pipeline's rehypeRaw plugin until
the closing tag landed.

Extend splitInlineReasoning with a second pass: after stripping every
closed <think>...</think> pair, route any remaining content from a
lone opener to the reasoning slot and leave only the preceding
preamble in content. Closed-tag behavior is unchanged.

Covers every provider whose stream emits reasoning inline as <think>
tags (MiniMax streaming path, MindIE, PatchedChatOpenAI, and any
gateway-served DeepSeek/OpenAI-compatible model).

* style(frontend): apply prettier formatting to streaming reasoning tests

* fix(frontend): skip <think> split for literal think tags in inline code

Treats a `<think>` opener immediately preceded by a backtick as part of
markdown inline code rather than a streaming reasoning marker. Prevents
permanent content truncation when an AI message documents the `<think>`
tag literally (e.g. ``Use `<think>` markers``), where the streaming-safe
fallback would otherwise route the rest of the answer into the reasoning
panel because no `</think>` ever arrives.

Adds regression tests for both the post-stream and mid-stream cases.
2026-05-26 09:35:07 +08:00
..
api feat(frontend): set up Vitest frontend testing infrastructure with CI workflow (#2147) 2026-04-12 18:00:43 +08:00
artifacts Stabilize write artifact previews (#3172) 2026-05-23 16:56:14 +08:00
auth feat(frontend): support static website demo mode (#3170) 2026-05-23 00:10:56 +08:00
messages fix(frontend): strip unclosed <think> tags from streaming AI content (#3218) 2026-05-26 09:35:07 +08:00
settings enable token usage by default (#2841) 2026-05-10 22:00:57 +08:00
streamdown fix(reasoning): prevent LLM-hallucinated HTML tags from rendering as DOM elements (#2321) 2026-04-19 19:27:34 +08:00
tasks fix(stability): resolve P0 blockers from v2.0-m1-rc1 stability audit (#3107) (#3131) 2026-05-21 21:18:10 +08:00
threads fix(frontend): avoid duplicate optimistic user message (#3002) 2026-05-23 17:02:23 +08:00
uploads feat(frontend): set up Vitest frontend testing infrastructure with CI workflow (#2147) 2026-04-12 18:00:43 +08:00
reasoning-trigger.test.ts Fix invalid HTML nesting in reasoning trigger during complex task rendering (#2382) 2026-04-21 09:41:28 +08:00