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

@@ -14,6 +14,7 @@ using Titano.App.Sections;
using Titano.App.Shell;
using Titano.App.Tests.Windows;
using Titano.Core.Advice;
using Titano.Core.Analysis;
using Titano.Core.Export;
using Titano.Core.Localization;
using Titano.Core.Model;
@@ -299,6 +300,36 @@ public sealed class EditorSmokeTests
}
});
/// <summary>
/// Frames inserted under the editor (a sync download, an import of earlier photos) move the frame on screen with its
/// photo: what the frame actions (Exclude, Set hero, a keyframe) apply to stays the photo the user looks at.
/// </summary>
[Test]
public Task TheFrameOnScreenStaysWhenFramesAreInsertedBeforeIt() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
var content = EditorFixture.Content(EditorFixture.Sunset, deep: false);
var source = new FakeSequenceSource(EditorFixture.Sunset, content);
var editor = new EditorViewModel(app.Shell, new EditorSession(source, content, []), [], EncoderHost.Client);
await using (editor)
{
editor.CurrentIndex = 5;
var shown = content.Frames[5].Id;
// An earlier photo arrives and the last frame goes: as many frames as before, each one place later.
var first = content.Frames[0];
IReadOnlyList<Titano.Core.Model.Frame> frames =
[.. new[] { first with { Id = Guid.CreateVersion7(), CapturedAt = first.CapturedAt!.Value.AddMinutes(-1) } }.Concat(content.Frames.SkipLast(1))
.Select((f, i) => f with { Index = i })];
source.Content = content with { Frames = frames, Light = LightAnalyzer.Analyze(frames) };
await editor.Session.ReloadAsync();
Assert.Equal(6, editor.CurrentIndex);
Assert.Equal(shown, editor.Session.Content.Frames[editor.CurrentIndex].Id);
Assert.Equal(6, editor.Frames.Selected?.Index);
}
});
/// <summary>The measuring tool of each section has content.</summary>
private static void ExpectMeasure(SequenceView view, EditorTab tab)
{