From a6a21decbd79a5c010be8124199ea9254307618d Mon Sep 17 00:00:00 2001 From: Jaap-Jan de Wit | DodoTech Date: Mon, 28 Sep 2026 20:49:40 +0200 Subject: [PATCH] Report a host's pinned paths among the fields an edit changed --- src/DodoSSH.Client.Sync/ItemKinds.cs | 1 + .../ScreenLayoutTests.cs | 10 +++++----- .../ItemKindsTests.cs | 20 +++++++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/DodoSSH.Client.Sync/ItemKinds.cs b/src/DodoSSH.Client.Sync/ItemKinds.cs index c879d73..c5774ee 100644 --- a/src/DodoSSH.Client.Sync/ItemKinds.cs +++ b/src/DodoSSH.Client.Sync/ItemKinds.cs @@ -274,6 +274,7 @@ internal sealed class HostKind : IItemKind Note(changed, "Group", before.GroupId, after.GroupId); Note(changed, "Tags", before.TagIds, after.TagIds); Note(changed, "Port forwards", before.PortForwards, after.PortForwards); + Note(changed, "Pinned paths", before.PinnedPaths, after.PinnedPaths); return changed; } diff --git a/tests/DodoSSH.Client.App.Layout.Tests/ScreenLayoutTests.cs b/tests/DodoSSH.Client.App.Layout.Tests/ScreenLayoutTests.cs index 81458b1..777976a 100644 --- a/tests/DodoSSH.Client.App.Layout.Tests/ScreenLayoutTests.cs +++ b/tests/DodoSSH.Client.App.Layout.Tests/ScreenLayoutTests.cs @@ -1020,10 +1020,10 @@ public sealed class ScreenLayoutTests : IAsyncLifetime } /// - /// The FIELDS column is the one that grows: it is a list of names, and a host has fourteen of them — - /// eleven until inheritance added "Password prompt", tags added "Tags" and forwards added "Port - /// forwards". Measured with an edit that touched several, because one field name fits anywhere. The - /// count is stated rather than derived, so + /// The FIELDS column is the one that grows: it is a list of names, and a host has fifteen of them — + /// eleven until inheritance added "Password prompt", tags added "Tags", forwards added "Port forwards" + /// and pinning added "Pinned paths". Measured with an edit that touched several, because one field + /// name fits anywhere. The count is stated rather than derived, so /// it has to be recounted against HostKind.Changes whenever a field is added; the literal in /// SeedLogsAsync is the thing that actually keeps the column measured at its worst. /// @@ -2252,7 +2252,7 @@ public sealed class ScreenLayoutTests : IAsyncLifetime ItemId = Guid.CreateVersion7(), ItemLabel = "customer-a-production-database", Operation = ActivityOperation.Updated, - ChangedFields = "Hostname, Port, Username, Options, Password prompt, Group, Tags, Port forwards", + ChangedFields = "Hostname, Port, Username, Options, Password prompt, Group, Tags, Port forwards, Pinned paths", At = new DateTimeOffset(2026, 7, 30, 9, 15, 0, TimeSpan.Zero), DeviceName = "jaap-jan-workstation", }, diff --git a/tests/DodoSSH.Client.Sync.Tests/ItemKindsTests.cs b/tests/DodoSSH.Client.Sync.Tests/ItemKindsTests.cs index 6f853e0..79acabd 100644 --- a/tests/DodoSSH.Client.Sync.Tests/ItemKindsTests.cs +++ b/tests/DodoSSH.Client.Sync.Tests/ItemKindsTests.cs @@ -1,3 +1,4 @@ +using DodoSSH.Client.Domain; using DodoSSH.Contracts; namespace DodoSSH.Client.Sync.Tests; @@ -53,4 +54,23 @@ public sealed class ItemKindsTests reconcilers.Keys.Order().ShouldBe(ItemKinds.SyncedTypes.Order()); } + + [Fact] + public void AHostEditThatOnlyChangedItsPins_IsReportedAsChangingPinnedPaths() + { + // Pinned paths were the one host field Changes did not look at, so an edit that only pinned or + // unpinned a directory reached the keychain log as an update that changed nothing. + var before = new HostSecret + { + Label = "db-01", + Hostname = "db-01.internal", + PinnedPaths = PinnedPathList.Create(["/var/log"]), + }; + var after = before with { PinnedPaths = PinnedPathList.Create(["/var/log", "/etc/nginx"]) }; + + HostKind.Instance.Changes(before, after).ShouldBe(["Pinned paths"]); + HostKind.Instance.Changes(before, before with { PinnedPaths = PinnedPathList.Empty }) + .ShouldBe(["Pinned paths"]); + HostKind.Instance.Changes(before, before with { }).ShouldBeEmpty(); + } }