fix(editor): read inserted frames before a render embeds the project

A render queued before the editor had seen frames inserted under it (a sync
download, an import of earlier photos, a scan without an event) embedded the
project's positions in the old frame order. Render now checks first that the
frames read are still the sequence's (ISequenceSource.FramesCurrentAsync: the
row's frames version on this PC, the manifest on a server). On this PC the
sequence is read again and the positions follow the frames; a server
sequence whose frames changed turns outdated and the render is not queued.

Reads of the sequence no longer overlap: a read waits for the one under way,
saves that meet new frames read them through the same slot, and they save
the project as it is once its positions followed. The frame on screen stays
on its photo when frames are inserted or removed before it.

Tests: the event-loss test waits for the listener's subscription before
dropping the stream, and the conflict tests flush once more after the
choice when a retry started before it was still failing.

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 19:59:45 +00:00
1 parent 99a0f37973
commit 827b224ee3
11 files changed
+351 -31

No files matched your search

+23 -3
View File
@@ -130,6 +130,13 @@ public sealed class RemoteSequenceSource : ISequenceSource
}, cancellationToken);
}
/// <remarks>Read from the server's manifest: a sequence whose frames are not this PC's becomes outdated.</remarks>
public async Task<bool> FramesCurrentAsync(CancellationToken cancellationToken)
{
if (IsOutdated) return false;
return Compare(await Call(() => _api.GetManifestAsync(Id, cancellationToken)));
}
public async ValueTask<ImageBuffer?> DecodeAsync(int index, int maxLongEdge, DecodePurpose purpose, CancellationToken cancellationToken)
{
if ((uint)index >= (uint)_remote.Frames.Count) return null;
@@ -305,9 +312,7 @@ public sealed class RemoteSequenceSource : ISequenceSource
{
try
{
var manifest = await _api.GetManifestAsync(Id, cancellationToken).ConfigureAwait(false);
if (SameFrames(manifest)) Volatile.Write(ref _framesVersion, manifest.FramesVersion);
else MarkOutdated();
Compare(await _api.GetManifestAsync(Id, cancellationToken).ConfigureAwait(false));
}
catch (Exception ex) when (ex is TitanoApiException or HttpRequestException or JsonException
|| (ex is OperationCanceledException && !cancellationToken.IsCancellationRequested))
@@ -344,6 +349,21 @@ public sealed class RemoteSequenceSource : ISequenceSource
JobChanged?.Invoke(job);
}
/// <summary>
/// Takes the server's frames as <paramref name="manifest"/> lists them: their frames version when they are this PC's
/// (saves name it), outdated otherwise. Returns whether they are.
/// </summary>
private bool Compare(SequenceManifest manifest)
{
if (!SameFrames(manifest))
{
MarkOutdated();
return false;
}
Volatile.Write(ref _framesVersion, manifest.FramesVersion);
return true;
}
/// <summary>The server's frames are the cached ones, in the same order (frame positions in the project mean the same frames).</summary>
private bool SameFrames(SequenceManifest manifest) =>
manifest.Frames.OrderBy(f => f.Index).Select(f => f.Id).SequenceEqual(_remote.Frames.Select(f => f.Id));