feat(editor): accounts without the Edit right open server sequences read-only
The Server screen offers Open with proxies to viewers; the editor now shows the sequence with every change disabled and the reason in the tooltips, the session refuses edits, undo and Optimise, and the source refuses to store a change. Render says when the account may not render on the server. The event listener stops cleanly when the editor closes and a late progress event no longer brings a finished job back to running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
17 files changed
+151
-67
No files matched your search
@@ -193,10 +193,12 @@
|
||||
<data name="Tooltips.Editor.Preview.ShotData" xml:space="preserve"><value>Show or hide the shot data</value></data>
|
||||
<data name="Tooltips.Editor.Preview.Vectors" xml:space="preserve"><value>Overlay the motion to the next frame measured by the engine</value></data>
|
||||
<data name="Tooltips.Editor.Preview.View" xml:space="preserve"><value>Drag the line to compare · drag to pan · wheel zooms · double-click 1:1</value></data>
|
||||
<data name="Tooltips.Editor.ReadOnly" xml:space="preserve"><value>Your account can look at this server sequence but not change it</value></data>
|
||||
<data name="Tooltips.Editor.Remote" xml:space="preserve"><value>Edited with proxies on this PC; changes are saved on {0} and analyses and renders run there</value></data>
|
||||
<data name="Tooltips.Editor.Render" xml:space="preserve"><value>Render with the selected preset; progress in the job bar · Ctrl+R</value></data>
|
||||
<data name="Tooltips.Editor.Render.NameError" xml:space="preserve"><value>Fix the file name first: {0}</value></data>
|
||||
<data name="Tooltips.Editor.Render.NoFrames" xml:space="preserve"><value>Every frame is excluded: include some in the Frames tab</value></data>
|
||||
<data name="Tooltips.Editor.Render.NoRight" xml:space="preserve"><value>Your account cannot render on {0}</value></data>
|
||||
<data name="Tooltips.Editor.Render.NoSource" xml:space="preserve"><value>The frame size is unknown: the frames could not be read</value></data>
|
||||
<data name="Tooltips.Editor.Render.Planning" xml:space="preserve"><value>Working out the render; ready in a moment</value></data>
|
||||
<data name="Tooltips.Editor.Render.Reveal" xml:space="preserve"><value>Show the rendered file in Explorer</value></data>
|
||||
|
||||
@@ -193,10 +193,12 @@
|
||||
<data name="Tooltips.Editor.Preview.ShotData" xml:space="preserve"><value>Mostra o nasconde i dati di scatto</value></data>
|
||||
<data name="Tooltips.Editor.Preview.Vectors" xml:space="preserve"><value>Sovrappone il movimento verso il fotogramma successivo misurato dal motore</value></data>
|
||||
<data name="Tooltips.Editor.Preview.View" xml:space="preserve"><value>Trascina la linea per confrontare · trascina per spostare · la rotellina ingrandisce · doppio clic 1:1</value></data>
|
||||
<data name="Tooltips.Editor.ReadOnly" xml:space="preserve"><value>Il tuo account può vedere questa sequenza del server ma non modificarla</value></data>
|
||||
<data name="Tooltips.Editor.Remote" xml:space="preserve"><value>Modificata con i proxy su questo PC; le modifiche si salvano su {0} e analisi e render vengono eseguiti lì</value></data>
|
||||
<data name="Tooltips.Editor.Render" xml:space="preserve"><value>Renderizza con il preset scelto; avanzamento nella barra dei lavori · Ctrl+R</value></data>
|
||||
<data name="Tooltips.Editor.Render.NameError" xml:space="preserve"><value>Correggi prima il nome del file: {0}</value></data>
|
||||
<data name="Tooltips.Editor.Render.NoFrames" xml:space="preserve"><value>Tutti i fotogrammi sono esclusi: includine alcuni nella scheda Fotogrammi</value></data>
|
||||
<data name="Tooltips.Editor.Render.NoRight" xml:space="preserve"><value>Il tuo account non può renderizzare su {0}</value></data>
|
||||
<data name="Tooltips.Editor.Render.NoSource" xml:space="preserve"><value>La dimensione dei fotogrammi è sconosciuta: non è stato possibile leggerli</value></data>
|
||||
<data name="Tooltips.Editor.Render.Planning" xml:space="preserve"><value>Calcolo del render in corso; pronto tra un attimo</value></data>
|
||||
<data name="Tooltips.Editor.Render.Reveal" xml:space="preserve"><value>Mostra il file del render in Esplora file</value></data>
|
||||
|
||||
@@ -45,8 +45,8 @@ public sealed class CameraTab : EditorTab
|
||||
new NumberRow(s, "Editor.Camera.OffsetY", "Tooltips.Editor.Camera.OffsetY", -1, 1, 0.05, p => p.Camera.OffsetY,
|
||||
(p, v) => p with { Camera = p.Camera with { OffsetY = v } }, EditorText.Placement),
|
||||
];
|
||||
AddKeyCommand = new RelayCommand(AddKey, () => !Editor.IsBusy && Keys.All(k => k.Frame != Editor.CurrentIndex));
|
||||
RemoveKeyCommand = new RelayCommand(RemoveKey, () => !Editor.IsBusy && SelectedKey >= 0);
|
||||
AddKeyCommand = new RelayCommand(AddKey, () => !Editor.IsLocked && Keys.All(k => k.Frame != Editor.CurrentIndex));
|
||||
RemoveKeyCommand = new RelayCommand(RemoveKey, () => !Editor.IsLocked && SelectedKey >= 0);
|
||||
CommitCurveCommand = new RelayCommand(CommitCurve);
|
||||
Refresh();
|
||||
}
|
||||
@@ -103,13 +103,13 @@ public sealed class CameraTab : EditorTab
|
||||
public ICommand RemoveKeyCommand { get; }
|
||||
|
||||
/// <summary>What Add keyframe does, or why it cannot run now.</summary>
|
||||
public string AddKeyToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy"
|
||||
: Keys.Any(k => k.Frame == Editor.CurrentIndex) ? "Tooltips.Editor.Camera.KeyExists" : "Tooltips.Editor.Camera.AddKey");
|
||||
public string AddKeyToolTip => Editor.LockedToolTip
|
||||
?? Loc.L(Keys.Any(k => k.Frame == Editor.CurrentIndex) ? "Tooltips.Editor.Camera.KeyExists" : "Tooltips.Editor.Camera.AddKey");
|
||||
|
||||
/// <summary>How to edit the keyframe curve, or why it waits.</summary>
|
||||
public string CurveToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy" : "Tooltips.Editor.Camera.Curve");
|
||||
public string CurveToolTip => Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.Camera.Curve");
|
||||
|
||||
public string RemoveKeyToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy" : HasSelectedKey ? "Tooltips.Editor.Camera.RemoveKey" : "Tooltips.Editor.Camera.NoKey");
|
||||
public string RemoveKeyToolTip => Editor.LockedToolTip ?? Loc.L(HasSelectedKey ? "Tooltips.Editor.Camera.RemoveKey" : "Tooltips.Editor.Camera.NoKey");
|
||||
|
||||
/// <summary>Run by the curve editor after each finished edit.</summary>
|
||||
public ICommand CommitCurveCommand { get; }
|
||||
@@ -248,7 +248,7 @@ public sealed class TimeTab : EditorTab
|
||||
public ICommand CommitCurveCommand { get; }
|
||||
|
||||
/// <summary>How to edit the remap curve, or why it waits.</summary>
|
||||
public string CurveToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy" : "Tooltips.Editor.Time.Curve");
|
||||
public string CurveToolTip => Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.Time.Curve");
|
||||
|
||||
/// <summary>"3,600 frames → 2 min 30 s · 24 fps".</summary>
|
||||
public string? PlanText { get => _planText; private set => Set(ref _planText, value); }
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
ToolTip="{Binding ResetToolTip}" Visibility="{Binding CanReset, Converter={StaticResource BoolToVisibility}}" />
|
||||
</Grid>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Focusable="False">
|
||||
<StackPanel IsEnabled="{Binding Editor.IsEditable}" ToolTip="{Binding Editor.BusyToolTip}" ToolTipService.ShowOnDisabled="True">
|
||||
<StackPanel IsEnabled="{Binding Editor.IsEditable}" ToolTip="{Binding Editor.LockedToolTip}" ToolTipService.ShowOnDisabled="True">
|
||||
<ItemsControl ItemsSource="{Binding Rows}" Focusable="False" />
|
||||
<ContentPresenter />
|
||||
</StackPanel>
|
||||
@@ -301,7 +301,7 @@
|
||||
Visibility="{Binding HasSavedCopies, Converter={StaticResource BoolToVisibility}}" />
|
||||
</StackPanel>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Focusable="False">
|
||||
<StackPanel IsEnabled="{Binding Editor.IsEditable}" ToolTip="{Binding Editor.BusyToolTip}" ToolTipService.ShowOnDisabled="True">
|
||||
<StackPanel IsEnabled="{Binding Editor.IsEditable}" ToolTip="{Binding Editor.LockedToolTip}" ToolTipService.ShowOnDisabled="True">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{StaticResource Editor.Grid.Label}" />
|
||||
|
||||
@@ -54,6 +54,9 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
/// <summary>A server sequence edited with proxies: saved, analysed and rendered on the server.</summary>
|
||||
public bool IsRemote => Source.IsRemote;
|
||||
|
||||
/// <summary>The project is shown, not changed (<see cref="ISequenceSource.IsReadOnly"/>): edits, undo and redo do nothing.</summary>
|
||||
public bool IsReadOnly => Source.IsReadOnly;
|
||||
|
||||
public SequenceContent Content { get; private set; }
|
||||
|
||||
public SequenceContext Context { get; private set; }
|
||||
@@ -79,15 +82,15 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
public bool Edit(Func<ProjectSettings, ProjectSettings> change, string? mergeKey = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(change);
|
||||
return History.Apply(change(Project), mergeKey);
|
||||
return !IsReadOnly && History.Apply(change(Project), mergeKey);
|
||||
}
|
||||
|
||||
/// <summary>The drag or key press behind a run of merged edits ended (<see cref="ProjectHistory.EndRun"/>).</summary>
|
||||
public void EndEditRun() => History.EndRun();
|
||||
|
||||
public bool Undo() => History.Undo();
|
||||
public bool Undo() => !IsReadOnly && History.Undo();
|
||||
|
||||
public bool Redo() => History.Redo();
|
||||
public bool Redo() => !IsReadOnly && History.Redo();
|
||||
|
||||
/// <summary>"Optimise section": the advisor's heavier decisions for <paramref name="section"/>, one undo step; returns what changed.</summary>
|
||||
public IReadOnlyList<SettingChange> Optimise(AdvisorSection section) => Optimise([section]);
|
||||
@@ -199,6 +202,7 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
|
||||
private IReadOnlyList<SettingChange> Optimise(IReadOnlyList<AdvisorSection> sections)
|
||||
{
|
||||
if (IsReadOnly) return [];
|
||||
var settings = Project;
|
||||
var changes = new List<SettingChange>();
|
||||
foreach (var section in sections)
|
||||
|
||||
@@ -16,8 +16,8 @@ public abstract class EditorTab : LocalizedViewModel
|
||||
Editor = editor;
|
||||
Key = key;
|
||||
Section = section;
|
||||
OptimiseCommand = new RelayCommand(() => Editor.Optimise(Section), () => CanOptimise && !Editor.IsBusy);
|
||||
ResetCommand = new RelayCommand(() => Editor.Session.ResetSection(Section), () => CanReset && !Editor.IsBusy);
|
||||
OptimiseCommand = new RelayCommand(() => Editor.Optimise(Section), () => CanOptimise && !Editor.IsLocked);
|
||||
ResetCommand = new RelayCommand(() => Editor.Session.ResetSection(Section), () => CanReset && !Editor.IsLocked);
|
||||
}
|
||||
|
||||
public EditorViewModel Editor { get; }
|
||||
@@ -40,9 +40,9 @@ public abstract class EditorTab : LocalizedViewModel
|
||||
public virtual bool CanReset => true;
|
||||
|
||||
/// <summary>What Optimise section does, or why it cannot run now.</summary>
|
||||
public string OptimiseToolTip => Loc.L(!CanOptimise ? "Tooltips.Editor.OptimiseNone" : Editor.IsBusy ? "Tooltips.Editor.Busy" : "Tooltips.Editor.OptimiseSection");
|
||||
public string OptimiseToolTip => !CanOptimise ? Loc.L("Tooltips.Editor.OptimiseNone") : Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.OptimiseSection");
|
||||
|
||||
public string ResetToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy" : "Tooltips.Editor.ResetSection");
|
||||
public string ResetToolTip => Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.ResetSection");
|
||||
|
||||
public ICommand OptimiseCommand { get; }
|
||||
|
||||
|
||||
@@ -86,11 +86,11 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
_player.Tick += (_, _) => Advance();
|
||||
|
||||
BackCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Library));
|
||||
_analyse = new AsyncRelayCommand(AnalyseAsync, () => !IsBusy && !IsAnalysing);
|
||||
OptimiseAllCommand = new RelayCommand(OptimiseAll, () => !IsBusy);
|
||||
_analyse = new AsyncRelayCommand(AnalyseAsync, () => !IsLocked && !IsAnalysing);
|
||||
OptimiseAllCommand = new RelayCommand(OptimiseAll, () => !IsLocked);
|
||||
_render = new AsyncRelayCommand(() => RenderAsync(JobPriority.User, batch: false), () => CanRender);
|
||||
UndoCommand = new RelayCommand(() => Session.Undo(), () => !IsBusy && Session.History.CanUndo);
|
||||
RedoCommand = new RelayCommand(() => Session.Redo(), () => !IsBusy && Session.History.CanRedo);
|
||||
UndoCommand = new RelayCommand(() => Session.Undo(), () => !IsLocked && Session.History.CanUndo);
|
||||
RedoCommand = new RelayCommand(() => Session.Redo(), () => !IsLocked && Session.History.CanRedo);
|
||||
PlayCommand = new RelayCommand(() => TogglePlay(limit: 0));
|
||||
PreviewClipCommand = new RelayCommand(() => TogglePlay(limit: ClipFrames()));
|
||||
StepBackCommand = new RelayCommand(() => CurrentIndex--);
|
||||
@@ -337,17 +337,24 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// <summary>A deep analysis of this sequence is queued or running (Analyse would queue it twice).</summary>
|
||||
public bool IsAnalysing => _jobs.Values.Any(j => j.Kind == JobKind.DeepAnalyse);
|
||||
|
||||
public bool IsEditable => !IsBusy;
|
||||
/// <summary>The project is shown, not changed: a server sequence for an account without the Edit right.</summary>
|
||||
public bool IsReadOnly => Session.IsReadOnly;
|
||||
|
||||
public string? BusyToolTip => IsBusy ? Loc.L("Tooltips.Editor.Busy") : null;
|
||||
/// <summary>Changes to the project wait (a job runs) or are not allowed (<see cref="IsReadOnly"/>); viewing tools stay live.</summary>
|
||||
public bool IsLocked => IsReadOnly || IsBusy;
|
||||
|
||||
public bool IsEditable => !IsLocked;
|
||||
|
||||
/// <summary>Why the controls that change the project are disabled; null while they are not.</summary>
|
||||
public string? LockedToolTip => IsReadOnly ? Loc.L("Tooltips.Editor.ReadOnly") : IsBusy ? Loc.L("Tooltips.Editor.Busy") : null;
|
||||
|
||||
/// <summary>What Analyse does and costs ("about 6 min" from the speed of the last analysis), or why it is disabled.</summary>
|
||||
public string AnalyseToolTip => IsBusy ? Loc.L("Tooltips.Editor.Busy")
|
||||
: IsAnalysing ? Loc.L("Tooltips.Editor.AnalyseQueued")
|
||||
public string AnalyseToolTip => LockedToolTip
|
||||
?? (IsAnalysing ? Loc.L("Tooltips.Editor.AnalyseQueued")
|
||||
: _analysisSecondsPerFrame is { } perFrame ? Loc.L("Tooltips.Editor.AnalyseCost", Formatting.Duration(TimeSpan.FromSeconds(perFrame * FrameCount)))
|
||||
: Loc.L("Tooltips.Editor.Analyse");
|
||||
: Loc.L("Tooltips.Editor.Analyse"));
|
||||
|
||||
public string OptimiseAllToolTip => Loc.L(IsBusy ? "Tooltips.Editor.Busy" : "Tooltips.Editor.OptimiseAll");
|
||||
public string OptimiseAllToolTip => LockedToolTip ?? Loc.L("Tooltips.Editor.OptimiseAll");
|
||||
|
||||
public bool IsPlaying => _player.IsEnabled;
|
||||
|
||||
@@ -384,6 +391,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// <summary>Why the project's export cannot be rendered now, localised; null when it can.</summary>
|
||||
public string? RenderBlockedReason => Plan switch
|
||||
{
|
||||
_ when IsRemote && !Shell.Services.Sync.CanRender => Loc.L("Tooltips.Editor.Render.NoRight", RemoteText ?? string.Empty),
|
||||
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),
|
||||
@@ -865,8 +873,9 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
{
|
||||
OnPropertyChanged(nameof(IsBusy));
|
||||
OnPropertyChanged(nameof(IsAnalysing));
|
||||
OnPropertyChanged(nameof(IsLocked));
|
||||
OnPropertyChanged(nameof(IsEditable));
|
||||
OnPropertyChanged(nameof(BusyToolTip));
|
||||
OnPropertyChanged(nameof(LockedToolTip));
|
||||
OnPropertyChanged(nameof(AnalyseToolTip));
|
||||
OnPropertyChanged(nameof(OptimiseAllToolTip));
|
||||
OnPropertyChanged(nameof(ServerJobText));
|
||||
|
||||
@@ -119,13 +119,13 @@ public sealed class ExportTab : EditorTab
|
||||
public ExportTab(EditorViewModel editor)
|
||||
: base(editor, "Export", AdvisorSection.Export)
|
||||
{
|
||||
SelectCommand = new RelayCommand(p => Select(p as PresetCard), _ => !Editor.IsBusy);
|
||||
SelectCommand = new RelayCommand(p => Select(p as PresetCard), _ => !Editor.IsLocked);
|
||||
_renderNow = new AsyncRelayCommand(() => Editor.RenderAsync(JobPriority.User, batch: false), () => Editor.CanRender);
|
||||
_addToQueue = new AsyncRelayCommand(() => Editor.RenderAsync(JobPriority.Normal, batch: false), () => Editor.CanRender);
|
||||
_batch = new AsyncRelayCommand(() => Editor.RenderAsync(JobPriority.User, batch: true), () => Editor.CanRender && Batch.Count > 0);
|
||||
HistoryCommand = new RelayCommand(OpenHistory);
|
||||
RevealLastCommand = new RelayCommand(() => ShellActions.Reveal(Editor.Session.Content.Renders[0].OutputPath), () => CanReveal);
|
||||
_restore = new AsyncRelayCommand(RestoreAsync, () => !Editor.IsBusy && SelectedCopy is not null);
|
||||
_restore = new AsyncRelayCommand(RestoreAsync, () => !Editor.IsLocked && SelectedCopy is not null);
|
||||
ResetFrameRateCommand = new RelayCommand(() => EditOverrides(o => o with { FrameRate = null }));
|
||||
Width = new EditableField(string.Empty, ValidateSize, v => EditOverrides(o => o with { Width = ParseSize(v) }), () => Loc.L("Tooltips.Editor.Export.Width"));
|
||||
Height = new EditableField(string.Empty, ValidateSize, v => EditOverrides(o => o with { Height = ParseSize(v) }), () => Loc.L("Tooltips.Editor.Export.Height"));
|
||||
@@ -211,7 +211,7 @@ public sealed class ExportTab : EditorTab
|
||||
/// <summary>"Restore · 03/10/2026 14:22".</summary>
|
||||
public string RestoreText => Loc.L("Editor.Export.Restore", SelectedCopy?.Label ?? string.Empty);
|
||||
|
||||
public string RestoreToolTip => Editor.IsBusy ? Loc.L("Tooltips.Editor.Busy") : Loc.L("Tooltips.Editor.Export.Restore", SelectedCopy?.Label ?? string.Empty);
|
||||
public string RestoreToolTip => Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.Export.Restore", SelectedCopy?.Label ?? string.Empty);
|
||||
|
||||
public ICommand RestoreCommand => _restore;
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public sealed class FrameRow(FramesTab owner, Frame frame, int index) : Observab
|
||||
|
||||
public string ExcludeText => Loc.L(IsExcluded ? "Editor.Frames.Include" : "Editor.Frames.Exclude");
|
||||
|
||||
public string ExcludeToolTip => Loc.L(owner.Editor.IsBusy ? "Tooltips.Editor.Busy" : IsExcluded ? "Tooltips.Editor.Frames.Include" : "Tooltips.Editor.Frames.Exclude");
|
||||
public string ExcludeToolTip => owner.Editor.LockedToolTip ?? Loc.L(IsExcluded ? "Tooltips.Editor.Frames.Include" : "Tooltips.Editor.Frames.Exclude");
|
||||
|
||||
/// <summary>A job of the sequence started or ended: the action tooltips say why they wait.</summary>
|
||||
public void RefreshBusy() => OnPropertyChanged(nameof(ExcludeToolTip));
|
||||
@@ -125,8 +125,8 @@ public sealed class FramesTab : EditorTab
|
||||
public FramesTab(EditorViewModel editor)
|
||||
: base(editor, "Frames", AdvisorSection.Frames)
|
||||
{
|
||||
ToggleExcludeCommand = new RelayCommand(p => ToggleExcluded(p is FrameRow row ? row.Index : Editor.CurrentIndex), _ => !Editor.IsBusy);
|
||||
SetHeroCommand = new RelayCommand(p => Editor.Session.SetHero(p is FrameRow row ? row.Index : Editor.CurrentIndex), _ => !Editor.IsBusy);
|
||||
ToggleExcludeCommand = new RelayCommand(p => ToggleExcluded(p is FrameRow row ? row.Index : Editor.CurrentIndex), _ => !Editor.IsLocked);
|
||||
SetHeroCommand = new RelayCommand(p => Editor.Session.SetHero(p is FrameRow row ? row.Index : Editor.CurrentIndex), _ => !Editor.IsLocked);
|
||||
SeekCommand = new RelayCommand(p =>
|
||||
{
|
||||
if (p is FindingItem { Frame: { } frame }) Editor.CurrentIndex = frame;
|
||||
@@ -179,10 +179,10 @@ public sealed class FramesTab : EditorTab
|
||||
|
||||
public string CurrentExcludeText => Loc.L(IsCurrentExcluded ? "Editor.Frames.IncludeFrame" : "Editor.Frames.ExcludeFrame");
|
||||
|
||||
public string CurrentExcludeToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy" : IsCurrentExcluded ? "Tooltips.Editor.Frames.Include" : "Tooltips.Editor.Frames.Exclude");
|
||||
public string CurrentExcludeToolTip => Editor.LockedToolTip ?? Loc.L(IsCurrentExcluded ? "Tooltips.Editor.Frames.Include" : "Tooltips.Editor.Frames.Exclude");
|
||||
|
||||
/// <summary>What Set hero does, or why it waits.</summary>
|
||||
public string HeroToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy" : "Tooltips.Editor.Frames.Hero");
|
||||
public string HeroToolTip => Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.Frames.Hero");
|
||||
|
||||
public override bool CanReset => false;
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ public interface ISequenceSource : IAsyncDisposable
|
||||
/// </summary>
|
||||
bool IsRemote { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The project is shown, not changed (a server sequence for an account without the Edit right): the editor
|
||||
/// disables every change and the source refuses to store one.
|
||||
/// </summary>
|
||||
bool IsReadOnly { get; }
|
||||
|
||||
/// <summary>A job that may concern the sequence changed (any thread): this PC's engine, or the server's events.</summary>
|
||||
event Action<Job>? JobChanged;
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ public sealed class LocalSequenceSource : ISequenceSource
|
||||
|
||||
public bool IsRemote => false;
|
||||
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
public event Action<Job>? JobChanged;
|
||||
|
||||
/// <summary>A save changed the frame the Library shows for the sequence: the stored row (any thread).</summary>
|
||||
|
||||
@@ -46,13 +46,15 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
private int _version;
|
||||
private int _disposed;
|
||||
|
||||
public RemoteSequenceSource(RemoteSequence remote, IRemoteSequenceApi api, ImageDecoder decoder)
|
||||
/// <param name="readOnly">The account may look at the sequence but not change it (no Edit right on the server).</param>
|
||||
public RemoteSequenceSource(RemoteSequence remote, IRemoteSequenceApi api, ImageDecoder decoder, bool readOnly = false)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(remote);
|
||||
ArgumentNullException.ThrowIfNull(api);
|
||||
ArgumentNullException.ThrowIfNull(decoder);
|
||||
_remote = remote;
|
||||
_api = api;
|
||||
IsReadOnly = readOnly;
|
||||
_frames = remote.OpenFrames(decoder);
|
||||
_pixels = (IFrameSource)_frames;
|
||||
var stopping = _stopping.Token;
|
||||
@@ -61,6 +63,8 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
|
||||
public bool IsRemote => true;
|
||||
|
||||
public bool IsReadOnly { get; }
|
||||
|
||||
public event Action<Job>? JobChanged;
|
||||
|
||||
/// <summary>The server sequence's id.</summary>
|
||||
@@ -126,6 +130,7 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
var stored = _stored ?? throw new InvalidOperationException("LoadAsync first.");
|
||||
var merged = ProjectMerge.SameValues(stored, basis) ? project : ProjectMerge.Merge(basis, project, stored);
|
||||
if (ProjectMerge.SameValues(merged, stored)) return merged;
|
||||
if (IsReadOnly) throw new InvalidOperationException(Loc.L("Editor.Error.RemoteReadOnly"));
|
||||
var hero = merged.HeroFrame == stored.HeroFrame ? (Guid?)null : HeroFrameId(merged);
|
||||
try
|
||||
{
|
||||
@@ -175,33 +180,30 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
private async Task ListenAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var failures = 0;
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
try
|
||||
{
|
||||
try
|
||||
while (true)
|
||||
{
|
||||
await foreach (var e in _api.EventsAsync(cancellationToken).ConfigureAwait(false))
|
||||
try
|
||||
{
|
||||
failures = 0;
|
||||
await OnEventAsync(e, cancellationToken).ConfigureAwait(false);
|
||||
await foreach (var e in _api.EventsAsync(cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
failures = 0;
|
||||
await OnEventAsync(e, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
Log.Info("editor", $"Events of the server lost for {_remote.Sequence.DisplayTitle}: {ex.Message}");
|
||||
}
|
||||
var delay = Math.Min(MaxBackoff.Ticks, MinBackoff.Ticks << Math.Min(failures++, 10));
|
||||
await Task.Delay(TimeSpan.FromTicks(delay), cancellationToken).ConfigureAwait(false);
|
||||
await RefreshTrackedAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Info("editor", $"Events of the server lost for {_remote.Sequence.DisplayTitle}: {ex.Message}");
|
||||
}
|
||||
try
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromTicks(Math.Min(MaxBackoff.Ticks, MinBackoff.Ticks << Math.Min(failures++, 10))), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await RefreshTrackedAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
// The editor closed.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +211,8 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
{
|
||||
switch (e)
|
||||
{
|
||||
case JobProgressEvent progress when _jobs.TryGetValue(progress.JobId, out var job):
|
||||
// A late progress event never brings a finished job back to running.
|
||||
case JobProgressEvent progress when _jobs.TryGetValue(progress.JobId, out var job) && job.State is JobState.Queued or JobState.Running:
|
||||
Publish(job with
|
||||
{
|
||||
State = JobState.Running,
|
||||
|
||||
@@ -117,7 +117,8 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
|
||||
/// <summary>
|
||||
/// Where <paramref name="sequenceId"/> lives: this PC's index, else a sequence of the signed-in server whose proxies
|
||||
/// this PC keeps (Server screen, "Open with proxies"), edited through the server (BRIEF §14.5).
|
||||
/// this PC keeps (Server screen, "Open with proxies"), edited through the server (BRIEF §14.5), or only shown when the
|
||||
/// account may not change it.
|
||||
/// </summary>
|
||||
private async Task<ISequenceSource> OpenSourceAsync(AppServices services, Guid sequenceId)
|
||||
{
|
||||
@@ -134,10 +135,8 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
// The proxy cache's index and files are read off the UI thread.
|
||||
if (sync.Server is not { } server || sync.Service is not { } service || await Task.Run(() => service.OpenRemote(server, sequenceId)) is not { } remote)
|
||||
throw new InvalidOperationException(Loc.L("Editor.Error.Missing"));
|
||||
// An editor whose saves the server refuses would only lose edits.
|
||||
if (!sync.Policy.CanEdit) throw new InvalidOperationException(Loc.L("Editor.Error.RemoteReadOnly"));
|
||||
var api = sync.ConnectEditor() ?? throw new InvalidOperationException(Loc.L("Editor.Error.Missing"));
|
||||
return new RemoteSequenceSource(remote, api, decoder);
|
||||
return new RemoteSequenceSource(remote, api, decoder, readOnly: !sync.Policy.CanEdit);
|
||||
}
|
||||
|
||||
/// <summary>Set hero changed the frame the Library shows (any thread): its card loads the new thumbnail.</summary>
|
||||
|
||||
@@ -58,6 +58,9 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
/// <summary>The signed-in account may send files (originals, renders) to the server.</summary>
|
||||
public bool CanUpload => Allows(Permissions.Upload);
|
||||
|
||||
/// <summary>The signed-in account may queue renders on the server.</summary>
|
||||
public bool CanRender => Allows(Permissions.Render);
|
||||
|
||||
/// <summary>Pauses uploads while the connection is metered and the option is on.</summary>
|
||||
public UploadHold Uploads { get; } = new(services);
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@ internal sealed class FakeSequenceSource(SyntheticSequence sequence, SequenceCon
|
||||
/// <summary>A server sequence: renders become one job per preset.</summary>
|
||||
public bool IsRemote { get; init; }
|
||||
|
||||
public bool IsReadOnly { get; init; }
|
||||
|
||||
/// <summary>Jobs <see cref="ListJobsAsync"/> returns.</summary>
|
||||
public List<Job> Jobs { get; } = [];
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ using Titano.App.Infrastructure;
|
||||
using Titano.App.Sections;
|
||||
using Titano.App.Shell;
|
||||
using Titano.App.Tests.Windows;
|
||||
using Titano.Core.Export;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Core.Project;
|
||||
using Titano.Testing;
|
||||
@@ -197,6 +199,20 @@ public sealed class EditorSmokeTests
|
||||
await editor.RenderAsync(JobPriority.User, batch: false);
|
||||
var queued = Assert.Contains(await editor.Session.Source.ListJobsAsync(CancellationToken.None), _ => true);
|
||||
Assert.Equal(JobKind.Render, queued.Kind);
|
||||
|
||||
// Without the Edit right a server sequence is only shown: every change is disabled and says why.
|
||||
var content = EditorFixture.Content(EditorFixture.Sunset);
|
||||
var looking = new EditorSession(new FakeSequenceSource(EditorFixture.Sunset, content) { IsRemote = true, IsReadOnly = true }, content, []);
|
||||
var viewer = new EditorViewModel(shell, looking, [], EncoderHost.Client);
|
||||
await using (viewer)
|
||||
{
|
||||
Assert.False(viewer.IsEditable);
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.ReadOnly"), viewer.LockedToolTip);
|
||||
Assert.Equal(Loc.L("Tooltips.Editor.ReadOnly"), viewer.Frames.HeroToolTip);
|
||||
Assert.False(viewer.Frames.SetHeroCommand.CanExecute(null));
|
||||
Assert.False(viewer.OptimiseAllCommand.CanExecute(null));
|
||||
Assert.False(viewer.AnalyseCommand.CanExecute(null));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -148,6 +148,33 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnAccountWithoutTheEditRightOnlyLooks()
|
||||
{
|
||||
var (source, api, _) = Open(readOnly: true);
|
||||
await using (source)
|
||||
{
|
||||
var content = await source.LoadAsync(context.Cancellation);
|
||||
Assert.True(source.IsReadOnly);
|
||||
var session = new EditorSession(source, content, [], TimeSpan.FromMilliseconds(20));
|
||||
await using (session)
|
||||
{
|
||||
Assert.True(session.IsReadOnly);
|
||||
Assert.False(session.Edit(p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.5 } }));
|
||||
Assert.False(session.SetHero(3));
|
||||
Assert.Empty(session.OptimiseAll());
|
||||
Assert.False(session.Undo());
|
||||
Assert.True(await session.FlushAsync(), "nothing waits for a save");
|
||||
}
|
||||
|
||||
// The source refuses a change as well; the same project is no change.
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
||||
source.SaveProjectAsync(content.Project with { HeroFrame = 1 }, content.Project, context.Cancellation));
|
||||
Assert.True(ProjectMerge.SameValues(content.Project, await source.SaveProjectAsync(content.Project, content.Project, context.Cancellation)));
|
||||
Assert.Empty(api.Edits);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnalysesAndRendersArePostedToTheServerOnePerPreset()
|
||||
{
|
||||
@@ -220,6 +247,13 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
api.Jobs[other] = api.Job(other, "render", "queued");
|
||||
api.Jobs[foreign] = api.Job(foreign, "render", "queued", Guid.CreateVersion7());
|
||||
Assert.SequenceEqual([other], (await source.ListJobsAsync(context.Cancellation)).Select(j => j.Id), "active jobs of this sequence only");
|
||||
|
||||
// A late progress event of the finished job does not bring it back to running.
|
||||
api.Publish(new JobProgressEvent(id, 19, 20, 2.5, 1));
|
||||
api.Jobs[other] = api.Job(other, "render", "running");
|
||||
api.Publish(new JobStateEvent(other, "running", null));
|
||||
await WaitAsync(() => Last(seen).Id == other);
|
||||
lock (seen) Assert.Equal(JobState.Done, seen.Last(j => j.Id == id).State);
|
||||
}
|
||||
Assert.True(api.Disposed, "closing the editor closes its connection");
|
||||
}
|
||||
@@ -237,11 +271,13 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
}
|
||||
}
|
||||
|
||||
private (RemoteSequenceSource Source, FakeRemoteSequenceApi Api, RemoteSequence Remote) Open(int frames = 6, int cached = int.MaxValue) =>
|
||||
Open(EditorFixture.Sequence(frames), cached);
|
||||
private (RemoteSequenceSource Source, FakeRemoteSequenceApi Api, RemoteSequence Remote) Open(int frames = 6, int cached = int.MaxValue,
|
||||
bool readOnly = false) =>
|
||||
Open(EditorFixture.Sequence(frames), cached, readOnly);
|
||||
|
||||
/// <summary>A server sequence whose first <paramref name="cached"/> proxies are on this PC (synthetic JPEGs).</summary>
|
||||
private (RemoteSequenceSource Source, FakeRemoteSequenceApi Api, RemoteSequence Remote) Open(SyntheticSequence sunset, int cached = int.MaxValue)
|
||||
private (RemoteSequenceSource Source, FakeRemoteSequenceApi Api, RemoteSequence Remote) Open(SyntheticSequence sunset, int cached = int.MaxValue,
|
||||
bool readOnly = false)
|
||||
{
|
||||
var folder = context.CreateTempDirectory("proxies");
|
||||
var sequence = new Sequence
|
||||
@@ -265,7 +301,7 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
}
|
||||
var remote = new RemoteSequence(Server, sequence, frames, files);
|
||||
var api = new FakeRemoteSequenceApi(sequence) { SettingsJson = new ProjectSettings().ToJson() };
|
||||
return (new RemoteSequenceSource(remote, api, DecoderFactory.CreateClient(null)), api, remote);
|
||||
return (new RemoteSequenceSource(remote, api, DecoderFactory.CreateClient(null), readOnly), api, remote);
|
||||
}
|
||||
|
||||
private static Job Last(List<Job> seen)
|
||||
|
||||
Reference in new issue
Block a user