[GH-ISSUE #16003] app/ui: thinking section re-creates ResizeObserver on every token and renders markdown when hidden #87877

Open
opened 2026-05-10 06:29:42 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @matteocelani on GitHub (May 6, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/16003

What is the issue?

Two problems in the thinking/reasoning panel:

  1. While the model is actively thinking, the ResizeObserver that measures content height is torn down and re-created on every single streamed token. This is unnecessary overhead — a ResizeObserver automatically detects size changes once attached.

  2. When thinking is finished and the section is collapsed, the full Streamdown + Shiki markdown rendering still runs behind the scenes even though the content is completely hidden (opacity 0, height 0). This wastes CPU cycles on invisible content.

Expected behavior
The ResizeObserver should be set up once when the element mounts and left running. The markdown rendering should be skipped entirely when the thinking section is collapsed and finished.

Relevant log output


OS

macOS

GPU

Apple

CPU

Apple

Ollama version

No response

Originally created by @matteocelani on GitHub (May 6, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/16003 ### What is the issue? Two problems in the thinking/reasoning panel: 1. While the model is actively thinking, the ResizeObserver that measures content height is torn down and re-created on every single streamed token. This is unnecessary overhead — a ResizeObserver automatically detects size changes once attached. 2. When thinking is finished and the section is collapsed, the full Streamdown + Shiki markdown rendering still runs behind the scenes even though the content is completely hidden (opacity 0, height 0). This wastes CPU cycles on invisible content. **Expected behavior** The ResizeObserver should be set up once when the element mounts and left running. The markdown rendering should be skipped entirely when the thinking section is collapsed and finished. ### Relevant log output ```shell ``` ### OS macOS ### GPU Apple ### CPU Apple ### Ollama version _No response_
GiteaMirror added the bug label 2026-05-10 06:29:42 -05:00
Author
Owner

@xmddmx commented on GitHub (May 6, 2026):

Great find - I would suspect this explains high CPU with lots of thinking tokens: https://github.com/ollama/ollama/issues/15797 happy to have that one merged or closed if you agree?

<!-- gh-comment-id:4390852922 --> @xmddmx commented on GitHub (May 6, 2026): Great find - I would suspect this explains high CPU with lots of thinking tokens: https://github.com/ollama/ollama/issues/15797 happy to have that one merged or closed if you agree?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#87877