Skip to content

Commit 05910b5

Browse files
THEtheChadclaude
andcommitted
fix(engine): Auto Sync refits only the crop fields an edit changed (#3056)
Auto Sync applied the changed crop leaves to each selected photo, then overwrote the whole crop geometry and aspect lock with the active photo's refitted crop whenever any crop field changed. A rect-only edit replaced each photo's angle, and an angle-only edit replaced each photo's rect. The refit now keeps each photo's angle, uses the lock the edit was made with, and assigns only the rect and/or aspect lock the delta contains. A photo of the same shape takes just the changed edges, as before; one of another shape refits the active photo's whole rect, since an edge or two spliced into its own rect would be in the wrong frame. Paste and Sync, which copy the whole crop, are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent da812d5 commit 05910b5

4 files changed

Lines changed: 98 additions & 12 deletions

File tree

‎crates/engine/src/lib.rs‎

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,11 @@ impl Session {
981981
/// With Auto Sync on, the ops that carry an edit of the active photo `id` (to `new`, as asked,
982982
/// before its crop is fitted) over to the other selected photos: only the settings that changed;
983983
/// never spot removal or red eye (they belong to one photo's pixels), nor the rendering process
984-
/// (Sync doesn't carry it either), nor history / snapshot restores. A changed crop is refitted to
985-
/// each photo's shape as Sync does ([`lightcraft_develop::Crop::refit`]). Constrain Crop then fits
986-
/// each photo's own crop: the active photo's fitted crop is never copied over another's.
984+
/// (Sync doesn't carry it either), nor history / snapshot restores. A changed crop rect or aspect
985+
/// lock is refitted to each photo's shape as Sync does ([`lightcraft_develop::Crop::refit`]),
986+
/// leaving the crop fields the edit didn't change (a rect edit keeps each photo's angle).
987+
/// Constrain Crop then fits each photo's own crop: the active photo's fitted crop is never
988+
/// copied over another's.
987989
fn auto_sync_ops(&self, id: PhotoId, new: &DevelopSettings, label: &str) -> Vec<Op> {
988990
if !self.auto_sync
989991
|| self.active() != Some(id)
@@ -1019,14 +1021,30 @@ impl Session {
10191021
.filter_map(|x| self.develop_of(*x).map(|d| (*x, d)))
10201022
.filter_map(|(x, d)| {
10211023
let mut synced = lightcraft_develop::apply_partial(&d, &delta, 1.0);
1022-
// a changed crop takes this photo's shape, as Sync and Paste give it (issue #3056)
1023-
if let Some(c) = delta.get("crop")
1024-
&& (c.get("geometry").is_some() || c.get("aspect").is_some())
1024+
// a changed crop takes this photo's shape, as Sync and Paste give it (issue #3056).
1025+
// Only what changed: the refit starts from this photo's crop with the changed leaves
1026+
// applied (a new rect keeps this photo's angle) under the lock the edit was made with,
1027+
// and sets only the rect and lock the edit changed (the refit keeps angle and flips).
1028+
let crop = delta.get("crop");
1029+
let rect_changed = crop.and_then(|c| c.get("geometry")).is_some_and(|g| g.get("rect").is_some());
1030+
let aspect_changed = crop.is_some_and(|c| c.get("aspect").is_some());
1031+
if (rect_changed || aspect_changed)
10251032
&& let (Some(from), Some(to)) = (self.oriented_dims(id, new.orientation), self.oriented_dims(x, synced.orientation))
10261033
{
1027-
let fit = new.crop.refit(from, to);
1028-
synced.crop.geometry = fit.geometry;
1029-
synced.crop.aspect = fit.aspect;
1034+
let mut start = lightcraft_develop::Crop { aspect: new.crop.aspect, ..synced.crop };
1035+
// a dragged edge or two mean nothing in a photo of another shape: it refits the
1036+
// active photo's whole rect (at its own angle); one of the same shape takes the edges
1037+
let same_shape = (from.0 * to.1 - to.0 * from.1).abs() <= 1e-6 * (to.0 * from.1);
1038+
if rect_changed && !same_shape {
1039+
start.geometry.rect = new.crop.geometry.rect;
1040+
}
1041+
let fit = start.refit(from, to);
1042+
if rect_changed {
1043+
synced.crop.geometry.rect = fit.geometry.rect;
1044+
}
1045+
if aspect_changed {
1046+
synced.crop.aspect = fit.aspect;
1047+
}
10301048
}
10311049
let synced = self.fit_constrained_crop(x, synced);
10321050
(synced != *d).then(|| self.develop_op(x, synced, label)).flatten()

‎crates/engine/src/tests.rs‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,73 @@ fn auto_sync_refits_a_crop_like_sync() {
752752
assert_eq!(auto.0, synced.0);
753753
}
754754

755+
/// Review of #3056: Auto Sync carries only the crop fields the edit changed. A new crop rect on the
756+
/// active photo is refitted to each other photo at that photo's own angle, which it keeps.
757+
#[test]
758+
fn auto_sync_of_a_crop_rect_keeps_each_photos_angle() {
759+
let mut s = demo();
760+
let (a, b, tall) = photos_by_shape(&mut s);
761+
for (id, angle) in [(b, 5.0), (tall, -3.0)] {
762+
s.execute("library.select", &json!({"ids": [id.0]})).unwrap();
763+
s.execute("crop.straighten", &json!({"angle": angle})).unwrap();
764+
}
765+
s.execute("library.select", &json!({"ids": [a.0, b.0, tall.0], "active": a.0})).unwrap();
766+
s.execute("develop.autoSync", &json!({"on": true})).unwrap();
767+
s.execute("crop.set", &json!({"rect": [0.3, 0.2, 0.7, 0.8]})).unwrap();
768+
let src = s.develop_of(a).unwrap().crop.geometry;
769+
assert_eq!(src.angle, 0.0);
770+
let d = s.develop_of(b).unwrap();
771+
assert_eq!((d.crop.geometry.rect, d.crop.geometry.angle), (src.rect, 5.0), "same shape: the rect, at b's own angle");
772+
let d = s.develop_of(tall).unwrap();
773+
assert_eq!(d.crop.geometry.angle, -3.0, "the portrait keeps its angle");
774+
let p = s.catalog.photo(tall).unwrap();
775+
assert!(d.crop.geometry.is_within_image(p.width as f64, p.height as f64), "{:?}", d.crop.geometry);
776+
let r = crop_px(&s, tall);
777+
assert!((r.aspect() - 1.0).abs() < 1e-6, "the square, refitted at the portrait's angle: {r:?}");
778+
}
779+
780+
/// Review of #3056: dragging one edge changes one leaf of the rect. A photo of another shape takes
781+
/// the active photo's whole crop refitted, not its own rect with that edge spliced in.
782+
#[test]
783+
fn auto_sync_of_one_crop_edge_refits_the_whole_crop_onto_another_shape() {
784+
let mut s = demo();
785+
let (a, _, tall) = photos_by_shape(&mut s);
786+
s.execute("library.select", &json!({"ids": [tall.0]})).unwrap();
787+
s.execute("crop.set", &json!({"rect": [0.1, 0.1, 0.9, 0.9], "angle": -3.0})).unwrap();
788+
s.execute("library.select", &json!({"ids": [a.0, tall.0], "active": a.0})).unwrap();
789+
s.execute("develop.autoSync", &json!({"on": true})).unwrap();
790+
s.execute("crop.set", &json!({"rect": [0.0, 0.0, 0.6, 1.0]})).unwrap();
791+
let (src, r) = (crop_px(&s, a), crop_px(&s, tall));
792+
assert!((r.aspect() - src.aspect()).abs() < 1e-6, "the active crop's shape: {src:?} vs {r:?}");
793+
assert_eq!(s.develop_of(tall).unwrap().crop.geometry.angle, -3.0, "the portrait keeps its angle");
794+
}
795+
796+
/// Review of #3056: a new angle on the active photo (its crop still fits, so only the angle
797+
/// changes) turns the other photos and leaves their own crop rect and aspect lock alone.
798+
#[test]
799+
fn auto_sync_of_a_crop_angle_keeps_each_photos_rect_and_lock() {
800+
let mut s = demo();
801+
let (a, b, tall) = photos_by_shape(&mut s);
802+
s.execute("library.select", &json!({"ids": [a.0]})).unwrap();
803+
s.execute("crop.set", &json!({"rect": [0.35, 0.35, 0.65, 0.65]})).unwrap();
804+
s.execute("library.select", &json!({"ids": [b.0]})).unwrap();
805+
s.execute("crop.set", &json!({"rect": [0.15, 0.15, 0.5, 0.6]})).unwrap();
806+
s.execute("library.select", &json!({"ids": [tall.0]})).unwrap();
807+
s.execute("crop.aspect", &json!({"aspect": "4x5"})).unwrap();
808+
let before: Vec<_> = [b, tall].iter().map(|id| s.develop_of(*id).unwrap().crop).collect();
809+
assert_eq!(before[1].aspect, Some((400, 500)));
810+
s.execute("library.select", &json!({"ids": [a.0, b.0, tall.0], "active": a.0})).unwrap();
811+
s.execute("develop.autoSync", &json!({"on": true})).unwrap();
812+
let rect = s.develop_of(a).unwrap().crop.geometry.rect;
813+
s.execute("crop.straighten", &json!({"angle": 3.0})).unwrap();
814+
assert_eq!(s.develop_of(a).unwrap().crop.geometry.rect, rect, "the small crop still fits: only the angle changed");
815+
for (id, was) in [b, tall].iter().zip(&before) {
816+
let d = s.develop_of(*id).unwrap();
817+
assert_eq!(d.crop.geometry.angle, 3.0, "the angle is synced");
818+
assert_eq!((d.crop.geometry.rect, d.crop.aspect), (was.geometry.rect, was.aspect), "its own rect and lock");
819+
}
820+
}
821+
755822
/// A crop of no size (or a hair wide), as a sidecar can set it, made the render's
756823
/// samplers read at infinite coordinates and its blurs ask for sigmas of millions of pixels: with a
757824
/// healing spot and masks on, render workers panicked (an i32 square in the blur, a bilinear

‎docs/parity-checklist.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts).
344344
|---|---|---|---|---|---|
345345
| LR-SYNC-COPY | Copy edit settings | P0 | ✅ | `cmd:develop.copy` | |
346346
| LR-SYNC-CHOOSE | Choose settings to copy | P0 | ✅ | `cmd:dialog.copySettings` | groups are coarser than per-slider |
347-
| LR-SYNC-PASTE | Paste to selection | P0 | ✅ | `cmd:develop.paste`, `crates/geom/src/crop.rs` (`CropGeometry::refit`) | pastes the groups chosen at copy time onto every selected photo, one undo step; Paste Selected Settings (MENU-EDIT-PASTESELECTED) chooses at paste time. A crop pasted, synced or Auto Synced onto a photo of another shape keeps its aspect ratio, angle and relative size, as in Lightroom, centred where it was unless that would leave the turned photo; a locked ratio is kept even on an uncropped photo, an Original lock or an unlocked uncropped photo takes the new photo's shape (`Crop::refit`); presets apply their crop as stored |
347+
| LR-SYNC-PASTE | Paste to selection | P0 | ✅ | `cmd:develop.paste`, `crates/geom/src/crop.rs` (`CropGeometry::refit`) | pastes the groups chosen at copy time onto every selected photo, one undo step; Paste Selected Settings (MENU-EDIT-PASTESELECTED) chooses at paste time. A crop pasted, synced or Auto Synced onto a photo of another shape keeps its aspect ratio, angle and relative size, as in Lightroom, centred where it was unless that would leave the turned photo; a locked ratio is kept even on an uncropped photo, an Original lock or an unlocked uncropped photo takes the new photo's shape (`Crop::refit`); Auto Sync carries only the crop fields the edit changed (a new rect keeps each photo's angle, a new angle each photo's rect); presets apply their crop as stored |
348348
| LR-SYNC-SYNCBTN | Sync active → selected | P1 | ✅ | `cmd:develop.sync` | |
349349
| LR-SYNC-PREVIOUS | Paste from previous / auto sync [Classic] | P2 | ✅ | `cmd:develop.pastePrevious`, `cmd:develop.autoSync` | ⌥⌘V pastes the previously active photo's settings (copy groups); Auto Sync (⌥⇧⌘A) |
350350

@@ -799,7 +799,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove
799799

800800
| Date | Change | Summary |
801801
|---|---|---|
802-
| 2026-10-27 | minor | MENU-EDIT-PASTESELECTED, LR-SYNC-PASTE, LR-REM-SYNC, LR-MASK-SYNC: the settings clipboard keeps the copied photo's whole settings, so Paste Selected Settings pastes any ticked group, also Crop and Remove left out of the copy (issue #3056); a crop pasted, pasted from previous, synced or Auto Synced onto a photo of another shape keeps its aspect ratio and aspect lock (`CropGeometry::refit`, `Crop::refit`); LR-SYNC-PASTE no longer says there is no Paste Selected; status counts unchanged |
802+
| 2026-10-27 | minor | MENU-EDIT-PASTESELECTED, LR-SYNC-PASTE, LR-REM-SYNC, LR-MASK-SYNC: the settings clipboard keeps the copied photo's whole settings, so Paste Selected Settings pastes any ticked group, also Crop and Remove left out of the copy (issue #3056); a crop pasted, pasted from previous, synced or Auto Synced onto a photo of another shape keeps its aspect ratio and aspect lock (`CropGeometry::refit`, `Crop::refit`), Auto Sync refitting only the crop fields the edit changed; LR-SYNC-PASTE no longer says there is no Paste Selected; status counts unchanged |
803803
| 2026-10-25 | patch | LR-BEHAV-TITLEBAR: the top bar's title-bar gestures come from craft-window's `title_bar`: a double-click follows the system setting, and a press on a button, the search field or a panel floating over the bar never moves the window; status counts unchanged |
804804
| 2026-10-24 | minor | KEYC-METADATA, LRC-LIB-KEYWORDS: ⌥0 / ⌥⇧0 (`keyword.nextSet`, `keyword.previousSet`) go to the next / previous keyword set; status counts unchanged (KEYC-METADATA stays 🟡) |
805805
| 2026-10-24 | minor | KEYC-METADATA: ⌘K / Ctrl+K (`panel.addKeywords`, Add Keywords) shows the Keywords panel, opens Keywording and puts the cursor in the Add keyword box; status counts unchanged (KEYC-METADATA stays 🟡) |

‎docs/whats-new.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
aspect ratio, angle and relative size instead of being stretched, and stays centred where it was as far as the photo
1111
allows (a straightened crop off the centre can move in to stay inside the turned photo). A locked ratio such as 3:2
1212
is kept even when it crops nothing on the copied photo; an Original lock takes the new photo's own shape. On a photo
13-
of the same shape the crop is pasted as it is. Presets apply their crop as stored.
13+
of the same shape the crop is pasted as it is. Presets apply their crop as stored. Auto Sync carries only what the
14+
edit changed: a new crop rectangle keeps each photo's own angle, and a new angle each photo's own rectangle.
1415

1516
## 2026-10-24
1617

0 commit comments

Comments
 (0)