Skip to content

fix(web): stop marking streamed thinking as complete before </think> arrives (lts/1.17.x) - #45683

Merged
wylswz merged 1 commit into
lts/1.17.xfrom
fix/lts-1.17-think-in-flight
Nov 6, 2026
Merged

wylswz merged 1 commit into
lts/1.17.xfrom
fix/lts-1.17-think-in-flight

Conversation

@alterxyz

@alterxyz alterxyz commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of the markdown-utils.ts part of fd2db63 (#44165) to lts/1.17.x. Fixes #45682.

On lts/1.17.x, preprocessThinkTag closes a still-streaming <think> with </think>, which becomes [ENDTHINKFLAG]. ThinkBlock then treats the in-flight thought as finished: the timer freezes at 0.0s and the block collapses while reasoning keeps streaming. This came in with #41764 (first released in 1.17.1).

main fixed it inside the larger #44165, which cannot be cherry-picked as a whole, so this PR ports only that hunk and keeps the provenance line in the commit message:

  • closeUnclosedThinkTags takes the trailing close tag as a parameter (default unchanged).
  • preprocessThinkTag passes </details>, so the HTML stays balanced without emitting the end marker. A completed <think>…</think> still produces [ENDTHINKFLAG] as before.
  • The two existing unit assertions are updated exactly as on main.

Screenshots

Before After
"Thought (0.0s)" shown and collapsed while reasoning is still streaming "Thinking…" keeps counting until </think> arrives (covered by unit tests; no new browser screenshot)

Validation

  • vp test run --project unit on markdown-utils.spec.ts, think-block.spec.tsx, markdown/index.spec.tsx, streamdown-wrapper.spec.tsx: 4 files, 52 tests passed.
  • Mutation check: with the old markdown-utils.ts and the updated spec, the two think-tag tests fail; with the fix they pass.
  • vp check on the two changed files: formatting, lint, and types passed.
  • .github/scripts/check-hotfix-cherry-picks.sh run locally against this branch: provenance verified.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

…arrives

While a response is streaming, preprocessThinkTag closed the still-open
<think> with </think>, which was then rewritten to [ENDTHINKFLAG]. The think
block treated the in-flight thought as finished on its first render: the
timer froze at 0.0s and the block collapsed while reasoning kept streaming.

Balance the trailing block with </details> instead, so the HTML stays
well-formed without emitting the end marker. Only the markdown-utils part of
the source commit is ported; the rest of it is unrelated to this fix.

(cherry picked from commit fd2db63)
@alterxyz
alterxyz requested a review from a team November 6, 2026 00:48
@github-actions github-actions Bot added web This relates to changes on the web. size:S This PR changes 10-29 lines, ignoring generated files. labels Nov 6, 2026
@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (lts/1.17.x@b3c94ba). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff              @@
##             lts/1.17.x   #45683   +/-   ##
=============================================
  Coverage              ?   87.74%           
=============================================
  Files                 ?     3795           
  Lines                 ?   135922           
  Branches              ?    44048           
=============================================
  Hits                  ?   119271           
  Misses                ?    16651           
  Partials              ?        0           
Flag Coverage Δ
dify-ui 93.73% <ø> (?)
web 87.70% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wylswz
wylswz merged commit 685946e into lts/1.17.x Nov 6, 2026
18 checks passed
@wylswz
wylswz deleted the fix/lts-1.17-think-in-flight branch November 6, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants