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

+32 -4
View File
@@ -77,6 +77,9 @@ internal sealed class FakeSequenceSource(SyntheticSequence sequence, SequenceCon
{
private readonly SyntheticFrameSource _pixels = new(sequence);
/// <summary>The frames the session read last (opened with, or loaded since).</summary>
private IReadOnlyList<Frame> _read = content.Frames;
public ProjectSettings Stored { get; set; } = content.Project;
public SequenceContent Content { get; set; } = content;
@@ -114,11 +117,36 @@ internal sealed class FakeSequenceSource(SyntheticSequence sequence, SequenceCon
/// <summary>Thrown by the next load (the sequence read again after a job).</summary>
public Exception? FailNextLoad { get; set; }
public Task<SequenceContent> LoadAsync(CancellationToken cancellationToken)
/// <summary>Awaited by the next load once it has read the sequence (a read that is slow to complete).</summary>
public Task? NextLoadGate { get; set; }
/// <summary>Times the sequence was read (<see cref="LoadAsync"/>).</summary>
public int Loads { get; private set; }
public async Task<SequenceContent> LoadAsync(CancellationToken cancellationToken)
{
if (FailNextLoad is not { } failure) return Task.FromResult(Content with { Project = Stored });
FailNextLoad = null;
return Task.FromException<SequenceContent>(failure);
if (FailNextLoad is { } failure)
{
FailNextLoad = null;
throw failure;
}
Loads++;
var content = Content with { Project = Stored };
if (NextLoadGate is { } gate)
{
NextLoadGate = null;
await gate;
}
_read = content.Frames;
return content;
}
/// <summary>Whether <see cref="Content"/> holds the frames read last; a server sequence becomes outdated when not.</summary>
public Task<bool> FramesCurrentAsync(CancellationToken cancellationToken)
{
var current = _read.Select(f => f.Id).SequenceEqual(Content.Frames.Select(f => f.Id));
if (!current && IsRemote) MarkOutdated();
return Task.FromResult(current);
}
public async ValueTask<ImageBuffer?> DecodeAsync(int index, int maxLongEdge, DecodePurpose purpose, CancellationToken cancellationToken)