Originally created by @gaby on GitHub (Mar 20, 2025).
Check Existing Issues
I have searched the existing issues and discussions.
I am using the latest version of Open WebUI.
Installation Method
Git Clone
Open WebUI Version
0.5.20
Ollama Version (if applicable)
No response
Operating System
Ubuntu 24.04
Browser (if applicable)
Firefox
Confirmation
I have read and followed all instructions in README.md.
I am using the latest version of both Open WebUI and Ollama.
I have included the browser console logs.
I have included the Docker container logs.
I have listed steps to reproduce the bug in detail.
Expected Behavior
When dealing with large code bases the UI should get all the content first then apply syntax highlighting. Instead of trying to apply it for every single response change.
ChatGPT for example will start rendering in the chat with no syntax highlight. It will then apply it after rendering the full response.
Actual Behavior
In a chat with large code bases the UI will take a long time to render the response. In some cases up to 30-60s after the GPU has finished.
Upon checking, I believe this is caused by the ContentRendering being applied on every change when processing response content.
Using o3-mini-high, one solution would be to debounce this:
$: (async () => {if(content){tokens=marked.lexer(replaceTokens(processResponseContent(content),sourceIds,model?.name,$user?.name));}})();
to one that debounces the parsing:
<script>import{marked}from'marked';import{replaceTokens,processResponseContent}from'$lib/utils';import{user}from'$lib/stores';importmarkedExtensionfrom'$lib/utils/marked/extension';importmarkedKatexExtensionfrom'$lib/utils/marked/katex-extension';importMarkdownTokensfrom'./Markdown/MarkdownTokens.svelte';import{createEventDispatcher,onDestroy}from'svelte';constdispatch=createEventDispatcher();exportletid;exportletcontent;exportletmodel=null;exportletsave=false;exportletsourceIds=[];exportletonSourceClick=()=>{};exportletonTaskClick=()=>{};lettokens=[];constoptions={throwOnError:false};marked.use(markedKatexExtension(options));marked.use(markedExtension(options));letdebounceTimeout;// Debounce the markdown processing so that we only re-parse once content stops changing
$:{// Clear any pending timeout if content changes
clearTimeout(debounceTimeout);if(content){debounceTimeout=setTimeout(()=>{tokens=marked.lexer(replaceTokens(processResponseContent(content),sourceIds,model?.name,$user?.name));},300);}else{tokens=[];}}onDestroy(()=>{clearTimeout(debounceTimeout);});</script>{#keyid}<MarkdownTokens{tokens}{id}{save}{onTaskClick}{onSourceClick}on:update={(e)=>{dispatch('update',e.detail);}}on:code={(e)=>{dispatch('code',e.detail);}}/>{/key}
Steps to Reproduce
N/a
Logs & Screenshots
N/a
Additional Information
N/a
Originally created by @gaby on GitHub (Mar 20, 2025).
### Check Existing Issues
- [x] I have searched the existing issues and discussions.
- [x] I am using the latest version of Open WebUI.
### Installation Method
Git Clone
### Open WebUI Version
0.5.20
### Ollama Version (if applicable)
_No response_
### Operating System
Ubuntu 24.04
### Browser (if applicable)
Firefox
### Confirmation
- [x] I have read and followed all instructions in `README.md`.
- [x] I am using the latest version of **both** Open WebUI and Ollama.
- [x] I have included the browser console logs.
- [x] I have included the Docker container logs.
- [x] I have listed steps to reproduce the bug in detail.
### Expected Behavior
When dealing with large code bases the UI should get all the content first then apply syntax highlighting. Instead of trying to apply it for every single response change.
ChatGPT for example will start rendering in the chat with no syntax highlight. It will then apply it after rendering the full response.
### Actual Behavior
In a chat with large code bases the UI will take a long time to render the response. In some cases up to 30-60s after the GPU has finished.
Upon checking, I believe this is caused by the ContentRendering being applied on every change when processing response content.
The call is here: https://github.com/open-webui/open-webui/blob/main/src/lib/components/chat/Messages/Markdown.svelte#L36
Using `o3-mini-high`, one solution would be to debounce this:
```svelte
$: (async () => {
if (content) {
tokens = marked.lexer(
replaceTokens(processResponseContent(content), sourceIds, model?.name, $user?.name)
);
}
})();
to one that debounces the parsing:
<script>
import { marked } from 'marked';
import { replaceTokens, processResponseContent } from '$lib/utils';
import { user } from '$lib/stores';
import markedExtension from '$lib/utils/marked/extension';
import markedKatexExtension from '$lib/utils/marked/katex-extension';
import MarkdownTokens from './Markdown/MarkdownTokens.svelte';
import { createEventDispatcher, onDestroy } from 'svelte';
const dispatch = createEventDispatcher();
export let id;
export let content;
export let model = null;
export let save = false;
export let sourceIds = [];
export let onSourceClick = () => {};
export let onTaskClick = () => {};
let tokens = [];
const options = { throwOnError: false };
marked.use(markedKatexExtension(options));
marked.use(markedExtension(options));
let debounceTimeout;
// Debounce the markdown processing so that we only re-parse once content stops changing
$: {
// Clear any pending timeout if content changes
clearTimeout(debounceTimeout);
if (content) {
debounceTimeout = setTimeout(() => {
tokens = marked.lexer(
replaceTokens(processResponseContent(content), sourceIds, model?.name, $user?.name)
);
}, 300);
} else {
tokens = [];
}
}
onDestroy(() => {
clearTimeout(debounceTimeout);
});
</script>
{#key id}
<MarkdownTokens
{tokens}
{id}
{save}
{onTaskClick}
{onSourceClick}
on:update={(e) => {
dispatch('update', e.detail);
}}
on:code={(e) => {
dispatch('code', e.detail);
}}
/>
{/key}
```
### Steps to Reproduce
N/a
### Logs & Screenshots
N/a
### Additional Information
N/a
GiteaMirror
added the bug label 2025-11-11 15:55:31 -06:00
The solution from o3 is a band-aid. In reality syntax highlight should be applied after response rendering has completed.
@gaby commented on GitHub (Mar 20, 2025):
The solution from o3 is a band-aid. In reality syntax highlight should be applied after response rendering has completed.
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.
Originally created by @gaby on GitHub (Mar 20, 2025).
Check Existing Issues
Installation Method
Git Clone
Open WebUI Version
0.5.20
Ollama Version (if applicable)
No response
Operating System
Ubuntu 24.04
Browser (if applicable)
Firefox
Confirmation
README.md.Expected Behavior
When dealing with large code bases the UI should get all the content first then apply syntax highlighting. Instead of trying to apply it for every single response change.
ChatGPT for example will start rendering in the chat with no syntax highlight. It will then apply it after rendering the full response.
Actual Behavior
In a chat with large code bases the UI will take a long time to render the response. In some cases up to 30-60s after the GPU has finished.
Upon checking, I believe this is caused by the ContentRendering being applied on every change when processing response content.
The call is here: https://github.com/open-webui/open-webui/blob/main/src/lib/components/chat/Messages/Markdown.svelte#L36
Using
o3-mini-high, one solution would be to debounce this:Steps to Reproduce
N/a
Logs & Screenshots
N/a
Additional Information
N/a
@gaby commented on GitHub (Mar 20, 2025):
The solution from o3 is a band-aid. In reality syntax highlight should be applied after response rendering has completed.