fix(editor): name the frames version in the remote editor's saves
The desktop editor of a server sequence relied on the server's sequenceChanged event to go read-only when frames changed. Scans publish none, and an event missed while the socket reconnected was never noticed, so a save made meanwhile passed the settings-version check and wrote positions in the old order over the ones the server had moved. The PATCH now carries expectedFramesVersion, the frames version of the proxies the editor holds. On 409 the editor reads the manifest: other frames make it outdated (read-only, Get proxies; the edit stays pending), the same frames at a new version retry at that version. After a lost event socket the frames are compared again. Servers that predate the field ignore it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
3 files changed
+73
-10
No files matched your search
@@ -433,6 +433,51 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SavesNameTheirFramesAndTheServerRefusesThemOnceItsFramesChanged()
|
||||
{
|
||||
var (source, api, remote) = Open();
|
||||
await using (source)
|
||||
{
|
||||
var content = await source.LoadAsync(context.Cancellation);
|
||||
var stored = await source.SaveProjectAsync(content.Project with { ExcludedFrames = [1] }, content.Project, context.Cancellation);
|
||||
|
||||
// A new frames version over the same frames: the save goes through at that version.
|
||||
api.FramesVersion = 2;
|
||||
stored = await source.SaveProjectAsync(stored with { HeroFrame = 2 }, stored, context.Cancellation);
|
||||
Assert.SequenceEqual([1, 1, 2], api.Edits.Select(e => e.Request.ExpectedFramesVersion ?? -1));
|
||||
Assert.SequenceEqual([true, false, true], api.Edits.Select(e => e.Accepted));
|
||||
|
||||
// An earlier photo reaches the server (a scan, an upload) and its positions move with their frames, before
|
||||
// any event reaches this editor: the server refuses the edit made on the old frames, which stays unsaved.
|
||||
api.Frames = [Guid.CreateVersion7(), .. remote.Frames.Select(f => f.Id)];
|
||||
api.FramesVersion = 3;
|
||||
api.SettingsJson = (ProjectSettings.FromJson(api.SettingsJson!) with { ExcludedFrames = [2], HeroFrame = 3 }).ToJson();
|
||||
var refused = await Assert.ThrowsAsync<ProxiesOutdatedException>(() =>
|
||||
source.SaveProjectAsync(stored with { ExcludedFrames = [1, 4] }, stored, context.Cancellation));
|
||||
Assert.Equal(Loc.L("Editor.Error.FramesChanged"), refused.Message);
|
||||
Assert.True(source.IsOutdated);
|
||||
Assert.False(api.Edits[^1].Accepted);
|
||||
Assert.SequenceEqual([2], ProjectSettings.FromJson(api.SettingsJson!).ExcludedFrames, "the server keeps the positions it moved");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task FramesChangedWhileTheEventsWereLostAreFoundOnReconnecting()
|
||||
{
|
||||
var (source, api, remote) = Open();
|
||||
await using (source)
|
||||
{
|
||||
await source.LoadAsync(context.Cancellation);
|
||||
api.DropEvents();
|
||||
api.Frames = [.. remote.Frames.Skip(1).Select(f => f.Id)];
|
||||
api.FramesVersion = 2;
|
||||
// The listener reconnects after its first delay (2 s) and compares the frames again.
|
||||
await WaitAsync(() => source.IsOutdated);
|
||||
Assert.True(source.IsReadOnly);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AConflictFoundOnOtherFramesIsNotMergedOntoThem()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user