The chatCompletionEventHandler runs getMessageContentParts() and removeAllDetails() on every streaming token to extract sentences for real-time TTS dispatch via CustomEvent('chat'). These functions perform multiple O(n) regex passes over the full accumulated message content, resulting in O(n^2) total work over a streaming response.
The only consumer of these events is CallOverlay.svelte, which is only mounted when showCallOverlay is true. Without the overlay open, the parsing runs but the dispatched events have no listeners.
Wrap all three TTS parsing blocks in an if () guard so the expensive regex work is skipped entirely for the vast majority of users who are not using the voice call feature.
This PR was tested extensively
with normal conversations
with call-mode conversations
with mixed conversations
TTS and STT
all work.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), 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.
🔄 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/22195
**Author:** [@Classic298](https://github.com/Classic298)
**Created:** 3/3/2026
**Status:** ✅ Merged
**Merged:** 3/6/2026
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `perf/guard-tts-parsing-during-streaming`
---
### 📝 Commits (1)
- [`a9272d8`](https://github.com/open-webui/open-webui/commit/a9272d859131679b000087259266b2e3677e90f9) perf: guard TTS sentence parsing behind showCallOverlay check
### 📊 Changes
**1 file changed** (+58 additions, -52 deletions)
<details>
<summary>View changed files</summary>
📝 `src/lib/components/chat/Chat.svelte` (+58 -52)
</details>
### 📄 Description
The chatCompletionEventHandler runs getMessageContentParts() and removeAllDetails() on every streaming token to extract sentences for real-time TTS dispatch via CustomEvent('chat'). These functions perform multiple O(n) regex passes over the full accumulated message content, resulting in O(n^2) total work over a streaming response.
<ins>**The only consumer of these events is CallOverlay.svelte, which is only mounted when showCallOverlay is true. Without the overlay open, the parsing runs but the dispatched events have no listeners.**</ins>
Wrap all three TTS parsing blocks in an if () guard so the expensive regex work is skipped entirely for the vast majority of users who are not using the voice call feature.
# This PR was tested extensively
with normal conversations
with call-mode conversations
with mixed conversations
TTS and STT
all work.
### 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.
-->
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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22195
Author: @Classic298
Created: 3/3/2026
Status: ✅ Merged
Merged: 3/6/2026
Merged by: @tjbck
Base:
dev← Head:perf/guard-tts-parsing-during-streaming📝 Commits (1)
a9272d8perf: guard TTS sentence parsing behind showCallOverlay check📊 Changes
1 file changed (+58 additions, -52 deletions)
View changed files
📝
src/lib/components/chat/Chat.svelte(+58 -52)📄 Description
The chatCompletionEventHandler runs getMessageContentParts() and removeAllDetails() on every streaming token to extract sentences for real-time TTS dispatch via CustomEvent('chat'). These functions perform multiple O(n) regex passes over the full accumulated message content, resulting in O(n^2) total work over a streaming response.
The only consumer of these events is CallOverlay.svelte, which is only mounted when showCallOverlay is true. Without the overlay open, the parsing runs but the dispatched events have no listeners.
Wrap all three TTS parsing blocks in an if () guard so the expensive regex work is skipped entirely for the vast majority of users who are not using the voice call feature.
This PR was tested extensively
with normal conversations
with call-mode conversations
with mixed conversations
TTS and STT
all work.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.