feat(editor): open server sequences with proxies, hero frame to the index, export sync and saved copies
Server sequences that are not in the local index open through a RemoteSequenceSource: proxies from the cache, project from the server's settings with their version (a 409 merges again), analysis report from the server, analyses and renders posted as server jobs (one per preset) and followed through the server's events. Set hero now reaches the index (SequenceEdit.HeroFrameId) so the Library card shows it. The Export tab gains the Sync option (remembered in the project) and restores "Save both" copies through undo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
36 files changed
+1307
-116
No files matched your search
@@ -69,6 +69,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
private IThumbnailSource _thumbnails;
|
||||
private int _playLimit;
|
||||
private double? _analysisSecondsPerFrame;
|
||||
private ExportSyncGate _syncGate = ExportSyncGate.SignedOut;
|
||||
private bool _disposed;
|
||||
|
||||
public EditorViewModel(ShellViewModel shell, EditorSession session, IReadOnlyList<IVideoEncoderProvider> encoders, EncoderHost host)
|
||||
@@ -107,7 +108,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
session.ProjectChanged += OnProjectChanged;
|
||||
session.ContentChanged += OnContentChanged;
|
||||
session.SaveFailed += OnSaveFailed;
|
||||
if (shell.Services.Jobs is { } jobs) jobs.JobChanged += OnJobChanged;
|
||||
session.Source.JobChanged += OnJobChanged;
|
||||
shell.Services.Sync.Changed += OnSyncChanged;
|
||||
UpdateMarkers();
|
||||
RequestCorrections();
|
||||
RequestPlan();
|
||||
@@ -122,6 +124,25 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
|
||||
public string Title => Session.Content.Sequence.DisplayTitle;
|
||||
|
||||
/// <summary>A server sequence edited with proxies (the header says where it lives).</summary>
|
||||
public bool IsRemote => Session.IsRemote;
|
||||
|
||||
/// <summary>"Studio NAS" beside the title of a server sequence.</summary>
|
||||
public string? RemoteText => IsRemote ? Shell.Services.Server.ServerName ?? Loc.L("Server.Label.Server") : null;
|
||||
|
||||
public string? RemoteToolTip => IsRemote ? Loc.L("Tooltips.Editor.Remote", RemoteText ?? string.Empty) : null;
|
||||
|
||||
/// <summary>"Render · 46 %" while an analysis or render of a server sequence runs on the server (the job bar shows this PC's jobs).</summary>
|
||||
public string? ServerJobText => ServerJob is { } job ? EditorText.ServerJob(job) : null;
|
||||
|
||||
/// <summary>Frames, speed and time left of the server job.</summary>
|
||||
public string? ServerJobToolTip => ServerJob is { } job ? EditorText.ServerJobDetail(job, RemoteText ?? string.Empty) : null;
|
||||
|
||||
/// <summary>The Export "Sync" option: available, or why not.</summary>
|
||||
public ExportSyncGate SyncGate { get => _syncGate; private set => Set(ref _syncGate, value); }
|
||||
|
||||
private Job? ServerJob => IsRemote ? _jobs.Values.Where(j => j.State == JobState.Running).OrderBy(j => j.Started).FirstOrDefault() : null;
|
||||
|
||||
/// <summary>
|
||||
/// "3,600 frames · Canon EOS R5 · 2 s interval · 2 h 00 m · 3 warnings"; on the Export tab what the video will be:
|
||||
/// "3,600 frames · 24 fps · 2 min 30 s · 3840×2160 · source 8192×5464" (Export.html).
|
||||
@@ -364,7 +385,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
null when _planned => Loc.L("Tooltips.Editor.Render.NoSource"),
|
||||
null => Loc.L("Tooltips.Editor.Render.Planning"),
|
||||
{ NameError: { } error } => Loc.L("Tooltips.Editor.Render.NameError", error),
|
||||
{ Setup.Encoder.IsReady: false } plan => plan.Setup.Encoder.Notices.LastOrDefault() is { } notice
|
||||
// The server picks its encoder (a render node, or its managed fallback): this PC's encoders do not decide.
|
||||
{ Setup.Encoder.IsReady: false } plan when !IsRemote => plan.Setup.Encoder.Notices.LastOrDefault() is { } notice
|
||||
? Loc.L(notice.Key, [.. notice.Args])
|
||||
: Loc.L("Editor.Export.Unavailable"),
|
||||
{ Setup.Plan.Frames.Count: 0 } => Loc.L("Tooltips.Editor.Render.NoFrames"),
|
||||
@@ -399,13 +421,17 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// <summary>"Optimise section": the advisor's heavier decisions, reported in a toast (what changed, from what to what).</summary>
|
||||
public void Optimise(AdvisorSection section) => Report(Session.Optimise(section));
|
||||
|
||||
/// <summary>Queues a render of the project's export (with its batch presets when <paramref name="batch"/>).</summary>
|
||||
/// <summary>
|
||||
/// Queues a render of the project's export (with its batch presets when <paramref name="batch"/>): on this PC's
|
||||
/// engine, or one server job per preset for a server sequence.
|
||||
/// </summary>
|
||||
public async Task RenderAsync(JobPriority priority, bool batch)
|
||||
{
|
||||
var export = batch ? Session.Project.Export : Session.Project.Export with { Batch = [] };
|
||||
var request = Session.RenderRequest(export) with { Priority = priority };
|
||||
await Session.SubmitAsync(request);
|
||||
Shell.Notify(Loc.L("Editor.Render.Queued"), request.Label, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
var requests = Session.RenderRequests(export);
|
||||
foreach (var request in requests) await Session.SubmitAsync(request with { Priority = priority });
|
||||
if (IsRemote) Shell.Notify(Loc.L("Editor.Render.QueuedServer", RemoteText ?? string.Empty), requests[0].Label);
|
||||
else Shell.Notify(Loc.L("Editor.Render.Queued"), requests[0].Label, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
}
|
||||
|
||||
/// <summary>Re-reads the enabled state of every command (the async ones keep their own event).</summary>
|
||||
@@ -452,14 +478,29 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
Task[] Work() => [_preview.Idle, _corrections.Idle, _plans.Idle, .. Tabs.OfType<ExportTab>().Select(t => t.EstimatesIdle)];
|
||||
}
|
||||
|
||||
/// <summary>Loads the jobs of this sequence already queued or running (busy state) and the speed of the last analysis.</summary>
|
||||
/// <summary>
|
||||
/// Loads the jobs of this sequence already queued or running (busy state), the speed of the last analysis and
|
||||
/// whether the Export "Sync" option applies.
|
||||
/// </summary>
|
||||
public async Task AttachJobsAsync()
|
||||
{
|
||||
if (Shell.Services.Jobs is not { } jobs) return;
|
||||
var page = await jobs.ListAsync(null, 200);
|
||||
foreach (var job in page.Items) Track(job);
|
||||
foreach (var job in page.Items.OrderBy(j => j.Finished)) LearnAnalysisSpeed(job);
|
||||
var jobs = await Session.Source.ListJobsAsync(CancellationToken.None);
|
||||
foreach (var job in jobs) Track(job);
|
||||
foreach (var job in jobs.OrderBy(j => j.Finished)) LearnAnalysisSpeed(job);
|
||||
OnBusyChanged();
|
||||
await RefreshSyncGateAsync();
|
||||
}
|
||||
|
||||
/// <summary>Reads again whether this sequence can send its renders to the signed-in server (session, link, rights).</summary>
|
||||
public async Task RefreshSyncGateAsync()
|
||||
{
|
||||
var sync = Shell.Services.Sync;
|
||||
var server = sync.Server;
|
||||
var linked = !IsRemote && server is not null && sync.Service is { } service
|
||||
&& await service.LinkOfAsync(server, Session.Content.Sequence.Id) is not null;
|
||||
if (_disposed) return;
|
||||
SyncGate = ExportSync.Gate(IsRemote, server, linked, sync.CanUpload);
|
||||
foreach (var tab in Tabs) tab.OnSyncGateChanged();
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
@@ -473,7 +514,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
Session.ProjectChanged -= OnProjectChanged;
|
||||
Session.ContentChanged -= OnContentChanged;
|
||||
Session.SaveFailed -= OnSaveFailed;
|
||||
if (Shell.Services.Jobs is { } jobs) jobs.JobChanged -= OnJobChanged;
|
||||
Session.Source.JobChanged -= OnJobChanged;
|
||||
Shell.Services.Sync.Changed -= OnSyncChanged;
|
||||
foreach (var tab in Tabs) tab.Dispose();
|
||||
base.Dispose();
|
||||
await Session.DisposeAsync();
|
||||
@@ -757,6 +799,22 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>The session, the sync links or the rights changed (any thread): whether the Export "Sync" option applies.</summary>
|
||||
private void OnSyncChanged() => _dispatcher.BeginInvoke(() => _ = OnSyncChangedAsync());
|
||||
|
||||
private async Task OnSyncChangedAsync()
|
||||
{
|
||||
if (_disposed) return;
|
||||
try
|
||||
{
|
||||
await RefreshSyncGateAsync();
|
||||
}
|
||||
catch (Data.DatabaseException ex)
|
||||
{
|
||||
Log.Warning("editor", "The sync state of the sequence could not be read", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void Track(Job job)
|
||||
{
|
||||
if (!job.TargetIds.Contains(Session.Content.Sequence.Id) || job.Kind is not (JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render)) return;
|
||||
@@ -777,13 +835,17 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
{
|
||||
await Session.ReloadAsync();
|
||||
}
|
||||
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or UnauthorizedAccessException)
|
||||
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or UnauthorizedAccessException
|
||||
or System.Net.Http.HttpRequestException or Protocol.Client.TitanoApiException)
|
||||
{
|
||||
Shell.ReportError(ex);
|
||||
return;
|
||||
}
|
||||
if (render is null || _disposed) return;
|
||||
var output = Session.Content.Renders.FirstOrDefault(r => render.Started is not { } started || r.Created >= started)?.OutputPath;
|
||||
// A server's render stays on the server: nothing to show in Explorer.
|
||||
var output = Session.Content.Renders.FirstOrDefault(r => render.Started is not { } started || r.Created >= started)?.OutputPath is { Length: > 0 } path
|
||||
? path
|
||||
: null;
|
||||
Shell.ShowToast(new Toast
|
||||
{
|
||||
Title = Loc.L("Editor.Render.Done"),
|
||||
@@ -802,6 +864,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
OnPropertyChanged(nameof(BusyToolTip));
|
||||
OnPropertyChanged(nameof(AnalyseToolTip));
|
||||
OnPropertyChanged(nameof(OptimiseAllToolTip));
|
||||
OnPropertyChanged(nameof(ServerJobText));
|
||||
OnPropertyChanged(nameof(ServerJobToolTip));
|
||||
foreach (var tab in Tabs) tab.OnBusyChanged();
|
||||
RefreshCommands();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user