Skip to content

story: Draw the chart gallery through a virtual list - #2950

Merged
huacnlee merged 1 commit into
mainfrom
story-chart-virtual-list
Sep 4, 2026
Merged

story: Draw the chart gallery through a virtual list#2950
huacnlee merged 1 commit into
mainfrom
story-chart-virtual-list

Conversation

@huacnlee

@huacnlee huacnlee commented Sep 4, 2026

Copy link
Copy Markdown
Member

The Chart story built all 37 chart cards on every frame. Scrolling it cost about 20 ms a frame and dropped nearly every frame.

This flattens the gallery into rows of cards and hands them to gpui_kit::list, so only the rows near the viewport are built. Measured on the same window before and after:

FPS Frame Dropped
Before 45 20.0 ms 100%
After 60 7.0 ms 0%

What changed

  • Each chart is a ChartCard variant built on demand, and the fixture data moved behind one shared ChartData handle instead of being cloned once per chart on every frame.
  • The groups are flattened into ChartRows of at most columns cards. The row width is measured during prepaint and the rows are re-chunked when it crosses a column boundary, so the cards keep the layout h_flex().flex_wrap() used to produce and still reflow when the panel is resized.
  • The list owns the scroll, so the story sets paddings() to zero and carries the inset itself. That leaves the scrollbar on the panel edge, where the container used to put it.

No visual change: same cards, same order, same separators, same spacing.

Test plan

  • cargo run -- chart, compared against main at the same window size: identical layout, and the FPS HUD numbers above.
  • Scrolled to the end and confirmed the separators, candlestick row and both Sankey cards render.
  • Resized the window narrower and confirmed the rows re-chunk.
  • cargo clippy -p gpui-component-story --all-targets -- --deny warnings, cargo fmt --check, typos.

AI-generated with Claude Code.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fa8SBaJvfC5GsECZ6qjrFu

The Chart story built all 37 chart cards on every frame, so scrolling it
cost ~20 ms a frame and dropped nearly every one.

Flatten the gallery into rows of cards and hand them to `gpui_kit::list`,
which builds only the rows near the viewport. The row width is measured
during prepaint and re-chunked when it crosses a column boundary, so the
cards keep the layout `flex_wrap` used to produce.

The list owns the scroll now, so the story drops the container padding
and carries the inset itself, leaving the scrollbar on the panel edge.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fa8SBaJvfC5GsECZ6qjrFu
@huacnlee
huacnlee enabled auto-merge (squash) September 4, 2026 10:17
@huacnlee
huacnlee merged commit 6bde4ad into main Sep 4, 2026
8 checks passed
@huacnlee
huacnlee deleted the story-chart-virtual-list branch September 4, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant