feat(workspace): render a project on this PC from its originals
A workspace project that holds its originals now renders locally (JobKind.WorkspaceRender), so the full-resolution render no longer waits on the home. This holds also when the home is a server. - The handler reads its inputs under the project's lease. It refuses proxies-only media, and it refuses frames without an original, saying how many lack one. It renders into exports/ with unique names and a resumable checkpoint. - Each output gets a ledger entry: SHA-256, the render id from RenderJobHandler.RenderId, and the version, recorded only when versions/ holds it and its hash verifies. - After rendering, the handler queues a WorkspaceSend follow-up for the outputs it recorded. A cancel leaves no partial file. - The editor routes Originals media to the local engine even for a server home, and lists those jobs beside the server's. It treats WorkspaceRender like Render for the toast and the reload, says "Sent home" when a send ends, and shows unsent ledger renders as "Not sent". - Version on render saves a changed project as a version noted "Render" before it renders, and sends it with Sync automatically. With the setting off, the render behaves as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c51d11080
commit
59e7aca006
12 files changed
+779
-32
No files matched your search
@@ -327,6 +327,9 @@
|
||||
ToolTip="{l:Loc Tooltips.Editor.Export.History}" Margin="6,0,0,0" Visibility="{Binding CanOpenHistory, Converter={StaticResource BoolToVisibility}}" />
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Link}" Content="{l:Loc Editor.Export.Reveal}" Command="{Binding RevealLastCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Render.Reveal}" Margin="6,0,0,0" Visibility="{Binding CanReveal, Converter={StaticResource BoolToVisibility}}" />
|
||||
<TextBlock DockPanel.Dock="Right" Text="{l:Loc Editor.Render.NotSent}" Style="{StaticResource Text.Faint}" FontSize="{StaticResource Size.Chip}"
|
||||
VerticalAlignment="Center" Margin="6,0,0,0" ToolTip="{Binding UnsentToolTip}"
|
||||
Visibility="{Binding HasUnsent, Converter={StaticResource BoolToVisibility}}" />
|
||||
<TextBlock Text="{Binding HistoryText}" Style="{StaticResource Text.Faint}" FontSize="{StaticResource Size.Chip}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center"
|
||||
ToolTip="{Binding HistoryText}" />
|
||||
</DockPanel>
|
||||
|
||||
@@ -634,7 +634,9 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
var export = batch ? RenderExport : RenderExport with { Batch = [] };
|
||||
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", ServerName), requests[0].Label);
|
||||
if (Session.Source is IProjectRenders { RendersLocally: true })
|
||||
Shell.Notify(Loc.L("Editor.Render.QueuedLocal"), requests[0].Label, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
else if (IsRemote) Shell.Notify(Loc.L("Editor.Render.QueuedServer", ServerName), 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));
|
||||
}
|
||||
|
||||
@@ -957,7 +959,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
private void RefreshSteps()
|
||||
{
|
||||
if (_disposed) return;
|
||||
var facts = new PathFacts(Session.Content, Session.Advice, Session.Project, _jobs.Active(JobKind.DeepAnalyse), _jobs.Active(JobKind.Render),
|
||||
var facts = new PathFacts(Session.Content, Session.Advice, Session.Project, _jobs.Active(JobKind.DeepAnalyse), _jobs.Active(JobKind.Render) ?? _jobs.Active(JobKind.WorkspaceRender),
|
||||
_planned ? RenderBlockedReason : null, _rendered.Matches(Session.Project));
|
||||
foreach (var tab in Tabs) tab.SetStep(EditPath.Of(tab.Key, facts));
|
||||
Analysis.OnStepChanged();
|
||||
@@ -1174,7 +1176,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
if (_disposed)
|
||||
{
|
||||
// Closed after the Jobs screen left this render's end to it (FollowsRender): said without a read.
|
||||
if (job is { Kind: JobKind.Render, State: JobState.Done } && _jobs.IsActive(job.Id) && Shell.Jobs.ClaimRenderToast(job.Id))
|
||||
if (job is { State: JobState.Done } && IsRender(job.Kind) && _jobs.IsActive(job.Id) && Shell.Jobs.ClaimRenderToast(job.Id))
|
||||
AnnounceRender(job, read: false);
|
||||
return;
|
||||
}
|
||||
@@ -1186,13 +1188,19 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
if (!wasActive) return;
|
||||
if (job is { Kind: JobKind.DeepAnalyse, State: JobState.Done }) ClearVisited();
|
||||
// A render this editor followed to its end is said here, with its output, unless the Jobs screen said it first.
|
||||
if (job.State == JobState.Done) _ = ReloadAsync(job.Kind == JobKind.Render && Shell.Jobs.ClaimRenderToast(job.Id) ? job : null);
|
||||
if (job.State == JobState.Done) _ = ReloadAsync(IsRender(job.Kind) && Shell.Jobs.ClaimRenderToast(job.Id) ? job : null);
|
||||
// A local render's send home (phase 5c): said once, here or on the Jobs screen.
|
||||
if (job is { Kind: JobKind.WorkspaceSend, State: JobState.Done } && Shell.Jobs.ClaimRenderToast(job.Id)) Shell.Notify(Loc.L("Editor.Render.SentHome"), Title);
|
||||
// An analysis may have written its Auto values into the library's settings (Main): the project takes them or says so.
|
||||
if (job.State == JobState.Done && _project is { } project) _ = project.JobEndedAsync(job);
|
||||
else if (IsRemote && job.State is JobState.Failed or JobState.Cancelled) ReportServerJobEnded(job);
|
||||
else if (IsRemote && job.Kind is not (JobKind.WorkspaceRender or JobKind.WorkspaceSend) && job.State is JobState.Failed or JobState.Cancelled)
|
||||
ReportServerJobEnded(job);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>A render of the sequence: at its home, or on this PC from a workspace project's originals (phase 5c).</summary>
|
||||
private static bool IsRender(JobKind kind) => kind is JobKind.Render or JobKind.WorkspaceRender;
|
||||
|
||||
/// <summary>
|
||||
/// The frames of the server sequence changed while it is open, or a workspace project's sync took a newer Chronos's
|
||||
/// settings (any thread): everything that changes the project is disabled and says why, and a toast says so (for a
|
||||
|
||||
@@ -403,6 +403,14 @@ public sealed class ExportTab : EditorTab
|
||||
? Loc.Plural("Editor.Export.History", renders.Count, Formatting.Date(renders[0].Created))
|
||||
: Loc.L("Editor.Export.NoHistory");
|
||||
|
||||
/// <summary>A workspace project's renders made on this PC that are not at its home yet (phase 5c): "Not sent".</summary>
|
||||
public bool HasUnsent => Editor.Session.Source is WorkspaceSequenceSource { UnsentRenders: > 0 };
|
||||
|
||||
/// <summary>Why the renders are not in the library (or on the server) yet, and that their files stay in the workspace.</summary>
|
||||
public string? UnsentToolTip => Editor.Session.Source is WorkspaceSequenceSource { UnsentRenders: > 0 } source
|
||||
? Loc.L(source.IsServerHome ? "Tooltips.Editor.Render.NotSent.Server" : "Tooltips.Editor.Render.NotSent")
|
||||
: null;
|
||||
|
||||
public IReadOnlyList<string> Batch => Export.Batch;
|
||||
|
||||
/// <summary>Completes when the card estimates in flight are done.</summary>
|
||||
|
||||
@@ -11,8 +11,8 @@ public sealed class SequenceJobs(Guid sequenceId)
|
||||
{
|
||||
private readonly Dictionary<Guid, Job> _active = [];
|
||||
|
||||
/// <summary>An analysis or render runs: settings wait.</summary>
|
||||
public bool IsBusy => _active.Values.Any(j => j.State == JobState.Running);
|
||||
/// <summary>An analysis or render runs: settings wait (a local render's send home does not hold them).</summary>
|
||||
public bool IsBusy => _active.Values.Any(j => j.State == JobState.Running && j.Kind != JobKind.WorkspaceSend);
|
||||
|
||||
/// <summary>A deep analysis waits, runs or is paused.</summary>
|
||||
public bool IsAnalysing => _active.Values.Any(j => j.Kind == JobKind.DeepAnalyse);
|
||||
@@ -23,13 +23,17 @@ public sealed class SequenceJobs(Guid sequenceId)
|
||||
/// <summary>The job of <paramref name="kind"/> to show, chosen as <see cref="Shown"/> is (the Edit path's steps).</summary>
|
||||
public Job? Active(JobKind kind) => First(_active.Values.Where(j => j.Kind == kind));
|
||||
|
||||
/// <summary>An analysis or render of this sequence.</summary>
|
||||
/// <summary>An analysis or render of this sequence, a workspace project's render on this PC or its send home (phase 5c).</summary>
|
||||
public bool Concerns(Job job)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
return job.TargetIds.Contains(sequenceId) && job.Kind is JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render;
|
||||
return job.TargetIds.Contains(sequenceId) && IsSequenceKind(job.Kind);
|
||||
}
|
||||
|
||||
/// <summary>The kinds the editor follows.</summary>
|
||||
public static bool IsSequenceKind(JobKind kind) =>
|
||||
kind is JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render or JobKind.WorkspaceRender or JobKind.WorkspaceSend;
|
||||
|
||||
/// <summary>The job is one of those that wait, run or are paused.</summary>
|
||||
public bool IsActive(Guid jobId) => _active.ContainsKey(jobId);
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ internal sealed class ServerJobs : IAsyncDisposable
|
||||
_changed(job);
|
||||
}
|
||||
|
||||
private bool Concerns(Job job) => job.TargetIds.Contains(_sequenceId) && job.Kind is JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render;
|
||||
private bool Concerns(Job job) => job.TargetIds.Contains(_sequenceId) && SequenceJobs.IsSequenceKind(job.Kind);
|
||||
|
||||
/// <summary>A sequence deleted on the server reads as gone, like a local one removed from the index.</summary>
|
||||
internal static async Task<T> Call<T>(Func<Task<T>> call)
|
||||
|
||||
@@ -29,6 +29,9 @@ public interface IProjectRenders
|
||||
{
|
||||
/// <summary>The jobs that render <paramref name="export"/> of <paramref name="project"/> (the editor's settings, positions on the source's frames).</summary>
|
||||
IReadOnlyList<ArchiveJobRequest> RenderRequests(Sequence sequence, ProjectSettings project, ExportSettings export, int sourceWidth, int sourceHeight);
|
||||
|
||||
/// <summary>The renders run on this PC (a workspace project holding its originals, phase 5c), whatever the home.</summary>
|
||||
bool RendersLocally { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -95,6 +98,8 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
private FramePhotos _photos = new([]);
|
||||
private BundleWorkspace? _workspace;
|
||||
private bool _readOnly;
|
||||
private bool _holdsOriginals;
|
||||
private int _unsent;
|
||||
private int _disposed;
|
||||
|
||||
/// <param name="server">The server the project's home is (phase 5b); null for a project of this PC's archive.</param>
|
||||
@@ -136,6 +141,15 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
/// <summary>Settings of a newer Chronos: shown, never saved.</summary>
|
||||
public bool IsReadOnly => Volatile.Read(ref _readOnly);
|
||||
|
||||
/// <summary>
|
||||
/// The media read last hold the originals (phase 5c): the project renders on this PC's engine from them, into its
|
||||
/// <c>exports/</c>, and the renders are sent home after (<see cref="JobKind.WorkspaceRender"/>), also for a server home.
|
||||
/// </summary>
|
||||
public bool RendersLocally => Volatile.Read(ref _holdsOriginals);
|
||||
|
||||
/// <summary>The local renders of the project's ledger not at the home yet, as read last.</summary>
|
||||
public int UnsentRenders => Volatile.Read(ref _unsent);
|
||||
|
||||
public bool IsOutdated => false;
|
||||
|
||||
/// <summary>The library's values and the editor's are asked about where both changed a setting, as a sync asks.</summary>
|
||||
@@ -179,6 +193,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
IReadOnlyList<Render> renders = row is null ? [] : await _db.Renders.ListBySequenceAsync(home.SequenceId, cancellationToken);
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
renders = [.. renders, .. UnsentOf(session.Project, home.SequenceId)];
|
||||
var frames = media.Frames;
|
||||
Swap(media, index, session.Bundle.Workspace!, session.IsReadOnly);
|
||||
var times = frames.Where(f => f.CapturedAt is not null).Select(f => f.CapturedAt!.Value).Order().ToList();
|
||||
@@ -278,6 +293,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
Created = r.Created,
|
||||
ProducedBy = r.ProducedBy,
|
||||
}).ToList() ?? [];
|
||||
renders = [.. renders.Concat(UnsentOf(session.Project, home.SequenceId)).OrderByDescending(r => r.Created)];
|
||||
var (deep, otherFrames) = ServerReport(report, session.Project.AnalysisPath, frames.Count);
|
||||
var context = SequenceContext.FromFrames(frames);
|
||||
return new SequenceContent(sequence, frames, session.Working, LightAnalyzer.Analyze(frames), deep, context.SourceWidth, context.SourceHeight, null, renders, [])
|
||||
@@ -495,7 +511,9 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
/// <remarks>A project whose home is a server queues its analyses and renders there; while this PC is not signed in to it, they are refused saying so.</remarks>
|
||||
public async Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_server is not null) return await ServerJobsOrThrow().SubmitAsync(request, cancellationToken);
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
// A render from the workspace's originals and its send run on this PC's engine, whatever the home (phase 5c).
|
||||
if (_server is not null && !RunsHere(request.Kind)) return await ServerJobsOrThrow().SubmitAsync(request, cancellationToken);
|
||||
if (_engine is null) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
var job = await _engine.EnqueueAsync(request, cancellationToken: cancellationToken);
|
||||
return job.Id;
|
||||
@@ -504,26 +522,40 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
/// <remarks>A server home's jobs are the server's; none are listed while it cannot be reached (the project opens all the same).</remarks>
|
||||
public async Task<IReadOnlyList<Job>> ListJobsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if (_server is null) return (await _db.Jobs.ListAsync(null, JobsListed, null, cancellationToken)).Items;
|
||||
if (Api() is null || Volatile.Read(ref _serverJobs) is not { } jobs) return [];
|
||||
var local = (await _db.Jobs.ListAsync(null, JobsListed, null, cancellationToken)).Items;
|
||||
if (_server is null) return local;
|
||||
// This PC's renders from the originals and their sends beside the server's jobs (phase 5c).
|
||||
IReadOnlyList<Job> here = [.. local.Where(j => RunsHere(j.Kind))];
|
||||
if (Api() is null || Volatile.Read(ref _serverJobs) is not { } jobs) return here;
|
||||
try
|
||||
{
|
||||
return await jobs.ListAsync(cancellationToken);
|
||||
return [.. (await jobs.ListAsync(cancellationToken)).Concat(here)];
|
||||
}
|
||||
catch (Exception ex) when (ServerProjectHome.IsUnavailable(ex, cancellationToken) || ex is ChronosApiException or EditorException)
|
||||
{
|
||||
Log.Info("editor", $"The server's jobs of workspace project {ProjectId} are not read now: {ex.Message}");
|
||||
return [];
|
||||
return here;
|
||||
}
|
||||
}
|
||||
|
||||
public Task CancelJobAsync(Guid jobId, CancellationToken cancellationToken) => _server is not null
|
||||
? ServerJobsOrThrow().CancelAsync(jobId, cancellationToken)
|
||||
: (_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).CancelAsync(jobId, cancellationToken);
|
||||
public async Task CancelJobAsync(Guid jobId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_server is not null && !await IsLocalJobAsync(jobId, cancellationToken)) await ServerJobsOrThrow().CancelAsync(jobId, cancellationToken);
|
||||
else await (_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).CancelAsync(jobId, cancellationToken);
|
||||
}
|
||||
|
||||
public Task RetryJobAsync(Guid jobId, CancellationToken cancellationToken) => _server is not null
|
||||
? ServerJobsOrThrow().RetryAsync(jobId, cancellationToken)
|
||||
: (_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).ResumeAsync(jobId, cancellationToken);
|
||||
public async Task RetryJobAsync(Guid jobId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (_server is not null && !await IsLocalJobAsync(jobId, cancellationToken)) await ServerJobsOrThrow().RetryAsync(jobId, cancellationToken);
|
||||
else await (_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).ResumeAsync(jobId, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>The kinds a workspace project runs on this PC's engine whatever its home: a render from its originals and its send home.</summary>
|
||||
private static bool RunsHere(JobKind kind) => kind is JobKind.WorkspaceRender or JobKind.WorkspaceSend;
|
||||
|
||||
/// <summary>A job of this PC's engine that runs here whatever the home (<see cref="RunsHere"/>).</summary>
|
||||
private async Task<bool> IsLocalJobAsync(Guid jobId, CancellationToken cancellationToken) =>
|
||||
await _db.Jobs.GetAsync(jobId, cancellationToken) is { } job && RunsHere(job.Kind);
|
||||
|
||||
/// <summary>
|
||||
/// The render at the home (owner review 2, R8: edit with proxies, render where the originals are): one job per preset
|
||||
@@ -542,6 +574,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
ArgumentNullException.ThrowIfNull(export);
|
||||
var portable = ProjectContent.ToPortable(project with { Export = export }, Photos);
|
||||
var hash = ProjectContent.Hash(portable);
|
||||
if (RendersLocally && Workspace is { } workspace) return LocalRenderRequests(sequence, workspace.Home, portable, hash, export, sourceWidth, sourceHeight);
|
||||
if (_server is not null)
|
||||
{
|
||||
if (InStepWithHome(project) is { } basis)
|
||||
@@ -566,6 +599,75 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
return [.. requests.Select(r => r with { ParametersJson = WithoutVersion(r.ParametersJson) })];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The render on this PC from the originals the workspace holds (phase 5c): one <see cref="JobKind.WorkspaceRender"/> per
|
||||
/// preset with the project's portable settings, naming the head version of <c>versions/</c> when the settings are the
|
||||
/// ones it holds (the render records it; an unsaved working state renders without a version), sent home after.
|
||||
/// </summary>
|
||||
private IReadOnlyList<ArchiveJobRequest> LocalRenderRequests(Sequence sequence, BundleHome home, string portable, string hash, ExportSettings export,
|
||||
int sourceWidth, int sourceHeight)
|
||||
{
|
||||
var head = HeadVersion(hash);
|
||||
var version = new ProjectVersion { Id = head ?? Guid.Empty, ProjectId = ProjectId, Number = 0, SettingsJson = portable, ContentHash = hash };
|
||||
var root = _sync.Store.Root;
|
||||
var server = home.IsArchive ? null : home.Server;
|
||||
return
|
||||
[
|
||||
.. ProcessingJobs.RenderVersion(sequence, version, export, sourceWidth, sourceHeight).Select(r => WorkspaceJobs.Render(home.SequenceId,
|
||||
r.Label ?? sequence.DisplayTitle, root, ProjectId, head, (head is null ? WithoutVersion(r.ParametersJson) : r.ParametersJson)!, server)),
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>The id of the newest version the workspace holds when it holds <paramref name="hash"/>; null otherwise.</summary>
|
||||
private Guid? HeadVersion(string hash)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Project.Versions() is [.., var last] && string.Equals(last.ContentHash, hash, StringComparison.OrdinalIgnoreCase) ? last.Id : null;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning("editor", $"The versions of workspace project {ProjectId} cannot be read; the render names none", ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The local renders of the project's ledger not at the home yet, as renders of <paramref name="sequenceId"/> (newest first).</summary>
|
||||
private IReadOnlyList<Render> UnsentOf(WorkspaceProject project, Guid sequenceId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var unsent = project.ReadRenders().Unsent;
|
||||
Volatile.Write(ref _unsent, unsent.Count);
|
||||
return
|
||||
[
|
||||
.. unsent.OrderByDescending(e => e.Rendered).Select(e => new Render
|
||||
{
|
||||
Id = e.RenderId,
|
||||
SequenceId = sequenceId,
|
||||
PresetName = e.PresetName,
|
||||
OutputPath = project.ExportFile(e.File),
|
||||
Codec = e.Codec,
|
||||
Width = e.Width,
|
||||
Height = e.Height,
|
||||
Fps = e.Fps,
|
||||
DurationSeconds = e.DurationSeconds,
|
||||
Bytes = e.Size,
|
||||
Created = e.Rendered,
|
||||
ProducedBy = Environment.MachineName,
|
||||
ProjectId = e.ProjectId,
|
||||
ProjectVersionId = e.ProjectVersionId,
|
||||
}),
|
||||
];
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning("editor", $"The render ledger of workspace project {ProjectId} cannot be read", ex);
|
||||
Volatile.Write(ref _unsent, 0);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The home's version the project is in step with: its base, when no version waits to be sent and the editor's project
|
||||
/// (<paramref name="project"/>) holds what the base holds; null otherwise.
|
||||
@@ -643,6 +745,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
_photos = index.Photos;
|
||||
_standIns = [.. index.Frames.Where(f => f.IsStandIn).Select(f => f.Id)];
|
||||
_workspace = workspace;
|
||||
_holdsOriginals = index.HoldsOriginals;
|
||||
changed = _readOnly != readOnly;
|
||||
_readOnly = readOnly;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public sealed class JobsViewModel : SectionViewModel
|
||||
else if (before != JobState.Failed && !IsSelected) _unseenFailures.Add(job.Id);
|
||||
var notice = JobNotices.For(before, job);
|
||||
// A flush can take the end before the editor that follows the render has seen it: the editor says it, with its output.
|
||||
if (notice == JobNotice.Done && job.Kind == JobKind.Render
|
||||
if (notice == JobNotice.Done && job.Kind is JobKind.Render or JobKind.WorkspaceRender or JobKind.WorkspaceSend
|
||||
&& (Shell.Sequence.Editor?.FollowsRender(job.Id) == true || !ClaimRenderToast(job.Id))) return;
|
||||
_endings.Add(notice, job);
|
||||
}
|
||||
|
||||
@@ -252,12 +252,15 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
/// <summary>
|
||||
/// Before a render (phase 5b): a project whose home is a server renders what the server holds, so changes not saved as a
|
||||
/// version, or versions not sent, are first offered to be saved and sent (Sync); false when the user kept them here,
|
||||
/// the server could not take them or no longer has the project, or a conflict waits. A project of this PC's archive
|
||||
/// renders as it is: true.
|
||||
/// the server could not take them or no longer has the project, or a conflict waits. A project of this PC's archive,
|
||||
/// or one rendered on this PC from its originals (phase 5c), renders as it is: true. With Settings › Workspace › Version
|
||||
/// on render, a changed project is saved as a version first (<see cref="SaveForRenderAsync"/>).
|
||||
/// </summary>
|
||||
public async Task<bool> ReadyToRenderAsync()
|
||||
{
|
||||
if (!IsServerHome) return true;
|
||||
if (_host.Settings.WorkspaceVersionOnRender && !await SaveForRenderAsync()) return false;
|
||||
// Rendered on this PC from the originals the workspace holds (phase 5c): the project renders as it is.
|
||||
if (!IsServerHome || _source.RendersLocally) return true;
|
||||
await StoreEditAsync();
|
||||
var status = await _host.StatusAsync(ProjectId);
|
||||
if (_disposed) return false;
|
||||
@@ -296,6 +299,45 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
return !_disposed && _source.InStepWithHome(_session.Project) is not null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Settings › Workspace › Version on render (phase 5c): a project changed since its last version is saved as a version
|
||||
/// noted "Render" before its render, and sent at once with Sync automatically when the home can be reached (out of reach,
|
||||
/// it waits here). False when it could not be saved, or the sync met a conflict to settle first.
|
||||
/// </summary>
|
||||
private async Task<bool> SaveForRenderAsync()
|
||||
{
|
||||
await StoreEditAsync();
|
||||
var status = await _host.StatusAsync(ProjectId);
|
||||
if (_disposed) return false;
|
||||
Apply(status);
|
||||
if (!status.Modified || !CanSaveVersion) return true;
|
||||
WorkspaceSaveResult result;
|
||||
try
|
||||
{
|
||||
result = await _host.SaveVersionAsync(ProjectId, Loc.L("Editor.Workspace.RenderNote"));
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning("workspace", $"Project {ProjectId} could not be saved before its render", ex);
|
||||
_ui.Notify(Loc.L("Editor.Workspace.RenderHeld"), WorkspaceText.Failure(ex, IsServerHome), isError: true);
|
||||
return false;
|
||||
}
|
||||
if (_disposed) return false;
|
||||
Apply(result.Status);
|
||||
if (result.Synced is { } taken) await TakeAsync(taken);
|
||||
if (result.Version is { } version)
|
||||
{
|
||||
// The home numbers what it stores: the last one sent is this version.
|
||||
var number = result.Synced is { Pushed.Count: > 0 } synced ? synced.Pushed[^1].Number : version.Number;
|
||||
_ui.Notify(Loc.L("Editor.Workspace.SavedForRender", Formatting.Count(number)), Name);
|
||||
}
|
||||
if (result.SyncError is { } error)
|
||||
_ui.Notify(Loc.L("Editor.Workspace.NotSent"), WorkspaceText.Failure(error, IsServerHome), isError: error is not HomeUnavailableException);
|
||||
if (result.Status.Conflict is not { } conflict) return true;
|
||||
AskConflict(conflict);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the working state as a version with <paramref name="note"/>, sent at once with Sync automatically; what the
|
||||
/// sync took from the home comes into the editor, a conflict it met is asked about.
|
||||
|
||||
Reference in new issue
Block a user