mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #22787] [CLOSED] fix: Improved handling of details and code blocks #26866
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22787
Author: @a4lg
Created: 3/18/2026
Status: ❌ Closed
Base:
dev← Head:improve-details-and-code-handling📝 Commits (1)
52ed2defix: Improved handling of details and code blocks📊 Changes
1 file changed (+110 additions, -21 deletions)
View changed files
📝
src/lib/utils/index.ts(+110 -21)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.
This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.
Before submitting, make sure you've checked the following:
devbranch. PRs targetingmainwill be immediately closed.devto ensure no unrelated commits (e.g. frommain) are included. Push updates to the existing PR branch instead of closing and reopening.Changelog Entry
Fixed
Additional Information
This commit introduces the unified segmentation logic to separate details and code blocks from the regular text. It also handles a new line after the details block (currently, all details block have a new line suffix).
While Markdown code block detection logic differs from the final Markdown rendering code, this is sufficient to fix the issue without touching the backend (besides, it's different from the Markdown rendering logic before this fix).
Note that however, there's a minor parser change: Details block (containing tool calls and reasoning blocks) are recognized without closing the starting tag. For instance,
<details</details>outside the code block is now recognized as a details block (it's almost certain that the this change only affects chats generated from deliberately chosen prompts).Screenshots or Videos
See #22786 for the issue before this fix. Four screenshots correspond to four screenshots in #22786.
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.