[PR #24957] perf: reduce chat rendering stalls #131612

Open
opened 2026-05-21 17:19:04 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24957
Author: @noufalkv
Created: 5/20/2026
Status: 🔄 Open

Base: devHead: perf/tor-chat-rendering-reviewed


📝 Commits (8)

  • 703c0ff perf(codeblock): mount the editor only while editing
  • a926995 perf(codeblock): bound syntax highlighting work
  • bdc30dd perf(tool-calls): render labels without nested markdown
  • 9f5818a perf(tool-calls): defer collapsed payload parsing
  • e76309d fix(markdown): route tool details through tool renderer
  • 633765d fix(markdown): normalize structural detail boundaries
  • dcee823 fix(chat): ignore stale navigation loads
  • ed19aa8 perf(streaming): remove hot-path debug logging

📊 Changes

8 files changed (+440 additions, -129 deletions)

View changed files

📝 src/lib/components/chat/Chat.svelte (+40 -22)
📝 src/lib/components/chat/Messages/CodeBlock.svelte (+86 -10)
📝 src/lib/components/chat/Messages/Markdown.svelte (+4 -1)
📝 src/lib/components/chat/Messages/Markdown/MarkdownTokens.svelte (+75 -68)
📝 src/lib/components/common/ToolCallDisplay.svelte (+82 -19)
src/lib/utils/marked/details-normalization.test.ts (+92 -0)
src/lib/utils/marked/details-normalization.ts (+59 -0)
📝 src/routes/+layout.svelte (+2 -9)

📄 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:

  • Linked Issue/Discussion: This PR references an existing Issue or DiscussionRelates to #24949. If one does not exist, create one first. PRs without a linked issue or discussion may be closed without review.
  • Target branch: The pull request targets the dev branch. PRs targeting main will be immediately closed.
  • Description: A concise description of the changes is provided below.
  • Changelog: A changelog entry following Keep a Changelog format is included at the bottom.
  • Documentation: Relevant documentation has been added or updated in the Open WebUI Docs Repository.
  • Dependencies: Any new or updated dependencies are explained, tested, and documented.
  • Testing: Manual tests have been performed to verify the fix/feature works correctly and does not introduce regressions. Screenshots or recordings are included where applicable.
  • No Unchecked AI Code: This PR is either human-written or has undergone thorough human review AND manual testing. Unreviewed AI-generated PRs may be closed immediately.
  • Self-Review: A self-review of the code has been performed, ensuring adherence to project coding standards.
  • Architecture: Smart defaults are preferred over new settings. Local state is used for ephemeral UI logic. Major architectural or UX changes have been discussed first.
  • Git Hygiene: The PR is rebased on dev, split into isolated commits, and contains no unrelated commits.
  • Title Prefix: The PR title uses one of the following prefixes:
    • BREAKING CHANGE: Changes affecting backward compatibility
    • build: Build system or dependency changes
    • ci: CI/CD workflow changes
    • chore: Refactoring, cleanup, or non-functional changes
    • docs: Documentation additions or updates
    • feat: New features or enhancements
    • fix: Bug fixes or corrections
    • i18n: Internationalization or localization changes
    • perf: Performance improvements
    • refactor: Code restructuring
    • style: Formatting changes (whitespace, semicolons, etc.)
    • test: Test additions or corrections
    • WIP: Work in progress

Changelog Entry

Description

  • Reduce heavy chat rendering work for markdown, code blocks, tool-call displays, and high-latency chat navigation.

Added

  • None.

Changed

  • Code blocks mount CodeMirror only when editing.
  • Large or streaming code blocks avoid expensive syntax highlighting work.
  • Tool-call labels render without nested markdown parsing.
  • Collapsed tool calls defer hidden payload parsing until it is needed.
  • Chat navigation ignores stale high-latency load completions.
  • Hot-path streaming debug logs are removed.

Deprecated

  • None.

Removed

  • None.

Fixed

  • Structural tool and reasoning details no longer leak as raw or escaped markdown when parsed next to adjacent assistant prose.
  • Reduced UI stalls caused by eager markdown, highlighting, and tool-call work in large chat histories.

Security

  • None.

Breaking Changes

  • None.

Additional Information

This PR supersedes #24952 and #24956 after maintainer/bot feedback. It keeps the implementation-only changes, preserves the required CLA section, and removes the stress-test fixture/script changes from the submitted branch.

The branch is split into one focused commit per isolated change:

  • perf(codeblock): mount the editor only while editing
  • perf(codeblock): bound syntax highlighting work
  • perf(tool-calls): render labels without nested markdown
  • perf(tool-calls): defer collapsed payload parsing
  • fix(markdown): route tool details through tool renderer
  • fix(markdown): normalize structural detail boundaries
  • fix(chat): ignore stale navigation loads
  • perf(streaming): remove hot-path debug logging

This PR was prepared by an autonomous AI coding agent at a user's request, then manually reviewed and tested before marking the checklist item above. Please review it as an ordinary external contribution; no maintainer affiliation is implied.

Validation performed on the cleaned branch:

  • git diff --check origin/dev...HEAD
  • npm run test:frontend -- --run
  • Changed-file scan for conflict markers, TODO/FIXME/debugger statements, and newly introduced debug logging.
  • Manual browser checks for long chat loading and complex markdown/tool details on desktop, mobile viewport, and a JIT-disabled Chromium run. The checks covered raw structural detail leakage, escaped entity leakage, collapsed and expanded tool details, and normal chat navigation behavior.

Screenshots or Videos

  • Not included; this is a render/performance-path change without a visual UI change.

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/24957 **Author:** [@noufalkv](https://github.com/noufalkv) **Created:** 5/20/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `perf/tor-chat-rendering-reviewed` --- ### 📝 Commits (8) - [`703c0ff`](https://github.com/open-webui/open-webui/commit/703c0ff34a1e7989273d2fd551debdf9eebcff7b) perf(codeblock): mount the editor only while editing - [`a926995`](https://github.com/open-webui/open-webui/commit/a9269958b3fac5ebaf06d6dda009815843dd84d9) perf(codeblock): bound syntax highlighting work - [`bdc30dd`](https://github.com/open-webui/open-webui/commit/bdc30ddbb5b3c530af22881cb399067e36d108bb) perf(tool-calls): render labels without nested markdown - [`9f5818a`](https://github.com/open-webui/open-webui/commit/9f5818a3e3c5ebb17cfde917be8eb62583659eb0) perf(tool-calls): defer collapsed payload parsing - [`e76309d`](https://github.com/open-webui/open-webui/commit/e76309df1b660559c143294400f8d9f18982ca19) fix(markdown): route tool details through tool renderer - [`633765d`](https://github.com/open-webui/open-webui/commit/633765df6d7f313e060ebaf7cc589d831fdb42a7) fix(markdown): normalize structural detail boundaries - [`dcee823`](https://github.com/open-webui/open-webui/commit/dcee823845b6749e63b318443e836f84983e523a) fix(chat): ignore stale navigation loads - [`ed19aa8`](https://github.com/open-webui/open-webui/commit/ed19aa81e0a84223cd7d0f31c71303e93c4845fd) perf(streaming): remove hot-path debug logging ### 📊 Changes **8 files changed** (+440 additions, -129 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/Chat.svelte` (+40 -22) 📝 `src/lib/components/chat/Messages/CodeBlock.svelte` (+86 -10) 📝 `src/lib/components/chat/Messages/Markdown.svelte` (+4 -1) 📝 `src/lib/components/chat/Messages/Markdown/MarkdownTokens.svelte` (+75 -68) 📝 `src/lib/components/common/ToolCallDisplay.svelte` (+82 -19) ➕ `src/lib/utils/marked/details-normalization.test.ts` (+92 -0) ➕ `src/lib/utils/marked/details-normalization.ts` (+59 -0) 📝 `src/routes/+layout.svelte` (+2 -9) </details> ### 📄 Description <!-- ⚠️ CRITICAL CHECKS FOR CONTRIBUTORS (READ, DON'T DELETE) ⚠️ 1. Target the `dev` branch. PRs targeting `main` will be automatically closed. 2. Do NOT delete the CLA section at the bottom. It is required for the bot to accept your PR. --> # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/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. <!-- ### ⚠️ Important: Your PR is a contribution, not a guarantee of merge. The most impactful way to contribute to Open WebUI is through well-written bug reports, detailed feature discussions, and thoughtful ideas. These directly shape the project. If you do open a pull request, please know that Open WebUI is held to the highest standard of code quality, consistency, and architectural coherence, and every line merged becomes something the core team must own, maintain, and support indefinitely. Submitted code may be refactored, rewritten, or used as inspiration for a different implementation. This is not a reflection of your work's quality. It is how we ensure that a small team can deeply understand and evolve every part of the codebase. --> **Before submitting, make sure you've checked the following:** - [ ] **Linked Issue/Discussion:** This PR references an existing [Issue](https://github.com/open-webui/open-webui/issues) or [Discussion](https://github.com/open-webui/open-webui/discussions) — `Relates to #24949`. If one does not exist, create one first. PRs without a linked issue or discussion may be closed without review. - [x] **Target branch:** The pull request targets the `dev` branch. **PRs targeting `main` will be immediately closed.** - [x] **Description:** A concise description of the changes is provided below. - [x] **Changelog:** A changelog entry following [Keep a Changelog](https://keepachangelog.com/) format is included at the bottom. - [ ] **Documentation:** Relevant documentation has been added or updated in the [Open WebUI Docs Repository](https://github.com/open-webui/docs). - [x] **Dependencies:** Any new or updated dependencies are explained, tested, and documented. - [x] **Testing:** Manual tests have been performed to verify the fix/feature works correctly and does not introduce regressions. Screenshots or recordings are included where applicable. - [x] **No Unchecked AI Code:** This PR is either human-written or has undergone thorough human review AND manual testing. Unreviewed AI-generated PRs may be closed immediately. - [x] **Self-Review:** A self-review of the code has been performed, ensuring adherence to project coding standards. - [x] **Architecture:** Smart defaults are preferred over new settings. Local state is used for ephemeral UI logic. Major architectural or UX changes have been discussed first. - [x] **Git Hygiene:** The PR is rebased on `dev`, split into isolated commits, and contains no unrelated commits. - [x] **Title Prefix:** The PR title uses one of the following prefixes: - **BREAKING CHANGE**: Changes affecting backward compatibility - **build**: Build system or dependency changes - **ci**: CI/CD workflow changes - **chore**: Refactoring, cleanup, or non-functional changes - **docs**: Documentation additions or updates - **feat**: New features or enhancements - **fix**: Bug fixes or corrections - **i18n**: Internationalization or localization changes - **perf**: Performance improvements - **refactor**: Code restructuring - **style**: Formatting changes (whitespace, semicolons, etc.) - **test**: Test additions or corrections - **WIP**: Work in progress # Changelog Entry ### Description - Reduce heavy chat rendering work for markdown, code blocks, tool-call displays, and high-latency chat navigation. ### Added - None. ### Changed - Code blocks mount CodeMirror only when editing. - Large or streaming code blocks avoid expensive syntax highlighting work. - Tool-call labels render without nested markdown parsing. - Collapsed tool calls defer hidden payload parsing until it is needed. - Chat navigation ignores stale high-latency load completions. - Hot-path streaming debug logs are removed. ### Deprecated - None. ### Removed - None. ### Fixed - Structural tool and reasoning details no longer leak as raw or escaped markdown when parsed next to adjacent assistant prose. - Reduced UI stalls caused by eager markdown, highlighting, and tool-call work in large chat histories. ### Security - None. ### Breaking Changes - None. --- ### Additional Information This PR supersedes #24952 and #24956 after maintainer/bot feedback. It keeps the implementation-only changes, preserves the required CLA section, and removes the stress-test fixture/script changes from the submitted branch. The branch is split into one focused commit per isolated change: - `perf(codeblock): mount the editor only while editing` - `perf(codeblock): bound syntax highlighting work` - `perf(tool-calls): render labels without nested markdown` - `perf(tool-calls): defer collapsed payload parsing` - `fix(markdown): route tool details through tool renderer` - `fix(markdown): normalize structural detail boundaries` - `fix(chat): ignore stale navigation loads` - `perf(streaming): remove hot-path debug logging` This PR was prepared by an autonomous AI coding agent at a user's request, then manually reviewed and tested before marking the checklist item above. Please review it as an ordinary external contribution; no maintainer affiliation is implied. Validation performed on the cleaned branch: - `git diff --check origin/dev...HEAD` - `npm run test:frontend -- --run` - Changed-file scan for conflict markers, TODO/FIXME/debugger statements, and newly introduced debug logging. - Manual browser checks for long chat loading and complex markdown/tool details on desktop, mobile viewport, and a JIT-disabled Chromium run. The checks covered raw structural detail leakage, escaped entity leakage, collapsed and expanded tool details, and normal chat navigation behavior. ### Screenshots or Videos - Not included; this is a render/performance-path change without a visual UI change. ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <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-21 17:19:04 -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#131612