plot: Keep finished appears across remounts with PlotAppearScope - #3308
Merged
Merged
Conversation
A plot's appear lives in its element state, so a plot that stops being painted, such as a row a virtual list scrolled away, draws in again when it comes back. `PlotAppearScope` remembers, in its own element state, which plots inside it finished appearing (by global element id and appear generation) and hands those a complete appear at once, asking for no frames. The memory goes with the scope, so closing the view or renaming the scope draws its plots in afresh. Without a scope nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
A plot's appear (#3296) lives in its element state. GPUI drops element state for anything not painted in a frame, so a plot inside a virtual list —
list,uniform_list, aListrow — forgets its appear once it scrolls past the overdraw and draws in again every time it comes back. The only workaround so far was.appear(false), which gives up the appear entirely.PlotAppearScopewraps the region that repaints its plots on and off:PlotAppear::complete()straight away: noPresencetracking and no frames, and hover is not held back.appear_generationstill replays, and a plot taken away mid-appear draws in again from the start.LayoutId, so a self-sizing child such aslist(..).flex_1()keeps working unchanged.It works for every
Plot: the built-in charts and hand-written plots, since the check sits intrack_appear, whichPlotElementalready calls.Public API
gpui-baseRe-exported as
gpui_component::plot::PlotAppearScope.Breaking Changes
None.
Test plan
cargo test -p gpui-base -p gpui-componentplot::appear:cargo clippy -p gpui-base -p gpui-component --lib --tests -- --deny warningswebsite/base/plot.md,website/component/chart.md(en + zh-CN),release-notes.mdThis is a
gpui-basechange: the appear state it extends already lives there.