Skip to content

perf(site/src/pages/AgentsPage/components/ChatElements): scroll markdown code blocks natively - #31365

Merged
mafredri merged 3 commits into
mainfrom
perf/chat-code-block-scroll
Nov 24, 2026
Merged

mafredri merged 3 commits into
mainfrom
perf/chat-code-block-scroll

Conversation

@mafredri

@mafredri mafredri commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Base: #29596 (perf/chat-interaction). Second of five stacked fixes.

Code blocks scrolled in Radix ScrollArea, which renders a <style> per instance, and WebKit restyles the whole document when a stylesheet is added or removed. They now scroll in a plain overflow-auto element. Tool renderers still use ScrollArea (ToolCall.tsx:505, TerminalOutput.tsx:43).

Visual change: the old block showed a 6 px overlay bar on hover (Radix's default type="hover"). scrollbar-thin gives a permanent 10 px bar with classic scrollbars: in Chromium on Linux an overflowing block grows from 38 to 48 px (Windows and macOS not tested).

WebKit, #31278 bench (a tool, not for merging), production builds of the pre-rebase versions of c0dd10843f (base) and 2d657a137f (this PR), 2 streaming chats with the same 1,416 stored rows in every run (143k nodes on base, 140k here), 3 alternating runs:

WebKit base this PR
open to full history 177.8 to 183.5 s 26.5 to 28.4 s
longest frame, 10 s phase 7.7 to 10.7 s 0.32 to 8.3 s
code blocks / <style> inserts, phase 1 to 2 / 1 to 2 2 / 0
recalcs over 1 s, whole recording 6, 7, 6 in 69 to 98 s 0, 1, 0 in 14 to 30 s

Full history: from page.goto until every stored message has a row and the inspector attaches; no run logged a stall or reload. Each recalculation over 1 s took 7.0 to 12.4 s. This PR's one began 1 s into a phase; its cause is not identified. The bench's frame counter misses a frame still running when the phase ends, so the longest-frame row reads frames from the timeline.

Chromium, same builds and history, 3 alternating runs: full history loaded in 23.6 to 25.2 s on base and 21.8 to 22.5 s here.

🤖 This PR was created with the help of Coder Agents, and will be reviewed by a human. 🏂🏻

@mafredri

This comment has been minimized.

@coder-agents-review

coder-agents-review Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-10-27 20:01 UTC by @mafredri

Review history
  • R1 (2026-10-27): 10 reviewers, 1 Nit, COMMENT. Review
  • R2 (2026-10-27): 6 reviewers, 1 Nit, APPROVE. Review

deep-review v0.13.0 | Round 2 | 0ff1441..4fd76a9

Last posted: Round 2, 1 findings (1 Nit), APPROVE. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 Nit Author fixed (4fd76a9) Response.stories.tsx:112 Predicate parameter still named v (viewport) though it now iterates every element R1 Gon Yes
CRF-2 P2 Dropped by orchestrator (comment already states both reasons: async FileViewer render and scrolled-state capture; suggested rewrite carries the same facts) Response.stories.tsx:107 Play comment narrates the code R1 Gon No
CRF-3 P4 Dropped by orchestrator (literal unchanged by the diff; offset purpose stated by the adjacent comment) Response.stories.tsx:121 scrollLeft = 200 unnamed offset R1 Gon No
CRF-4 OOS Out of scope (body) ToolCall.tsx:489 Tool-call ScrollArea still inserts a per-instance <style> on mount R1 Killua, Mafuuu, Pariston No
CRF-5 OOS Out of scope (body) TerminalOutput.tsx:43 Terminal output ScrollArea still inserts a per-instance <style>; execute rows auto-expand R1 Killua, Mafuuu, Pariston No
CRF-6 OOS Out of scope (body) ScrollArea.tsx:40 Shared ScrollArea wrapper inherits Radix per-instance <style> for all consumers R1 Pariston No
CRF-7 Note Note (body) Response.tsx:241 index.css:737-742 says non-auto scrollbar-width disables overlay scrollbars on macOS Chromium too R1 Netero No

Contested and acknowledged

None.

Round log

Round 1

Full panel (round 1). Netero: no findings, 1 Note. Panel: ging-ts, ging-react, nami, killua, pariston, mafuuu, bisky, gon, leorio, plus wildcard razor (random draw). Size 10 exceeds the focused target of 6-8 because ging-ts, ging-react, nami and killua are triggered specialists, Bisky is required (story changed), and Gon and Leorio have a round 1 floor. The workspace disconnected while several reviewers ran the Storybook suite concurrently; pariston, mafuuu, razor and bisky were resumed on the same agents and wrote their own files. Bisky's draft P3 (story may pass without the table min-w-full wrapper) was empirically disproved by Bisky: with a bare div the story fails. 1 Nit posted, 2 dropped, 3 out of scope, 1 Note. Reviewed against 0ff1441..8ac6897.

Round 2

Fix round (one commit, 4fd76a9, renames a predicate parameter; no files added or moved, no signature change). Churn guard PROCEED: CRF-1 addressed. Netero: no findings, verified CRF-1. Panel: gon (raised CRF-1), bisky (test file changed), ging-ts and ging-react (.tsx changed), nami (frontend file changed), plus wildcard chopper (random draw). No new findings. Dropped CRF-2 and CRF-3 re-checked: the delta does not touch their lines, so their dispositions stand. Storybook suite passed 18 of 18 at head (Netero, Chopper). Reviewed against 0ff1441..4fd76a9.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T20:04:41.607560Z 4fd76a9 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as outdated.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR replaces the Radix ScrollArea around markdown code blocks with a native overflow-auto container and updates the LongLineFencedBlock story to find it. 1 Nit. LongLineFencedBlock passes at head and fails when the table min-w-full wrapper is replaced with a bare div, so the story covers the wrapper.

Out of scope (needs a ticket or explicit acceptance by a human):

  • site/src/pages/AgentsPage/components/ChatElements/tools/ToolCall.tsx:489: ToolCall.Scrollable still mounts a ScrollArea, so each tool row that expands or mounts inserts a document <style> and triggers the same WebKit whole-document restyle.
  • site/src/pages/AgentsPage/components/ChatElements/tools/TerminalOutput.tsx:43: ExecuteTool.tsx:55-62 opens execute output by default, so every execute row with output in history mounts a ScrollArea and inserts a <style>; shell-heavy chats keep the WebKit stall this PR removes for code blocks (not benchmarked).
  • site/src/components/ScrollArea/ScrollArea.tsx:40: the shared wrapper inherits Radix's per-instance <style>, so all of its consumers pay the restyle cost on mount.

Notes:

  • The PR description lists macOS as untested. site/src/index.css:737-742 states that any non-auto scrollbar-width opts out of overlay scrollbars on macOS Chromium, so the permanent bar and the 38 to 48 px height change likely apply there too (inferred from that comment, not run on macOS).

🤖 This review was automatically generated with Coder Agents.

@mafredri

Copy link
Copy Markdown
Member Author

@codex review
/coder-agents-review

🤖

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 4fd76a9234

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of 4fd76a9, which renames the story predicate parameter to el. The rename is verified and this round has no new findings. LongLineFencedBlock and the rest of Response.stories.tsx pass at head (18 of 18). The three out-of-scope ScrollArea items from the previous review still need a ticket or explicit acceptance by a human.

🤖 This review was automatically generated with Coder Agents.

@mafredri
mafredri added this pull request to stack #31375 October 27, 2026 21:24
@mafredri
mafredri marked this pull request as ready for review October 27, 2026 21:27
@mafredri
mafredri requested a review from a team as a code owner October 27, 2026 21:27
@pr-queue-manager
pr-queue-manager Bot requested a review from jakehwll October 27, 2026 21:32
kylecarbs
kylecarbs previously approved these changes Oct 27, 2026
@mafredri
mafredri force-pushed the perf/chat-code-block-scroll branch from 4fd76a9 to b65aa98 Compare October 30, 2026 11:38
@mafredri
mafredri force-pushed the perf/chat-code-block-scroll branch from b65aa98 to 109d548 Compare October 30, 2026 18:37
@mafredri
mafredri force-pushed the perf/chat-code-block-scroll branch from 109d548 to 19a0f7e Compare November 4, 2026 11:01
@mafredri
mafredri force-pushed the perf/chat-code-block-scroll branch from 19a0f7e to 9848f76 Compare November 6, 2026 19:44
@linear-code

linear-code Bot commented Nov 13, 2026

Copy link
Copy Markdown

CODAGT-1081

Base automatically changed from perf/chat-interaction to main November 23, 2026 15:39
mafredri added a commit that referenced this pull request Nov 23, 2026
…29596)

