From 421a8e5126a56ede1cdce45d5b53289c96a848f9 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 3 Nov 2026 04:34:50 +0000 Subject: [PATCH 1/5] fix(doc): stop frame_relative on a looping parent chain A restored dev snapshot can replace an ancestor with a historical descendant while the root keeps that ancestor as its parent; frame_relative walked the parent chain without a guard and never returned. It now stops after more hops than the document has nodes, as is_ancestor does. --- crates/doc/src/lib.rs | 7 +++++++ crates/doc/src/tests.rs | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index 89eb97269..b637aa8f7 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -585,7 +585,14 @@ impl Document { let Some(n) = self.node(id) else { return Affine::IDENTITY }; let mut t = n.transform; let mut parent = n.parent; + // More hops than nodes means the parent chain loops (a restored snapshot can leave one): + // stop rather than spin. + let mut hops = 0; while let Some(p) = parent.and_then(|p| self.node(p)).filter(|p| p.kind.bounds_follow_children()) { + hops += 1; + if hops > self.nodes.len() { + break; + } t = p.transform * t; parent = p.parent; } diff --git a/crates/doc/src/tests.rs b/crates/doc/src/tests.rs index a0e3e17b0..4e55336b6 100644 --- a/crates/doc/src/tests.rs +++ b/crates/doc/src/tests.rs @@ -846,3 +846,16 @@ fn the_colour_walker_visits_calculation_literals() { let ColorOperand::Literal { literal } = from else { panic!("literal operand") }; assert_eq!(literal.a, 0.5, "the mix's stored literal was converted like every other colour"); } + +#[test] +fn frame_relative_ends_on_a_looping_parent_chain() { + let mut d = Document::new("x"); + let p = page(&d); + let f = d.create(p, NodeKind::Group, "F", 0.0, 0.0, 100.0, 100.0).unwrap(); + let g = d.create(f, NodeKind::Group, "G", 0.0, 0.0, 10.0, 10.0).unwrap(); + let mut v = serde_json::to_value(&d).unwrap(); + // F's parent is its own child G (as a restored snapshot can leave things). + v["nodes"][f.to_string()]["parent"] = serde_json::json!(g); + let bad: Document = serde_json::from_value(v).unwrap(); + let _ = bad.frame_relative(g); +} From 2dc7bed2a0fd4c516a2edfded323efcc0478ea90 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Tue, 3 Nov 2026 21:08:19 -0500 Subject: [PATCH 2/5] M12: connectors attached to a side start 4 pt outside the border (#1916) A connector end attached to a side was routed from the middle of that side, so the stroke's centre line started on the border and half its width plus the round cap lay on the fill, and several connectors leaving one side piled up into a knot sticking into the card. FigJam starts the line a few pixels outside the border and connectors leaving one side run together along the side's normal before they fan out (the issue's screenshots). `board_route::END_GAP` (4 pt): an end attached to a side (`RouteEnd::Box`) starts that far outside it along the side's normal; an end placed by hand on the object (`RouteEnd::On`) keeps its exact point; a free end is unchanged. The pinned route coordinates in the engine, format and UI tests move with it; the overlay's attach points stay on the border. Docs: the Connectors rows, status line and history of boards-parity.md. Co-Authored-By: Claude Fable 5.1 --- crates/doc/src/board_route.rs | 15 ++++-- crates/doc/src/board_route_tests.rs | 49 +++++++++++++++++++ crates/doc/src/lib.rs | 4 +- crates/engine/src/board_connector_tests.rs | 26 +++++----- crates/engine/src/board_reshape_tests.rs | 12 ++--- crates/engine/src/board_tests.rs | 22 +++++---- crates/engine/src/board_tools_tests.rs | 14 +++--- crates/engine/src/boards/board/tools.rs | 12 +++-- crates/engine/src/canvas/snap.rs | 18 +++++-- crates/engine/src/connector_anywhere_tests.rs | 2 +- crates/format/src/fig/tail_tests.rs | 6 +-- crates/ui-egui/src/board_ui_tests.rs | 2 +- docs/boards-parity.md | 7 +-- 13 files changed, 136 insertions(+), 53 deletions(-) create mode 100644 crates/doc/src/board_route_tests.rs diff --git a/crates/doc/src/board_route.rs b/crates/doc/src/board_route.rs index 1aa45c810..7949674d9 100644 --- a/crates/doc/src/board_route.rs +++ b/crates/doc/src/board_route.rs @@ -28,9 +28,15 @@ impl RouteEnd { /// How far an elbow connector going around the objects it joins keeps from them. const ROOM: f64 = 24.0; -/// The points a connector runs through from `from` to `to`: from the middle of the side of each -/// box facing the other end (or the side it names), straight, in right angles, or (curved) its two -/// ends with the curve's two control points between them. `None` when a point isn't finite. +/// How far outside the border a connector attached to a side starts and ends (#1916): the stroke's +/// round cap never lies on the fill, and several connectors leaving one side run together along the +/// side's normal for this much before they part, as FigJam's do. +pub const END_GAP: f64 = 4.0; + +/// The points a connector runs through from `from` to `to`: from [`END_GAP`] outside the middle of +/// the side of each box facing the other end (or the side it names), straight, in right angles, or +/// (curved) its two ends with the curve's two control points between them. `None` when a point isn't +/// finite. pub fn route_points(from: RouteEnd, to: RouteEnd, routing: Routing) -> Option> { let (p0, s0) = attach(from, to.centre()); let (p1, s1) = attach(to, from.centre()); @@ -169,8 +175,9 @@ fn attach(e: RouteEnd, other: Point) -> (Point, Option) { RouteEnd::Point(p) => (p, None), RouteEnd::Box(b, side) => { let side = named_or_facing(b, side, other); - (side.point(b), Some(side)) + (side.point(b) + side.normal() * END_GAP, Some(side)) } + // Placed by hand: the point is the user's, gap or not. RouteEnd::On(b, side, p) => (p, Some(named_or_facing(b, side, other))), } } diff --git a/crates/doc/src/board_route_tests.rs b/crates/doc/src/board_route_tests.rs new file mode 100644 index 000000000..a1e972cba --- /dev/null +++ b/crates/doc/src/board_route_tests.rs @@ -0,0 +1,49 @@ +//! Connector routes (`board_route`): where an end attached to a side starts (#1916). + +use figcraft_geom::{Point, Rect}; + +use crate::board::{Routing, Side}; +use crate::board_route::{END_GAP, RouteEnd, route_points}; + +fn shape(x: f64, y: f64) -> Rect { + Rect::new(x, y, x + 100.0, y + 60.0) +} + +/// An end attached to a side starts `END_GAP` outside the middle of that side, not on the border, +/// so the stroke never lies on the fill (#1916: FigJam starts the line a few pixels outside). +#[test] +fn an_attached_end_starts_outside_the_border() { + let (a, b) = (shape(0.0, 0.0), shape(300.0, 0.0)); + for routing in [Routing::Straight, Routing::Elbow, Routing::Curved] { + let pts = route_points(RouteEnd::Box(a, Side::Auto), RouteEnd::Box(b, Side::Auto), routing).unwrap(); + assert_eq!(pts.first().copied(), Some(Point::new(100.0 + END_GAP, 30.0)), "{routing:?}: leaves the right side"); + assert_eq!(pts.last().copied(), Some(Point::new(300.0 - END_GAP, 30.0)), "{routing:?}: arrives at the left side"); + } + // A named side, and the gap along its own normal. + let pts = route_points(RouteEnd::Box(a, Side::Bottom), RouteEnd::Point(Point::new(50.0, 200.0)), Routing::Straight).unwrap(); + assert_eq!(pts.first().copied(), Some(Point::new(50.0, 60.0 + END_GAP))); +} + +/// Several connectors leaving one side run together along its normal before they part: an elbow's +/// and a curve's first run leave straight out of the side. +#[test] +fn connectors_from_one_side_leave_together() { + let a = shape(0.0, 0.0); + let (up, down) = (RouteEnd::Box(shape(300.0, -200.0), Side::Auto), RouteEnd::Box(shape(300.0, 200.0), Side::Auto)); + for routing in [Routing::Elbow, Routing::Curved] { + let p = route_points(RouteEnd::Box(a, Side::Right), up, routing).unwrap(); + let q = route_points(RouteEnd::Box(a, Side::Right), down, routing).unwrap(); + assert_eq!(p[0], q[0], "{routing:?}: the same start"); + assert_eq!(p[1].y, p[0].y, "{routing:?}: out along the side's normal first"); + assert_eq!(q[1].y, q[0].y, "{routing:?}: out along the side's normal first"); + } +} + +/// A point placed by hand on the object (`RouteEnd::On`) is the user's: no gap is added. +#[test] +fn a_hand_placed_end_keeps_its_point() { + let a = shape(0.0, 0.0); + let on = Point::new(80.0, 60.0); + let pts = route_points(RouteEnd::On(a, Side::Bottom, on), RouteEnd::Point(Point::new(80.0, 200.0)), Routing::Straight).unwrap(); + assert_eq!(pts.first().copied(), Some(on)); +} diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index 0181ffd21..ff6fc3b0f 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -27,7 +27,7 @@ pub mod vector_faces; pub mod vector_regions; pub use board::*; -pub use board_route::{RouteEnd, attached_sides, path_handles, reshaped, route_along, route_points}; +pub use board_route::{END_GAP, RouteEnd, attached_sides, path_handles, reshaped, route_along, route_points}; pub use colors::*; pub use comments::*; pub use facilitation::*; @@ -1299,6 +1299,8 @@ fn remap_action(a: &mut proto::Action, map: &BTreeMap) { #[cfg(test)] mod blur_tests; #[cfg(test)] +mod board_route_tests; +#[cfg(test)] mod board_shape_tests; #[cfg(test)] mod boolean_hit_tests; diff --git a/crates/engine/src/board_connector_tests.rs b/crates/engine/src/board_connector_tests.rs index da5b3b924..7b6f2dc0a 100644 --- a/crates/engine/src/board_connector_tests.rs +++ b/crates/engine/src/board_connector_tests.rs @@ -2,7 +2,7 @@ //! command and a drag of the selected connector's end), curved connectors, and elbows that go //! around the objects they join. -use figcraft_doc::{BoardItem, End, NodeKind, Routing, Side}; +use figcraft_doc::{BoardItem, END_GAP, End, NodeKind, Routing, Side}; use figcraft_geom::{Point, Rect}; use serde_json::json; @@ -27,7 +27,7 @@ fn reattach_moves_one_end_and_undoes() { s.execute("board.reattach", &json!({"id": k, "end": "to", "target": c, "side": "top"})).unwrap(); assert_eq!(connector(&s, k).to, End::Node { node: c, side: Side::Top, at: None }); assert_eq!(connector(&s, k).from.node(), Some(a)); - assert!(near(*drawn(&s, k).last().unwrap(), Point::new(650.0, 0.0)), "arrives on c's top: {:?}", drawn(&s, k)); + assert!(near(*drawn(&s, k).last().unwrap(), Point::new(650.0, -END_GAP)), "arrives END_GAP above c's top: {:?}", drawn(&s, k)); s.execute("edit.undo", &json!({})).unwrap(); assert_eq!(connector(&s, k).to.node(), Some(b), "one undo step"); // Off into the canvas: the end stays there, free. The selection is the default connector. @@ -107,9 +107,9 @@ fn curved_connectors_leave_and_arrive_along_the_sides() { let NodeKind::Vector { network } = &n.kind else { panic!("a vector") }; assert_eq!((network.vertices.len(), network.segments.len()), (2, 1)); assert!(!network.segments[0].is_straight(), "one curve"); - assert_eq!(drawn(&s, k), vec![Point::new(100.0, 50.0), Point::new(300.0, 50.0)]); + assert_eq!(drawn(&s, k), vec![Point::new(104.0, 50.0), Point::new(296.0, 50.0)]); // Side to side in a line: the curve's control points lie on that line, so its box is flat. - assert!(n.height.abs() < 1e-9 && (n.width - 200.0).abs() < 1e-9, "{} × {}", n.width, n.height); + assert!(n.height.abs() < 1e-9 && (n.width - 192.0).abs() < 1e-9, "{} × {}", n.width, n.height); // From a's bottom to c's top: out downwards and in from above; the box holds the whole curve. let k2 = id( &s.execute("board.connector", &json!({"from": a, "to": c, "fromSide": "bottom", "toSide": "top", "style": "curved", "label": "x"})).unwrap(), @@ -146,18 +146,18 @@ fn elbows_go_around_the_objects_they_join() { let pts = drawn(&s, k2); let (ra, rb) = (Rect::new(0.0, 0.0, 100.0, 100.0), Rect::new(300.0, 0.0, 400.0, 100.0)); assert!(!through(&pts, ra) && !through(&pts, rb), "{pts:?}"); - assert_eq!(pts.first().copied(), Some(Point::new(0.0, 50.0))); - assert_eq!(pts.last().copied(), Some(Point::new(400.0, 50.0))); + assert_eq!(pts.first().copied(), Some(Point::new(-END_GAP, 50.0))); + assert_eq!(pts.last().copied(), Some(Point::new(400.0 + END_GAP, 50.0))); assert_eq!(pts.len(), 6, "out, over, down and in: {pts:?}"); assert!(pts.iter().all(|p| p.y <= 50.0), "over the top, the nearer way round: {pts:?}"); assert!(pts.windows(2).all(|w| w[0].x == w[1].x || w[0].y == w[1].y), "right angles only"); // Facing each other, the short way stays. - assert_eq!(drawn(&s, k), vec![Point::new(100.0, 50.0), Point::new(300.0, 50.0)]); + assert_eq!(drawn(&s, k), vec![Point::new(104.0, 50.0), Point::new(296.0, 50.0)]); // An end at the bottom of b leaving towards a above it: around b's side and up. s.execute("board.reattach", &json!({"id": k2, "end": "to", "target": b, "side": "bottom"})).unwrap(); let pts = drawn(&s, k2); assert!(!through(&pts, ra) && !through(&pts, rb), "{pts:?}"); - assert_eq!(pts.last().copied(), Some(Point::new(350.0, 100.0))); + assert_eq!(pts.last().copied(), Some(Point::new(350.0, 100.0 + END_GAP))); } #[test] @@ -202,8 +202,12 @@ fn the_connector_being_drawn_is_the_one_made() { // Over b: its four attach points, the one the end is at lit, and b outlined. assert_eq!(ov.drop_target, Some(b)); let lit: Vec<[f64; 2]> = ov.attach.iter().filter(|a| a.1).map(|a| a.0).collect(); + // The lit attach point is the side's middle, on the border; the route's end sits + // END_GAP outside it along the side's normal (#1916). let end = *drawn(&s, drawing.id).last().unwrap(); - assert_eq!((ov.attach.len(), lit), (4, vec![[end.x, end.y]]), "{style}"); + assert_eq!(ov.attach.len(), 4, "{style}"); + let [lit] = lit.as_slice() else { panic!("{style}: one lit attach point, got {lit:?}") }; + assert!(((lit[0] - end.x).abs() + (lit[1] - end.y).abs() - END_GAP).abs() < 1e-9, "{style}: {lit:?} is END_GAP inside {end:?}"); } else { assert!(ov.attach.is_empty() && ov.drop_target.is_none(), "a free end"); } @@ -259,7 +263,7 @@ fn an_end_dropped_along_a_side_attaches_to_that_side() { s.pointer(&ev(PointerKind::Up, drop)).unwrap(); assert_eq!(connector(&s, k).from, End::Node { node: a, side, at: None }, "{drop:?}"); if side != Side::Auto { - assert_eq!(drawn(&s, k)[0], side.point(bounds), "the route leaves from that side"); + assert_eq!(drawn(&s, k)[0], side.point(bounds) + side.normal() * END_GAP, "the route leaves from that side, END_GAP out"); } } } @@ -307,5 +311,5 @@ fn a_connector_end_snaps_to_the_attach_point_under_the_pointer() { (connector(&s, k).from, connector(&s, k).to), (End::Node { node: a, side: Side::Right, at: None }, End::Node { node: b, side: Side::Top, at: None }) ); - assert_eq!(drawn(&s, k), vec![Point::new(100.0, 50.0), Point::new(350.0, 200.0)]); + assert_eq!(drawn(&s, k), vec![Point::new(104.0, 50.0), Point::new(350.0, 196.0)]); } diff --git a/crates/engine/src/board_reshape_tests.rs b/crates/engine/src/board_reshape_tests.rs index 5a73267e3..ea4572cef 100644 --- a/crates/engine/src/board_reshape_tests.rs +++ b/crates/engine/src/board_reshape_tests.rs @@ -11,8 +11,8 @@ use crate::board::{route, selected_connector_handles}; use crate::board_tests::{board, connector, drawn, id, near}; use crate::tools::{PointerEvent, PointerKind}; -const A: Point = Point::new(100.0, 50.0); -const B: Point = Point::new(300.0, 250.0); +const A: Point = Point::new(104.0, 50.0); +const B: Point = Point::new(296.0, 250.0); /// Shapes a (at the origin) and b (down and to the right), 100 × 100, joined side to side. fn joined(style: &str) -> (Session, NodeId, NodeId, NodeId) { @@ -80,11 +80,11 @@ fn a_reshaped_connector_keeps_the_sides_it_left_by() { fn the_first_and_last_runs_gain_a_run_and_stay_on_their_ends() { let (mut s, _, _, k) = joined("elbow"); reshape(&mut s, k, 0.0, 150.0, 120.0).unwrap(); - assert_eq!(drawn(&s, k), [A, pt(124.0, 50.0), pt(124.0, 120.0), pt(200.0, 120.0), pt(200.0, 250.0), B]); + assert_eq!(drawn(&s, k), [A, pt(128.0, 50.0), pt(128.0, 120.0), pt(200.0, 120.0), pt(200.0, 250.0), B]); let last = drawn(&s, k).len() - 2; reshape(&mut s, k, last as f64, 250.0, 200.0).unwrap(); let pts = drawn(&s, k); - assert_eq!(pts, [A, pt(124.0, 50.0), pt(124.0, 120.0), pt(200.0, 120.0), pt(200.0, 200.0), pt(276.0, 200.0), pt(276.0, 250.0), B]); + assert_eq!(pts, [A, pt(128.0, 50.0), pt(128.0, 120.0), pt(200.0, 120.0), pt(200.0, 200.0), pt(272.0, 200.0), pt(272.0, 250.0), B]); assert!(right_angled(&pts)); } @@ -97,8 +97,8 @@ fn a_lone_run_gains_a_run_at_each_end() { let k = id(&s.execute("board.connector", &json!({"from": a, "to": b, "style": "elbow"})).unwrap(), "id"); assert_eq!(drawn(&s, k).len(), 2); reshape(&mut s, k, 0.0, 200.0, -40.0).unwrap(); - let (l, r) = (pt(100.0, 50.0), pt(300.0, 50.0)); - assert_eq!(drawn(&s, k), [l, pt(124.0, 50.0), pt(124.0, -40.0), pt(276.0, -40.0), pt(276.0, 50.0), r]); + let (l, r) = (pt(104.0, 50.0), pt(296.0, 50.0)); + assert_eq!(drawn(&s, k), [l, pt(128.0, 50.0), pt(128.0, -40.0), pt(272.0, -40.0), pt(272.0, 50.0), r]); } #[test] diff --git a/crates/engine/src/board_tests.rs b/crates/engine/src/board_tests.rs index 6849ac421..9e99bd1c9 100644 --- a/crates/engine/src/board_tests.rs +++ b/crates/engine/src/board_tests.rs @@ -168,7 +168,7 @@ fn connectors_follow_what_they_join_and_undo_with_it() { let b = id(&s.execute("board.sticky", &json!({"x": 400, "y": 0})).unwrap(), "id"); let c = id(&s.execute("board.connector", &json!({"from": a, "to": b, "style": "straight", "label": "then"})).unwrap(), "id"); let pts = drawn(&s, c); - assert!(near(pts[0], Point::new(200.0, 100.0)) && near(pts[1], Point::new(400.0, 100.0)), "{pts:?}"); + assert!(near(pts[0], Point::new(204.0, 100.0)) && near(pts[1], Point::new(396.0, 100.0)), "{pts:?}"); assert_eq!(node(&s, c).stroke.cap_end, StrokeCap::TriangleArrow); // Its label sits at the middle. let label = crate::board::label_of(s.doc().unwrap(), c).unwrap(); @@ -178,19 +178,19 @@ fn connectors_follow_what_they_join_and_undo_with_it() { s.execute("board.setStyle", &json!({"ids": [c], "style": "elbow"})).unwrap(); s.execute("transform.move", &json!({"ids": [b], "dx": 0, "dy": 300})).unwrap(); let pts = drawn(&s, c); - assert!(near(pts[0], Point::new(200.0, 100.0)) && near(*pts.last().unwrap(), Point::new(400.0, 400.0)), "{pts:?}"); + assert!(near(pts[0], Point::new(204.0, 100.0)) && near(*pts.last().unwrap(), Point::new(396.0, 400.0)), "{pts:?}"); assert!(pts.windows(2).all(|w| w[0].x == w[1].x || w[0].y == w[1].y), "right angles: {pts:?}"); // Undo takes the move back and the route with it. s.execute("edit.undo", &json!({})).unwrap(); - assert!(near(*drawn(&s, c).last().unwrap(), Point::new(400.0, 100.0))); + assert!(near(*drawn(&s, c).last().unwrap(), Point::new(396.0, 100.0))); // A deleted end stays where it was, as a point. s.execute("edit.delete", &json!({"ids": [b]})).unwrap(); assert!(matches!(connector(&s, c).to, End::Point { .. })); - assert!(near(*drawn(&s, c).last().unwrap(), Point::new(400.0, 100.0))); + assert!(near(*drawn(&s, c).last().unwrap(), Point::new(396.0, 100.0))); // A connector moved on its own takes its free end along; the attached one stays. s.execute("transform.move", &json!({"ids": [c], "dx": 0, "dy": 50})).unwrap(); - assert!(matches!(connector(&s, c).to, End::Point { x, y } if x == 400.0 && y == 150.0), "{:?}", connector(&s, c)); - assert!(near(drawn(&s, c)[0], Point::new(200.0, 100.0))); + assert!(matches!(connector(&s, c).to, End::Point { x, y } if x == 396.0 && y == 150.0), "{:?}", connector(&s, c)); + assert!(near(drawn(&s, c)[0], Point::new(204.0, 100.0))); // Deleting the connector takes its label. s.execute("edit.delete", &json!({"ids": [c]})).unwrap(); assert!(!s.doc().unwrap().contains(label)); @@ -210,8 +210,8 @@ fn routes_are_the_same_for_the_same_document() { let doc = s.doc().unwrap(); let r = route(doc, &c).unwrap(); assert_eq!(r, route(&doc.clone(), &c).unwrap()); - // Down out of the bottom, across halfway, down into the point. - assert_eq!(r, vec![Point::new(80.0, 160.0), Point::new(80.0, 330.0), Point::new(300.0, 330.0), Point::new(300.0, 500.0)]); + // Down out of the bottom (END_GAP below it), across halfway, down into the point. + assert_eq!(r, vec![Point::new(80.0, 164.0), Point::new(80.0, 332.0), Point::new(300.0, 332.0), Point::new(300.0, 500.0)]); } #[test] @@ -338,7 +338,7 @@ fn boards_sync_in_live_sessions() { let doc = room.server.document(); let NodeKind::Vector { network } = &doc.node(c).unwrap().kind else { panic!("not a vector") }; let end = doc.world_transform(c) * network.vertices.last().unwrap().point(); - assert_eq!(end, Point::new(400.0, 350.0), "to the moved sticky's facing side"); + assert_eq!(end, Point::new(396.0, 350.0), "to END_GAP before the moved sticky's facing side"); assert_eq!(doc.node(a).unwrap().fills[0].solid_color(), board_color("violet")); } @@ -410,7 +410,9 @@ fn a_press_on_a_stickys_background_picks_and_drags_it() { s.pointer(&PointerEvent::at(PointerKind::Up, 100.0, 450.0, 1.0)).unwrap(); assert_eq!(s.selection(), vec![a]); assert_eq!(node(&s, a).transform.translation().y, 300.0); - assert!(near(drawn(&s, c)[0], Point::new(200.0, 400.0)), "the connector followed the drag: {:?}", drawn(&s, c)); + // Its own connector's start, END_GAP outside its edge, is no snap target for it (#1916). + assert_eq!(node(&s, a).transform.translation().x, 0.0, "not nudged sideways by its own connector"); + assert!(near(drawn(&s, c)[0], Point::new(204.0, 400.0)), "the connector followed the drag: {:?}", drawn(&s, c)); } #[test] diff --git a/crates/engine/src/board_tools_tests.rs b/crates/engine/src/board_tools_tests.rs index 6862e4219..24e6df7dd 100644 --- a/crates/engine/src/board_tools_tests.rs +++ b/crates/engine/src/board_tools_tests.rs @@ -100,18 +100,18 @@ fn routes_take_named_sides_and_free_points() { let side = |n, side| End::Node { node: n, side, at: None }; let p = |x, y| End::Point { x, y }; let pt = Point::new; - // Side to side: out, across halfway, in. - assert_eq!(elbow(side(a, Side::Right), side(b, Side::Left)), vec![pt(100.0, 50.0), pt(200.0, 50.0), pt(200.0, 350.0), pt(300.0, 350.0)]); + // Side to side: out (from END_GAP outside each side), across halfway, in. + assert_eq!(elbow(side(a, Side::Right), side(b, Side::Left)), vec![pt(104.0, 50.0), pt(200.0, 50.0), pt(200.0, 350.0), pt(296.0, 350.0)]); // A side and a top or bottom: one turn. - assert_eq!(elbow(side(a, Side::Right), side(b, Side::Top)), vec![pt(100.0, 50.0), pt(350.0, 50.0), pt(350.0, 300.0)]); - assert_eq!(elbow(side(a, Side::Bottom), side(b, Side::Left)), vec![pt(50.0, 100.0), pt(50.0, 350.0), pt(300.0, 350.0)]); + assert_eq!(elbow(side(a, Side::Right), side(b, Side::Top)), vec![pt(104.0, 50.0), pt(350.0, 50.0), pt(350.0, 296.0)]); + assert_eq!(elbow(side(a, Side::Bottom), side(b, Side::Left)), vec![pt(50.0, 104.0), pt(50.0, 350.0), pt(296.0, 350.0)]); // Two free points: the longer way first; in a line, no turns. assert_eq!(elbow(p(0.0, 0.0), p(100.0, 40.0)), vec![pt(0.0, 0.0), pt(50.0, 0.0), pt(50.0, 40.0), pt(100.0, 40.0)]); assert_eq!(elbow(p(0.0, 0.0), p(100.0, 0.0)), vec![pt(0.0, 0.0), pt(100.0, 0.0)]); // An automatic side faces the other end. let straight = route(doc, &figcraft_doc::Connector { from: side(a, Side::Auto), to: p(50.0, 500.0), routing: figcraft_doc::Routing::Straight, path: None }); - assert_eq!(straight.unwrap(), vec![pt(50.0, 100.0), pt(50.0, 500.0)]); + assert_eq!(straight.unwrap(), vec![pt(50.0, 104.0), pt(50.0, 500.0)]); assert_eq!(Side::from_id("TOP"), Some(Side::Top)); assert_eq!(Side::from_id("inside"), None); // The same place twice is refused, as are a side that doesn't exist and a point without numbers. @@ -128,10 +128,10 @@ fn a_connector_follows_a_layer_whose_section_moves_and_ignores_unrelated_edits() let a = id(&s.execute("board.sticky", &json!({"x": 50, "y": 50, "parent": sec})).unwrap(), "id"); let b = id(&s.execute("board.stamp", &json!({"x": 800, "y": 150})).unwrap(), "id"); let c = id(&s.execute("board.connector", &json!({"from": a, "to": b, "style": "straight"})).unwrap(), "id"); - assert!(near(drawn(&s, c)[0], Point::new(250.0, 150.0))); + assert!(near(drawn(&s, c)[0], Point::new(254.0, 150.0))); // Only the section is edited; the sticky inside it moves with it, and so does the connector. s.execute("transform.move", &json!({"ids": [sec], "dx": 0, "dy": 100})).unwrap(); - assert!(near(drawn(&s, c)[0], Point::new(250.0, 250.0)), "{:?}", drawn(&s, c)); + assert!(near(drawn(&s, c)[0], Point::new(254.0, 250.0)), "{:?}", drawn(&s, c)); // An edit that touches neither end leaves the connector as it was. let before = s.doc().unwrap().node_arc(c).cloned().unwrap(); s.execute("board.sticky", &json!({"x": 0, "y": 900})).unwrap(); diff --git a/crates/engine/src/boards/board/tools.rs b/crates/engine/src/boards/board/tools.rs index cf4753357..71f0dcc5b 100644 --- a/crates/engine/src/boards/board/tools.rs +++ b/crates/engine/src/boards/board/tools.rs @@ -133,13 +133,19 @@ impl Session { (to.node().is_none() || to.node() != from.node()).then_some(to) } - /// The object `end` is on (if any) outlined, with its attach points; the one the end is at - /// (`at`, else its named side's) lit. + /// The object `end` is on (if any) outlined, with its attach points (the side middles, on the + /// border); the one the end is at lit: the nearest to `at` (a route's end sits `END_GAP` outside + /// its side's middle, #1916), else its named side's. fn show_attach(&mut self, end: Option, at: Option) { let attach = match end { Some(End::Node { node, side, .. }) => self.doc().ok().and_then(|d| d.world_bounds(node)).map(|b| { let on = at.or_else(|| (side != Side::Auto).then(|| side.point(b))); - SIDES.map(|s| s.point(b)).map(|p| ([p.x, p.y], on.is_some_and(|o| (o - p).hypot() < 1e-6))).to_vec() + let pts = SIDES.map(|s| s.point(b)); + let lit = on.and_then(|o| { + let near = pts.iter().enumerate().map(|(i, p)| (i, (o - *p).hypot())).filter(|(_, d)| *d <= figcraft_doc::END_GAP + 1e-6); + near.min_by(|x, y| x.1.total_cmp(&y.1)).map(|(i, _)| i) + }); + pts.iter().enumerate().map(|(i, p)| ([p.x, p.y], lit == Some(i))).collect() }), _ => None, }; diff --git a/crates/engine/src/canvas/snap.rs b/crates/engine/src/canvas/snap.rs index fab63810c..97c23fa6c 100644 --- a/crates/engine/src/canvas/snap.rs +++ b/crates/engine/src/canvas/snap.rs @@ -4,7 +4,7 @@ //! guide lines (with spacing labels) for the canvas to draw in red. Vector points also snap to //! other points (see `vectoredit::snap`); landing on one shows a marker (a zero-length guide). -use figcraft_doc::{Document, NodeId}; +use figcraft_doc::{BoardItem, Document, NodeId}; use figcraft_geom::{Affine, Point, Rect, Vec2, transform_rect_bbox}; use serde::Serialize; @@ -94,10 +94,22 @@ impl Targets { t.ys.push((y, b.x0, b.x1)); } } - // Siblings and, at the top level, all top-level layers. + // Siblings and, at the top level, all top-level layers. A board connector joined to a + // moving layer re-routes with it, as does its label: no snapping to where its own route + // starts (#1916). + let follows = |id: NodeId| match doc.node(id).and_then(|n| n.board.as_ref()) { + Some(BoardItem::Connector(k)) => [k.from.node(), k.to.node()].into_iter().flatten().any(|e| moving.contains(&e)), + _ => false, + }; if let Some(p) = doc.node(parent) { for c in &p.children { - if moving.contains(c) || !doc.node(*c).is_some_and(|n| n.visible) { + let Some(n) = doc.node(*c).filter(|n| n.visible) else { continue }; + let joined = match n.board.as_ref() { + Some(BoardItem::Connector(_)) => follows(*c), + Some(BoardItem::Label { connector }) => follows(*connector), + _ => false, + }; + if moving.contains(c) || joined { continue; } if let Some(b) = bbox(*c) { diff --git a/crates/engine/src/connector_anywhere_tests.rs b/crates/engine/src/connector_anywhere_tests.rs index 15776fb23..f979eca57 100644 --- a/crates/engine/src/connector_anywhere_tests.rs +++ b/crates/engine/src/connector_anywhere_tests.rs @@ -46,7 +46,7 @@ fn without_cmd_an_end_keeps_snapping_to_a_side() { let end = *drawn(&s, k).last().unwrap(); drag_end(&mut s, end, Point::new(650.0, 25.0), false); assert_eq!(connector(&s, k).to, End::Node { node: b, side: Side::Right, at: None }); - assert!(near(*drawn(&s, k).last().unwrap(), Point::new(700.0, 50.0))); + assert!(near(*drawn(&s, k).last().unwrap(), Point::new(700.0 + figcraft_doc::END_GAP, 50.0)), "END_GAP outside the side"); } #[test] diff --git a/crates/format/src/fig/tail_tests.rs b/crates/format/src/fig/tail_tests.rs index 2c8cce032..8937ffa5a 100644 --- a/crates/format/src/fig/tail_tests.rs +++ b/crates/format/src/fig/tail_tests.rs @@ -619,7 +619,7 @@ fn other_layer_kinds_import_as_the_closest_layers() { let world = doc.world_transform(link.id); let ends: Vec<(f64, f64)> = network_of(&doc, "Link").vertices.iter().map(|v| world * figcraft_doc::geom::Point::new(v.x, v.y)).map(|p| (p.x, p.y)).collect(); - assert_eq!(ends, [(0.0, 300.0), (200.0, 300.0), (200.0, 50.0), (400.0, 50.0)]); + assert_eq!(ends, [(0.0, 300.0), (198.0, 300.0), (198.0, 50.0), (396.0, 50.0)]); assert_eq!(link.stroke.cap_end, StrokeCap::TriangleArrow); // A table: a frame. assert!(matches!(named(&doc, "Grid").kind, NodeKind::Frame)); @@ -656,9 +656,9 @@ fn connectors_without_a_saved_path_follow_their_line_style() { // Curved: one curve from A's right side to B's left, leaving and arriving level. let curve = network_of(&doc, "Curve"); let ends: Vec<_> = curve.vertices.iter().map(|v| world("Curve") * figcraft_doc::geom::Point::new(v.x, v.y)).collect(); - assert_eq!(ends.iter().map(|p| (p.x, p.y)).collect::>(), [(100.0, 650.0), (300.0, 650.0)]); + assert_eq!(ends.iter().map(|p| (p.x, p.y)).collect::>(), [(104.0, 650.0), (296.0, 650.0)], "END_GAP outside the sides"); assert_eq!(curve.segments.len(), 1); - assert_eq!((curve.segments[0].ta, curve.segments[0].tb), ((100.0, 0.0), (-100.0, 0.0)), "the curve leaves and arrives along the sides"); + assert_eq!((curve.segments[0].ta, curve.segments[0].tb), ((96.0, 0.0), (-96.0, 0.0)), "the curve leaves and arrives along the sides"); // Straight: unchanged, to the points the file gives on the layers. let line: Vec<_> = network_of(&doc, "Line").vertices.iter().map(|v| world("Line") * figcraft_doc::geom::Point::new(v.x, v.y)).map(|p| (p.x, p.y)).collect(); diff --git a/crates/ui-egui/src/board_ui_tests.rs b/crates/ui-egui/src/board_ui_tests.rs index 554d117d9..867ba139a 100644 --- a/crates/ui-egui/src/board_ui_tests.rs +++ b/crates/ui-egui/src/board_ui_tests.rs @@ -290,7 +290,7 @@ fn a_selected_connector_shows_its_ends_as_handles() { let b = u.app.session.execute("board.sticky", &json!({"x": 400, "y": 0})).unwrap()["id"].clone(); u.app.session.execute("board.connector", &json!({"from": a, "to": b, "style": "straight"})).unwrap(); let shapes = flat(&u.frame_output(vec![]).shapes); - let ends = [u.app.to_screen(200.0, 100.0), u.app.to_screen(400.0, 100.0)]; + let ends = [u.app.to_screen(204.0, 100.0), u.app.to_screen(396.0, 100.0)]; for end in ends { let ring = shapes.iter().any(|s| matches!(s, egui::Shape::Circle(c) if (c.center - end).length() < 0.5 && c.radius == 5.0)); assert!(ring, "a handle at {end:?}"); diff --git a/docs/boards-parity.md b/docs/boards-parity.md index 7526d39aa..689dc60a6 100644 --- a/docs/boards-parity.md +++ b/docs/boards-parity.md @@ -1,6 +1,6 @@ # Boards parity -> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-10-31 · **Change:** minor (a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a connector end dropped along a side of a shape attaches to that side (#1708); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a connector's bar sets its start and end points, dashes, weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); "+" handles beside a selected sticky or shape make the next one, joined by a connector (#1597); a FigJam `.jam` file opens as a board (#1342); board grid settings: dots, lines, graph paper or none, spacing, size and contrast; the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); templates and tables; facilitation: a shared timer and voting sessions; the dot grid, dragging a connector's end to re-attach it, curved connectors, elbows that go around what they join) · **Target:** the incumbent's whiteboard product (behaviour from its public help centre) +> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-04 · **Change:** minor (a connector attached to a side starts 4 pt outside the border, so its stroke never lies on the fill and connectors leaving one side run together before they part (#1916); a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a connector end dropped along a side of a shape attaches to that side (#1708); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a connector's bar sets its start and end points, dashes, weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); "+" handles beside a selected sticky or shape make the next one, joined by a connector (#1597); a FigJam `.jam` file opens as a board (#1342); board grid settings: dots, lines, graph paper or none, spacing, size and contrast; the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); templates and tables; facilitation: a shared timer and voting sessions; the dot grid, dragging a connector's end to re-attach it, curved connectors, elbows that go around what they join) · **Target:** the incumbent's whiteboard product (behaviour from its public help centre) **Breadth ~47%, ready ~29% (estimated, erring low).** A board is a FigCraft file of its own kind (`file.newBoard`) with a dot grid on the page, sticky notes, shapes with text, connectors that @@ -34,10 +34,10 @@ all end with the same geometry. | Sticky options: hide the author, change size presets, sticky stacks | partial | `board.sticky {author: false}`; no size presets or stacks | | Shapes with text | done | rectangle, rounded rectangle, ellipse, diamond, triangle, speech bubble, chevron; text centred and wrapping inside the outline; shape type and text size from the contextual bar | | Shape auto-fit to its text, more shapes (cylinder, cross, star…), shape libraries | missing | | -| Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed; an end dropped on the outer half of an object takes the side it is towards (a drop along a whole edge chooses that edge), one in the middle takes the facing side; re-routed when either end moves or resizes; a deleted end stays where it was | +| Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed; an end dropped on the outer half of an object takes the side it is towards (a drop along a whole edge chooses that edge), one in the middle takes the facing side; re-routed when either end moves or resizes; a deleted end stays where it was; an end attached to a side starts 4 pt outside the border (`board_route::END_GAP`), so the stroke never lies on the fill and connectors leaving one side run together along the side's normal before they part (#1916) | | Shapes with text | done | 23 outlines: rectangle, rounded rectangle, ellipse, diamond, triangle up and down, parallelogram right and left, trapezoid, pentagon, hexagon, octagon, star, plus, arrow left and right, chevron, speech bubble, and the flowchart symbols database, document, predefined process, manual input and internal storage; text centred and wrapping inside the outline; shape type and text size from the contextual bar | | Shape auto-fit to its text, the advanced shape libraries (engineering and other icon shapes) | missing | | -| Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed, and within 10 px of one the end keeps that side; re-routed when either end moves or resizes; a deleted end stays where it was | +| Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed, and within 10 px of one the end keeps that side; re-routed when either end moves or resizes; a deleted end stays where it was; an end attached to a side starts 4 pt outside the border (`board_route::END_GAP`), so the stroke never lies on the fill and connectors leaving one side run together along the side's normal before they part (#1916) | | Create the next shape already connected | done | a selected sticky or shape shows a "+" beside each side; hovering one shows where the next goes, clicking makes one of the same kind, size and colour there, joined by a connector as the Connector tool makes one, and starts typing in it; one undo step (`board.addConnected {id?, side?, edit?}`, #1597). Shift+Cmd/Ctrl+Enter on a selected (or edited) shape adds the next shape on its right, joined the same way, and goes on typing; on a sticky it adds a sticky beside it without a connector, as before | | Curved connectors, elbows around objects, dragging an end to re-attach | done | `board.setStyle {style: curved}` (and the contextual bar): one curve leaving and arriving along the sides; an elbow whose short way would cross what it joins goes around their boxes, 24 units clear; a selected connector shows its two ends as handles, and dragging one onto an object attaches it there (the object is outlined while dragging), onto empty canvas leaves it free (`board.reattach {id, end, target, side?}`, one undo step) | | A connector end on any part of an object | done | holding Cmd/Ctrl while moving an end places it where the pointer is on the object, as a share of its box, so it follows moves and resizes; the line leaves by the side facing the other end. Without the key an end snaps to a side | @@ -70,6 +70,7 @@ all end with the same geometry. | Date | Change | Summary | |---|---|---| +| 2026-11-04 | minor | M12, #1916: a connector end attached to a side starts 4 pt outside the border (`board_route::END_GAP`), as FigJam's do (the issue's screenshots: the line starts a few pixels outside, with a round cap, and connectors leaving one side run together along the side's normal before they fan out), so the stroke never lies on the fill; the `.jam` importer's routes, re-attached ends, path handles and labels follow the route's points; an end placed by hand with Cmd/Ctrl held keeps its exact point. Tests: `board_route_tests` (three). Numbers unchanged. | | 2026-10-31 | minor | M12: as the help describes, holding Cmd/Ctrl while moving a connector's end places it on any part of an object instead of snapping to a side. It keeps that spot as a fraction of the object's box, so it follows the object when it moves or resizes, and without the key an end snaps as before. `board.connector {fromAt, toAt}` and `board.reattach {at}` take it; saved only when set. Numbers unchanged | | 2026-10-31 | patch | M12, #1708: a connector end dropped on the outer half of a shape takes the side it is towards, instead of only within 10 px of a side's middle, so a drop anywhere along an edge chooses that edge (dragging a selected connector's end and with the connector tool, ring included); a drop in the middle of a shape still takes the facing side. | | 2026-10-31 | minor | M12, #1710: a selected elbow or curved connector shows path handles. Dragging a run moves it and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins, is saved with the file, and goes back to routing itself when the style changes or an end moves to something else. | From 7be7c054ebaa7b4bb5d0ae148607642cb714a75e Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Tue, 3 Nov 2026 21:46:34 -0500 Subject: [PATCH 3/5] M12: a connector joined to a layer inside a moving section is no snap target; the docs say which connectors share a run (#1916) Review: a section moving carries its stickies and their connectors, so those connectors and their labels are no snap targets for the section either (an end counts as carried when its node or any ancestor is moving). The parity rows, the END_GAP doc and the test's doc no longer say connectors from one side run together: elbows share their first run along the normal, curves leave tangent to it, straight ones fan out from the same point. Co-Authored-By: Claude Fable 5.1 --- crates/doc/src/board_route.rs | 4 ++-- crates/doc/src/board_route_tests.rs | 4 ++-- crates/engine/src/board_tools_tests.rs | 26 ++++++++++++++++++++++++++ crates/engine/src/canvas/snap.rs | 7 ++++--- docs/boards-parity.md | 8 ++++---- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/crates/doc/src/board_route.rs b/crates/doc/src/board_route.rs index 7949674d9..74e143cf0 100644 --- a/crates/doc/src/board_route.rs +++ b/crates/doc/src/board_route.rs @@ -29,8 +29,8 @@ impl RouteEnd { const ROOM: f64 = 24.0; /// How far outside the border a connector attached to a side starts and ends (#1916): the stroke's -/// round cap never lies on the fill, and several connectors leaving one side run together along the -/// side's normal for this much before they part, as FigJam's do. +/// round cap never lies on the fill, and elbows leaving one side share their first run along the +/// side's normal (curves leave tangent to it), as FigJam's connectors do. pub const END_GAP: f64 = 4.0; /// The points a connector runs through from `from` to `to`: from [`END_GAP`] outside the middle of diff --git a/crates/doc/src/board_route_tests.rs b/crates/doc/src/board_route_tests.rs index a1e972cba..43530df15 100644 --- a/crates/doc/src/board_route_tests.rs +++ b/crates/doc/src/board_route_tests.rs @@ -24,8 +24,8 @@ fn an_attached_end_starts_outside_the_border() { assert_eq!(pts.first().copied(), Some(Point::new(50.0, 60.0 + END_GAP))); } -/// Several connectors leaving one side run together along its normal before they part: an elbow's -/// and a curve's first run leave straight out of the side. +/// Elbows leaving one side share their first run along its normal, and curves leave tangent to it: +/// the second point of each lies straight out of the side. #[test] fn connectors_from_one_side_leave_together() { let a = shape(0.0, 0.0); diff --git a/crates/engine/src/board_tools_tests.rs b/crates/engine/src/board_tools_tests.rs index 24e6df7dd..6ed291e13 100644 --- a/crates/engine/src/board_tools_tests.rs +++ b/crates/engine/src/board_tools_tests.rs @@ -276,3 +276,29 @@ fn a_board_tool_left_on_presses_as_move_in_a_design_file() { assert_eq!(s.tool.tool, ToolId::Move); assert_eq!(s.selection(), vec![r], "the press selected as Move does"); } + +/// #1916: a connector's start, END_GAP outside the layer it leaves, is a snap line for other layers +/// but not for that layer, nor for a section holding it (both carry the connector along), and nor +/// is the connector's label. +#[test] +fn a_connector_joined_to_a_moving_layer_or_its_section_is_no_snap_target() { + let mut s = board(); + let sec = id(&s.execute("node.create", &json!({"type": "section", "x": 0, "y": 0, "width": 300, "height": 300})).unwrap(), "id"); + let a = id(&s.execute("board.sticky", &json!({"x": 50, "y": 50, "parent": sec})).unwrap(), "id"); + let b = id(&s.execute("board.stamp", &json!({"x": 800, "y": 150})).unwrap(), "id"); + let c = id(&s.execute("board.connector", &json!({"from": a, "to": b, "style": "straight", "label": "to"})).unwrap(), "id"); + // A layer the connector has nothing to do with. + let d = id(&s.execute("board.sticky", &json!({"x": 0, "y": 900})).unwrap(), "id"); + let page = s.page().unwrap(); + let start = drawn(&s, c)[0].x; + let label = crate::board::label_of(s.doc().unwrap(), c).unwrap(); + let lx = s.doc().unwrap().world_bounds(label).unwrap().x0; + // A box whose left edge is 1 past a line snaps back by 1 when the line is a target. + let pull = |s: &Session, moving: &[NodeId], x: f64| { + let t = crate::snap::Targets::gather(s.doc().unwrap(), page, moving); + t.snap_rect(figcraft_geom::Rect::new(x + 1.0, 600.0, x + 9.0, 610.0), 4.0).0 + }; + assert_eq!((pull(&s, &[d], start), pull(&s, &[d], lx)), (-1.0, -1.0), "for an unrelated layer, the connector and its label snap"); + assert_eq!(pull(&s, &[b], start), 0.0, "not for the layer it arrives at"); + assert_eq!((pull(&s, &[sec], start), pull(&s, &[sec], lx)), (0.0, 0.0), "not for the section the connector leaves from"); +} diff --git a/crates/engine/src/canvas/snap.rs b/crates/engine/src/canvas/snap.rs index 97c23fa6c..cd40437d3 100644 --- a/crates/engine/src/canvas/snap.rs +++ b/crates/engine/src/canvas/snap.rs @@ -95,10 +95,11 @@ impl Targets { } } // Siblings and, at the top level, all top-level layers. A board connector joined to a - // moving layer re-routes with it, as does its label: no snapping to where its own route - // starts (#1916). + // moving layer, or to one inside it (a section carries its stickies), re-routes with it, as + // does its label: no snapping to where its own route starts (#1916). + let carried = |e: NodeId| moving.contains(&e) || doc.ancestors(e).iter().any(|a| moving.contains(a)); let follows = |id: NodeId| match doc.node(id).and_then(|n| n.board.as_ref()) { - Some(BoardItem::Connector(k)) => [k.from.node(), k.to.node()].into_iter().flatten().any(|e| moving.contains(&e)), + Some(BoardItem::Connector(k)) => [k.from.node(), k.to.node()].into_iter().flatten().any(carried), _ => false, }; if let Some(p) = doc.node(parent) { diff --git a/docs/boards-parity.md b/docs/boards-parity.md index 689dc60a6..b364c759f 100644 --- a/docs/boards-parity.md +++ b/docs/boards-parity.md @@ -1,6 +1,6 @@ # Boards parity -> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-04 · **Change:** minor (a connector attached to a side starts 4 pt outside the border, so its stroke never lies on the fill and connectors leaving one side run together before they part (#1916); a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a connector end dropped along a side of a shape attaches to that side (#1708); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a connector's bar sets its start and end points, dashes, weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); "+" handles beside a selected sticky or shape make the next one, joined by a connector (#1597); a FigJam `.jam` file opens as a board (#1342); board grid settings: dots, lines, graph paper or none, spacing, size and contrast; the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); templates and tables; facilitation: a shared timer and voting sessions; the dot grid, dragging a connector's end to re-attach it, curved connectors, elbows that go around what they join) · **Target:** the incumbent's whiteboard product (behaviour from its public help centre) +> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-04 · **Change:** minor (a connector attached to a side starts 4 pt outside the border, so its stroke never lies on the fill (#1916); a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a connector end dropped along a side of a shape attaches to that side (#1708); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a connector's bar sets its start and end points, dashes, weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); "+" handles beside a selected sticky or shape make the next one, joined by a connector (#1597); a FigJam `.jam` file opens as a board (#1342); board grid settings: dots, lines, graph paper or none, spacing, size and contrast; the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); templates and tables; facilitation: a shared timer and voting sessions; the dot grid, dragging a connector's end to re-attach it, curved connectors, elbows that go around what they join) · **Target:** the incumbent's whiteboard product (behaviour from its public help centre) **Breadth ~47%, ready ~29% (estimated, erring low).** A board is a FigCraft file of its own kind (`file.newBoard`) with a dot grid on the page, sticky notes, shapes with text, connectors that @@ -34,10 +34,10 @@ all end with the same geometry. | Sticky options: hide the author, change size presets, sticky stacks | partial | `board.sticky {author: false}`; no size presets or stacks | | Shapes with text | done | rectangle, rounded rectangle, ellipse, diamond, triangle, speech bubble, chevron; text centred and wrapping inside the outline; shape type and text size from the contextual bar | | Shape auto-fit to its text, more shapes (cylinder, cross, star…), shape libraries | missing | | -| Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed; an end dropped on the outer half of an object takes the side it is towards (a drop along a whole edge chooses that edge), one in the middle takes the facing side; re-routed when either end moves or resizes; a deleted end stays where it was; an end attached to a side starts 4 pt outside the border (`board_route::END_GAP`), so the stroke never lies on the fill and connectors leaving one side run together along the side's normal before they part (#1916) | +| Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed; an end dropped on the outer half of an object takes the side it is towards (a drop along a whole edge chooses that edge), one in the middle takes the facing side; re-routed when either end moves or resizes; a deleted end stays where it was; an end attached to a side starts 4 pt outside the border (`board_route::END_GAP`), so the stroke never lies on the fill; elbows leaving one side share their first run along its normal and curves leave tangent to it (#1916) | | Shapes with text | done | 23 outlines: rectangle, rounded rectangle, ellipse, diamond, triangle up and down, parallelogram right and left, trapezoid, pentagon, hexagon, octagon, star, plus, arrow left and right, chevron, speech bubble, and the flowchart symbols database, document, predefined process, manual input and internal storage; text centred and wrapping inside the outline; shape type and text size from the contextual bar | | Shape auto-fit to its text, the advanced shape libraries (engineering and other icon shapes) | missing | | -| Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed, and within 10 px of one the end keeps that side; re-routed when either end moves or resizes; a deleted end stays where it was; an end attached to a side starts 4 pt outside the border (`board_route::END_GAP`), so the stroke never lies on the fill and connectors leaving one side run together along the side's normal before they part (#1916) | +| Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed, and within 10 px of one the end keeps that side; re-routed when either end moves or resizes; a deleted end stays where it was; an end attached to a side starts 4 pt outside the border (`board_route::END_GAP`), so the stroke never lies on the fill; elbows leaving one side share their first run along its normal and curves leave tangent to it (#1916) | | Create the next shape already connected | done | a selected sticky or shape shows a "+" beside each side; hovering one shows where the next goes, clicking makes one of the same kind, size and colour there, joined by a connector as the Connector tool makes one, and starts typing in it; one undo step (`board.addConnected {id?, side?, edit?}`, #1597). Shift+Cmd/Ctrl+Enter on a selected (or edited) shape adds the next shape on its right, joined the same way, and goes on typing; on a sticky it adds a sticky beside it without a connector, as before | | Curved connectors, elbows around objects, dragging an end to re-attach | done | `board.setStyle {style: curved}` (and the contextual bar): one curve leaving and arriving along the sides; an elbow whose short way would cross what it joins goes around their boxes, 24 units clear; a selected connector shows its two ends as handles, and dragging one onto an object attaches it there (the object is outlined while dragging), onto empty canvas leaves it free (`board.reattach {id, end, target, side?}`, one undo step) | | A connector end on any part of an object | done | holding Cmd/Ctrl while moving an end places it where the pointer is on the object, as a share of its box, so it follows moves and resizes; the line leaves by the side facing the other end. Without the key an end snaps to a side | @@ -70,7 +70,7 @@ all end with the same geometry. | Date | Change | Summary | |---|---|---| -| 2026-11-04 | minor | M12, #1916: a connector end attached to a side starts 4 pt outside the border (`board_route::END_GAP`), as FigJam's do (the issue's screenshots: the line starts a few pixels outside, with a round cap, and connectors leaving one side run together along the side's normal before they fan out), so the stroke never lies on the fill; the `.jam` importer's routes, re-attached ends, path handles and labels follow the route's points; an end placed by hand with Cmd/Ctrl held keeps its exact point. Tests: `board_route_tests` (three). Numbers unchanged. | +| 2026-11-04 | minor | M12, #1916: a connector end attached to a side starts 4 pt outside the border (`board_route::END_GAP`), as FigJam's do (the issue's screenshots: the line starts a few pixels outside, with a round cap), so the stroke never lies on the fill; elbows leaving one side share their first run along its normal, curves leave tangent to it and straight ones fan out from the same point; the `.jam` importer's routes, re-attached ends, path handles and labels follow the route's points; an end placed by hand with Cmd/Ctrl held keeps its exact point. Tests: `board_route_tests` (three). Numbers unchanged. | | 2026-10-31 | minor | M12: as the help describes, holding Cmd/Ctrl while moving a connector's end places it on any part of an object instead of snapping to a side. It keeps that spot as a fraction of the object's box, so it follows the object when it moves or resizes, and without the key an end snaps as before. `board.connector {fromAt, toAt}` and `board.reattach {at}` take it; saved only when set. Numbers unchanged | | 2026-10-31 | patch | M12, #1708: a connector end dropped on the outer half of a shape takes the side it is towards, instead of only within 10 px of a side's middle, so a drop anywhere along an edge chooses that edge (dragging a selected connector's end and with the connector tool, ring included); a drop in the middle of a shape still takes the facing side. | | 2026-10-31 | minor | M12, #1710: a selected elbow or curved connector shows path handles. Dragging a run moves it and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins, is saved with the file, and goes back to routing itself when the style changes or an end moves to something else. | From fb5587245068a444f551eb6e414483ea19c09668 Mon Sep 17 00:00:00 2001 From: Filip Strajnar Date: Fri, 6 Nov 2026 12:17:11 +0100 Subject: [PATCH 4/5] M9: one auto layout edit on each side of a branch is one conflict (#2026) A padding changed on both sides of a branch gave a conflict for every size and place auto layout worked out from it: the component's, each instance's and their hugging parents' width and height, each instance's layout, and every child's position (10 in a file with one instance, 138 with 15). The merge was refused until each had a side, yet the merged file laid itself out again from the padding whatever they got. A `layout` conflict also took all auto layout fields together, so a gap changed only on the branch was lost when main won the padding. `merge::plan` now leaves out properties both sides changed to values both files work out for themselves (`Plan::derived`): a hugging auto layout frame's or a filling child's size, text sizing to its characters, an auto layout child's place (when both sides turn and scale it the same way), and a value a layer in an instance has as its main's layer has it. Merging keeps the file merged into's own value and normalising lays it out from the merged inputs. `layout` and `childLayout` merge field by field: a field changed on one side (or the same way on both) merges, and each field changed both ways is a conflict of its own (`Key::Field`, `/layout.padding`), written whole from the merged fields and each picked side's value. The review shows it as "auto layout padding" with both sides' values ("8, 8, 8, 8"). Tests: `branch_tests::one_conflicting_auto_layout_edit_is_one_conflict` (the issue's file: one conflict, either side laid out as if set directly), `auto_layout_fields_changed_one_way_survive_a_conflict` (merge and update from main), `sizes_auto_layout_works_out_never_conflict`; the merge fuzz test leaves worked-out values out of what each side must show. Docs: collaboration-parity.md, mcp.md, ROADMAP.md. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LvG6E2LxvJ6MuFmiLA6Zqm --- ROADMAP.md | 3 +- crates/collab/src/merge.rs | 217 ++++++++++++++++++++++++-- crates/engine/src/branch_tests.rs | 116 +++++++++++++- crates/engine/src/sharing/branches.rs | 20 +++ docs/collaboration-parity.md | 5 +- docs/mcp.md | 5 +- 6 files changed, 347 insertions(+), 19 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 60f5962d2..a8fe24715 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -2,7 +2,7 @@ **Stage: alpha** · next: beta, ~26 points and ~162–292 h away (one Opus 5.5 agent; ~33–67 h wall-clock with 5 agents) -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-02 · **Change:** minor (glass bends towards its core, and rounded rectangles work it out in closed form; glass's light is a line on its bevel and splay turns the bend towards the centre; glass bends with a thick-lens profile and splits its colours over 8 steps; glass effects take variables and keep their frost within 0–100; web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprint buckets (#1102); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); progress docs cleaned of what merges left twice: rows merged into one, repeated status items removed, and `cargo xtask docs` (in `ci`) fails on a repeated table row or status item; a name typed for a variable or collection finds the one with that exact id before one named like it, and stored mode ids, font family variables and the panels' labels read exact ids (#1613); plugin widgets have hover styles: a layer's `hover` fill, stroke, opacity or text colour shows while the pointer is over it (gap 6); `.fig` elbowed and curved connectors without a saved path are routed like board connectors instead of drawn straight (gap 1); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; `figcraft-cli connect publish` publishes a code repository's code connect mappings to a design file (gap 16); while a drag only moves a large selection, its outlines, box, slots, spacing and Design panel values are worked out once and shifted, not rebuilt on every move (#1571); Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); an imported or pasted file finds an installed family under the other names its fonts give it, and with other case and spacing, instead of reporting it missing (#1292); a development example generates figcraft-cli's shell completions and man pages from its clap definitions (part of #1396); `.fig` ZIP image reads share a total byte budget and count skipped images in the import warnings (#1076); German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; the server key is checked by comparing SHA-256 hashes of the presented and the kept key, as the deployment guide says (#1130); opening a file contacts no team library server it names until you check it (#1097); a hostile server can no longer grow a client's memory with made-up people, and a session remembers a bounded number of deleted layer ids (#1121); `doc.list` gives AI agents and plugins the open files' names, not their paths (#1117); with a large selection, frames where nothing changed reuse the selection's outlines, box and slots and the Design panel's instance and position values instead of working them out again (#1571); team libraries and plugins larger than the 16 MiB download burst can be downloaded again, more slowly (#1089); a batch keeps one undo snapshot, not one per step (#1099); files nested 256 levels deep import on the browser's 1 MB stack (#1101); SVG and PDF exports count pattern sources and the renders they embed from the layer's depth, so one cap bounds a whole export (#1082); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); joining and leaving a file nobody is editing reads and writes nothing on the server: it stays loaded a minute after everyone leaves (#1074); opening a `.figcraft` file unpacks at most 6 GiB in all (2 GiB in the browser), every area together (#1079); hovering the canvas hit-tests once per pointer move, not on every frame, and moving an auto layout frame no longer lays out its contents again on every move (#1571); `.fig` instance expansion no longer walks variable nodes for every instance or copies every outer override row into each nested instance (#1077); `comment.people` lists names that were only @mentioned, and `comment.next` and `comment.prompt` carry the mentions too (#1415); grid auto-placement looks for free cells a 64-bit word at a time and skips what blocks it, with the same placements (#1083); with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); a recovery copy made while a version is previewed holds the file, not the version shown; a FigJam `.jam` file opens as a board (#1342); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); share links can comment: a third access level beside edit and view, whose holder sees the file live and adds, replies to, reacts to and resolves comments but can't change the design; Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); `comment.list {mentions}` lists only the threads that @mention a name (#1415); in the browser an internal error that stops the page keeps its unsaved files, which open again on reload (#1123); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); figcraft-cli parses its arguments with clap, following RFC-0012 (#1396); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); the browser build publishes files to a server, so Share ▸ Online and Publish to server work there (#917); the browser build uses the fonts installed on the computer once asked, each read when text uses it (#1051); SVG import reads `color()` and `color-mix()` colours, with a note and a grey for those it can't (#1550); the portable Windows zip keeps its settings, recovery copies and plugins in `config\` beside the executable, starting with an installed copy's preferences; the window starts on other graphics when its first ones fail before the first frame: Direct3D 12 compiles with FXC and no device compiles wgpu's indirect-validation shaders, then Vulkan, OpenGL and lower requirements on the power-saving GPU (#965, #1438); Thai, Lao, Khmer and Burmese lines break between words (#1219); an AI agent attached over MCP shows where it works (#1416); a manual overlay's position can be dragged on the canvas (#405); one name for live sessions and comments: Preferences ▸ Your name, in the Join dialog too, kept in the browser, and a rename shows at once in the sessions you are in (#1380); requests that change a server's files have a budget per address, the server key's too, and join codes are found by their hash (#1075); the Join dialog shows a join from the click until its file is ready, with Cancel, and a failed join with Try again (#1381); SVG import draws each pattern tile once per scale, within the layer budget (#1080); Vietnamese letters typed with combining marks (decomposed) take one font that has every mark, instead of missing-glyph boxes beside the letter (#1478); comment.list reports each message's @mentions (#1415); mask groups draw only over the area they can paint, and nested isolated layers share one memory budget (#1061); components can't contain their own instances, directly or through other components; `edit.duplicate` returns an id map with `map: true` (#995); the batches kept for reconnecting apps are bounded in bytes by default, and `figcraft-server` takes `max_log_mb` (#1069); MCP and control calls name their document (#998); sibling placement in live sessions searches instead of counting (#1065); an AI agent attached over MCP comments under its own name, with an Agent label (#1414); the instance-swap menus have a search field (#1338); a refused batch's fixes take time linear in the batch (#1063); the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); large images on the canvas draw from a smaller copy, so two 16k images no longer lag (#1483); a file's JPEG thumbnail can't crash the home screen (#1491's progressive JPEG check, now shared); `.fig` import: library text styles linked by asset key, and override rows restating a nested level (#1234); `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); Download a missing free font from the Missing fonts window (`font.download`, #754); the web build's wasm back under its 24 MiB gate (#1472); shadows of images with transparent pixels follow their alpha (#1289); Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); offline Penpot 2.x import/export (#1143); optional batch continue-on-error with per-step outcomes (#1386); the Design panel's sections on one grid (#858); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); images placed at their own size, 2x screenshots in points (#1360); the toolbar on one 32 pt grid, without its Resources button (#1210); M4: zero-length round-capped dashes draw dots; dash expansion uses the existing safety budget; extracted from #1143; Arabic draft catalog; scaled instances keep their scale when their main is rebuilt (#922); .fig embedded images are copied once per blob, not once per hash (#1059); page ruler guides survive save and reopen (#1476); colour picker LCH and OKLCH models; non-ASCII layer names transliterate in code export (#1235); branches in live sessions and branch history entries, gap 17; plugin widgets take text input and a property menu (plugin API 4); boards: templates and tables; boards: a shared timer and voting sessions; boards: the dot grid, connector ends dragged to re-attach, curved connectors; Installed weights of an embedded font family (#1246); `.sketch` import, best effort (Sketch 48 and newer); CJK line breaking: JIS X 4051's line-start and line-end sets completed with the halfwidth small kana, the halfwidth and spacing (semi-)voiced sound marks, the iteration marks 〱–〵 and the halfwidth parentheses, with behaviour cases for each; Adobe Fonts found on macOS (#298); egui 0.37 hidden-capture deadline contract; Dev Mode measurements kept on the canvas and a read-only layers panel; boards: a board area row and progress entry; community fixes in #507, #510, #529 and #530: auto-save, a text box by dragging, batch step references, removing someone from a live session, Russian and Turkish catalogs reviewed, Czech and Indonesian drafts, the Japanese draft completed, zoom previews, the web clipboard, Alt-drag snapping and Cmd+D repeat, recovery copies, crash and rollback fixes, colour emoji, `.fig` import fixes; earlier changes are in the revision history below) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-06 · **Change:** patch (one auto layout edit on each side of a branch is one conflict, its field: auto layout settings merge field by field, and sizes and places auto layout works out, or values an instance takes from its main, no longer conflict (#2026); glass bends towards its core, and rounded rectangles work it out in closed form; glass's light is a line on its bevel and splay turns the bend towards the centre; glass bends with a thick-lens profile and splits its colours over 8 steps; glass effects take variables and keep their frost within 0–100; web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprint buckets (#1102); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); progress docs cleaned of what merges left twice: rows merged into one, repeated status items removed, and `cargo xtask docs` (in `ci`) fails on a repeated table row or status item; a name typed for a variable or collection finds the one with that exact id before one named like it, and stored mode ids, font family variables and the panels' labels read exact ids (#1613); plugin widgets have hover styles: a layer's `hover` fill, stroke, opacity or text colour shows while the pointer is over it (gap 6); `.fig` elbowed and curved connectors without a saved path are routed like board connectors instead of drawn straight (gap 1); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; `figcraft-cli connect publish` publishes a code repository's code connect mappings to a design file (gap 16); while a drag only moves a large selection, its outlines, box, slots, spacing and Design panel values are worked out once and shifted, not rebuilt on every move (#1571); Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); an imported or pasted file finds an installed family under the other names its fonts give it, and with other case and spacing, instead of reporting it missing (#1292); a development example generates figcraft-cli's shell completions and man pages from its clap definitions (part of #1396); `.fig` ZIP image reads share a total byte budget and count skipped images in the import warnings (#1076); German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; the server key is checked by comparing SHA-256 hashes of the presented and the kept key, as the deployment guide says (#1130); opening a file contacts no team library server it names until you check it (#1097); a hostile server can no longer grow a client's memory with made-up people, and a session remembers a bounded number of deleted layer ids (#1121); `doc.list` gives AI agents and plugins the open files' names, not their paths (#1117); with a large selection, frames where nothing changed reuse the selection's outlines, box and slots and the Design panel's instance and position values instead of working them out again (#1571); team libraries and plugins larger than the 16 MiB download burst can be downloaded again, more slowly (#1089); a batch keeps one undo snapshot, not one per step (#1099); files nested 256 levels deep import on the browser's 1 MB stack (#1101); SVG and PDF exports count pattern sources and the renders they embed from the layer's depth, so one cap bounds a whole export (#1082); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); joining and leaving a file nobody is editing reads and writes nothing on the server: it stays loaded a minute after everyone leaves (#1074); opening a `.figcraft` file unpacks at most 6 GiB in all (2 GiB in the browser), every area together (#1079); hovering the canvas hit-tests once per pointer move, not on every frame, and moving an auto layout frame no longer lays out its contents again on every move (#1571); `.fig` instance expansion no longer walks variable nodes for every instance or copies every outer override row into each nested instance (#1077); `comment.people` lists names that were only @mentioned, and `comment.next` and `comment.prompt` carry the mentions too (#1415); grid auto-placement looks for free cells a 64-bit word at a time and skips what blocks it, with the same placements (#1083); with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); a recovery copy made while a version is previewed holds the file, not the version shown; a FigJam `.jam` file opens as a board (#1342); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); share links can comment: a third access level beside edit and view, whose holder sees the file live and adds, replies to, reacts to and resolves comments but can't change the design; Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); `comment.list {mentions}` lists only the threads that @mention a name (#1415); in the browser an internal error that stops the page keeps its unsaved files, which open again on reload (#1123); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); figcraft-cli parses its arguments with clap, following RFC-0012 (#1396); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); the browser build publishes files to a server, so Share ▸ Online and Publish to server work there (#917); the browser build uses the fonts installed on the computer once asked, each read when text uses it (#1051); SVG import reads `color()` and `color-mix()` colours, with a note and a grey for those it can't (#1550); the portable Windows zip keeps its settings, recovery copies and plugins in `config\` beside the executable, starting with an installed copy's preferences; the window starts on other graphics when its first ones fail before the first frame: Direct3D 12 compiles with FXC and no device compiles wgpu's indirect-validation shaders, then Vulkan, OpenGL and lower requirements on the power-saving GPU (#965, #1438); Thai, Lao, Khmer and Burmese lines break between words (#1219); an AI agent attached over MCP shows where it works (#1416); a manual overlay's position can be dragged on the canvas (#405); one name for live sessions and comments: Preferences ▸ Your name, in the Join dialog too, kept in the browser, and a rename shows at once in the sessions you are in (#1380); requests that change a server's files have a budget per address, the server key's too, and join codes are found by their hash (#1075); the Join dialog shows a join from the click until its file is ready, with Cancel, and a failed join with Try again (#1381); SVG import draws each pattern tile once per scale, within the layer budget (#1080); Vietnamese letters typed with combining marks (decomposed) take one font that has every mark, instead of missing-glyph boxes beside the letter (#1478); comment.list reports each message's @mentions (#1415); mask groups draw only over the area they can paint, and nested isolated layers share one memory budget (#1061); components can't contain their own instances, directly or through other components; `edit.duplicate` returns an id map with `map: true` (#995); the batches kept for reconnecting apps are bounded in bytes by default, and `figcraft-server` takes `max_log_mb` (#1069); MCP and control calls name their document (#998); sibling placement in live sessions searches instead of counting (#1065); an AI agent attached over MCP comments under its own name, with an Agent label (#1414); the instance-swap menus have a search field (#1338); a refused batch's fixes take time linear in the batch (#1063); the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); large images on the canvas draw from a smaller copy, so two 16k images no longer lag (#1483); a file's JPEG thumbnail can't crash the home screen (#1491's progressive JPEG check, now shared); `.fig` import: library text styles linked by asset key, and override rows restating a nested level (#1234); `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); Download a missing free font from the Missing fonts window (`font.download`, #754); the web build's wasm back under its 24 MiB gate (#1472); shadows of images with transparent pixels follow their alpha (#1289); Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); offline Penpot 2.x import/export (#1143); optional batch continue-on-error with per-step outcomes (#1386); the Design panel's sections on one grid (#858); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); images placed at their own size, 2x screenshots in points (#1360); the toolbar on one 32 pt grid, without its Resources button (#1210); M4: zero-length round-capped dashes draw dots; dash expansion uses the existing safety budget; extracted from #1143; Arabic draft catalog; scaled instances keep their scale when their main is rebuilt (#922); .fig embedded images are copied once per blob, not once per hash (#1059); page ruler guides survive save and reopen (#1476); colour picker LCH and OKLCH models; non-ASCII layer names transliterate in code export (#1235); branches in live sessions and branch history entries, gap 17; plugin widgets take text input and a property menu (plugin API 4); boards: templates and tables; boards: a shared timer and voting sessions; boards: the dot grid, connector ends dragged to re-attach, curved connectors; Installed weights of an embedded font family (#1246); `.sketch` import, best effort (Sketch 48 and newer); CJK line breaking: JIS X 4051's line-start and line-end sets completed with the halfwidth small kana, the halfwidth and spacing (semi-)voiced sound marks, the iteration marks 〱–〵 and the halfwidth parentheses, with behaviour cases for each; Adobe Fonts found on macOS (#298); egui 0.37 hidden-capture deadline contract; Dev Mode measurements kept on the canvas and a read-only layers panel; boards: a board area row and progress entry; community fixes in #507, #510, #529 and #530: auto-save, a text box by dragging, batch step references, removing someone from a live session, Russian and Turkish catalogs reviewed, Czech and Indonesian drafts, the Japanese draft completed, zoom previews, the web clipboard, Alt-drag snapping and Cmd+D repeat, recovery copies, crash and rollback fixes, colour emoji, `.fig` import fixes; earlier changes are in the revision history below) · **Target:** Figma Design (desktop app 126.10.7) FigCraft is a clean-room, open-source, pure-Rust reimplementation of the Figma design workflow, native on macOS, Windows, Linux and FreeBSD and in the browser, fully drivable by agents through @@ -358,6 +358,7 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md). | Date | Change | Summary | |---|---|---| +| 2026-11-06 | patch | M9, #2026: a branch merge counts one conflict per auto layout field changed both ways, not one for every size and place auto layout works out from it; values an instance takes from its main no longer conflict, and auto layout settings changed one way survive a conflict on another field. Tests: `branch_tests::one_conflicting_auto_layout_edit_is_one_conflict`, `branch_tests::auto_layout_fields_changed_one_way_survive_a_conflict`, `branch_tests::sizes_auto_layout_works_out_never_conflict`. Numbers unchanged | | 2026-11-02 | patch | M8, #1885: a glass whose shape is too big to keep whole at the zoom (past `MAX_SHAPE_PX` with its core's margin) bends along its edge normals instead of working out a core, so its fields never cover more pixels than a kept shape's, and the core's feature transform holds 16 bytes a pixel. The edge normals are box-blurred twice again and the bend directions once, as documented. Test: `glass::tests::a_shape_too_big_to_keep_bends_along_its_normals`. Numbers unchanged | | 2026-11-02 | minor | M3, #1885: glass bends the backdrop towards its core, the shape shrunk by `depth` and the bevel, as the reference tool's: round a sharp corner the bend turns smoothly instead of meeting along the diagonal, and a part thinner than twice that (a capsule, a letter's stroke) bends across itself towards its own middle (pixels about as deep as any within 2 px). Rectangles, frames, components, instances and sections whose corners aren't smoothed work their glass out in closed form, with nothing to rasterise, transform or keep: a zoom frame draws in 40 ms instead of 54 and a resize frame in 46 instead of 67 (`glass_render_timings`, release, 2×). Other shapes keep their fields, with the bend directions for the last two depths asked for beside them, so dragging the Depth slider works out only those again. Tests: `glass::tests::a_sharp_corner_bends_round_towards_the_core`, `glass::tests::a_thin_part_bends_across_itself`, `glass::tests::neighbouring_strokes_bend_towards_their_own_middles`, `glass::tests::a_rounded_rectangle_in_closed_form_matches_its_distance_transform`, `glass_cut_tests::what_the_shape_depends_on_works_it_out_again_and_nothing_else_does`. Numbers unchanged | | 2026-11-02 | minor | M3, #1885: glass's light is a line on its 1-unit bevel added to the backdrop, as the reference tool's: fully where the edge faces the light, none below 0.35 of facing it and 0.6 as much on the opposite side, with a faint gradient across the curve, 5% darker facing the light and lighter opposite (it was a glow mixed towards white, as deep as `splay` made it). `splay` turns the bend from along the edge's normal towards the way away from the layer's centre, as the reference tool's does, and no longer widens the light: files with a splay above 0 look different. The direction to the centre is worked out in the shape's own frame, so cut renders match. Tests: `glass::tests::the_light_lies_on_the_bevel_and_the_gradient_across_the_curve`, `backdrop_tests::splay_turns_the_bend_towards_the_centre`, `glass_cut_tests::the_light_is_a_line_on_the_bevel`. Numbers unchanged | diff --git a/crates/collab/src/merge.rs b/crates/collab/src/merge.rs index 9c21a56ad..3b6ebdce8 100644 --- a/crates/collab/src/merge.rs +++ b/crates/collab/src/merge.rs @@ -9,16 +9,20 @@ //! interactions, accessibility annotations, Dev Mode resources and measurements) merge item by //! item: both sides changing different items of the list (or one adding items at its end) is no //! conflict, only the same item changed both ways or the list shortened on a side while the other -//! changed it. Nothing that conflicts is merged until it is resolved: each conflict is resolved for -//! one side, and the other side's changes to it are left out. Everything else from both sides is -//! kept. +//! changed it. Auto layout settings (a frame's and a child's) merge field by field: each field +//! changed both ways is a conflict of its own, and the other fields merge. Values a file works out +//! for itself (a size or place auto layout gives a layer, text sizing to its characters, a value a +//! layer in an instance takes from its main component) never conflict: the merged file works them +//! out again from what they follow. Nothing that conflicts is merged until it is resolved: each +//! conflict is resolved for one side, and the other side's changes to it are left out. Everything +//! else from both sides is kept. use std::collections::{BTreeMap, BTreeSet}; use std::fmt; -use figcraft_doc::{Document, NodeId}; +use figcraft_doc::{Document, Node, NodeId, NodeKind, Sizing, TextAutoResize}; use serde::{Deserialize, Serialize}; -use serde_json::Value; +use serde_json::{Map, Value}; use crate::change::{Change, DocProp, Entry, Json, Prop}; use crate::replica::{Mode, Positions, Replica, create_change}; @@ -33,6 +37,7 @@ pub enum Side { } impl Side { + /// The side that isn't `self`. pub fn other(self) -> Side { match self { Side::Branch => Side::Main, @@ -48,6 +53,7 @@ impl Side { } } + /// The side `"branch"` or `"main"` names (`None` for anything else). pub fn parse(s: &str) -> Option { match s { "branch" => Some(Side::Branch), @@ -62,6 +68,9 @@ impl Side { pub enum Key { /// A layer property. A layer's parent and position are one property (where it is). Node(NodeId, Prop), + /// One field of a layer property that merges field by field ([`PER_FIELD`]): `padding` of + /// `layout`, `sizing_h` of `childLayout`… + Field(NodeId, Prop, String), /// A layer deleted on one side and edited (it or what's inside it) on the other. Layer(NodeId), /// A document-level property. @@ -78,11 +87,13 @@ fn camel(v: &T) -> String { } } -/// `12/fills`, `12/layer`, `doc/styleOrder`, `style/S:3`, `comment/7`… (the keys resolutions use). +/// `12/fills`, `12/layout.padding`, `12/layer`, `doc/styleOrder`, `style/S:3`, `comment/7`… (the +/// keys resolutions use). impl fmt::Display for Key { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Key::Node(id, prop) => write!(f, "{id}/{}", camel(prop)), + Key::Field(id, prop, field) => write!(f, "{id}/{}.{field}", camel(prop)), Key::Layer(id) => write!(f, "{id}/layer"), Key::Doc(prop) => write!(f, "doc/{}", camel(prop)), Key::Entry(e) => match e { @@ -129,10 +140,25 @@ pub struct Plan { /// The main file's changes since the base. pub main: Vec, pub conflicts: Vec, + /// Layer properties changed both ways to values both files work out for themselves + /// ([`computed`]): no conflict, and a merge leaves the file merged into its own value. + derived: BTreeSet, + /// Layer properties ([`Key::Node`]) merged field by field with fields in conflict. + fields: BTreeMap, branch_positions: Positions, main_positions: Positions, } +/// A layer property merged field by field ([`merge_fields`]): the value with every field changed +/// one way (or the same way on both sides) merged, and each side's values of the fields changed +/// both ways (`Null` for a field a side left out). +#[derive(Clone, Debug, Default, PartialEq)] +struct Fields { + merged: Map, + branch: Map, + main: Map, +} + /// Document-level properties that belong to each copy, not to the work: the file name (a branch /// is named after itself) and the page it opens on. fn merges(c: &Change) -> bool { @@ -152,6 +178,7 @@ fn key_of(c: &Change) -> Option { }) } +/// The changes (indexes) in `changes` grouped by what they write ([`key_of`]). fn by_key(changes: &[Change]) -> BTreeMap> { let mut out: BTreeMap> = BTreeMap::new(); for (i, c) in changes.iter().enumerate() { @@ -193,6 +220,108 @@ fn merged_list(base: &Document, key: &Key, b: Option<&Change>, m: Option<&Change merge_items(o.0.as_array()?, bv.0.as_array()?, mv.0.as_array()?).map(|v| Json(Value::Array(v))) } +/// Layer properties whose fields merge one by one: auto layout settings, a frame's (`layout`) and +/// a child's (`childLayout`). Changing the padding on one side and the gap on the other is no +/// conflict, and each field changed both ways is a conflict of its own ([`Key::Field`]). +const PER_FIELD: &[Prop] = &[Prop::Layout, Prop::ChildLayout]; + +/// Three-way merge of object `o` changed to `b` on one side and `m` on the other, field by field: +/// a field changed on one side takes that side's value, and one changed both ways (differently) +/// is in conflict. `None` when any of them isn't an object (auto layout added or removed). +fn merge_fields(o: &Value, b: &Value, m: &Value) -> Option { + let (o, b, m) = (o.as_object()?, b.as_object()?, m.as_object()?); + let names: BTreeSet<&String> = o.keys().chain(b.keys()).chain(m.keys()).collect(); + let mut out = Fields::default(); + for name in names { + let (base, x, y) = (o.get(name), b.get(name), m.get(name)); + let kept = if x == base { + y + } else if y == base || x == y { + x + } else { + out.branch.insert(name.clone(), x.cloned().unwrap_or(Value::Null)); + out.main.insert(name.clone(), y.cloned().unwrap_or(Value::Null)); + base + }; + if let Some(v) = kept { + out.merged.insert(name.clone(), v.clone()); + } + } + Some(out) +} + +/// Both sides' writes `b` and `m` of property `key` (one of [`PER_FIELD`]) merged field by field +/// against the base; `None` when `key` isn't such a property or a value isn't an object. +fn merged_fields(base: &Document, key: &Key, b: Option<&Change>, m: Option<&Change>) -> Option { + let Key::Node(id, prop) = key else { return None }; + let (Some(Change::Set { value: bv, .. }), Some(Change::Set { value: mv, .. })) = (b, m) else { return None }; + if !PER_FIELD.contains(prop) { + return None; + } + let o = prop.get(base.node(*id)?).ok()?; + merge_fields(&o.0, &bv.0, &mv.0) +} + +/// Whether layer `n` of `doc` is placed by its parent's auto layout (not absolute). +fn in_flow(doc: &Document, n: &Node) -> bool { + !n.child_layout.absolute && n.parent.and_then(|p| doc.node(p)).is_some_and(|p| p.layout.is_some()) +} + +/// Whether auto layout or text works out layer `n`'s width (`horizontal`) or height: an auto layout +/// frame hugging its contents, a child filling its auto layout parent, or text sizing to its +/// characters. +fn sized_for_itself(doc: &Document, n: &Node, horizontal: bool) -> bool { + let sizing = if horizontal { n.child_layout.sizing_h } else { n.child_layout.sizing_v }; + let by_layout = match sizing { + Sizing::Hug => n.layout.is_some(), + Sizing::Fill => in_flow(doc, n), + Sizing::Fixed => false, + }; + let by_text = match &n.kind { + NodeKind::Text(t) => t.auto_resize == TextAutoResize::WidthAndHeight || (!horizontal && t.auto_resize == TextAutoResize::Height), + _ => false, + }; + by_layout || by_text +} + +/// Whether layer `n` of `doc` (an instance, or a layer inside one) has property `prop` as its main +/// component's layer has it: it follows the main rather than overriding it. +fn follows_main(doc: &Document, n: &Node, prop: Prop) -> bool { + let main = match &n.kind { + NodeKind::Instance { component, .. } => Some(*component), + _ => n.source, + }; + Prop::FIELDS.contains(&prop) && main.and_then(|m| doc.node(m)).is_some_and(|m| !prop.differs(n, m)) +} + +/// Whether layer property `key` holds a value `doc` works out for itself rather than one set on +/// the layer: a size auto layout or text gives it ([`sized_for_itself`]), its place in an auto +/// layout parent, or a value it takes from its main component ([`follows_main`]). +fn computed(doc: &Document, key: &Key) -> bool { + let Key::Node(id, prop) = key else { return false }; + let Some(n) = doc.node(*id) else { return false }; + let by_layout = match prop { + Prop::Width => sized_for_itself(doc, n, true), + Prop::Height => sized_for_itself(doc, n, false), + Prop::Transform => in_flow(doc, n), + _ => false, + }; + by_layout || follows_main(doc, n, *prop) +} + +/// Whether property `key`, changed both ways, is one both files work out for themselves +/// ([`computed`]), so neither side's value is a choice to make. A place given by auto layout is +/// only that when both sides also turn and scale the layer the same way (a rotation is set on the +/// layer, not worked out). +fn derived_on_both(branch: &Document, main: &Document, key: &Key) -> bool { + if !(computed(branch, key) && computed(main, key)) { + return false; + } + let Key::Node(id, Prop::Transform) = key else { return true }; + let linear = |doc: &Document| doc.node(*id).map(|n| n.transform.as_coeffs()).map(|c| [c[0], c[1], c[2], c[3]]); + linear(branch) == linear(main) +} + /// The change at the only index in `c`. fn only<'a>(c: &[usize], all: &'a [Change]) -> Option<&'a Change> { match c { @@ -265,6 +394,8 @@ pub fn plan(base: &Document, branch: &Document, main: &Document) -> Result = m.changes.into_iter().filter(merges).collect(); let mut conflicts = Vec::new(); let mut lists = Vec::new(); + let mut derived = BTreeSet::new(); + let mut fields = BTreeMap::new(); let km = by_key(&mc); for (k, bi) in by_key(&bc) { // Deletions conflict with edits (below); images are content-addressed, so never differ. @@ -279,13 +410,28 @@ pub fn plan(base: &Document, branch: &Document, main: &Document) -> Result lists.push((bi, mi.clone(), value)), - None => conflicts.push(Conflict { key: k, deleted_by: None, branch: bi, main: mi.clone() }), + if derived_on_both(branch, main, &k) { + derived.insert(k); + continue; + } + if let Some(value) = merged_list(base, &k, only(&bi, &bc), only(mi, &mc)) { + lists.push((bi, mi.clone(), value)); + continue; + } + match (&k, merged_fields(base, &k, only(&bi, &bc), only(mi, &mc))) { + (_, Some(f)) if f.branch.is_empty() => lists.push((bi, mi.clone(), Json(Value::Object(f.merged)))), + (Key::Node(id, prop), Some(f)) => { + for name in f.branch.keys() { + let key = Key::Field(*id, *prop, name.clone()); + conflicts.push(Conflict { key, deleted_by: None, branch: bi.clone(), main: mi.clone() }); + } + fields.insert(k, f); + } + _ => conflicts.push(Conflict { key: k, deleted_by: None, branch: bi, main: mi.clone() }), } } - // Both sides' writes of a list merged item by item become the merged list, so merging either - // way writes it. + // Both sides' writes of a list merged item by item (or of auto layout settings merged field by + // field) become the merged value, so merging either way writes it. for (bi, mi, value) in lists { for (changes, at) in [(&mut bc, bi), (&mut mc, mi)] { for i in at { @@ -313,6 +459,8 @@ pub fn plan(base: &Document, branch: &Document, main: &Document) -> Result &BTreeSet { + &self.derived + } + + /// The branch's and main's values of field conflict `key` ([`Key::Field`]); `None` for other + /// keys. + pub fn field_values(&self, key: &Key) -> Option<(&Value, &Value)> { + let Key::Field(id, prop, name) = key else { return None }; + let f = self.fields.get(&Key::Node(*id, *prop))?; + Some((f.branch.get(name)?, f.main.get(name)?)) + } + + /// The side `pick` chose for each field in conflict of every property merged field by field, + /// written into the value merged from the other fields: the writes that replace both sides' + /// own writes of those properties. + fn field_writes(&self, pick: &dyn Fn(&Key) -> Option) -> Vec { + let mut out = Vec::new(); + for (key, f) in &self.fields { + let Key::Node(id, prop) = key else { continue }; + let mut value = f.merged.clone(); + for name in f.branch.keys() { + let won = if pick(&Key::Field(*id, *prop, name.clone())) == Some(Side::Branch) { &f.branch } else { &f.main }; + match won.get(name) { + Some(Value::Null) | None => value.remove(name), + Some(v) => value.insert(name.clone(), v.clone()), + }; + } + out.push(Change::Set { id: *id, prop: *prop, value: Json(Value::Object(value)) }); + } + out + } + + /// `side`'s positions (fractional keys) of the layers, for applying its changes elsewhere. fn positions(&self, side: Side) -> &Positions { match side { Side::Branch => &self.branch_positions, @@ -355,7 +539,10 @@ impl Plan { let mut skip: BTreeSet = BTreeSet::new(); let mut batch = Vec::new(); for c in &self.conflicts { - if pick(&c.key) != Some(from) { + if matches!(c.key, Key::Field(..)) { + // Written whole below, each field from the side picked for it. + skip.extend(c.changes(from)); + } else if pick(&c.key) != Some(from) { skip.extend(c.changes(from)); } else if let (Key::Layer(id), Some(by)) = (&c.key, c.deleted_by) && by != from @@ -372,7 +559,11 @@ impl Plan { // shortcut: images a side stopped using are kept (unused ones cost file size only); drop // them if files grow. let kept = |c: &Change| !matches!(c, Change::Remove { entry: Entry::Image(_) }); - batch.extend(self.changes(from).iter().enumerate().filter(|(i, c)| !skip.contains(i) && kept(c)).map(|(_, c)| c.clone())); + // Values both files work out for themselves stay as `into` has them; normalising the merged + // file works them out again from what changed. + let own = |c: &Change| key_of(c).is_some_and(|k| self.derived.contains(&k)); + batch.extend(self.changes(from).iter().enumerate().filter(|(i, c)| !skip.contains(i) && kept(c) && !own(c)).map(|(_, c)| c.clone())); + batch.extend(self.field_writes(pick)); let mut r = Replica::from_parts(into.clone(), self.positions(from.other()).clone()); let applied = r.apply(&batch, Mode::Strict)?; Ok((r.document().clone(), applied.touched)) diff --git a/crates/engine/src/branch_tests.rs b/crates/engine/src/branch_tests.rs index f0e8a72e5..fc6159537 100644 --- a/crates/engine/src/branch_tests.rs +++ b/crates/engine/src/branch_tests.rs @@ -193,6 +193,109 @@ fn branch_commands_refuse_what_makes_no_sense() { assert!(s.execute("branch.merge", &json!({"id": "nope"})).is_err()); } +/// Node id `v` of a command's answer (`{"id": …}` or a bare id). +fn idv(v: &Value) -> NodeId { + NodeId(v.get("id").unwrap_or(v).as_u64().unwrap()) +} + +/// The issue #2026 file, with a branch of it made and shown: a component `Card` (horizontal auto +/// layout hugging its contents, padding 12, one 40×20 rectangle) and an instance of it in a +/// vertical auto layout frame hugging its contents. Returns (session, branch id, card, instance, +/// frame, rectangle). +fn card_file() -> (Session, String, NodeId, NodeId, NodeId, NodeId) { + let mut s = Session::with_document(Document::new("Cards")); + let props = json!({"layout": "horizontal", "padding": 12, "sizingH": "hug", "sizingV": "hug"}); + let frame = idv(&ok(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 100, "height": 50, "name": "Card", "props": props}))); + let rect = idv(&ok(&mut s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 40, "height": 20, "parent": frame}))); + let card = idv(&ok(&mut s, "component.create", json!({"ids": [frame]}))); + let props = json!({"layout": "vertical", "padding": 0, "sizingH": "hug", "sizingV": "hug"}); + let stack = idv(&ok(&mut s, "frame.create", json!({"x": 0, "y": 200, "width": 100, "height": 100, "name": "Stack", "props": props}))); + let inst = idv(&ok(&mut s, "instance.create", json!({"component": card, "parent": stack}))); + let b = ok(&mut s, "branch.create", json!({"name": "padding 8"})); + (s, b["id"].as_str().unwrap().to_string(), card, inst, stack, rect) +} + +/// Size and place of every layer of `doc` (what auto layout works out). +fn geometry(doc: &Document) -> Vec<(NodeId, [f64; 8])> { + doc.nodes() + .map(|n| { + let c = n.transform.as_coeffs(); + (n.id, [n.width, n.height, c[0], c[1], c[2], c[3], c[4], c[5]]) + }) + .collect() +} + +/// Issue #2026: one auto layout edit on each side is one conflict (the field changed both ways), +/// not one for every size and place auto layout works out from it; the merged file lays out +/// from the padding picked. +#[test] +fn one_conflicting_auto_layout_edit_is_one_conflict() { + for (pick, padding) in [("branch", 8.0), ("main", 16.0)] { + let (mut s, id, card, inst, _, _) = card_file(); + ok(&mut s, "node.set", json!({"id": card, "props": {"padding": 8}})); + ok(&mut s, "doc.switch", json!({"index": 0})); + ok(&mut s, "node.set", json!({"id": card, "props": {"padding": 16}})); + // What main looks like with the picked padding set directly. + let mut direct = Session::with_document(s.doc().unwrap().clone()); + ok(&mut direct, "node.set", json!({"id": card, "props": {"padding": padding}})); + let review = ok(&mut s, "branch.review", json!({"id": id})); + let conflicts = review["conflicts"].as_array().unwrap(); + assert_eq!(conflicts.len(), 1, "{review}"); + let key = format!("{card}/layout.padding"); + assert_eq!(conflicts[0]["key"], key.as_str()); + assert_eq!( + (&conflicts[0]["property"], &conflicts[0]["branch"], &conflicts[0]["main"]), + (&json!("auto layout padding"), &json!("8, 8, 8, 8"), &json!("16, 16, 16, 16")) + ); + let err = s.execute("branch.merge", &json!({"id": id})).unwrap_err().to_string(); + assert!(err.contains(&key) && !err.contains("width"), "{err}"); + ok(&mut s, "branch.merge", json!({"id": id, "resolutions": {&key: pick}})); + let doc = s.doc().unwrap(); + for n in [card, inst] { + assert_eq!(doc.node(n).unwrap().layout.as_ref().unwrap().padding, [padding; 4], "{pick} wins"); + } + assert_eq!(geometry(doc), geometry(direct.doc().unwrap()), "{pick} wins: laid out from the padding picked"); + } +} + +/// Auto layout merges field by field: a gap changed only on the branch is kept whichever side's +/// padding wins, both when merging and when updating the branch from main. +#[test] +fn auto_layout_fields_changed_one_way_survive_a_conflict() { + for (cmd, pick, padding) in [("branch.merge", "main", 16.0), ("branch.merge", "branch", 8.0), ("branch.updateFromMain", "main", 16.0)] { + let (mut s, id, card, _, _, _) = card_file(); + ok(&mut s, "node.set", json!({"id": card, "props": {"padding": 8, "gap": 30}})); + ok(&mut s, "doc.switch", json!({"index": 0})); + ok(&mut s, "node.set", json!({"id": card, "props": {"padding": 16, "mainAlign": "center"}})); + let key = format!("{card}/layout.padding"); + let review = ok(&mut s, "branch.review", json!({"id": id})); + assert_eq!(review["conflicts"].as_array().unwrap().iter().map(|c| c["key"].clone()).collect::>(), vec![json!(key)], "{review}"); + ok(&mut s, cmd, json!({"id": id, "resolutions": {&key: pick}})); + if cmd == "branch.updateFromMain" { + ok(&mut s, "doc.switch", json!({"index": 1})); + } + let layout = s.doc().unwrap().node(card).unwrap().layout.clone().unwrap(); + assert_eq!((layout.padding, layout.gap, layout.main_align), ([padding; 4], 30.0, figcraft_doc::MainAlign::Center), "{cmd}, {pick} wins"); + } +} + +/// Auto layout on one side and a hugging frame's size on both: the sizes auto layout works out +/// on each side are no conflict, and merging leaves no stale size behind. +#[test] +fn sizes_auto_layout_works_out_never_conflict() { + let (mut s, id, card, _, stack, rect) = card_file(); + ok(&mut s, "node.set", json!({"id": rect, "props": {"width": 60}})); + ok(&mut s, "doc.switch", json!({"index": 0})); + ok(&mut s, "node.set", json!({"id": card, "props": {"padding": 4}})); + let review = ok(&mut s, "branch.review", json!({"id": id})); + assert_eq!(review["conflicts"], json!([]), "{review}"); + let mut direct = Session::with_document(s.doc().unwrap().clone()); + ok(&mut direct, "node.set", json!({"id": rect, "props": {"width": 60}})); + ok(&mut s, "branch.merge", json!({"id": id})); + assert_eq!(s.doc().unwrap().node(stack).unwrap().width, 60.0 + 8.0); + assert_eq!(geometry(s.doc().unwrap()), geometry(direct.doc().unwrap())); +} + /// Every change a side made (that the other side didn't overwrite) shows in `doc`. fn shows(changes: &[Change], doc: &Document) -> Result<(), String> { let r = Replica::new(doc.clone()); @@ -282,16 +385,25 @@ fn random_edits_on_both_sides_merge() { let none = |_: &figcraft_collab::merge::Key| None; let (into_main, _) = p.merge(&m, Side::Branch, &none).unwrap_or_else(|e| panic!("seed {seed}: {e}")); let (into_branch, _) = p.merge(&b, Side::Main, &none).unwrap_or_else(|e| panic!("seed {seed}: {e}")); + // Values both sides work out for themselves (sizes and places auto layout gives) stay + // as the file merged into has them. + let chosen = |changes: &[Change]| -> Vec { + changes + .iter() + .filter(|c| !matches!(c, Change::Set { id, prop, .. } if p.derived().contains(&Key::Node(*id, *prop)))) + .cloned() + .collect() + }; let mut both = Replica::new(start.clone()); both.apply(&p.main, Mode::Strict).unwrap(); - both.apply(&p.branch, Mode::Strict).unwrap(); + both.apply(&chosen(&p.branch), Mode::Strict).unwrap(); let mut want = both.document().clone(); (want.name, want.current_page) = (m.name.clone(), m.current_page); assert_eq!(into_main, want, "seed {seed}"); for doc in [&into_main, &into_branch] { assert!(doc.validate().is_empty(), "seed {seed}: {:?}", doc.validate()); for side in [&p.branch, &p.main] { - shows(side, doc).unwrap_or_else(|c| panic!("seed {seed}: lost {c}")); + shows(&chosen(side), doc).unwrap_or_else(|c| panic!("seed {seed}: lost {c}")); } } } else { diff --git a/crates/engine/src/sharing/branches.rs b/crates/engine/src/sharing/branches.rs index c4a5b7b09..e29e18359 100644 --- a/crates/engine/src/sharing/branches.rs +++ b/crates/engine/src/sharing/branches.rs @@ -611,6 +611,21 @@ fn doc_change(plan: &Plan, c: &Change) -> Option { Some(DocChange { what, change: entry_change(plan, c) }) } +/// One side's value of an auto layout field in conflict, in words: `16`, `8, 8, 8, 8`, `min`, +/// `on`, `none`. +fn field_text(v: &Value) -> String { + match v { + Value::Null => "none".to_string(), + Value::Bool(on) => if *on { "on" } else { "off" }.to_string(), + Value::Number(n) => n.as_f64().map_or_else(|| n.to_string(), |x| x.to_string()), + Value::String(s) => words(s), + Value::Array(items) => items.iter().map(field_text).collect::>().join(", "), + Value::Object(_) => v.to_string(), + } +} + +/// The review's row for conflict `c`: the layer (or file entry) and property, and what each side +/// changed it to. fn conflict_row(plan: &Plan, c: &Conflict, base: &Document, head: &Document, main: &Document) -> ConflictRow { let layer = |id: NodeId| main.node(id).or(head.node(id)).or(base.node(id)).map_or_else(|| id.to_string(), |n| n.name.clone()); let text = |side: Side| match c.changes(side).first().and_then(|i| plan.changes(side).get(*i)) { @@ -627,6 +642,11 @@ fn conflict_row(plan: &Plan, c: &Conflict, base: &Document, head: &Document, mai let property = if *prop == Prop::Parent { "place in layers".to_string() } else { words(prop) }; (Some(*id), layer(*id), property, b, m) } + Key::Field(id, prop, field) => { + let (b, m) = plan.field_values(&c.key).map_or_else(|| ("changed".into(), "changed".into()), |(b, m)| (field_text(b), field_text(m))); + let owner = if *prop == Prop::Layout { "auto layout".to_string() } else { words(prop) }; + (Some(*id), layer(*id), format!("{owner} {}", field.replace('_', " ")), b, m) + } Key::Layer(id) => { let (b, m) = if c.deleted_by == Some(Side::Branch) { ("deleted", "edited") } else { ("edited", "deleted") }; (Some(*id), layer(*id), "layer".to_string(), b.to_string(), m.to_string()) diff --git a/docs/collaboration-parity.md b/docs/collaboration-parity.md index fb54a8d55..6c08edf53 100644 --- a/docs/collaboration-parity.md +++ b/docs/collaboration-parity.md @@ -1,6 +1,6 @@ # Collaboration parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-31 · **Change:** minor (a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); `figcraft-server` checks the server key by comparing SHA-256 digests, not the raw keys (#1130); joining and leaving a file nobody is editing reads and writes nothing on the server: it stays loaded a minute after everyone leaves (#1074); `comment.people` lists names that were only @mentioned, and `comment.next` and `comment.prompt` carry the mentions too (#1415); share links can comment: a third access level beside edit and view, whose holder sees the file live and adds, replies to, reacts to and resolves comments but can't change the design; `comment.list {mentions}` lists only the threads that @mention a name (#1415); the browser build publishes files to a server, so Share ▸ Online and Publish to server work there (#917); an AI agent attached over MCP shows where it works (#1416); one name for live sessions and comments: Preferences ▸ Your name, in the Join dialog too, kept in the browser, and a rename shows at once in the sessions you are in (#1380); the Join dialog shows a join from the click until its file is ready, with Cancel, and a failed join with Try again (#1381); requests that change a server's files have a budget per address, the server key's too, and join codes are found by their hash (#1075); comment.list reports each message's @mentions (#1415); the batches kept for reconnecting apps are bounded in bytes by default, and `figcraft-server` takes `max_log_mb` (#1069); sibling placement in live sessions searches instead of counting (#1065); an AI agent attached over MCP comments under its own name, with an Agent label (#1414); a refused batch's fixes take time linear in the batch (#1063); image entries are checked as they apply; branches in live sessions and branch history entries; server message limits follow `max_file_mb`; a damaged log generation field keeps flushed edits; the web build joins from a `#join=` link; removing someone from a live session; live-session revert guard; live sessions per document; a public figcraft-server: open hosting, owner tokens, per-address limits, idle expiry, moderation, install.sh; cursor chat and spotlight in live sessions; branch version history and finer list merges; comments and version history behaviour suite and fixes; hosting the server: `wss://` in the desktop app, server releases, deployment guide; team libraries on the server and swap library; branches: create, update from main, review and merge; wording: the standalone server with share links to edit or view; numbers unchanged) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-06 · **Change:** patch (one auto layout edit on each side of a branch is one conflict, its field: auto layout settings merge field by field, and sizes and places auto layout works out, or values an instance takes from its main, no longer conflict (#2026); a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); `figcraft-server` checks the server key by comparing SHA-256 digests, not the raw keys (#1130); joining and leaving a file nobody is editing reads and writes nothing on the server: it stays loaded a minute after everyone leaves (#1074); `comment.people` lists names that were only @mentioned, and `comment.next` and `comment.prompt` carry the mentions too (#1415); share links can comment: a third access level beside edit and view, whose holder sees the file live and adds, replies to, reacts to and resolves comments but can't change the design; `comment.list {mentions}` lists only the threads that @mention a name (#1415); the browser build publishes files to a server, so Share ▸ Online and Publish to server work there (#917); an AI agent attached over MCP shows where it works (#1416); one name for live sessions and comments: Preferences ▸ Your name, in the Join dialog too, kept in the browser, and a rename shows at once in the sessions you are in (#1380); the Join dialog shows a join from the click until its file is ready, with Cancel, and a failed join with Try again (#1381); requests that change a server's files have a budget per address, the server key's too, and join codes are found by their hash (#1075); comment.list reports each message's @mentions (#1415); the batches kept for reconnecting apps are bounded in bytes by default, and `figcraft-server` takes `max_log_mb` (#1069); sibling placement in live sessions searches instead of counting (#1065); an AI agent attached over MCP comments under its own name, with an Agent label (#1414); a refused batch's fixes take time linear in the batch (#1063); image entries are checked as they apply; branches in live sessions and branch history entries; server message limits follow `max_file_mb`; a damaged log generation field keeps flushed edits; the web build joins from a `#join=` link; removing someone from a live session; live-session revert guard; live sessions per document; a public figcraft-server: open hosting, owner tokens, per-address limits, idle expiry, moderation, install.sh; cursor chat and spotlight in live sessions; branch version history and finer list merges; comments and version history behaviour suite and fixes; hosting the server: `wss://` in the desktop app, server releases, deployment guide; team libraries on the server and swap library; branches: create, update from main, review and merge; wording: the standalone server with share links to edit or view; numbers unchanged) · **Target:** Figma Design (desktop app 126.10.7) Figma is multiplayer first; FigCraft is local first. **Ready ~13% (estimated):** comments, version history and branches (review and merge) work inside one file; the real-time collaboration core landed in #103 (sync model, @@ -18,7 +18,7 @@ cursors, selections, text carets, cursor chat and spotlights shown live ([`colla | Share links, permissions (view / edit), teams and projects | yes | **partial**: sharing with a join code from the Share popover (online: the file goes to the server in Preferences and the server names its edit, comment and view links with short codes; local network: the app hosts and the code carries its address; one field joins with a code or a link, in the popover and on the home screen, and the Join dialog then shows the join until its file is ready (Cancel), or why it failed (Try again, #1381); the browser build also joins from a link in its URL's fragment, `#join=…`, which never reaches the web host's logs, capped at 6 KiB and checked like a `figcraft://` link (#712; unit-tested, not run in a browser), and shares online and publishes to a server as the desktop app does, though not on the local network (#917; the owner token of a file it puts on an open server lasts as long as the page)); `figcraft-server` share links per file with edit, comment or view access (a viewer sees changes and presence, a "View only" badge and only the moving tools; a commenter also adds, replies to, reacts to and resolves comment threads, with a "Can comment" badge and the comment tool, #1525; the server refuses their other edits), revocable at once, tokens stored as hashes; managed from the app's Share popover (first links), the server's command line or a managing connection. On a server open to the public, whoever published a file manages it with its owner token (links, name, removal: `collab.manageFile`), which the app remembers: Home ▸ Online lists your online files (open again as owner, start and stop sharing, copy the code, rename, remove, forget), with one request per server for what became of them; anyone in a file can report it, and the operator blocks addresses. The person hosting a session, or a file's owner, removes someone from it (right-click their avatar, `collab.removePerson`): they are disconnected and their address can't join that file again while it runs. The list is per computer; a server only a team reaches can also list the files shared from it now for everyone (`team_files`): Home ▸ Online shows that team list for the server in Preferences, a row joins its file, and its links (`figcraft://join?server=…&file=…&team=1`, or the browser build's) carry no secret and stop working with the share. No accounts, teams or projects | 8–17 | | Comments: pins on frames and layers, threads, reactions, @mentions, resolve, unread, search and filters, links, in the presenter | yes (shared) | **done, local**: stored in the file, your name from Preferences (an AI agent attached over MCP comments as its own name, marked Agent); a behaviour suite from the documentation (pinning and following layers, threads, own edits and deletes, mentions, reactions, C and Shift+C, stepping, filters, saving, copy and paste); restoring a version keeps them. `comment.list` (CLI, MCP) gives each message its `mentions` (`{name, known, you}`, by the highlighting rule). In a live session threads sync and anyone in it can reply, react and resolve (no accounts: a name is who you are) | (shared once multiplayer lands) | | Version history: named versions, autosave checkpoints, view before restore, restore, duplicate | yes (cloud) | **done**, saved in the `.figcraft` file: restoring keeps the replaced design as an autosave first, a titled autosave becomes a named version, merging a branch records the file before and after. Versions are per person in a live session (a shared history needs accounts); no comparing two versions (Dev Mode compares a ready-for-dev layer with its state when marked) | — | -| Branching and merging | yes (paid plans) | **done, also in live sessions**: branches saved in the `.figcraft` file, each opened in its own tab; Review and merge shows both sides' changes since the branch was made and the conflicts (the same property on both sides, or a layer deleted on one side and edited on the other), each resolved for the branch or main; merge as one undo step (the branch is archived, the main file's history gets a version for the merge), update from main, archive. Each branch keeps its own version history (saved, viewed and restored on the branch tab, kept when it is merged or archived; entries for its creation and updates from main); fills, strokes, effects, layout grids, export settings, guides, interactions, annotations and Dev Mode resources merge item by item. In a live session a branch stays with its author (its ids in their own client space, far above the main file's) and merging it is one edit everyone gets; peers' edits merge against the branch's own base and conflicts resolve as offline; a view link refuses merging. Left: others in the session can't see or open your branches (the server would have to keep them); text runs conflict as a whole; a branch made offline that adds layers merges only outside a session | 1–2 | +| Branching and merging | yes (paid plans) | **done, also in live sessions**: branches saved in the `.figcraft` file, each opened in its own tab; Review and merge shows both sides' changes since the branch was made and the conflicts (the same property on both sides, or a layer deleted on one side and edited on the other), each resolved for the branch or main; merge as one undo step (the branch is archived, the main file's history gets a version for the merge), update from main, archive. Each branch keeps its own version history (saved, viewed and restored on the branch tab, kept when it is merged or archived; entries for its creation and updates from main); fills, strokes, effects, layout grids, export settings, guides, interactions, annotations and Dev Mode resources merge item by item. Auto layout settings (a frame's and a child's) merge field by field, each field changed both ways a conflict of its own (`/layout.padding`), and sizes and places auto layout works out (hugging, filling, a child's place) or that an instance takes from its main are no conflict: the merged file lays them out again. In a live session a branch stays with its author (its ids in their own client space, far above the main file's) and merging it is one edit everyone gets; peers' edits merge against the branch's own base and conflicts resolve as offline; a view link refuses merging. Left: others in the session can't see or open your branches (the server would have to keep them); text runs conflict as a whole; a branch made offline that adds layers merges only outside a session | 1–2 | | Team / organization libraries | yes | **partial**: a file's library is published to `figcraft-server` under the file and enabled in other files by a share link (per-asset versions, background update checks, overrides kept), usage counts per component and file, swapping a library by names ([components-parity](components-parity.md), [server.md](server.md#team-libraries)). No team-wide library list, accounts or analytics over time | 4–8 | | Notifications, activity | yes | no | with sharing | @@ -26,6 +26,7 @@ cursors, selections, text carets, cursor chat and spotlights shown live ([`colla | Date | Change | Summary | |---|---|---| +| 2026-11-06 | patch | M9, #2026: one conflicting auto layout edit added a conflict for every size and place it moved (a padding changed on both sides of a file with one instance gave 10, with 15 instances 138), and a `layout` conflict took all auto layout fields together, so a gap changed only on the branch was lost if main won the padding. `merge::plan` now leaves out values both sides work out for themselves: a hugging frame's or a filling child's size, text sizing to its characters, an auto layout child's place (when both sides turn it the same way) and a value a layer in an instance takes from its main; merging keeps the file merged into's own value and normalising lays it out from the merged inputs. `layout` and `childLayout` merge field by field: a field changed on one side merges, each field changed both ways is its own conflict (`/layout.padding`, shown as auto layout padding with both sides' values). Tests: `branch_tests::one_conflicting_auto_layout_edit_is_one_conflict`, `branch_tests::auto_layout_fields_changed_one_way_survive_a_conflict`, `branch_tests::sizes_auto_layout_works_out_never_conflict`; the merge fuzz test leaves worked-out values out of what each side must show | | 2026-10-31 | patch | M9, #1665: the document in a live session's welcome goes compressed (deflate) to clients whose hello announces `packed`, about seven times smaller on the wire (a synthetic file of 4,040 layers: 397 KB to 53 KB); older clients keep getting it uncompressed, and the client reads a packed document only up to the size an uncompressed welcome could have had. | | 2026-10-30 | minor | M9, part of #742: a team list on `figcraft-server`. With `team_files = "edit"` (or `comment`, `view`) everyone who reaches the server sees the files shared from it now (a link of theirs has a join code: Share ▸ Start sharing) and joins them by a team list link, `figcraft://join?server=…&file=…&team=1`, which carries no secret: the server hands out the file's team link while it stays shared (`ResolveTeam`, answered like a join code), and Stop sharing revokes it with the others, disconnecting whoever joined with it. Turning the list off or changing its access refuses the old team links at once. `collab.files {refresh}` asks the server in Preferences for its list (`Admin::Team`; not the public server FigCraft ships with), and Home ▸ Online shows it below your own files: a row joins its file, its menu copies the link for the app or, with the server's `web_url`, for the browser build (`#join=…`). A browser build served beside its server names it with ``, the page's default for sharing, codes and the team list. No accounts: the list is for a server only your team reaches. Tests: `team_tests` (the server and apps over loopback), `code_tests` (links and the browser's driver), `online_tests` (the Online section), `query_tests` (the page's server). Percentages and hours unchanged | | 2026-10-30 | minor | M9, #1130: `figcraft-server` compares the SHA-256 digests of the presented and the kept server key instead of the raw strings, as `docs/server.md` says; the key file, `figcraft-server key` and rotation are unchanged. Numbers unchanged. | diff --git a/docs/mcp.md b/docs/mcp.md index b5e49e749..a0c967ef9 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -1353,7 +1353,10 @@ branches). Driven with `run_command`: export settings, guides, prototype interactions, annotations and Dev Mode resources compare item by item, so changing different items of one list on each side, or adding items at its end on one side, merges without a conflict; other lists, such as code links, compare whole; a layer's parent - and position are one property, `parent`), a layer deleted on one side while the other edited it or what's inside it + and position are one property, `parent`; auto layout settings, `layout` and `childLayout`, compare + field by field, each field changed both ways its own conflict, `/layout.padding`; sizes and + places auto layout works out, and values a layer in an instance takes from its main, are never + conflicts: the merged file works them out again), a layer deleted on one side while the other edited it or what's inside it (`/layer`, with `deletedBy`), or a document-level entry or setting changed on both sides (`style/`, `variable/`, `comment/`, `doc/`…). - `branch.merge {id?, resolutions?}` merges the branch into the main file as one undo step, From dad4203370fc04ed1146d592c5ebb092fd1ac3e6 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 7 Nov 2026 07:53:57 +0700 Subject: [PATCH 5/5] Auto layout parity: Suggest auto layout's row says what it does in our own words --- docs/auto-layout-parity.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/auto-layout-parity.md b/docs/auto-layout-parity.md index 71b1c30b7..41f4e33c4 100644 --- a/docs/auto-layout-parity.md +++ b/docs/auto-layout-parity.md @@ -92,7 +92,7 @@ Status: **pass** (a case in the suite holds), **fixed** (the suite found a diver | Arrow keys move children one place (flows, rows, columns, grid cells, into neighbours) | done | `al_keys_tests.rs` | | Constraints: left, right, left and right, centre, scale; top/bottom likewise | done | | | Layout grids: columns, rows, grid; stretch/left/centre/right; variables bound | done | | -| Suggest auto layout | done | "Figma will try to determine which objects in a frame or component should be placed in an auto layout frame, then adds as many auto layout frames as needed to make the full design responsive. These auto layout frames are created all at once, while attempting to preserve the placement of your designs" ([Toggle on auto layout in designs](https://help.figma.com/hc/en-us/articles/5731482952599-Toggle-on-auto-layout-in-designs)). `layout.suggest` used to run `layout.add` and made one row of everything (#1823). Now it splits a frame's layers, by their boxes in the frame, along the vertical axis first: sorted by top edge, a layer joins the current row while it starts above the row's bottom (or together with it), and a gap, even a zero one, between the row and the next layer starts a new row. With two or more rows the frame becomes a Vertical auto layout whose items are the rows; otherwise the same split by columns gives a Horizontal one; if the layers overlap along both axes the frame gets no auto layout and the result carries a warning. A row or column of several layers goes into a new frame without fill or clipping, sized to it and inserted in its place (it hugs its content), and the split repeats inside it, to a depth of 16 and for up to 1,000 layers per frame (past that, or when a mask is among the layers, the layers are laid out in one list as Add auto layout does, with a warning). The frame keeps its size, Fixed: the gap is the distance between the bands, the padding along the flow is the first band's offset and the room left after the last, across the flow the smallest offset (alignment start), so with equal gaps and bands that start at the same offset every layer keeps its box exactly. When the gaps differ by more than 0.5 px the smallest is used and `warnings` says the later bands move; when the bands start at different offsets across the flow (a centred title above a card) they line up at the smallest, which moves the others, and `warnings` says so. Instances and layers inside them are refused with the error Convert to group gives, before anything changes; a main component works. `direction` sets the top level only. A single group becomes a frame in place and several layers are wrapped in a frame (both hug), as Add auto layout does; a frame with fewer than two layers is laid out as Add auto layout does. One undo step. Tests in `crates/engine/src/layout_suggest_tests.rs`: `two_rows_of_two_squares_become_a_vertical_frame_of_two_horizontal_rows`, `suggesting_auto_layout_is_one_undo_step`, `three_squares_in_a_row_get_one_horizontal_layout_without_nesting`, `three_squares_in_a_column_get_one_vertical_layout_without_nesting`, `a_header_above_two_columns_of_squares_gives_a_row_per_line`, `a_header_above_a_tall_layer_beside_a_column_nests_three_levels`, `unequal_gaps_use_the_smallest_and_say_so`, `overlapping_layers_leave_the_frame_without_auto_layout_and_say_so`, `a_group_becomes_a_frame_in_place_and_follows_the_rules`, `several_layers_are_wrapped_in_a_frame_that_is_then_split`, `a_direction_forces_the_top_level_and_nested_frames_follow_the_gaps`, `a_frame_with_one_layer_is_laid_out_like_add_auto_layout`, `add_auto_layout_still_makes_a_single_row`, `a_centred_title_above_a_card_is_lined_up_at_the_card_edge_with_a_warning`, `instances_and_layers_inside_them_are_refused_and_a_main_component_works`. Not attempted: overlapping layers, keeping uneven offsets across the flow (they line up at the smallest, with a warning), grids | +| Suggest auto layout | done | The target works out which layers belong together and adds as many auto layout frames as the design needs, in one step, keeping the placement. `layout.suggest` used to run `layout.add` and made one row of everything (#1823). Now it splits a frame's layers, by their boxes in the frame, along the vertical axis first: sorted by top edge, a layer joins the current row while it starts above the row's bottom (or together with it), and a gap, even a zero one, between the row and the next layer starts a new row. With two or more rows the frame becomes a Vertical auto layout whose items are the rows; otherwise the same split by columns gives a Horizontal one; if the layers overlap along both axes the frame gets no auto layout and the result carries a warning. A row or column of several layers goes into a new frame without fill or clipping, sized to it and inserted in its place (it hugs its content), and the split repeats inside it, to a depth of 16 and for up to 1,000 layers per frame (past that, or when a mask is among the layers, the layers are laid out in one list as Add auto layout does, with a warning). The frame keeps its size, Fixed: the gap is the distance between the bands, the padding along the flow is the first band's offset and the room left after the last, across the flow the smallest offset (alignment start), so with equal gaps and bands that start at the same offset every layer keeps its box exactly. When the gaps differ by more than 0.5 px the smallest is used and `warnings` says the later bands move; when the bands start at different offsets across the flow (a centred title above a card) they line up at the smallest, which moves the others, and `warnings` says so. Instances and layers inside them are refused with the error Convert to group gives, before anything changes; a main component works. `direction` sets the top level only. A single group becomes a frame in place and several layers are wrapped in a frame (both hug), as Add auto layout does; a frame with fewer than two layers is laid out as Add auto layout does. One undo step. Tests in `crates/engine/src/layout_suggest_tests.rs`: `two_rows_of_two_squares_become_a_vertical_frame_of_two_horizontal_rows`, `suggesting_auto_layout_is_one_undo_step`, `three_squares_in_a_row_get_one_horizontal_layout_without_nesting`, `three_squares_in_a_column_get_one_vertical_layout_without_nesting`, `a_header_above_two_columns_of_squares_gives_a_row_per_line`, `a_header_above_a_tall_layer_beside_a_column_nests_three_levels`, `unequal_gaps_use_the_smallest_and_say_so`, `overlapping_layers_leave_the_frame_without_auto_layout_and_say_so`, `a_group_becomes_a_frame_in_place_and_follows_the_rules`, `several_layers_are_wrapped_in_a_frame_that_is_then_split`, `a_direction_forces_the_top_level_and_nested_frames_follow_the_gaps`, `a_frame_with_one_layer_is_laid_out_like_add_auto_layout`, `add_auto_layout_still_makes_a_single_row`, `a_centred_title_above_a_card_is_lined_up_at_the_card_edge_with_a_warning`, `instances_and_layers_inside_them_are_refused_and_a_main_component_works`. Not attempted: overlapping layers, keeping uneven offsets across the flow (they line up at the smallest, with a warning), grids | | "Add auto layout" on a selection | done | the Layout sidebar exposes Add auto layout (+) for groups and frames using the same `layout.add` command as the context menu; a single group becomes a frame in place, keeping its id, name and direct children; adding auto layout to an empty frame keeps its size, Fixed (it collapsed to 20×20); a frame with content still hugs it, as does a new frame wrapped around a selection (#369). `node.set` with auto layout keys on a mix of layers applies them to the frames and warns about the rest instead of failing the whole call (#603) | | Real Figma files laid out identically | **not checked** | needs `.fig` or REST import of real files ([gaps](gaps.md) #1, #3) | | Performance: re-flow only where sizes or places changed | done | measured in `cargo xtask bench` (components at scale) | @@ -101,7 +101,7 @@ Status: **pass** (a case in the suite holds), **fixed** (the suite found a diver | Date | Change | Summary | |---|---|---| -| 2026-11-05 | patch | M2, #1823: Suggest auto layout is no longer Add auto layout under another name. "Figma will try to determine which objects in a frame or component should be placed in an auto layout frame, then adds as many auto layout frames as needed to make the full design responsive ... while attempting to preserve the placement of your designs" (Toggle on auto layout in designs): `layout.suggest` splits a frame's layers into rows (Vertical) or else columns (Horizontal) by the gaps between their boxes, wraps each band of several layers in a new frame without fill or clipping that hugs it, and repeats inside it (16 levels, 1,000 layers per frame at most). The frame keeps its size; gap and padding come from the bands, so layers keep their boxes where the gaps are even and the bands start at the same offset; instances and layers inside them are refused; uneven gaps (smallest used), bands that start at different offsets across the flow (lined up at the smallest) and layers that overlap along both axes come back as `warnings`. `direction` sets the top level only; one undo step; `layout.add` is unchanged. Tests in `layout_suggest_tests.rs` | +| 2026-11-05 | patch | M2, #1823: Suggest auto layout is no longer Add auto layout under another name: `layout.suggest` splits a frame's layers into rows (Vertical) or else columns (Horizontal) by the gaps between their boxes, wraps each band of several layers in a new frame without fill or clipping that hugs it, and repeats inside it (16 levels, 1,000 layers per frame at most). The frame keeps its size; gap and padding come from the bands, so layers keep their boxes where the gaps are even and the bands start at the same offset; instances and layers inside them are refused; uneven gaps (smallest used), bands that start at different offsets across the flow (lined up at the smallest) and layers that overlap along both axes come back as `warnings`. `direction` sets the top level only; one undo step; `layout.add` is unchanged. Tests in `layout_suggest_tests.rs` | | 2026-11-02 | patch | M2, #1824: fill container children share the free space by their content area: each one's own insets (padding and an included inside stroke, from the same `insets` the frame uses) come off the free space before the equal split and go back on its share, so a child with more padding or a thicker inside stroke takes a little more and the content areas match ("Figma distributes space amongst fill container children by the children's content area instead of by their size, matching the CSS border-box model", Use auto layout with CSS Flexbox in mind). Min and max still clamp the outer sizes and the frozen-share loop is as it was; children without insets split as before. Test: `nested_tests::fill_children_share_by_content_area` | | 2026-11-02 | patch | M2, #1838: a double-click on an edge of an auto layout frame's bounding box sets Hug contents on that axis, Alt+double-click on an edge of a child's Fill container ("Double-click the vertical or horizontal edge of an auto layout object's bounding box to set it to Hug contents", "Hold ⌥ Option or Alt and double-click ... to set it to Fill container", Guide to auto layout); a vertical edge sizes the width, a horizontal one the height; the Keyboard shortcuts panel lists both gestures. Test: `double_click_tests::a_double_click_on_an_auto_layout_edge_hugs_and_with_alt_fills`. Numbers unchanged. | | 2026-11-02 | patch | M2: a child of an auto layout frame resized to the full space available to it on an axis (the frame's size less its padding: across the flow for any child, along the flow for a lone child) becomes Fill container on that axis, whether by `transform.resize`, the W/H fields or a canvas handle ("Child objects of an auto layout frame will also be set to Fill container if they are manually resized to the full available space of the parent frame", Guide to auto layout). Any other size keeps the axis Fixed as before; beside siblings along the flow, in a hugging or wrapping frame, in a grid and for a layer that ignores the layout nothing changes. Test: `al_behaviour_tests::a_child_resized_to_the_full_available_space_becomes_fill` |