story: Draw the chart gallery through a virtual list - #2950
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:What changed
ChartCardvariant built on demand, and the fixture data moved behind one sharedChartDatahandle instead of being cloned once per chart on every frame.ChartRows of at mostcolumnscards. The row width is measured during prepaint and the rows are re-chunked when it crosses a column boundary, so the cards keep the layouth_flex().flex_wrap()used to produce and still reflow when the panel is resized.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 againstmainat the same window size: identical layout, and the FPS HUD numbers above.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