fix(dekstop): when streaming markdown with code blocks, scroll jumped erratically. #7431

Closed
opened 2026-02-16 18:07:09 -05:00 by yindo · 1 comment
Owner

Originally created by @ProdigyRahul on GitHub (Jan 24, 2026).

Originally assigned to: @adamdotdevin on GitHub.

Description

when streaming markdown with code blocks, scroll jumped erratically.
found the cause: setupCodeCopy() ran on every render, wrapping <pre> blocks with <div data-component="markdown-code"> + copy buttons. these wrappers weren't in the HTML
output, so on next render the DOM was completely replaced via innerHTML, destroying wrappers, then setupCodeCopy re-added them. This cycle caused layout thrashing → scroll jumping.

Issue Video:
https://jumpshare.com/s/zb0Mn1orq7Wgw5NTaJcQ

Plugins

No response

OpenCode version

1.1.34

Steps to reproduce

No response

Screenshot and/or share link

https://jumpshare.com/s/zb0Mn1orq7Wgw5NTaJcQ

Operating System

macOS Tahoe 26.2

Terminal

No response

Originally created by @ProdigyRahul on GitHub (Jan 24, 2026). Originally assigned to: @adamdotdevin on GitHub. ### Description when streaming markdown with code blocks, scroll jumped erratically. found the cause: `setupCodeCopy()` ran on every render, wrapping `<pre>` blocks with `<div data-component="markdown-code">` + copy buttons. these wrappers weren't in the HTML output, so on next render the DOM was completely replaced via innerHTML, destroying wrappers, then setupCodeCopy re-added them. This cycle caused layout thrashing → scroll jumping. Issue Video: https://jumpshare.com/s/zb0Mn1orq7Wgw5NTaJcQ ### Plugins _No response_ ### OpenCode version 1.1.34 ### Steps to reproduce _No response_ ### Screenshot and/or share link https://jumpshare.com/s/zb0Mn1orq7Wgw5NTaJcQ ### Operating System macOS Tahoe 26.2 ### Terminal _No response_
yindo added the bugperfweb labels 2026-02-16 18:07:09 -05:00
yindo closed this issue 2026-02-16 18:07:09 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 24, 2026):

While there are related scroll/rendering issues in the repository (#9886 for disruptive auto-scroll behavior, #6172 for high CPU during streaming), this issue appears to have a distinct root cause related to the setupCodeCopy() function being called on every render and causing DOM replacement via innerHTML. The related issues have different underlying causes and solutions, so this is likely not a duplicate. However, it's worth noting these exist as they may interact with each other's fixes.

@github-actions[bot] commented on GitHub (Jan 24, 2026): While there are related scroll/rendering issues in the repository (#9886 for disruptive auto-scroll behavior, #6172 for high CPU during streaming), this issue appears to have a distinct root cause related to the `setupCodeCopy()` function being called on every render and causing DOM replacement via innerHTML. The related issues have different underlying causes and solutions, so this is likely not a duplicate. However, it's worth noting these exist as they may interact with each other's fixes.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7431