fix(editor): server jobs, stale proxies and read-only accounts in the remote editor
- A server sequence whose cached frames are no longer the server's (a load, a 409 merge or a frames change event finds other frame ids) turns read-only and says why; opening it, or a sequence without cached proxies, queues the proxy download and opens it when done. Signed out reads "Connect to the server". - Server jobs show queued, running (with a bar), paused and analysing glyphs in the header with Cancel; a failed or cancelled one raises a toast with Retry. Progress alone no longer refreshes the whole editor. - The server job list is read by state and kind to its last page; "Add to queue" sets the job's priority; the event listener survives any failure and always releases its frames and connection. - An account that may render but not edit picks the preset to render without changing the project; preset cards and their batch boxes say why they wait. - Export tab of a server sequence: no local encoder, notices or folder; no Jobs history link. Sync at 12 px beside a folder that keeps 96 px and trims. - Restore's Undo puts back the project from before the restore, only while that restore is the editor's last change. - Export "Sync" of a render that ends while the session is down is queued for the saved session's server; skips are logged; sync follows the engine before it starts. - Capture: sequence-remote-export, -running and -readonly, and sequence-export-copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
27 files changed
+932
-173
No files matched your search
@@ -9,14 +9,20 @@ using Titano.Protocol.Client;
|
||||
namespace Titano.App.Tests.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// One server sequence as the API serves it to an editor: settings with a version that refuses stale edits (409),
|
||||
/// recorded edits and posted jobs, jobs other clients run, an analysis report and an event stream the test feeds.
|
||||
/// One server sequence as the API serves it to an editor: its frames, settings with a version that refuses stale edits
|
||||
/// (409), recorded edits and posted jobs (with their priority, cancel and retry), jobs other clients run, an analysis
|
||||
/// report and an event stream the test feeds.
|
||||
/// </summary>
|
||||
internal sealed class FakeRemoteSequenceApi(Sequence sequence) : IRemoteSequenceApi
|
||||
internal sealed class FakeRemoteSequenceApi(Sequence sequence, IReadOnlyList<Guid> frames) : IRemoteSequenceApi
|
||||
{
|
||||
private readonly Lock _gate = new();
|
||||
private readonly Channel<ServerEvent> _events = Channel.CreateUnbounded<ServerEvent>();
|
||||
|
||||
/// <summary>The server's frames in order (another list when frames are added or removed on the server).</summary>
|
||||
public IReadOnlyList<Guid> Frames { get; set; } = frames;
|
||||
|
||||
public int FramesVersion { get; set; } = 1;
|
||||
|
||||
public string? SettingsJson { get; set; }
|
||||
|
||||
public int SettingsVersion { get; set; } = 3;
|
||||
@@ -30,6 +36,9 @@ internal sealed class FakeRemoteSequenceApi(Sequence sequence) : IRemoteSequence
|
||||
|
||||
public List<CreateJobRequest> Posted { get; } = [];
|
||||
|
||||
/// <summary>Priorities set after jobs were posted (job, wire name).</summary>
|
||||
public List<(Guid Job, string Priority)> Priorities { get; } = [];
|
||||
|
||||
public Dictionary<Guid, JobDto> Jobs { get; } = [];
|
||||
|
||||
/// <summary>Someone else edits the settings before each of the next edits reaches the server (it is refused with 409).</summary>
|
||||
@@ -54,7 +63,8 @@ internal sealed class FakeRemoteSequenceApi(Sequence sequence) : IRemoteSequence
|
||||
lock (_gate)
|
||||
{
|
||||
Check(id);
|
||||
return Task.FromResult(new SequenceManifest(id, 1, SettingsVersion, SettingsJson, [], [], [
|
||||
return Task.FromResult(new SequenceManifest(id, FramesVersion, SettingsVersion, SettingsJson, [],
|
||||
[.. Frames.Select((frame, i) => new ManifestFrame(frame, i, $"IMG_{i:0000}.JPG", 1_000, "00", true, true))], [
|
||||
new RenderDto(Guid.CreateVersion7(), "4K archive", "hevc", 3840, 2160, 24, 5, 2_000_000_000, DateTimeOffset.UtcNow.AddDays(-1), "studio-pc"),
|
||||
]));
|
||||
}
|
||||
@@ -117,6 +127,17 @@ internal sealed class FakeRemoteSequenceApi(Sequence sequence) : IRemoteSequence
|
||||
lock (_gate) return Task.FromResult<IReadOnlyList<JobDto>>([.. Jobs.Values.Where(j => j.State is "queued" or "running" or "paused")]);
|
||||
}
|
||||
|
||||
public Task<JobDto> CancelJobAsync(Guid id, CancellationToken cancellationToken) =>
|
||||
Change(id, job => job with { State = "cancelled", Finished = DateTimeOffset.UtcNow });
|
||||
|
||||
public Task<JobDto> RetryJobAsync(Guid id, CancellationToken cancellationToken) => Change(id, job => job with { State = "queued", Error = null, Finished = null });
|
||||
|
||||
public Task<JobDto> SetJobPriorityAsync(Guid id, string priority, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_gate) Priorities.Add((id, priority));
|
||||
return Change(id, job => job with { Priority = priority });
|
||||
}
|
||||
|
||||
public async IAsyncEnumerable<ServerEvent> EventsAsync([EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
while (await _events.Reader.WaitToReadAsync(cancellationToken))
|
||||
@@ -135,6 +156,15 @@ internal sealed class FakeRemoteSequenceApi(Sequence sequence) : IRemoteSequence
|
||||
null, SettingsVersion, 1, 0, null, DateTimeOffset.UtcNow);
|
||||
}
|
||||
|
||||
private Task<JobDto> Change(Guid id, Func<JobDto, JobDto> change)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (!Jobs.TryGetValue(id, out var job)) throw new TitanoApiException(HttpStatusCode.NotFound, new ApiError("not_found", "job", "job"));
|
||||
return Task.FromResult(Jobs[id] = change(job));
|
||||
}
|
||||
}
|
||||
|
||||
private void Check(Guid id)
|
||||
{
|
||||
if (Gone || id != sequence.Id) throw new TitanoApiException(HttpStatusCode.NotFound, new ApiError("not_found", "gone", "sequence"));
|
||||
|
||||
Reference in new issue
Block a user