Base: `main`. First of a stack; #31365, #31366, #31367 and #31572
follow.

`useChatDropdownPosition`, which both chat composers use, sets five
`--mobile-dropdown-*` properties on `<html>` from an effect that
re-reads the composer's position on focus, input, selection, scroll and
resize, at every width. Only below-`md` utilities read them, and a
changed custom property on the root restyles every element. Browsers
skip a write of an equal value, so on `main` the root restyles each time
a value changes, for example when the composer grows by a line.

This PR runs the effect only below `md`, where dropdown positioning is
unchanged.

#31278 bench (a tool, not for merging) on production builds of
`f348cd66d7` (this PR's base on `main` then) and the pre-rebase version
of `af7b2c7b4a` (this PR; later commits change only tests), one chat
with 72k nodes at 1800 px, 3 alternating runs per side:

| keystroke that wraps the composer | `main` | this PR |
|---|---|---|
| Chromium | 467 to 649 ms | 17 to 32 ms |
| WebKit | 3,381 to 3,892 ms | 99 to 118 ms |

Other keystrokes and focusing the composer did not change beyond noise.

<details>
<summary>Run details</summary>

Each run types 560 characters after 340 prefilled ones, so the composer
grows by a line 6 times in Chromium and 5 in WebKit. Each wrap cell
gives min to max over the wrapping keystrokes of all 3 runs.

| p50, min to max | `main` | this PR |
|---|---|---|
| Chromium, other keystrokes | 23 to 24 ms | 23 to 24 ms |
| WebKit, other keystrokes | 97 to 99 ms | 97 to 98 ms |
| Chromium focus, pointer | 11 to 13 ms | 11 to 15 ms |
| WebKit focus, pointer | 271 to 332 ms | 303 to 324 ms |

</details>

> 🤖 This PR was created with the help of Coder Agents, and has been
reviewed by a human. 🏂🏻
Radix ScrollArea renders a <style> element per instance, and WebKit
restyles the whole document whenever a stylesheet is added or removed,
so every streamed code block that mounted or unmounted cost a
document-wide style recalculation. Code blocks now scroll in a plain
overflow element that uses the global scrollbar color.
@mafredri
mafredri force-pushed the perf/chat-code-block-scroll branch from 2d657a1 to cdc601b Compare November 23, 2026 15:40
@mafredri
mafredri merged commit 1f5915c into main Nov 24, 2026
27 checks passed
@mafredri
mafredri deleted the perf/chat-code-block-scroll branch November 24, 2026 11:43
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026

This branch had an error being deployed

1 failed deployment
docs-preview — cdc601b4 Deployed Nov 24, 2026 by mafredri via cleanup #399
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants