M8: a drag that only moves the selection shifts what was worked out at its start #1640
All Vouch review confidence checks passed
Residual risk 0.35 = Change Risk (0.52) × (1 − Review Confidence (0.32)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 59% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1640"
general
weight: 0.35
coderabbitai[bot]
What
This is the third part of #1571. During a drag, the first frame after each move holds a new document. With a large selection, that frame rebuilt everything #1611 keeps between frames:
Most drags only move the selected layers: every one moves by the same offset from where the drag started. None of those values change in such a move except where things are on the screen. So now:
Interaction::moved_by, the offset in page units). It doesn't note it for:- a layer in an auto layout flow (the layout places it, or closes the gap it leaves);
- a copy dragged out with Alt;
- anything other than a move.
Nothing looks different. A test compares what the canvas draws during a move with what a fresh canvas draws for the moved document.
How
crates/engine/src/doc_state.rs:Interaction::moved_by: Option<(f64, f64)>. It lives and goes with the gesture.crates/engine/src/canvas/tools/drag.rs: the free-move branch of a Move drag sets it after each preview when:- it isn't a copy;
- the layers didn't take a slot in an auto layout frame;
-
only_shiftedholds: no moved layer is in an auto layout flow or inside another moved layer.Otherwise it is
None.crates/ui-egui/src/selection_cache.rs:moved(ds)gives the start document and the offset while the selection is the gesture's.moved:-
canvas/overlays.rs:shown_geometryuses the start document's cached geometry and translates the outline shapes and the box.-
canvas/outline.rs: the slots are kept against the start document.-
canvas/selection_spacing.rs: the spacing layout is kept against it too.-
panels/right.rs:designpasses the start document to every section but Position's values. Position reads the instance facts from the start document too, so that cache isn't made again every frame.panels/export_panel.rs: the section's values are computed once per document and selection (Exports), throughselection_cache::cached.The canvas texture is still uploaded whole after each render. A partial upload would need:
Work::Partialcarries only a pixel count);That is a bigger change than this one, so it is left as a next step.
Measurements
Same synthetic file and script as #1601 and #1611:
I measured the same build with the reuse switched off and on, via a temporary switch now removed, two rounds each. The "UI ms" column is the UI pass per frame, mean.
| Case | Before: CPU / UI ms | After: CPU / UI ms |
|---|---|---|
| Hover over the canvas (control) | 33% / 0.62 | 30% / 0.58 |
| Drag one auto layout frame | 47% / 0.78 | 42% / 0.68 |
| Drag everything selected (648 layers) | 135% / 2.10 (max 7.8) | 117% / 1.44 (max 4.6) |
In "drag everything", per frame, from temporary probes:
A first try got the panel slower: the Position section and the layout section asked the instance cache about different documents, so it was made again every frame. The probes caught it before these runs.
Tests
crates/engine/src/moved_by_tests.rs:- a plain move of two layers reports its offset, and each layer moved by exactly that much;
- the note is gone after the release;
- a layer selected with its frame moves once, with it;
- a layer in an auto layout flow and an Alt copy report nothing.
crates/ui-egui/src/canvas/selection_cache_tests.rs:- during a move, the geometry made from the drag's start document is kept across moves;
- every shape the overlays draw sits where a fresh canvas showing the moved document draws it, to 0.01 pt;
- the start document stands in only while the selection is the gesture's own.
cargo xtask cipasses.Parity notes
None: no behaviour or visual change.
Not verified / what remains for #1571
Dragging 648 layers is better, but not clearly smooth end to end yet.
Part of #1571
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Performance
Dragging eligible large selections is more responsive. Selection outlines, the selection box, slot indicators, spacing, and Design panel values stay updated during movement without being fully recalculated on every drag update.
* This optimization applies to straightforward moves; auto-layout-managed moves and Alt-drag copies continue to use the existing behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->