[PR #24636] [CLOSED] fix: add blank line separator between serialized output parts to fix raw <details> rendering #98788

Closed
opened 2026-05-16 01:38:53 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24636
Author: @siriusa51
Created: 5/13/2026
Status: Closed

Base: devHead: fix/serialize-output-blank-line


📝 Commits (1)

  • 1f0cbac fix: add blank line separator between serialized output parts

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+1 -1)

📄 Description

Pull Request Checklist

Before submitting, make sure you've checked the following:

  • Target branch: Verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request down below.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Testing: Perform manual tests to verify the implemented fix works as intended and does not break any other functionality.
  • Design & Architecture: Prefer smart defaults over adding new settings.
  • Git Hygiene: Keep PRs atomic (one logical change).
  • Title Prefix: fix

Changelog Entry

Description

Fixes <details type="reasoning">, <details type="tool_calls">, and <details type="code_interpreter"> blocks being displayed as raw HTML text in chat instead of being rendered as collapsible UI components.

Root Cause

In serialize_output() in backend/open_webui/utils/middleware.py, output parts (text, reasoning, tool calls, code interpreter) are joined with a single newline ('\n'.join(parts)). In Markdown, block-level elements must be preceded by a blank line (\n\n) to be recognized as a new block. Without it, marked's paragraph tokenizer absorbs the <details> tag into the preceding paragraph, preventing the custom details marked extension from ever being triggered. The HTML falls through to HTMLToken.svelte which renders it as raw text via {token.text} (textContent interpolation) instead of {@html}.

Fixed

  • Changed '\n'.join(parts).strip() to '\n\n'.join(parts).strip() in serialize_output() to ensure a blank line exists between every block-level element in the serialized output.

Additional Information

See detailed root cause analysis at https://github.com/open-webui/open-webui/issues/24634#issuecomment-4436505583

Related issues: #24634, #24635


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/24636 **Author:** [@siriusa51](https://github.com/siriusa51) **Created:** 5/13/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/serialize-output-blank-line` --- ### 📝 Commits (1) - [`1f0cbac`](https://github.com/open-webui/open-webui/commit/1f0cbac7d65e8459007be74f55b302a9d039558e) fix: add blank line separator between serialized output parts ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+1 -1) </details> ### 📄 Description # Pull Request Checklist **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request down below. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Testing:** Perform manual tests to verify the implemented fix works as intended and does not break any other functionality. - [x] **Design & Architecture:** Prefer smart defaults over adding new settings. - [x] **Git Hygiene:** Keep PRs atomic (one logical change). - [x] **Title Prefix:** fix # Changelog Entry ### Description Fixes `<details type="reasoning">`, `<details type="tool_calls">`, and `<details type="code_interpreter">` blocks being displayed as raw HTML text in chat instead of being rendered as collapsible UI components. ### Root Cause In `serialize_output()` in `backend/open_webui/utils/middleware.py`, output parts (text, reasoning, tool calls, code interpreter) are joined with a single newline (`'\n'.join(parts)`). In Markdown, block-level elements must be preceded by a blank line (`\n\n`) to be recognized as a new block. Without it, marked's paragraph tokenizer absorbs the `<details>` tag into the preceding paragraph, preventing the custom `details` marked extension from ever being triggered. The HTML falls through to `HTMLToken.svelte` which renders it as raw text via `{token.text}` (textContent interpolation) instead of `{@html}`. ### Fixed - Changed `'\n'.join(parts).strip()` to `'\n\n'.join(parts).strip()` in `serialize_output()` to ensure a blank line exists between every block-level element in the serialized output. ### Additional Information See detailed root cause analysis at https://github.com/open-webui/open-webui/issues/24634#issuecomment-4436505583 Related issues: #24634, #24635 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-16 01:38:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#98788