merge: third-pass sync and editor fixes (W-2, W-3, W-4, W-16)

Merge branch fix3/sync-editor into the verification branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 20:02:15 +00:00
commit 8897363e60
21 files changed
+1038 -79

No files matched your search

@@ -167,6 +167,47 @@ public sealed class ProjectSettingsTests
Assert.Null(ProjectSettings.MoveFramePositions("""{ "heroFrame": 1, "HeroFrame": 1 }""", new Dictionary<int, int> { [1] = 2 }));
}
[Test]
public void AnEditorsPositionsFollowFramesInsertedUnderItAsTheIndexMovedTheStoredOnes()
{
// An editor read four frames; a download then inserted two earlier photos, one of which an exclusion waited for.
var photos = Enumerable.Range(0, 6).Select(Photo).ToList();
var ids = Enumerable.Range(0, 6).Select(_ => Guid.CreateVersion7()).ToList();
IReadOnlyList<Guid> before = ids[2..];
var after = ids.Select((id, i) => new Titano.Core.Model.Frame
{
Id = id,
SequenceId = Guid.Empty,
Index = i,
RelativePath = $"s/IMG_{i}.JPG",
FileName = $"IMG_{i}.JPG",
Sha256 = photos[i].Sha256,
Size = photos[i].Size,
CapturedAt = photos[i].CapturedAt,
}).ToList();
var project = new ProjectSettings
{
ExcludedFrames = [1, 3],
HeroFrame = 0,
Camera = new CameraSettings { Keyframes = [new CameraKey(2, 0.5, 0.5, 1, 0)] },
Exposure = new ExposureSettings { DeflickerWindow = new Auto<int>().WithManual(41) },
PendingFrames = [new PendingFrame { Sha256 = photos[1].Sha256, Size = photos[1].Size, Excluded = true }],
};
var followed = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.FollowFrames(project.ToJson(), before, after)));
Assert.SequenceEqual([1, 3, 5], followed.ExcludedFrames);
Assert.Equal(2, followed.HeroFrame);
Assert.SequenceEqual([4], followed.Camera.Keyframes.Select(k => k.Frame));
Assert.Equal(41, followed.Exposure.DeflickerWindow.Manual);
Assert.Null(followed.PendingFrames);
// The same frames: nothing moves. A frame the editor read that is gone: positions stay, as the index leaves them.
Assert.Null(ProjectSettings.FollowFrames(new ProjectSettings { ExcludedFrames = [1] }.ToJson(), ids, after));
var removed = after.Where(f => f.Id != ids[3]).Select((f, i) => f with { Index = i }).ToList();
Assert.Null(ProjectSettings.FollowFrames(new ProjectSettings { ExcludedFrames = [1, 3] }.ToJson(), before, removed));
}
[Test]
public void PositionsCrossToAnotherCopyByPhotoAndWaitForPhotosItLacks()
{
@@ -283,6 +324,102 @@ public sealed class ProjectSettingsTests
Assert.Null(cleared.PendingFrames);
}
[Test]
public void APhotoHeldTwiceKeepsEachCopysPositions()
{
// The server adopted a folder holding photo 1 twice ('IMG_0001.JPG', 'IMG_0001 (1).JPG'); this PC keeps it once.
var photos = Enumerable.Range(0, 3).Select(Photo).ToList();
var server = Frames([photos[0], photos[1], photos[1], photos[2]]);
var here = Frames(photos);
var project = new ProjectSettings
{
ExcludedFrames = [2],
HeroFrame = 2,
Camera = new CameraSettings { Keyframes = [new CameraKey(1, 0.1, 0.5, 1, 0), new CameraKey(2, 0.2, 0.5, 1, 0)] },
};
// The second copy, which the deep analysis flags as a duplicate, is excluded there: this PC still renders its only copy.
var taken = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.TranslateFramePositions(project.ToJson(), server, here)));
Assert.Empty(taken.ExcludedFrames);
Assert.Null(taken.HeroFrame);
Assert.SequenceEqual([1], taken.Camera.Keyframes.Select(k => k.Frame));
Assert.Equal(0.1, taken.Camera.Keyframes[0].CenterX);
var waiting = Assert.NotNull(taken.PendingFrames);
Assert.Count(1, waiting);
Assert.True(waiting[0] is { Excluded: true, Hero: true, Occurrence: 1 } && waiting[0].Sha256 == photos[1].Sha256);
Assert.Count(1, waiting[0].Keyframes);
Assert.Equal(0.2, waiting[0].Keyframes[0].CenterX);
Assert.Contains("\"occurrence\": 1", taken.ToJson());
// Sent back after an edit of something else, every position lands on the copy it named.
var edited = taken with { Exposure = new ExposureSettings { ExposureOffsetEv = 0.3 } };
var back = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.TranslateFramePositions(edited.ToJson(), here, server)));
Assert.SequenceEqual([2], back.ExcludedFrames);
Assert.Equal(2, back.HeroFrame);
Assert.SequenceEqual([1, 2], back.Camera.Keyframes.Select(k => k.Frame));
Assert.SequenceEqual([0.1, 0.2], back.Camera.Keyframes.Select(k => k.CenterX));
Assert.Null(back.PendingFrames);
// Both copies excluded there: this PC excludes its copy, and the server gets both back.
var both = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.TranslateFramePositions(new ProjectSettings { ExcludedFrames = [1, 2] }.ToJson(), server, here)));
Assert.SequenceEqual([1], both.ExcludedFrames);
var excluded = Assert.NotNull(both.PendingFrames);
Assert.Count(1, excluded);
Assert.True(excluded[0] is { Excluded: true, Hero: false, Occurrence: 1 });
var returned = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.TranslateFramePositions(both.ToJson(), here, server)));
Assert.SequenceEqual([1, 2], returned.ExcludedFrames);
Assert.Null(returned.PendingFrames);
}
[Test]
public void TheCopiesOfAPhotoAreToldApartByTheirOrder()
{
var time = new DateTime(2026, 9, 28, 18, 0, 0);
var hashed = new FramePhoto(new string('a', 64), 100, time);
var other = new FramePhoto(new string('b', 64), 200, time);
var unhashed = new FramePhoto(null, 100, time);
// The frame at 3 has not been hashed yet: it may be a copy of the photo, or another photo of the same size taken in
// the same second. The frames with the photo's hash are its copies; size and capture time match the unhashed one.
var frames = Frames([other, hashed, other, unhashed, hashed]);
Assert.SequenceEqual([1, 4], new[] { 0, 1, 2 }.Select(n => frames.IndexOf(hashed, n)).OfType<int>());
Assert.Null(frames.IndexOf(hashed, 2));
Assert.SequenceEqual([1, 3, 4], new[] { 0, 1, 2 }.Select(n => frames.IndexOf(unhashed, n)).OfType<int>());
Assert.SequenceEqual([0, 0, 1, 1, 1], Enumerable.Range(0, 5).Select(frames.Occurrence));
Assert.Equal(0, frames.Occurrence(9));
Assert.Equal(2, frames.IndexOf(new FramePhoto(new string('B', 64), 0, null), 1));
// Without a frame holding its hash, a hashed photo is the frames not hashed yet with its size and capture time.
Assert.Equal(3, frames.IndexOf(new FramePhoto(new string('c', 64), 100, time)));
}
[Test]
public void APhotoNotHashedYetDoesNotTakeThePositionsOfAnotherWithItsSizeAndTime()
{
// Two photos of a burst share size and capture time (a RAW of constant size, no sub-second times). The server has
// not hashed the first yet; this PC has hashed both and does not have the third photo yet.
var time = new DateTime(2026, 9, 28, 18, 0, 0);
var (first, second) = (new FramePhoto(new string('a', 64), 100, time), new FramePhoto(new string('b', 64), 100, time));
var server = Frames([first with { Sha256 = null }, second, Photo(3)]);
var here = Frames([first, second]);
// The second photo excluded on the server is the second here, and back; the first stays the hero on both.
var project = new ProjectSettings { ExcludedFrames = [1, 2], HeroFrame = 0 };
var taken = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.TranslateFramePositions(project.ToJson(), server, here)));
Assert.SequenceEqual([1], taken.ExcludedFrames);
Assert.Equal(0, taken.HeroFrame);
var waiting = Assert.NotNull(taken.PendingFrames);
Assert.True(waiting is [{ Excluded: true, Occurrence: 0 }] && waiting[0].Sha256 == Photo(3).Sha256, "only the third photo waits");
var back = ProjectSettings.FromJson(Assert.NotNull(ProjectSettings.TranslateFramePositions(taken.ToJson(), here, server)));
Assert.SequenceEqual([1, 2], back.ExcludedFrames);
Assert.Equal(0, back.HeroFrame);
Assert.Null(back.PendingFrames);
// A copy that has not hashed its first frame still finds the second photo by its hash, not on that frame.
Assert.Equal(1, server.IndexOf(second));
Assert.Equal(0, server.Occurrence(1));
Assert.Equal(0, server.IndexOf(first));
}
[Test]
public void AProjectNamingNoFrameCrossesAsItIs()
{