From 964bccdfb260e1ac384206497a9a789c859f990e Mon Sep 17 00:00:00 2001 From: soul Date: Sat, 28 Nov 2026 05:09:28 +0100 Subject: [PATCH] push: an added anchor keeps its Id (found by the add-on's first Package over push) --- .../Aetheria.Shared.Tests/ShipAuthoringPushTests.cs | 13 +++++++++++++ tools/AetherDb/ShipAuthoringPush.cs | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/Aetheria.Shared.Tests/ShipAuthoringPushTests.cs b/tests/Aetheria.Shared.Tests/ShipAuthoringPushTests.cs index a829f43dc..38ee11501 100644 --- a/tests/Aetheria.Shared.Tests/ShipAuthoringPushTests.cs +++ b/tests/Aetheria.Shared.Tests/ShipAuthoringPushTests.cs @@ -119,6 +119,19 @@ public sealed class ShipAuthoringPushTests : IDisposable Assert.Equal(files, Listing(path)); } + // An anchor the request adds is a whole anchor: the Id is the one the validator and the node binding read. + [Fact] + public void AnAddedAnchorKeepsItsId() + { + var path = Package(); + var request = Edit(Open(path), json => ((JArray)json["visual"]["anchors"]).Add( + new JObject { ["id"] = "extra", ["role"] = "map-icon", ["node"] = "extra", ["parent"] = null, ["order"] = 0 })); + var (code, changes, outcome) = Push(path, request, apply: true); + Assert.True(code == 0, outcome.ToString()); + Assert.Contains("mod-ship:mod.skiff anchor[extra] added", changes); + Assert.Contains(Parse(Open(path))["visual"]["anchors"], anchor => (string)anchor["id"] == "extra"); + } + [Fact] public void ApplyWritesTheDryRunResult() { diff --git a/tools/AetherDb/ShipAuthoringPush.cs b/tools/AetherDb/ShipAuthoringPush.cs index 9f85de9be..cbea54503 100644 --- a/tools/AetherDb/ShipAuthoringPush.cs +++ b/tools/AetherDb/ShipAuthoringPush.cs @@ -531,7 +531,7 @@ public static class ShipAuthoringPush if (string.IsNullOrWhiteSpace(row.Id)) throw new InvalidOperationException("visual: every anchor needs an id."); if (!seen.Add(row.Id)) throw new InvalidOperationException($"visual: anchor id {row.Id} is used twice."); // Joint is not authored here and is carried by the anchor's identity; so is its element id. - var target = stored.TryGetValue(row.Id, out var found) ? Copy(found) : new ShipAnchor { ElementId = row.Id }; + var target = stored.TryGetValue(row.Id, out var found) ? Copy(found) : new ShipAnchor { Id = row.Id, ElementId = row.Id }; target.Role = row.Role; target.ModelNodeId = row.Node; target.ParentId = row.Parent;