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
+11
-1
@@ -50,12 +50,14 @@
|
||||
<data name="Editor.Copy.Same" xml:space="preserve"><value>Nothing to restore</value></data>
|
||||
<data name="Editor.Copy.Undo" xml:space="preserve"><value>Undo</value></data>
|
||||
<data name="Editor.Empty" xml:space="preserve"><value>Pick a sequence in the Library</value></data>
|
||||
<data name="Editor.Error.FramesChanged" xml:space="preserve"><value>The frames of this sequence changed on the server; get its proxies again.</value><comment>long</comment></data>
|
||||
<data name="Editor.Error.Missing" xml:space="preserve"><value>This sequence is no longer in the archive.</value><comment>long</comment></data>
|
||||
<data name="Editor.Error.NoEngine" xml:space="preserve"><value>Jobs cannot run until the archive index is open.</value><comment>long</comment></data>
|
||||
<data name="Editor.Error.Project" xml:space="preserve"><value>The settings of this sequence cannot be read.</value><comment>long</comment></data>
|
||||
<data name="Editor.Error.RemoteReadOnly" xml:space="preserve"><value>Your account cannot change the sequences of this server.</value><comment>long</comment></data>
|
||||
<data name="Editor.Error.SaveConflict" xml:space="preserve"><value>The settings of this sequence were changed elsewhere at the same time.</value><comment>long</comment></data>
|
||||
<data name="Editor.Error.SavedCopy" xml:space="preserve"><value>The saved settings {0} cannot be read.</value><comment>long</comment></data>
|
||||
<data name="Editor.Error.SignedOut" xml:space="preserve"><value>Connect to the server to open this sequence.</value><comment>long</comment></data>
|
||||
<data name="Editor.Export.About" xml:space="preserve"><value>about {0}</value></data>
|
||||
<data name="Editor.Export.AddToQueue" xml:space="preserve"><value>Add to queue</value></data>
|
||||
<data name="Editor.Export.Batch" xml:space="preserve"><value>Batch…</value></data>
|
||||
@@ -85,7 +87,7 @@
|
||||
<data name="Editor.Export.Recommended" xml:space="preserve"><value>Recommended</value></data>
|
||||
<data name="Editor.Export.RenderNow" xml:space="preserve"><value>Render now</value></data>
|
||||
<data name="Editor.Export.Resolution" xml:space="preserve"><value>Resolution</value></data>
|
||||
<data name="Editor.Export.Restore" xml:space="preserve"><value>Restore · {0}</value></data>
|
||||
<data name="Editor.Export.Restore" xml:space="preserve"><value>Restore settings · {0}</value></data>
|
||||
<data name="Editor.Export.RestoreName" xml:space="preserve"><value>Restore copy</value></data>
|
||||
<data name="Editor.Export.Result" xml:space="preserve"><value>Result</value></data>
|
||||
<data name="Editor.Export.Reveal" xml:space="preserve"><value>show file</value></data>
|
||||
@@ -160,6 +162,8 @@
|
||||
<data name="Editor.Optimise.Nothing" xml:space="preserve"><value>Nothing to change</value></data>
|
||||
<data name="Editor.OptimiseAll" xml:space="preserve"><value>Optimise all</value></data>
|
||||
<data name="Editor.OptimiseSection" xml:space="preserve"><value>Optimise section</value></data>
|
||||
<data name="Editor.Outdated.Fetch" xml:space="preserve"><value>Get proxies</value></data>
|
||||
<data name="Editor.Outdated.Title" xml:space="preserve"><value>Frames changed on {0}</value></data>
|
||||
<data name="Editor.Preview" xml:space="preserve"><value>Preview</value></data>
|
||||
<data name="Editor.Preview.ActualSize" xml:space="preserve"><value>1:1</value><comment>invariant</comment></data>
|
||||
<data name="Editor.Preview.Clip" xml:space="preserve"><value>Preview 10 s</value></data>
|
||||
@@ -177,9 +181,13 @@
|
||||
<data name="Editor.Preview.Unreadable" xml:space="preserve"><value>This frame cannot be read.</value></data>
|
||||
<data name="Editor.Preview.Vectors" xml:space="preserve"><value>Vectors</value></data>
|
||||
<data name="Editor.Preview.Wipe" xml:space="preserve"><value>original | corrected</value></data>
|
||||
<data name="Editor.Proxies.Failed" xml:space="preserve"><value>Proxies not received</value></data>
|
||||
<data name="Editor.Proxies.Fetching" xml:space="preserve"><value>Getting the proxies</value></data>
|
||||
<data name="Editor.Regions.Auto" xml:space="preserve"><value>Auto</value></data>
|
||||
<data name="Editor.Regions.Horizon" xml:space="preserve"><value>Horizon</value></data>
|
||||
<data name="Editor.Regions.Luminance" xml:space="preserve"><value>Luminance</value></data>
|
||||
<data name="Editor.Remote.Outdated" xml:space="preserve"><value>{0} · proxies outdated</value></data>
|
||||
<data name="Editor.Remote.ReadOnly" xml:space="preserve"><value>{0} · read-only</value></data>
|
||||
<data name="Editor.Render" xml:space="preserve"><value>Render · {0}</value></data>
|
||||
<data name="Editor.Render.Done" xml:space="preserve"><value>Render finished</value></data>
|
||||
<data name="Editor.Render.Queued" xml:space="preserve"><value>Render queued</value></data>
|
||||
@@ -191,6 +199,8 @@
|
||||
<data name="Editor.Save.Failed" xml:space="preserve"><value>Changes not saved</value></data>
|
||||
<data name="Editor.Save.Retry" xml:space="preserve"><value>Retry</value></data>
|
||||
<data name="Editor.Sections" xml:space="preserve"><value>Sections</value></data>
|
||||
<data name="Editor.ServerJob.Cancel" xml:space="preserve"><value>Cancel job</value></data>
|
||||
<data name="Editor.ServerJob.Ended" xml:space="preserve"><value>{0} {1} on {2}</value></data>
|
||||
<data name="Editor.ServerJob.Left" xml:space="preserve"><value>{0} left</value></data>
|
||||
<data name="Editor.Shot.Aperture" xml:space="preserve"><value>f/{0}</value><comment>invariant</comment></data>
|
||||
<data name="Editor.Shot.Focal" xml:space="preserve"><value>{0} mm</value><comment>invariant</comment></data>
|
||||
|
||||
+10
-1
@@ -125,6 +125,7 @@
|
||||
<data name="Tooltips.Editor.Export.Colour" xml:space="preserve"><value>Rec.709 colour; 10-bit avoids banding in skies, HDR is not offered</value></data>
|
||||
<data name="Tooltips.Editor.Export.Container" xml:space="preserve"><value>MP4, AVI, GIF, APNG or a folder of images; the codec list follows</value></data>
|
||||
<data name="Tooltips.Editor.Export.Encoder" xml:space="preserve"><value>Encoder on this PC; Auto prefers hardware</value></data>
|
||||
<data name="Tooltips.Editor.Export.EncoderServer" xml:space="preserve"><value>{0} or its render node picks the encoder</value></data>
|
||||
<data name="Tooltips.Editor.Export.Folder" xml:space="preserve"><value>Where renders go: {0}</value></data>
|
||||
<data name="Tooltips.Editor.Export.FolderServer" xml:space="preserve"><value>Renders of a server sequence go to its exports folder on the server</value></data>
|
||||
<data name="Tooltips.Editor.Export.FrameRate" xml:space="preserve"><value>Frames per second of the video file</value></data>
|
||||
@@ -137,7 +138,7 @@
|
||||
<data name="Tooltips.Editor.Export.Preset" xml:space="preserve"><value>Render with {0}; editing a value makes it Custom</value></data>
|
||||
<data name="Tooltips.Editor.Export.Quality" xml:space="preserve"><value>Image quality; 95 looks lossless, lower makes smaller files</value></data>
|
||||
<data name="Tooltips.Editor.Export.Recommended" xml:space="preserve"><value>Advisor pick: {0}</value></data>
|
||||
<data name="Tooltips.Editor.Export.Restore" xml:space="preserve"><value>Make this PC’s settings kept on {0} the project; Ctrl+Z undoes it</value></data>
|
||||
<data name="Tooltips.Editor.Export.Restore" xml:space="preserve"><value>Use this PC’s settings saved on {0} as the project · Ctrl+Z undoes</value></data>
|
||||
<data name="Tooltips.Editor.Export.RestoreChoice" xml:space="preserve"><value>Choose another copy of this PC’s settings, kept when a sync conflict was settled</value></data>
|
||||
<data name="Tooltips.Editor.Export.SizeInvalid" xml:space="preserve"><value>Enter a size between 16 and 16384 pixels</value></data>
|
||||
<data name="Tooltips.Editor.Export.Sync" xml:space="preserve"><value>After each render on this PC, also send the file to the server; large files take time</value></data>
|
||||
@@ -179,6 +180,8 @@
|
||||
<data name="Tooltips.Editor.OptimiseAll" xml:space="preserve"><value>Let the advisor set every section from the analysis and list what changed</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseNone" xml:space="preserve"><value>The advisor never stacks on its own: a median erases moving stars</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseSection" xml:space="preserve"><value>Apply the advisor’s heavier choices for this section and list what changed · Ctrl+Z undoes</value></data>
|
||||
<data name="Tooltips.Editor.Outdated" xml:space="preserve"><value>Frames were added or removed on {0} since the proxies were fetched; get them again to edit or render</value></data>
|
||||
<data name="Tooltips.Editor.Outdated.Fetch" xml:space="preserve"><value>Fetch the proxies again and reopen the sequence; the job bar shows the download</value></data>
|
||||
<data name="Tooltips.Editor.Pause" xml:space="preserve"><value>Pause · Space</value></data>
|
||||
<data name="Tooltips.Editor.Play" xml:space="preserve"><value>Play the frames · Space; arrows step one frame</value></data>
|
||||
<data name="Tooltips.Editor.Preview.ActualSize" xml:space="preserve"><value>Show pixels at 1:1 without interpolation · Ctrl+1; Ctrl+0 fits</value></data>
|
||||
@@ -195,6 +198,7 @@
|
||||
<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.RemoteReadOnly" xml:space="preserve"><value>Shown from {0}; your account can look at this sequence but not change it</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>
|
||||
@@ -203,10 +207,15 @@
|
||||
<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>
|
||||
<data name="Tooltips.Editor.RenderChoice" xml:space="preserve"><value>Choose another preset</value></data>
|
||||
<data name="Tooltips.Editor.RenderChoiceReadOnly" xml:space="preserve"><value>Choose the preset to render; the project keeps its own</value></data>
|
||||
<data name="Tooltips.Editor.RenderServer" xml:space="preserve"><value>Render on {0} with the selected preset; progress beside the title · Ctrl+R</value></data>
|
||||
<data name="Tooltips.Editor.ResetSection" xml:space="preserve"><value>Return every control of this section to Auto · Ctrl+Z undoes</value></data>
|
||||
<data name="Tooltips.Editor.Save.Retry" xml:space="preserve"><value>Try to save now; saving is also retried automatically</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob" xml:space="preserve"><value>{0} running on {1}</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob.Cancel" xml:space="preserve"><value>Cancel the job on {0}; Retry in the notice that follows queues it again from its last checkpoint</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob.Paused" xml:space="preserve"><value>{0} paused on {1}</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob.Queued" xml:space="preserve"><value>{0} waiting on {1}</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob.Retry" xml:space="preserve"><value>Queue the job on {0} again from its last checkpoint</value></data>
|
||||
<data name="Tooltips.Editor.Stack.Length" xml:space="preserve"><value>Frames combined into each output frame; trails and smoothing grow with it</value></data>
|
||||
<data name="Tooltips.Editor.Stack.Mode" xml:space="preserve"><value>Median and mean remove noise and moving things; star trails keep the brightest pixels</value></data>
|
||||
<data name="Tooltips.Editor.Tab.Camera" xml:space="preserve"><value>Crop, aspect, virtual camera moves</value></data>
|
||||
|
||||
+11
-1
@@ -49,12 +49,14 @@
|
||||
<data name="Editor.Copy.Same" xml:space="preserve"><value>Niente da ripristinare</value></data>
|
||||
<data name="Editor.Copy.Undo" xml:space="preserve"><value>Annulla</value></data>
|
||||
<data name="Editor.Empty" xml:space="preserve"><value>Scegli una sequenza in Libreria</value></data>
|
||||
<data name="Editor.Error.FramesChanged" xml:space="preserve"><value>I fotogrammi di questa sequenza sono cambiati sul server; scarica di nuovo i proxy.</value></data>
|
||||
<data name="Editor.Error.Missing" xml:space="preserve"><value>Questa sequenza non è più nell’archivio.</value></data>
|
||||
<data name="Editor.Error.NoEngine" xml:space="preserve"><value>I lavori non possono partire finché l’indice dell’archivio non è aperto.</value></data>
|
||||
<data name="Editor.Error.Project" xml:space="preserve"><value>Le impostazioni di questa sequenza non sono leggibili.</value></data>
|
||||
<data name="Editor.Error.RemoteReadOnly" xml:space="preserve"><value>Il tuo account non può modificare le sequenze di questo server.</value></data>
|
||||
<data name="Editor.Error.SaveConflict" xml:space="preserve"><value>Le impostazioni di questa sequenza sono state modificate altrove nello stesso momento.</value></data>
|
||||
<data name="Editor.Error.SavedCopy" xml:space="preserve"><value>Le impostazioni salvate {0} non si possono leggere.</value></data>
|
||||
<data name="Editor.Error.SignedOut" xml:space="preserve"><value>Connettiti al server per aprire questa sequenza.</value></data>
|
||||
<data name="Editor.Export.About" xml:space="preserve"><value>circa {0}</value></data>
|
||||
<data name="Editor.Export.AddToQueue" xml:space="preserve"><value>Metti in coda</value></data>
|
||||
<data name="Editor.Export.Batch" xml:space="preserve"><value>In serie…</value></data>
|
||||
@@ -80,7 +82,7 @@
|
||||
<data name="Editor.Export.Recommended" xml:space="preserve"><value>Consigliato</value></data>
|
||||
<data name="Editor.Export.RenderNow" xml:space="preserve"><value>Renderizza ora</value></data>
|
||||
<data name="Editor.Export.Resolution" xml:space="preserve"><value>Risoluzione</value></data>
|
||||
<data name="Editor.Export.Restore" xml:space="preserve"><value>Ripristina · {0}</value></data>
|
||||
<data name="Editor.Export.Restore" xml:space="preserve"><value>Ripristina impostazioni · {0}</value></data>
|
||||
<data name="Editor.Export.RestoreName" xml:space="preserve"><value>Ripristina copia</value></data>
|
||||
<data name="Editor.Export.Result" xml:space="preserve"><value>Risultato</value></data>
|
||||
<data name="Editor.Export.Reveal" xml:space="preserve"><value>mostra file</value></data>
|
||||
@@ -151,6 +153,8 @@
|
||||
<data name="Editor.Optimise.Nothing" xml:space="preserve"><value>Niente da cambiare</value></data>
|
||||
<data name="Editor.OptimiseAll" xml:space="preserve"><value>Ottimizza tutto</value></data>
|
||||
<data name="Editor.OptimiseSection" xml:space="preserve"><value>Ottimizza sezione</value></data>
|
||||
<data name="Editor.Outdated.Fetch" xml:space="preserve"><value>Scarica i proxy</value></data>
|
||||
<data name="Editor.Outdated.Title" xml:space="preserve"><value>Fotogrammi cambiati su {0}</value></data>
|
||||
<data name="Editor.Preview" xml:space="preserve"><value>Anteprima</value></data>
|
||||
<data name="Editor.Preview.Clip" xml:space="preserve"><value>Anteprima 10 s</value></data>
|
||||
<data name="Editor.Preview.Compare" xml:space="preserve"><value>Confronta</value></data>
|
||||
@@ -167,9 +171,13 @@
|
||||
<data name="Editor.Preview.Unreadable" xml:space="preserve"><value>Questo fotogramma non si può leggere.</value></data>
|
||||
<data name="Editor.Preview.Vectors" xml:space="preserve"><value>Vettori</value></data>
|
||||
<data name="Editor.Preview.Wipe" xml:space="preserve"><value>originale | corretto</value></data>
|
||||
<data name="Editor.Proxies.Failed" xml:space="preserve"><value>Proxy non ricevuti</value></data>
|
||||
<data name="Editor.Proxies.Fetching" xml:space="preserve"><value>Scaricamento dei proxy</value></data>
|
||||
<data name="Editor.Regions.Auto" xml:space="preserve"><value>Auto</value></data>
|
||||
<data name="Editor.Regions.Horizon" xml:space="preserve"><value>Orizzonte</value></data>
|
||||
<data name="Editor.Regions.Luminance" xml:space="preserve"><value>Luminanza</value></data>
|
||||
<data name="Editor.Remote.Outdated" xml:space="preserve"><value>{0} · proxy superati</value></data>
|
||||
<data name="Editor.Remote.ReadOnly" xml:space="preserve"><value>{0} · sola lettura</value></data>
|
||||
<data name="Editor.Render" xml:space="preserve"><value>Renderizza · {0}</value></data>
|
||||
<data name="Editor.Render.Done" xml:space="preserve"><value>Render completato</value></data>
|
||||
<data name="Editor.Render.Queued" xml:space="preserve"><value>Render in coda</value></data>
|
||||
@@ -181,6 +189,8 @@
|
||||
<data name="Editor.Save.Failed" xml:space="preserve"><value>Modifiche non salvate</value></data>
|
||||
<data name="Editor.Save.Retry" xml:space="preserve"><value>Riprova</value></data>
|
||||
<data name="Editor.Sections" xml:space="preserve"><value>Sezioni</value></data>
|
||||
<data name="Editor.ServerJob.Cancel" xml:space="preserve"><value>Annulla attività</value></data>
|
||||
<data name="Editor.ServerJob.Ended" xml:space="preserve"><value>{0} su {2}: {1}</value></data>
|
||||
<data name="Editor.ServerJob.Left" xml:space="preserve"><value>mancano {0}</value></data>
|
||||
<data name="Editor.Stack.Length" xml:space="preserve"><value>Lunghezza</value></data>
|
||||
<data name="Editor.Stack.Mean" xml:space="preserve"><value>Media</value></data>
|
||||
|
||||
@@ -125,6 +125,7 @@
|
||||
<data name="Tooltips.Editor.Export.Colour" xml:space="preserve"><value>Colore Rec.709; 10 bit evitano il banding nel cielo, l’HDR non è disponibile</value></data>
|
||||
<data name="Tooltips.Editor.Export.Container" xml:space="preserve"><value>MP4, AVI, GIF, APNG o una cartella di immagini; l’elenco dei codec si adegua</value></data>
|
||||
<data name="Tooltips.Editor.Export.Encoder" xml:space="preserve"><value>Encoder di questo PC; Auto preferisce l’hardware</value></data>
|
||||
<data name="Tooltips.Editor.Export.EncoderServer" xml:space="preserve"><value>L’encoder lo sceglie {0} o il suo nodo di rendering</value></data>
|
||||
<data name="Tooltips.Editor.Export.Folder" xml:space="preserve"><value>Dove vanno i render: {0}</value></data>
|
||||
<data name="Tooltips.Editor.Export.FolderServer" xml:space="preserve"><value>I render di una sequenza del server vanno nella sua cartella exports sul server</value></data>
|
||||
<data name="Tooltips.Editor.Export.FrameRate" xml:space="preserve"><value>Fotogrammi al secondo del file video</value></data>
|
||||
@@ -137,7 +138,7 @@
|
||||
<data name="Tooltips.Editor.Export.Preset" xml:space="preserve"><value>Renderizza con {0}; modificare un valore lo rende Personalizzato</value></data>
|
||||
<data name="Tooltips.Editor.Export.Quality" xml:space="preserve"><value>Qualità dell’immagine; 95 sembra senza perdite, meno fa file più piccoli</value></data>
|
||||
<data name="Tooltips.Editor.Export.Recommended" xml:space="preserve"><value>Scelta del consulente: {0}</value></data>
|
||||
<data name="Tooltips.Editor.Export.Restore" xml:space="preserve"><value>Rende progetto le impostazioni di questo PC conservate il {0}; Ctrl+Z annulla</value></data>
|
||||
<data name="Tooltips.Editor.Export.Restore" xml:space="preserve"><value>Usa come progetto le impostazioni di questo PC salvate il {0} · Ctrl+Z annulla</value></data>
|
||||
<data name="Tooltips.Editor.Export.RestoreChoice" xml:space="preserve"><value>Scegli un’altra copia delle impostazioni di questo PC, conservata quando un conflitto di sincronizzazione è stato risolto</value></data>
|
||||
<data name="Tooltips.Editor.Export.SizeInvalid" xml:space="preserve"><value>Inserisci una dimensione tra 16 e 16384 pixel</value></data>
|
||||
<data name="Tooltips.Editor.Export.Sync" xml:space="preserve"><value>Dopo ogni render su questo PC invia il file anche al server; i file grandi richiedono tempo</value></data>
|
||||
@@ -179,6 +180,8 @@
|
||||
<data name="Tooltips.Editor.OptimiseAll" xml:space="preserve"><value>Lascia che il consulente imposti ogni sezione dall’analisi ed elenchi cosa è cambiato</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseNone" xml:space="preserve"><value>Il consulente non fa mai stacking da solo: una mediana cancella le stelle in movimento</value></data>
|
||||
<data name="Tooltips.Editor.OptimiseSection" xml:space="preserve"><value>Applica le scelte più incisive del consulente per questa sezione ed elenca cosa è cambiato · Ctrl+Z annulla</value></data>
|
||||
<data name="Tooltips.Editor.Outdated" xml:space="preserve"><value>Su {0} sono stati aggiunti o tolti fotogrammi dopo lo scaricamento dei proxy; scaricali di nuovo per modificare o renderizzare</value></data>
|
||||
<data name="Tooltips.Editor.Outdated.Fetch" xml:space="preserve"><value>Scarica di nuovo i proxy e riapri la sequenza; la barra delle attività mostra lo scaricamento</value></data>
|
||||
<data name="Tooltips.Editor.Pause" xml:space="preserve"><value>Pausa · Spazio</value></data>
|
||||
<data name="Tooltips.Editor.Play" xml:space="preserve"><value>Riproduce i fotogrammi · Spazio; le frecce avanzano di uno</value></data>
|
||||
<data name="Tooltips.Editor.Preview.ActualSize" xml:space="preserve"><value>Mostra i pixel 1:1 senza interpolazione · Ctrl+1; Ctrl+0 adatta</value></data>
|
||||
@@ -195,6 +198,7 @@
|
||||
<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.RemoteReadOnly" xml:space="preserve"><value>Mostrata da {0}; il tuo account può vedere questa sequenza ma non modificarla</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>
|
||||
@@ -203,10 +207,15 @@
|
||||
<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>
|
||||
<data name="Tooltips.Editor.RenderChoice" xml:space="preserve"><value>Scegli un altro preset</value></data>
|
||||
<data name="Tooltips.Editor.RenderChoiceReadOnly" xml:space="preserve"><value>Scegli il preset da renderizzare; il progetto mantiene il suo</value></data>
|
||||
<data name="Tooltips.Editor.RenderServer" xml:space="preserve"><value>Renderizza su {0} con il preset scelto; avanzamento accanto al titolo · Ctrl+R</value></data>
|
||||
<data name="Tooltips.Editor.ResetSection" xml:space="preserve"><value>Riporta in Auto ogni controllo di questa sezione · Ctrl+Z annulla</value></data>
|
||||
<data name="Tooltips.Editor.Save.Retry" xml:space="preserve"><value>Prova a salvare ora; il salvataggio viene anche ritentato da solo</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob" xml:space="preserve"><value>{0} in corso su {1}</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob.Cancel" xml:space="preserve"><value>Annulla l’attività su {0}; Riprova nell’avviso che segue la rimette in coda dall’ultimo punto di ripresa</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob.Paused" xml:space="preserve"><value>{0} in pausa su {1}</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob.Queued" xml:space="preserve"><value>{0} in attesa su {1}</value></data>
|
||||
<data name="Tooltips.Editor.ServerJob.Retry" xml:space="preserve"><value>Rimetti in coda l’attività su {0} dall’ultimo punto di ripresa</value></data>
|
||||
<data name="Tooltips.Editor.Stack.Length" xml:space="preserve"><value>Fotogrammi combinati in ogni fotogramma d’uscita; scie e levigatura crescono con esso</value></data>
|
||||
<data name="Tooltips.Editor.Stack.Mode" xml:space="preserve"><value>Mediana e media tolgono rumore e ciò che si muove; le scie stellari tengono i pixel più luminosi</value></data>
|
||||
<data name="Tooltips.Editor.Tab.Camera" xml:space="preserve"><value>Ritaglio, formato, movimenti della camera virtuale</value></data>
|
||||
|
||||
@@ -45,6 +45,7 @@ public sealed class SampleData
|
||||
private TitanoDatabase? _db;
|
||||
private Guid _sunrise;
|
||||
private Guid _lakeComo;
|
||||
private Permissions _permissions = RolePermissions.Default(UserRole.Editor);
|
||||
|
||||
private SampleData(AppServices services) => _services = services;
|
||||
|
||||
@@ -56,13 +57,13 @@ public sealed class SampleData
|
||||
{
|
||||
if (!services.Environment.IsCapture) throw new InvalidOperationException("Sample data only runs in a capture environment.");
|
||||
var settings = services.Settings;
|
||||
var sample = new SampleData(services);
|
||||
services.Server.Dispose();
|
||||
services.Server = new ServerSession(settings, services.SaveSettings, new SampleServerApiFactory(), new PlainTokenProtector());
|
||||
services.Server = new ServerSession(settings, services.SaveSettings, new SampleServerApiFactory(sample), new PlainTokenProtector());
|
||||
services.Encoders = new SampleEncoders();
|
||||
services.CheckForUpdateAsync = _ => Task.FromResult<ReleaseInfo?>(null);
|
||||
services.Devices.Dispose();
|
||||
services.Devices = new SampleDeviceMonitor();
|
||||
var sample = new SampleData(services);
|
||||
services.Sync.RemoteFactory = (_, _, _) => sample._remote;
|
||||
services.Sync.EditorFactory = (_, _, _) => sample._remote;
|
||||
return sample;
|
||||
@@ -163,6 +164,44 @@ public sealed class SampleData
|
||||
for (var i = 0; i < 200 && await db.Jobs.GetAsync(job.Id) is { State: JobState.Queued or JobState.Running }; i++) await Task.Delay(50);
|
||||
}
|
||||
|
||||
/// <summary>A render of Sunrise over Superga running on the sample server, 43 % done (the remote editor's server job).</summary>
|
||||
public void RunServerRender() => _remote.Run(_sunrise, "render", 1_240, 2_880);
|
||||
|
||||
/// <summary>The sample server's jobs end (none waits or runs any more).</summary>
|
||||
public void EndServerJobs() => _remote.EndJobs();
|
||||
|
||||
/// <summary>
|
||||
/// The signed-in account keeps Read, Upload and Render but loses Edit (server sequences open read-only); the
|
||||
/// session is read again so the client sees it.
|
||||
/// </summary>
|
||||
public async Task RestrictAccountAsync()
|
||||
{
|
||||
_permissions = Permissions.Read | Permissions.Upload | Permissions.Render;
|
||||
await _services.Server.RestoreAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The editor's sample as a sequence the sample server also has (so its Export "Sync" applies), with two copies of
|
||||
/// this PC's settings kept by "Save both" in its <c>.titano</c> folder.
|
||||
/// </summary>
|
||||
public async Task KeepEditorCopiesAsync(Guid sequenceId)
|
||||
{
|
||||
var db = _db ?? throw new InvalidOperationException("FillAsync first.");
|
||||
var sequence = await db.Sequences.GetAsync(sequenceId) ?? throw new InvalidOperationException("FillEditorAsync first.");
|
||||
var archive = await db.Archives.GetAsync(sequence.ArchiveId) ?? throw new InvalidOperationException("FillEditorAsync first.");
|
||||
var meta = new ArchivePaths(archive.RootPath).Sequence(sequence.Folder).MetaDirectory;
|
||||
Directory.CreateDirectory(meta);
|
||||
var project = sequence.SettingsJson is { } json ? ProjectSettings.FromJson(json) : new ProjectSettings();
|
||||
var copies = new (DateTime Saved, double OffsetEv)[] { (new DateTime(2026, 9, 30, 21, 14, 5), 0.3), (new DateTime(2026, 10, 2, 8, 41, 37), -0.2) };
|
||||
foreach (var (saved, offset) in copies)
|
||||
{
|
||||
var copy = project with { Exposure = project.Exposure with { ExposureOffsetEv = offset } };
|
||||
Titano.Core.IO.AtomicFile.WriteAllText(Path.Combine(meta, SyncService.SavedCopyName(saved)), copy.ToJson());
|
||||
}
|
||||
var remote = _remote.Add(SampleSyncRemote.Dto(sequence), sequence.SettingsJson, sequence.FrameCount);
|
||||
await _services.Sync.Service!.LinkAsync(ServerAddress, remote, sequence.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The server's side: six sequences this PC also holds (two the same, one with settings changed on both sides, one
|
||||
/// with more originals on the server, one with more here, one with renders this PC lacks) and two only on the server;
|
||||
@@ -582,15 +621,15 @@ public sealed class SampleData
|
||||
}
|
||||
|
||||
/// <summary>A server that always answers as "Studio NAS" with a self-signed certificate the sample trusts.</summary>
|
||||
private sealed class SampleServerApiFactory : IServerApiFactory
|
||||
private sealed class SampleServerApiFactory(SampleData sample) : IServerApiFactory
|
||||
{
|
||||
public IServerApi Create(Uri baseAddress, IReadOnlyCollection<string> trustedFingerprints) => new SampleServerApi(baseAddress, trustedFingerprints);
|
||||
public IServerApi Create(Uri baseAddress, IReadOnlyCollection<string> trustedFingerprints) => new SampleServerApi(sample, baseAddress, trustedFingerprints);
|
||||
}
|
||||
|
||||
private sealed class SampleServerApi(Uri baseAddress, IReadOnlyCollection<string> trusted) : IServerApi
|
||||
/// <summary>The sample account, an editor unless <see cref="RestrictAccountAsync"/> took the Edit right away.</summary>
|
||||
private sealed class SampleServerApi(SampleData sample, Uri baseAddress, IReadOnlyCollection<string> trusted) : IServerApi
|
||||
{
|
||||
private static readonly UserDto User = new(Guid.Empty, "alberto", "Alberto", "editor", (long)RolePermissions.Default(UserRole.Editor), 5_000_000_000_000,
|
||||
2_100_000_000_000, false, false,
|
||||
private UserDto User => new(Guid.Empty, "alberto", "Alberto", "editor", (long)sample._permissions, 5_000_000_000_000, 2_100_000_000_000, false, false,
|
||||
new DateTimeOffset(2025, 1, 1, 0, 0, 0, TimeSpan.Zero), DateTimeOffset.UtcNow);
|
||||
|
||||
public Uri BaseAddress { get; } = baseAddress;
|
||||
@@ -623,8 +662,8 @@ public sealed class SampleData
|
||||
/// <summary>
|
||||
/// The sample server's sequences for the sync table and the editor of a server sequence: listings, manifests
|
||||
/// (frames hashed from their index, so unhashed sample frames match them by count; renders as many as the listing
|
||||
/// says), settings edits, proxies (generated JPEGs) and jobs the editor posts (kept queued); uploads, originals and
|
||||
/// analysis reports are not part of the screenshots.
|
||||
/// says), settings edits, proxies (generated JPEGs) and jobs the editor posts (kept queued until cancelled, or run by
|
||||
/// <see cref="Run"/>); uploads, originals and analysis reports are not part of the screenshots.
|
||||
/// </summary>
|
||||
private sealed class SampleSyncRemote : ISyncRemote, IRemoteSequenceApi
|
||||
{
|
||||
@@ -723,6 +762,20 @@ public sealed class SampleData
|
||||
return Task.FromResult(job);
|
||||
}
|
||||
|
||||
/// <summary>A job of <paramref name="kind"/> running for <paramref name="sequenceId"/>, <paramref name="done"/> of <paramref name="total"/> frames.</summary>
|
||||
public void Run(Guid sequenceId, string kind, long done, long total)
|
||||
{
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
var job = new JobDto(Guid.CreateVersion7(), kind, [sequenceId], null, "running", "user", done, total, 11.3, (total - done) / 11.3, null, "studio-pc", 1,
|
||||
null, now.AddMinutes(-2), now.AddMinutes(-2), null);
|
||||
lock (_jobs) _jobs[job.Id] = job;
|
||||
}
|
||||
|
||||
public void EndJobs()
|
||||
{
|
||||
lock (_jobs) _jobs.Clear();
|
||||
}
|
||||
|
||||
public Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_jobs) return Task.FromResult(_jobs[id]);
|
||||
@@ -730,7 +783,21 @@ public sealed class SampleData
|
||||
|
||||
public Task<IReadOnlyList<JobDto>> ListActiveJobsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_jobs) return Task.FromResult<IReadOnlyList<JobDto>>([.. _jobs.Values]);
|
||||
lock (_jobs) 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) =>
|
||||
Task.FromResult(Update(id, job => job with { State = "cancelled", Finished = DateTimeOffset.UtcNow }));
|
||||
|
||||
public Task<JobDto> RetryJobAsync(Guid id, CancellationToken cancellationToken) =>
|
||||
Task.FromResult(Update(id, job => job with { State = "queued", Error = null, Finished = null }));
|
||||
|
||||
public Task<JobDto> SetJobPriorityAsync(Guid id, string priority, CancellationToken cancellationToken) =>
|
||||
Task.FromResult(Update(id, job => job with { Priority = priority }));
|
||||
|
||||
private JobDto Update(Guid id, Func<JobDto, JobDto> change)
|
||||
{
|
||||
lock (_jobs) return _jobs[id] = change(_jobs[id]);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -228,8 +228,9 @@
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type e:PresetCard}">
|
||||
<!-- Disabled while a job runs or the project cannot change: the card's tooltip says why. -->
|
||||
<Button Style="{StaticResource Button.PresetCard}" Command="{Binding SelectCommand}" CommandParameter="{Binding}" ToolTip="{Binding ToolTip}"
|
||||
AutomationProperties.Name="{Binding Name}">
|
||||
ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{Binding Name}">
|
||||
<DockPanel>
|
||||
<!-- The chip moves under the name when both do not fit on one line. -->
|
||||
<WrapPanel DockPanel.Dock="Top">
|
||||
@@ -240,7 +241,7 @@
|
||||
</WrapPanel>
|
||||
<DockPanel DockPanel.Dock="Bottom">
|
||||
<CheckBox DockPanel.Dock="Right" IsChecked="{Binding IsInBatch}" Visibility="{Binding CanBatch, Converter={StaticResource BoolToVisibility}}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Export.InBatch}" AutomationProperties.Name="{l:Loc Editor.Export.InBatch}" Margin="6,0,0,0" />
|
||||
ToolTip="{Binding BatchToolTip}" ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{l:Loc Editor.Export.InBatch}" Margin="6,0,0,0" />
|
||||
<TextBlock Text="{Binding Estimate}" FontSize="{StaticResource Size.Secondary}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center"
|
||||
Typography.NumeralAlignment="Tabular" />
|
||||
</DockPanel>
|
||||
|
||||
@@ -287,7 +287,7 @@
|
||||
ToolTip="{Binding Editor.RenderToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<DockPanel Margin="0,8,0,0">
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Link}" Content="{l:Loc Editor.Export.HistoryLink}" Command="{Binding HistoryCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Export.History}" Margin="6,0,0,0" />
|
||||
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 Text="{Binding HistoryText}" Style="{StaticResource Text.Faint}" FontSize="{StaticResource Size.Chip}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center"
|
||||
@@ -380,8 +380,8 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox ItemsSource="{Binding Encoders}" SelectedItem="{Binding SelectedEncoder}" DisplayMemberPath="Label"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Export.Encoder}" AutomationProperties.Name="{l:Loc Editor.Export.Encoder}" />
|
||||
<ComboBox ItemsSource="{Binding Encoders}" SelectedItem="{Binding SelectedEncoder}" DisplayMemberPath="Label" IsEnabled="{Binding CanChooseEncoder}"
|
||||
ToolTip="{Binding EncoderToolTip}" ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{l:Loc Editor.Export.Encoder}" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding EncoderKind}" FontSize="{StaticResource Size.Secondary}" VerticalAlignment="Center" Margin="8,0,0,0">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
@@ -406,16 +406,23 @@
|
||||
shell:EditBehavior.Field="{Binding NameTemplate}" ToolTip="{Binding NameTemplate.ToolTip}" AutomationProperties.Name="{l:Loc Editor.Export.FileName}" />
|
||||
|
||||
<TextBlock Grid.Row="8" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.SaveTo}" ToolTip="{l:Loc Editor.Export.SaveTo}" />
|
||||
<!-- The folder keeps at least 96 px and ends in an ellipsis (its full path is in the tooltip); Sync at 12 px, 6 px after it (Export.html). -->
|
||||
<Grid Grid.Row="8" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" MinWidth="96" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox ItemsSource="{Binding SaveChoices}" SelectedItem="{Binding SelectedSave}" DisplayMemberPath="Label" IsEnabled="{Binding CanChooseFolder}"
|
||||
ToolTip="{Binding SaveToolTip}" ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{l:Loc Editor.Export.SaveTo}" />
|
||||
<ComboBox ItemsSource="{Binding SaveChoices}" SelectedItem="{Binding SelectedSave}" IsEnabled="{Binding CanChooseFolder}"
|
||||
ToolTip="{Binding SaveToolTip}" ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{l:Loc Editor.Export.SaveTo}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type e:SaveChoice}">
|
||||
<TextBlock Text="{Binding Label}" TextTrimming="CharacterEllipsis" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<!-- Export.html "Sync": also send the render to the server the sequence is linked to. -->
|
||||
<CheckBox Grid.Column="1" Margin="8,0,0,0" VerticalAlignment="Center" Content="{l:Loc Editor.Export.Sync}" IsChecked="{Binding SyncToServer}"
|
||||
IsEnabled="{Binding CanSync}" ToolTip="{Binding SyncToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<CheckBox Grid.Column="1" Margin="6,0,0,0" VerticalAlignment="Center" FontSize="{StaticResource Size.Secondary}" Content="{l:Loc Editor.Export.Sync}"
|
||||
IsChecked="{Binding SyncToServer}" IsEnabled="{Binding CanSync}" ToolTip="{Binding SyncToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -29,18 +29,32 @@ public static class EditorText
|
||||
return string.Join(Separator, parts);
|
||||
}
|
||||
|
||||
/// <summary>"Render · 46 %": a job the server runs for a server sequence (the job bar shows this PC's jobs only).</summary>
|
||||
/// <summary>
|
||||
/// "Render · 46 %", "Render · queued", "Deep analysis · paused": a job the server runs for a server sequence (the job
|
||||
/// bar shows this PC's jobs only).
|
||||
/// </summary>
|
||||
public static string ServerJob(Job job)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
return job.ProgressTotal > 0 ? JobText.Kind(job.Kind) + Separator + Formatting.Percent((double)job.ProgressDone / job.ProgressTotal) : JobText.Kind(job.Kind);
|
||||
return job switch
|
||||
{
|
||||
{ State: JobState.Running, ProgressTotal: > 0 } => JobText.Kind(job.Kind) + Separator + Formatting.Percent((double)job.ProgressDone / job.ProgressTotal),
|
||||
{ State: JobState.Running } => JobText.Kind(job.Kind),
|
||||
_ => JobText.Kind(job.Kind) + Separator + Loc.L("Jobs.State." + job.State),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>"Render running on Studio NAS · 1,240 / 3,600 · 11.3 fps · 3 min left".</summary>
|
||||
/// <summary>"Render running on Studio NAS · 1,240 / 3,600 · 11.3 fps · 3 min left"; "Render waiting on Studio NAS".</summary>
|
||||
public static string ServerJobDetail(Job job, string server)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
var parts = new List<string> { Loc.L("Tooltips.Editor.ServerJob", JobText.Kind(job.Kind), server) };
|
||||
var key = job.State switch
|
||||
{
|
||||
JobState.Queued => "Tooltips.Editor.ServerJob.Queued",
|
||||
JobState.Paused => "Tooltips.Editor.ServerJob.Paused",
|
||||
_ => "Tooltips.Editor.ServerJob",
|
||||
};
|
||||
var parts = new List<string> { Loc.L(key, JobText.Kind(job.Kind), server) };
|
||||
if (JobText.Counter(job.ProgressDone, job.ProgressTotal) is { Length: > 0 } counter) parts.Add(counter);
|
||||
if (JobText.Speed(job.Kind, job.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed);
|
||||
if (job.Eta is { } eta) parts.Add(Loc.L("Editor.ServerJob.Left", Formatting.Duration(eta)));
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Jobs;
|
||||
using Titano.App.Shell;
|
||||
using Titano.Core.Advice;
|
||||
using Titano.Core.Analysis;
|
||||
@@ -42,6 +43,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
private readonly Dictionary<Guid, Job> _jobs = [];
|
||||
private readonly AsyncRelayCommand _analyse;
|
||||
private readonly AsyncRelayCommand _render;
|
||||
private readonly AsyncRelayCommand _cancelServerJob;
|
||||
private PreviewRenderer _renderer;
|
||||
private int _currentIndex;
|
||||
private EditorTab _selectedTab;
|
||||
@@ -64,7 +66,9 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
private bool _previewBusy;
|
||||
private RenderCorrections? _correctionsValue;
|
||||
private ExportPlan? _plan;
|
||||
private int _planVersion;
|
||||
private bool _planned;
|
||||
private string? _renderPreset;
|
||||
private IReadOnlyList<TimelineMarker> _markers = [];
|
||||
private IThumbnailSource _thumbnails;
|
||||
private int _playLimit;
|
||||
@@ -89,6 +93,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
_analyse = new AsyncRelayCommand(AnalyseAsync, () => !IsLocked && !IsAnalysing);
|
||||
OptimiseAllCommand = new RelayCommand(OptimiseAll, () => !IsLocked);
|
||||
_render = new AsyncRelayCommand(() => RenderAsync(JobPriority.User, batch: false), () => CanRender);
|
||||
_cancelServerJob = new AsyncRelayCommand(CancelServerJobAsync, () => ServerJob is not null);
|
||||
UndoCommand = new RelayCommand(() => Session.Undo(), () => !IsLocked && Session.History.CanUndo);
|
||||
RedoCommand = new RelayCommand(() => Session.Redo(), () => !IsLocked && Session.History.CanRedo);
|
||||
PlayCommand = new RelayCommand(() => TogglePlay(limit: 0));
|
||||
@@ -111,6 +116,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
session.ContentChanged += OnContentChanged;
|
||||
session.SaveFailed += OnSaveFailed;
|
||||
session.Source.JobChanged += OnJobChanged;
|
||||
session.Source.ReadOnlyChanged += OnReadOnlyChanged;
|
||||
shell.Services.Sync.Changed += OnSyncChanged;
|
||||
UpdateMarkers();
|
||||
RequestCorrections();
|
||||
@@ -129,21 +135,56 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// <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;
|
||||
/// <summary>The server a server sequence lives on ("Studio NAS"); null for a sequence of this PC.</summary>
|
||||
public string? ServerName => 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>"Studio NAS" beside the title of a server sequence; "Studio NAS · read-only" when it is only shown.</summary>
|
||||
public string? RemoteText => !IsRemote ? null
|
||||
: IsOutdated ? Loc.L("Editor.Remote.Outdated", ServerName)
|
||||
: IsReadOnly ? Loc.L("Editor.Remote.ReadOnly", ServerName)
|
||||
: ServerName;
|
||||
|
||||
/// <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? RemoteToolTip => !IsRemote ? null
|
||||
: IsOutdated ? Loc.L("Tooltips.Editor.Outdated", ServerName)
|
||||
: IsReadOnly ? Loc.L("Tooltips.Editor.RemoteReadOnly", ServerName)
|
||||
: Loc.L("Tooltips.Editor.Remote", ServerName);
|
||||
|
||||
/// <summary>
|
||||
/// "Render · 46 %", "Render · queued": the analysis or render of a server sequence the server runs or holds (the job
|
||||
/// bar shows this PC's jobs); null when there is none.
|
||||
/// </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;
|
||||
public string? ServerJobToolTip => ServerJob is { } job ? EditorText.ServerJobDetail(job, ServerName ?? string.Empty) : null;
|
||||
|
||||
/// <summary>The glyph of the server job (DESIGN §4): ◐ an analysis running, ● a render running, ○ waiting, paused.</summary>
|
||||
public StatusKind ServerJobKind => ServerJob switch
|
||||
{
|
||||
{ State: JobState.Running, Kind: JobKind.DeepAnalyse or JobKind.LightAnalyse } => StatusKind.Analysing,
|
||||
{ State: JobState.Running } => StatusKind.Running,
|
||||
{ State: JobState.Paused } => StatusKind.Paused,
|
||||
_ => StatusKind.Queued,
|
||||
};
|
||||
|
||||
/// <summary>The server job runs and reports how far it is (its progress bar shows).</summary>
|
||||
public bool HasServerJobProgress => ServerJob is { State: JobState.Running, ProgressTotal: > 0 };
|
||||
|
||||
/// <summary>Fraction of the server job done (0–1).</summary>
|
||||
public double ServerJobProgress => ServerJob is { State: JobState.Running, ProgressTotal: > 0 } job ? (double)job.ProgressDone / job.ProgressTotal : 0;
|
||||
|
||||
/// <summary>Cancels the server job (BRIEF §11.5: cancel is always available); the toast that follows offers Retry.</summary>
|
||||
public ICommand CancelServerJobCommand => _cancelServerJob;
|
||||
|
||||
public string? CancelServerJobToolTip => IsRemote ? Loc.L("Tooltips.Editor.ServerJob.Cancel", ServerName) : 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>The server job the header shows: one running, else one paused, else the oldest waiting.</summary>
|
||||
private Job? ServerJob => IsRemote
|
||||
? _jobs.Values.OrderBy(j => j.State switch { JobState.Running => 0, JobState.Paused => 1, _ => 2 }).ThenBy(j => j.Started ?? j.Created).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:
|
||||
@@ -334,19 +375,28 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// <summary>An analysis or render of this sequence is running: settings wait, viewing tools stay live.</summary>
|
||||
public bool IsBusy => _jobs.Values.Any(j => j.State == JobState.Running);
|
||||
|
||||
/// <summary>A deep analysis of this sequence is queued or running (Analyse would queue it twice).</summary>
|
||||
/// <summary>A deep analysis of this sequence is queued, running or paused (Analyse would queue it twice).</summary>
|
||||
public bool IsAnalysing => _jobs.Values.Any(j => j.Kind == JobKind.DeepAnalyse);
|
||||
|
||||
/// <summary>The project is shown, not changed: a server sequence for an account without the Edit right.</summary>
|
||||
/// <summary>
|
||||
/// The project is shown, not changed: a server sequence for an account without the Edit right, or one whose frames
|
||||
/// changed on the server (<see cref="IsOutdated"/>).
|
||||
/// </summary>
|
||||
public bool IsReadOnly => Session.IsReadOnly;
|
||||
|
||||
/// <summary>The frames on the server are no longer the proxies this PC shows: nothing is saved or rendered until they are fetched again.</summary>
|
||||
public bool IsOutdated => Session.Source.IsOutdated;
|
||||
|
||||
/// <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;
|
||||
public string? LockedToolTip => IsOutdated ? Loc.L("Tooltips.Editor.Outdated", ServerName)
|
||||
: 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 => LockedToolTip
|
||||
@@ -369,29 +419,55 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
|
||||
public IReadOnlyList<Choice> RenderChoices { get; }
|
||||
|
||||
/// <summary>The export preset the Render button renders (choosing another one sets it).</summary>
|
||||
/// <summary>
|
||||
/// The export preset the Render button renders: choosing another one sets it in the project, or, for an account that
|
||||
/// may render but not edit (<see cref="IsReadOnly"/>), only in this editor.
|
||||
/// </summary>
|
||||
public Choice? SelectedRenderChoice
|
||||
{
|
||||
get => RenderChoices.FirstOrDefault(c => string.Equals((string)c.Value, Plan?.Export.PresetId ?? EditorSettings.ExportPreset.Effective(Session.Project, null),
|
||||
StringComparison.OrdinalIgnoreCase));
|
||||
get
|
||||
{
|
||||
var id = (IsReadOnly ? _renderPreset : null) ?? Plan?.Export.PresetId ?? EditorSettings.ExportPreset.Effective(Session.Project, null);
|
||||
return RenderChoices.FirstOrDefault(c => string.Equals((string)c.Value, id, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value?.Value is not string id) return;
|
||||
Session.Edit(p => p with { Export = p.Export with { Preset = p.Export.Preset.WithManual(id), Overrides = new ExportOverrides() } });
|
||||
if (!IsReadOnly)
|
||||
{
|
||||
Session.Edit(p => p with { Export = p.Export with { Preset = p.Export.Preset.WithManual(id), Overrides = new ExportOverrides() } });
|
||||
return;
|
||||
}
|
||||
if (string.Equals(id, _renderPreset, StringComparison.OrdinalIgnoreCase)) return;
|
||||
_renderPreset = id;
|
||||
OnPropertyChanged();
|
||||
RequestPlan();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The export Render renders: the project's, or with the preset chosen in the Render menu of a read-only session
|
||||
/// (the project keeps its own; the batch stays the project's).
|
||||
/// </summary>
|
||||
public ExportSettings RenderExport => IsReadOnly && _renderPreset is { } id
|
||||
? Session.ExportFor(id) with { Batch = Session.Project.Export.Batch }
|
||||
: Session.Project.Export;
|
||||
|
||||
/// <summary>"Render · 4K archive".</summary>
|
||||
public string RenderText => Loc.L("Editor.Render", Plan?.PresetName ?? string.Empty);
|
||||
|
||||
public string RenderToolTip => RenderBlockedReason ?? (IsRemote ? Loc.L("Tooltips.Editor.RenderServer", RemoteText ?? string.Empty) : Loc.L("Tooltips.Editor.Render"));
|
||||
public string RenderToolTip => RenderBlockedReason ?? (IsRemote ? Loc.L("Tooltips.Editor.RenderServer", ServerName) : Loc.L("Tooltips.Editor.Render"));
|
||||
|
||||
/// <summary>The ▾ part of Render: another preset for the project, or only for this render when the project cannot change.</summary>
|
||||
public string RenderChoiceToolTip => Loc.L(IsReadOnly ? "Tooltips.Editor.RenderChoiceReadOnly" : "Tooltips.Editor.RenderChoice");
|
||||
|
||||
public bool CanRender => RenderBlockedReason is null;
|
||||
|
||||
/// <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),
|
||||
_ when IsRemote && !Shell.Services.Sync.CanRender => Loc.L("Tooltips.Editor.Render.NoRight", ServerName),
|
||||
_ when IsOutdated => Loc.L("Tooltips.Editor.Outdated", ServerName),
|
||||
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),
|
||||
@@ -437,10 +513,10 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// </summary>
|
||||
public async Task RenderAsync(JobPriority priority, bool batch)
|
||||
{
|
||||
var export = batch ? Session.Project.Export : Session.Project.Export with { Batch = [] };
|
||||
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", RemoteText ?? string.Empty), requests[0].Label);
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -449,6 +525,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
{
|
||||
_analyse.RaiseCanExecuteChanged();
|
||||
_render.RaiseCanExecuteChanged();
|
||||
_cancelServerJob.RaiseCanExecuteChanged();
|
||||
foreach (var tab in Tabs) tab.RefreshCommands();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
@@ -525,6 +602,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
Session.ContentChanged -= OnContentChanged;
|
||||
Session.SaveFailed -= OnSaveFailed;
|
||||
Session.Source.JobChanged -= OnJobChanged;
|
||||
Session.Source.ReadOnlyChanged -= OnReadOnlyChanged;
|
||||
Shell.Services.Sync.Changed -= OnSyncChanged;
|
||||
foreach (var tab in Tabs) tab.Dispose();
|
||||
base.Dispose();
|
||||
@@ -624,16 +702,16 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
foreach (var tab in Tabs) tab.OnCorrectionsChanged();
|
||||
}
|
||||
|
||||
private void RequestPlan() => _ = RunPlanAsync(Planner, Session.Project);
|
||||
private void RequestPlan() => _ = RunPlanAsync(Planner, Session.Project, RenderExport, ++_planVersion);
|
||||
|
||||
private async Task RunPlanAsync(ExportPlanner planner, ProjectSettings project)
|
||||
private async Task RunPlanAsync(ExportPlanner planner, ProjectSettings project, ExportSettings export, int version)
|
||||
{
|
||||
ExportPlan? plan = null;
|
||||
try
|
||||
{
|
||||
await _plans.Schedule(_ =>
|
||||
{
|
||||
plan = planner.Plan(project);
|
||||
plan = planner.Plan(project, export);
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
@@ -641,13 +719,11 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
{
|
||||
Log.Warning("editor", "Planning the export failed", ex);
|
||||
}
|
||||
if (_disposed || !ReferenceEquals(planner, Planner) || !ReferenceEquals(project, Session.Project)) return;
|
||||
// A later request (a new project, another render choice) owns the plan.
|
||||
if (_disposed || !ReferenceEquals(planner, Planner) || version != _planVersion) return;
|
||||
_planned = true;
|
||||
Plan = plan;
|
||||
OnPropertyChanged(nameof(RenderText));
|
||||
OnPropertyChanged(nameof(RenderToolTip));
|
||||
OnPropertyChanged(nameof(RenderBlockedReason));
|
||||
OnPropertyChanged(nameof(CanRender));
|
||||
OnRenderStateChanged();
|
||||
OnPropertyChanged(nameof(SelectedRenderChoice));
|
||||
OnPropertyChanged(nameof(Summary));
|
||||
foreach (var tab in Tabs) tab.OnPlanChanged();
|
||||
@@ -793,24 +869,72 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
{
|
||||
await Session.SubmitAsync(Session.AnalysisRequest());
|
||||
// The Jobs screen lists this PC's jobs; a server's analysis shows beside the title.
|
||||
if (IsRemote) Shell.Notify(Loc.L("Editor.Analyse.QueuedServer", RemoteText ?? string.Empty), Title);
|
||||
if (IsRemote) Shell.Notify(Loc.L("Editor.Analyse.QueuedServer", ServerName), Title);
|
||||
else Shell.Notify(Loc.L("Editor.Analyse.Queued"), Title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
}
|
||||
|
||||
private void OnJobChanged(Job job)
|
||||
{
|
||||
if (!job.TargetIds.Contains(Session.Content.Sequence.Id) || job.Kind is not (JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render)) return;
|
||||
if (!Concerns(job)) return;
|
||||
_dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (_disposed) return;
|
||||
var wasActive = _jobs.ContainsKey(job.Id);
|
||||
Track(job);
|
||||
// Progress alone (several times a second on a server) only moves the server job's text and bar.
|
||||
if (Track(job)) OnBusyChanged();
|
||||
else OnServerJobChanged();
|
||||
LearnAnalysisSpeed(job);
|
||||
OnBusyChanged();
|
||||
if (wasActive && job.State == JobState.Done) _ = ReloadAsync(job.Kind == JobKind.Render ? job : null);
|
||||
if (!wasActive) return;
|
||||
if (job.State == JobState.Done) _ = ReloadAsync(job.Kind == JobKind.Render ? job : null);
|
||||
else if (IsRemote && job.State is JobState.Failed or JobState.Cancelled) ReportServerJobEnded(job);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The frames of the server sequence changed while it is open (any thread): everything that changes the project is
|
||||
/// disabled and saying why, and a toast offers to fetch the proxies again.
|
||||
/// </summary>
|
||||
private void OnReadOnlyChanged() => _dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (_disposed) return;
|
||||
OnPropertyChanged(nameof(IsReadOnly));
|
||||
OnPropertyChanged(nameof(IsOutdated));
|
||||
OnPropertyChanged(nameof(RemoteText));
|
||||
OnPropertyChanged(nameof(RemoteToolTip));
|
||||
OnPropertyChanged(nameof(RenderChoiceToolTip));
|
||||
OnRenderStateChanged();
|
||||
OnBusyChanged();
|
||||
if (!IsOutdated) return;
|
||||
var (id, title) = (Session.Content.Sequence.Id, Title);
|
||||
Shell.ShowToast(new Toast
|
||||
{
|
||||
Title = Loc.L("Editor.Outdated.Title", ServerName),
|
||||
Message = title,
|
||||
ActionText = Loc.L("Editor.Outdated.Fetch"),
|
||||
ActionToolTip = Loc.L("Tooltips.Editor.Outdated.Fetch"),
|
||||
ActionCommand = new AsyncRelayCommand(() => Shell.Sequence.FetchProxiesAsync(id, title)),
|
||||
});
|
||||
});
|
||||
|
||||
/// <summary>A server job of this sequence failed or was cancelled: what happened, and Retry (BRIEF §11.5).</summary>
|
||||
private void ReportServerJobEnded(Job job)
|
||||
{
|
||||
var server = ServerName ?? string.Empty;
|
||||
Shell.ShowToast(new Toast
|
||||
{
|
||||
Title = Loc.L("Editor.ServerJob.Ended", JobText.Kind(job.Kind), Loc.L("Jobs.State." + job.State), server),
|
||||
Message = job.Error ?? job.TargetLabel ?? Title,
|
||||
ActionText = Loc.L("Jobs.Action.Retry"),
|
||||
ActionToolTip = Loc.L("Tooltips.Editor.ServerJob.Retry", server),
|
||||
ActionCommand = new AsyncRelayCommand(() => Session.Source.RetryJobAsync(job.Id, CancellationToken.None), () => !_disposed),
|
||||
});
|
||||
}
|
||||
|
||||
private async Task CancelServerJobAsync()
|
||||
{
|
||||
if (ServerJob is { } job) await Session.Source.CancelJobAsync(job.Id, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <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());
|
||||
|
||||
@@ -827,11 +951,19 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private void Track(Job job)
|
||||
/// <summary>An analysis or render of this sequence.</summary>
|
||||
private bool Concerns(Job job) =>
|
||||
job.TargetIds.Contains(Session.Content.Sequence.Id) && job.Kind is JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render;
|
||||
|
||||
/// <summary>Keeps the jobs of this sequence that wait, run or are paused.</summary>
|
||||
/// <returns>Whether a job joined or left them or changed state (progress alone does not count).</returns>
|
||||
private bool Track(Job job)
|
||||
{
|
||||
if (!job.TargetIds.Contains(Session.Content.Sequence.Id) || job.Kind is not (JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render)) return;
|
||||
if (job.State is JobState.Queued or JobState.Running) _jobs[job.Id] = job;
|
||||
else _jobs.Remove(job.Id);
|
||||
if (!Concerns(job)) return false;
|
||||
if (job.State is not (JobState.Queued or JobState.Running or JobState.Paused)) return _jobs.Remove(job.Id);
|
||||
var changed = !_jobs.TryGetValue(job.Id, out var known) || known.State != job.State;
|
||||
_jobs[job.Id] = job;
|
||||
return changed;
|
||||
}
|
||||
|
||||
/// <summary>Seconds per frame of the latest finished deep analysis (any sequence): the cost Analyse announces.</summary>
|
||||
@@ -878,12 +1010,31 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
OnPropertyChanged(nameof(LockedToolTip));
|
||||
OnPropertyChanged(nameof(AnalyseToolTip));
|
||||
OnPropertyChanged(nameof(OptimiseAllToolTip));
|
||||
OnPropertyChanged(nameof(ServerJobText));
|
||||
OnPropertyChanged(nameof(ServerJobToolTip));
|
||||
OnServerJobChanged();
|
||||
foreach (var tab in Tabs) tab.OnBusyChanged();
|
||||
RefreshCommands();
|
||||
}
|
||||
|
||||
private void OnServerJobChanged()
|
||||
{
|
||||
if (!IsRemote) return;
|
||||
OnPropertyChanged(nameof(ServerJobText));
|
||||
OnPropertyChanged(nameof(ServerJobToolTip));
|
||||
OnPropertyChanged(nameof(ServerJobKind));
|
||||
OnPropertyChanged(nameof(HasServerJobProgress));
|
||||
OnPropertyChanged(nameof(ServerJobProgress));
|
||||
_cancelServerJob.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
/// <summary>What Render renders and whether it can (the plan, the rights or the frames changed).</summary>
|
||||
private void OnRenderStateChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(RenderText));
|
||||
OnPropertyChanged(nameof(RenderToolTip));
|
||||
OnPropertyChanged(nameof(RenderBlockedReason));
|
||||
OnPropertyChanged(nameof(CanRender));
|
||||
}
|
||||
|
||||
/// <summary>A rendered preview as frozen bitmaps and overlays in picture pixels (built off the UI thread).</summary>
|
||||
private sealed record PreviewResult(ImageSource Corrected, ImageSource Original, Rect Crop, IReadOnlyList<Point> Horizon, IReadOnlyList<MotionVector> Vectors,
|
||||
ImageSource? Waveform)
|
||||
|
||||
@@ -25,10 +25,17 @@ public enum ExportSyncGate
|
||||
NoUpload,
|
||||
}
|
||||
|
||||
/// <summary>What became of the Export "Sync" of a finished render.</summary>
|
||||
/// <param name="Gate">Why the render was not sent, or <see cref="ExportSyncGate.Available"/>.</param>
|
||||
/// <param name="Send">The queued send job; null when it was not queued.</param>
|
||||
public sealed record ExportSyncResult(ExportSyncGate Gate, Job? Send);
|
||||
|
||||
/// <summary>
|
||||
/// Export "Sync" (Export.html, BRIEF §14.5): a render made on this PC whose export asked for it is sent to the server
|
||||
/// the sequence is linked to once it is done (<see cref="SyncService.EnqueueSendExportsAsync"/>), while signed in with
|
||||
/// the Upload right. The choice travels inside the render job (its export), so it holds after the editor closes.
|
||||
/// Export "Sync" (Export.html "register the export on the server when connected", BRIEF §14.5): a render made on this
|
||||
/// PC whose export asked for it is sent to the server the sequence is linked to once it is done
|
||||
/// (<see cref="SyncService.EnqueueSendExportsAsync"/>). The choice travels inside the render job (its export), so it
|
||||
/// holds after the editor closes; a render that ends while the session is down is queued for the last session's server
|
||||
/// and its send waits for the session (and fails visibly on the Jobs screen when it does not come back).
|
||||
/// </summary>
|
||||
public sealed class ExportSync(TitanoDatabase db, SyncService sync, JobEngine engine)
|
||||
{
|
||||
@@ -42,18 +49,20 @@ public sealed class ExportSync(TitanoDatabase db, SyncService sync, JobEngine en
|
||||
: !canUpload ? ExportSyncGate.NoUpload
|
||||
: ExportSyncGate.Available;
|
||||
|
||||
/// <summary>
|
||||
/// Queues sending a finished render's output; returns the send job, or null when the job is not a finished render
|
||||
/// of this PC that asked for it, or the sequence cannot be sent now.
|
||||
/// </summary>
|
||||
public async Task<Job?> SendAsync(Job job, string? server, bool canUpload, CancellationToken cancellationToken = default)
|
||||
/// <summary>Queues sending a finished render's output.</summary>
|
||||
/// <param name="server">Key of the server: the signed-in one, else the one of the saved session; null without either.</param>
|
||||
/// <param name="canUpload">The account may send files (assumed while the session is down: the server refuses the send otherwise).</param>
|
||||
/// <returns>The send job or why there is none; null when the job is not a finished render of this PC that asked for it.</returns>
|
||||
public async Task<ExportSyncResult?> SendAsync(Job job, string? server, bool canUpload, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
if (job is not { Kind: JobKind.Render, State: JobState.Done, TargetIds: [var target] } || !Wanted(job)) return null;
|
||||
if (await db.Sequences.GetAsync(target, cancellationToken) is not { } local) return null;
|
||||
var linked = server is not null && await sync.LinkOfAsync(server, local.Id, cancellationToken) is not null;
|
||||
if (Gate(false, server, linked, canUpload) != ExportSyncGate.Available) return null;
|
||||
return await sync.EnqueueSendExportsAsync(engine, server!, local, cancellationToken);
|
||||
var gate = Gate(false, server, linked, canUpload);
|
||||
return gate == ExportSyncGate.Available
|
||||
? new ExportSyncResult(gate, await sync.EnqueueSendExportsAsync(engine, server!, local, cancellationToken))
|
||||
: new ExportSyncResult(gate, null);
|
||||
}
|
||||
|
||||
private static bool Wanted(Job job)
|
||||
|
||||
@@ -10,6 +10,7 @@ using Titano.Core.Model;
|
||||
using Titano.Core.Project;
|
||||
using Titano.Core.Video;
|
||||
using Titano.Data.Processing;
|
||||
using Titano.Ui.Controls;
|
||||
using Titano.Ui.Mvvm;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
@@ -31,9 +32,12 @@ public sealed class PresetCard(ExportTab owner, ExportChoice choice) : Observabl
|
||||
/// <summary>Sequence presets apply full settings; export presets only choose the output.</summary>
|
||||
public bool IsSequencePreset => Choice.Sequence is not null;
|
||||
|
||||
public string ToolTip => Choice.Reason is { } reason
|
||||
/// <summary>What choosing the card does, or why it cannot be chosen now (a job runs, the project cannot change).</summary>
|
||||
public string ToolTip => owner.Editor.LockedToolTip ?? (Choice.Reason is { } reason
|
||||
? Loc.L(IsSequencePreset ? "Tooltips.Editor.Export.ApplyPreset" : "Tooltips.Editor.Export.Recommended", reason)
|
||||
: Loc.L("Tooltips.Editor.Export.Preset", Name);
|
||||
: Loc.L("Tooltips.Editor.Export.Preset", Name));
|
||||
|
||||
public string BatchToolTip => owner.Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.Export.InBatch");
|
||||
|
||||
/// <summary>"MP4 · HEVC Main10 · 3840×2160 · 24 fps".</summary>
|
||||
public string? Format { get => _format; private set => Set(ref _format, value); }
|
||||
@@ -57,6 +61,7 @@ public sealed class PresetCard(ExportTab owner, ExportChoice choice) : Observabl
|
||||
|
||||
public ICommand SelectCommand => owner.SelectCommand;
|
||||
|
||||
/// <remarks>A server sequence renders on the server: this PC's encoders neither name nor rule out the encoding.</remarks>
|
||||
public void Update(ExportPlan? plan)
|
||||
{
|
||||
if (plan is null)
|
||||
@@ -65,12 +70,20 @@ public sealed class PresetCard(ExportTab owner, ExportChoice choice) : Observabl
|
||||
return;
|
||||
}
|
||||
var settings = plan.Setup.Encoder.Settings;
|
||||
var remote = owner.Editor.IsRemote;
|
||||
Format = EditorText.Format(plan.Export, settings.Width, settings.Height);
|
||||
Encoding = EditorText.Encoding(plan.Export, settings.BitRate, plan.Setup.Encoder.Capability?.Name);
|
||||
Estimate = plan.Setup.Encoder.IsReady ? EditorText.Estimate(plan.Estimate) : Loc.L("Editor.Export.Unavailable");
|
||||
Encoding = EditorText.Encoding(plan.Export, settings.BitRate, remote ? null : plan.Setup.Encoder.Capability?.Name);
|
||||
Estimate = remote || plan.Setup.Encoder.IsReady ? EditorText.Estimate(plan.Estimate) : Loc.L("Editor.Export.Unavailable");
|
||||
}
|
||||
|
||||
public void RefreshBatch() => OnPropertyChanged(nameof(IsInBatch));
|
||||
|
||||
/// <summary>A job of the sequence started or ended, or the project became read-only: the tooltips say why the card waits.</summary>
|
||||
public void RefreshLocked()
|
||||
{
|
||||
OnPropertyChanged(nameof(ToolTip));
|
||||
OnPropertyChanged(nameof(BatchToolTip));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A codec choice of the Output panel with the profile and depth it implies.</summary>
|
||||
@@ -154,11 +167,14 @@ public sealed class ExportTab : EditorTab
|
||||
public string AddToQueueToolTip => Editor.RenderBlockedReason ?? Loc.L("Tooltips.Editor.Export.AddToQueue");
|
||||
|
||||
public string BatchToolTip => Editor.RenderBlockedReason ?? (Batch.Count == 0 ? Loc.L("Tooltips.Editor.Export.BatchEmpty")
|
||||
: Editor.IsRemote ? Loc.L("Tooltips.Editor.Export.BatchServer", Editor.RemoteText ?? string.Empty)
|
||||
: Editor.IsRemote ? Loc.L("Tooltips.Editor.Export.BatchServer", Editor.ServerName)
|
||||
: Loc.L("Tooltips.Editor.Export.Batch"));
|
||||
|
||||
public bool HasHistory => Editor.Session.Content.Renders.Count > 0;
|
||||
|
||||
/// <summary>The "history" link opens this PC's Jobs screen, which does not list a server's jobs.</summary>
|
||||
public bool CanOpenHistory => !Editor.IsRemote;
|
||||
|
||||
/// <summary>The newest render is a file on this PC (a server's renders stay on the server).</summary>
|
||||
public bool CanReveal => Editor.Session.Content.Renders is [{ OutputPath.Length: > 0 }, ..];
|
||||
|
||||
@@ -208,7 +224,7 @@ public sealed class ExportTab : EditorTab
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>"Restore · 03/10/2026 14:22".</summary>
|
||||
/// <summary>"Restore settings · 03/10/2026 14:22".</summary>
|
||||
public string RestoreText => Loc.L("Editor.Export.Restore", SelectedCopy?.Label ?? string.Empty);
|
||||
|
||||
public string RestoreToolTip => Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.Export.Restore", SelectedCopy?.Label ?? string.Empty);
|
||||
@@ -296,6 +312,11 @@ public sealed class ExportTab : EditorTab
|
||||
|
||||
public IReadOnlyList<Choice> Encoders { get => _encoders; private set => Set(ref _encoders, value); }
|
||||
|
||||
/// <summary>The encoder is this PC's choice only for its own renders; the server or its render node picks its own.</summary>
|
||||
public bool CanChooseEncoder => !Editor.IsRemote;
|
||||
|
||||
public string EncoderToolTip => Editor.IsRemote ? Loc.L("Tooltips.Editor.Export.EncoderServer", Editor.ServerName) : Loc.L("Tooltips.Editor.Export.Encoder");
|
||||
|
||||
public Choice? SelectedEncoder
|
||||
{
|
||||
get => Encoders.FirstOrDefault(e => Equals(e.Value, Export.Overrides.Encoder ?? string.Empty));
|
||||
@@ -305,10 +326,12 @@ public sealed class ExportTab : EditorTab
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>"hardware", "software" (the word, not a colour, carries the state).</summary>
|
||||
public string? EncoderKind => Editor.Plan?.Setup.Encoder.Capability is { } c ? Loc.L(c.Hardware ? "Editor.Export.Hardware" : "Editor.Export.Software") : null;
|
||||
/// <summary>"hardware", "software" for this PC's encoder (the word, not a colour, carries the state).</summary>
|
||||
public string? EncoderKind => !Editor.IsRemote && Editor.Plan?.Setup.Encoder.Capability is { } c
|
||||
? Loc.L(c.Hardware ? "Editor.Export.Hardware" : "Editor.Export.Software")
|
||||
: null;
|
||||
|
||||
public bool IsHardware => Editor.Plan?.Setup.Encoder.Capability?.Hardware == true;
|
||||
public bool IsHardware => !Editor.IsRemote && Editor.Plan?.Setup.Encoder.Capability?.Hardware == true;
|
||||
|
||||
public IReadOnlyList<Choice> Depths { get => _depths; private set => Set(ref _depths, value); }
|
||||
|
||||
@@ -332,9 +355,10 @@ public sealed class ExportTab : EditorTab
|
||||
|
||||
public IReadOnlyList<SaveChoice> SaveChoices { get => _saveChoices; private set => Set(ref _saveChoices, value); }
|
||||
|
||||
/// <summary>The project's folder; a server sequence always renders into its exports folder on the server.</summary>
|
||||
public SaveChoice? SelectedSave
|
||||
{
|
||||
get => SaveChoices.FirstOrDefault(c => !c.Browse && c.Folder == Export.Folder);
|
||||
get => SaveChoices.FirstOrDefault(c => !c.Browse && c.Folder == (CanChooseFolder ? Export.Folder : null));
|
||||
set
|
||||
{
|
||||
if (_refreshing || value is null) return;
|
||||
@@ -353,10 +377,11 @@ public sealed class ExportTab : EditorTab
|
||||
? Loc.L("Tooltips.Editor.Export.FolderServer")
|
||||
: Loc.L("Tooltips.Editor.Export.Folder", Export.Folder ?? Editor.Session.Content.ExportsFolder ?? string.Empty);
|
||||
|
||||
public string? EstimatedSize => Editor.Plan is { Setup.Encoder.IsReady: true } plan ? Formatting.Bytes(plan.Estimate.Bytes) : null;
|
||||
public string? EstimatedSize => Estimated is { } plan ? Formatting.Bytes(plan.Estimate.Bytes) : null;
|
||||
|
||||
public string? EstimatedTime => Editor.Plan is { Setup.Encoder.IsReady: true } plan
|
||||
? Loc.L("Editor.Export.About", Formatting.Duration(plan.Estimate.Time)) + (plan.Setup.Encoder.Capability is { } c ? " · " + c.Name : string.Empty)
|
||||
/// <summary>"about 5 min · NVENC"; without this PC's encoder for a server sequence.</summary>
|
||||
public string? EstimatedTime => Estimated is { } plan
|
||||
? Loc.L("Editor.Export.About", Formatting.Duration(plan.Estimate.Time)) + (!Editor.IsRemote && plan.Setup.Encoder.Capability is { } c ? " · " + c.Name : string.Empty)
|
||||
: null;
|
||||
|
||||
public string? ResultName => Editor.Plan?.FileName;
|
||||
@@ -378,6 +403,9 @@ public sealed class ExportTab : EditorTab
|
||||
|
||||
private ResolvedExport Resolved => Editor.Plan?.Export ?? ExportResolver.Resolve(Export);
|
||||
|
||||
/// <summary>The plan when its estimates mean something: this PC can encode it, or the server renders it.</summary>
|
||||
private ExportPlan? Estimated => Editor.Plan is { } plan && (Editor.IsRemote || plan.Setup.Encoder.IsReady) ? plan : null;
|
||||
|
||||
public bool IsInBatch(string presetId) => Export.Batch.Contains(presetId, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public void SetInBatch(string presetId, bool value)
|
||||
@@ -393,8 +421,8 @@ public sealed class ExportTab : EditorTab
|
||||
try
|
||||
{
|
||||
UpdateLists();
|
||||
SaveChoices = Export.Folder is { } folder
|
||||
? [new SaveChoice(null), new SaveChoice(folder), new SaveChoice(null, Browse: true)]
|
||||
SaveChoices = !CanChooseFolder ? [new SaveChoice(null)]
|
||||
: Export.Folder is { } folder ? [new SaveChoice(null), new SaveChoice(folder), new SaveChoice(null, Browse: true)]
|
||||
: [new SaveChoice(null), new SaveChoice(null, Browse: true)];
|
||||
if (!NameTemplate.IsDirty) NameTemplate.Load(Export.NameTemplate);
|
||||
OnAllPropertiesChanged();
|
||||
@@ -403,11 +431,8 @@ public sealed class ExportTab : EditorTab
|
||||
{
|
||||
_refreshing = false;
|
||||
}
|
||||
foreach (var card in Cards)
|
||||
{
|
||||
card.IsSelected = card.Choice.Sequence is null && string.Equals(card.Choice.ExportPresetId, Resolved.PresetId, StringComparison.OrdinalIgnoreCase);
|
||||
card.RefreshBatch();
|
||||
}
|
||||
SelectCards();
|
||||
foreach (var card in Cards) card.RefreshBatch();
|
||||
_ = EstimateCardsAsync();
|
||||
}
|
||||
|
||||
@@ -420,15 +445,21 @@ public sealed class ExportTab : EditorTab
|
||||
if (!Width.IsDirty) Width.Load(settings?.Width.ToString(CultureInfo.InvariantCulture) ?? string.Empty);
|
||||
if (!Height.IsDirty) Height.Load(settings?.Height.ToString(CultureInfo.InvariantCulture) ?? string.Empty);
|
||||
UpdateLists();
|
||||
Notices = Editor.Plan is { } plan
|
||||
? [.. plan.Setup.Warnings.Select(w => Loc.L(w.Key, [.. w.Args])).Concat(plan.Export.Warnings.Select(k => Loc.L(k))).Distinct()]
|
||||
: [];
|
||||
Notices = Editor.Plan is { } plan ? PlanNotices(plan) : [];
|
||||
OnAllPropertiesChanged();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_refreshing = false;
|
||||
}
|
||||
// The plan follows the preset a read-only session chose to render.
|
||||
SelectCards();
|
||||
}
|
||||
|
||||
public override void OnBusyChanged()
|
||||
{
|
||||
base.OnBusyChanged();
|
||||
foreach (var card in Cards) card.RefreshLocked();
|
||||
}
|
||||
|
||||
public override void OnContentChanged()
|
||||
@@ -479,6 +510,24 @@ public sealed class ExportTab : EditorTab
|
||||
|
||||
private void LoadCards() => Cards = [.. ExportPlanner.Choices(Editor.Session.Presets, Editor.Session.Advice).Select(c => new PresetCard(this, c))];
|
||||
|
||||
/// <summary>The card of the export preset the plan renders.</summary>
|
||||
private void SelectCards()
|
||||
{
|
||||
foreach (var card in Cards)
|
||||
card.IsSelected = card.Choice.Sequence is null && string.Equals(card.Choice.ExportPresetId, Resolved.PresetId, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What the plan changed or cannot do, localised; for a server sequence without this PC's encoder notices (the server
|
||||
/// or its render node picks the encoder).
|
||||
/// </summary>
|
||||
private IReadOnlyList<string> PlanNotices(ExportPlan plan)
|
||||
{
|
||||
var encoder = Editor.IsRemote ? plan.Setup.Encoder.Notices.Select(n => n.Key).ToHashSet(StringComparer.Ordinal) : [];
|
||||
return [.. plan.Setup.Warnings.Where(w => !encoder.Contains(w.Key)).Select(w => Loc.L(w.Key, [.. w.Args]))
|
||||
.Concat(plan.Export.Warnings.Select(k => Loc.L(k))).Distinct()];
|
||||
}
|
||||
|
||||
/// <summary>Estimates every card off the UI thread for the project as it is now (latest request wins).</summary>
|
||||
private async Task EstimateCardsAsync()
|
||||
{
|
||||
@@ -507,13 +556,18 @@ public sealed class ExportTab : EditorTab
|
||||
for (var i = 0; i < cards.Count; i++) cards[i].Update(plans[i]);
|
||||
}
|
||||
|
||||
/// <summary>Makes the chosen copy the project as one undo step; the toast offers Undo.</summary>
|
||||
/// <summary>
|
||||
/// Makes the chosen copy the project as one undo step. The toast's Undo brings back the project as it was before, as
|
||||
/// a new step, while the restore is still the last change of this editor (a later edit would otherwise be undone).
|
||||
/// </summary>
|
||||
private async Task RestoreAsync()
|
||||
{
|
||||
if (SelectedCopy is not { } copy) return;
|
||||
var session = Editor.Session;
|
||||
var before = session.Project;
|
||||
try
|
||||
{
|
||||
if (!await Editor.Session.RestoreAsync(copy))
|
||||
if (!await session.RestoreAsync(copy))
|
||||
{
|
||||
Editor.Shell.Notify(Loc.L("Editor.Copy.Same"), copy.Label);
|
||||
return;
|
||||
@@ -524,7 +578,17 @@ public sealed class ExportTab : EditorTab
|
||||
Editor.Shell.ReportError(ex);
|
||||
return;
|
||||
}
|
||||
Editor.Shell.Notify(Loc.L("Editor.Copy.Restored"), copy.Label, Loc.L("Editor.Copy.Undo"), Loc.L("Tooltips.Editor.Copy.Undo"), () => Editor.Session.Undo());
|
||||
var restored = session.Project;
|
||||
var editor = Editor;
|
||||
bool Undoable() => ReferenceEquals(editor.Shell.Sequence.Editor, editor) && ReferenceEquals(session.Project, restored);
|
||||
editor.Shell.ShowToast(new Toast
|
||||
{
|
||||
Title = Loc.L("Editor.Copy.Restored"),
|
||||
Message = copy.Label,
|
||||
ActionText = Loc.L("Editor.Copy.Undo"),
|
||||
ActionToolTip = Loc.L("Tooltips.Editor.Copy.Undo"),
|
||||
ActionCommand = new RelayCommand(() => session.Edit(_ => before), Undoable),
|
||||
});
|
||||
}
|
||||
|
||||
private void OpenHistory()
|
||||
|
||||
@@ -25,9 +25,18 @@ public interface IRemoteSequenceApi : IDisposable
|
||||
|
||||
Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Jobs waiting or running on the server.</summary>
|
||||
/// <summary>Every analysis and render job waiting, running or paused on the server (all pages).</summary>
|
||||
Task<IReadOnlyList<JobDto>> ListActiveJobsAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Cancels a waiting or running job; returns it as the server now has it.</summary>
|
||||
Task<JobDto> CancelJobAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Queues a failed or cancelled job again from its checkpoint; returns it as the server now has it.</summary>
|
||||
Task<JobDto> RetryJobAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Moves a waiting job up or down the queue (<paramref name="priority"/>: background, normal or user).</summary>
|
||||
Task<JobDto> SetJobPriorityAsync(Guid id, string priority, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Server events until cancelled or the socket closes.</summary>
|
||||
IAsyncEnumerable<ServerEvent> EventsAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -21,11 +21,22 @@ public interface ISequenceSource : IAsyncDisposable
|
||||
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.
|
||||
/// The project is shown, not changed: a server sequence for an account without the Edit right, or one whose frames
|
||||
/// changed on the server (<see cref="IsOutdated"/>). The editor disables every change and the source refuses to
|
||||
/// store one. It can turn true while the sequence is open (<see cref="ReadOnlyChanged"/>).
|
||||
/// </summary>
|
||||
bool IsReadOnly { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The frames this PC shows are no longer the sequence's (frames added or removed on the server since its proxies
|
||||
/// were fetched): frame positions in the project would point at other frames, so nothing is saved or rendered until
|
||||
/// the sequence is opened again with fresh proxies.
|
||||
/// </summary>
|
||||
bool IsOutdated { get; }
|
||||
|
||||
/// <summary><see cref="IsReadOnly"/> changed (any thread).</summary>
|
||||
event Action? ReadOnlyChanged;
|
||||
|
||||
/// <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;
|
||||
|
||||
@@ -51,6 +62,12 @@ public interface ISequenceSource : IAsyncDisposable
|
||||
|
||||
/// <summary>Recent jobs that may concern the sequence (queued, running, finished), for the busy state and the cost of Analyse.</summary>
|
||||
Task<IReadOnlyList<Job>> ListJobsAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Cancels a job of the sequence that waits or runs; its new state arrives through <see cref="JobChanged"/>.</summary>
|
||||
Task CancelJobAsync(Guid jobId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Queues a failed or cancelled job of the sequence again from its checkpoint.</summary>
|
||||
Task RetryJobAsync(Guid jobId, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>A sequence as the editor opens it.</summary>
|
||||
|
||||
@@ -55,6 +55,15 @@ public sealed class LocalSequenceSource : ISequenceSource
|
||||
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
public bool IsOutdated => false;
|
||||
|
||||
/// <summary>A sequence of this PC is never read-only.</summary>
|
||||
public event Action? ReadOnlyChanged
|
||||
{
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
|
||||
public event Action<Job>? JobChanged;
|
||||
|
||||
/// <summary>A save changed the frame the Library shows for the sequence: the stored row (any thread).</summary>
|
||||
@@ -153,6 +162,12 @@ public sealed class LocalSequenceSource : ISequenceSource
|
||||
public async Task<IReadOnlyList<Job>> ListJobsAsync(CancellationToken cancellationToken) =>
|
||||
(await _db.Jobs.ListAsync(null, JobsListed, null, cancellationToken)).Items;
|
||||
|
||||
public Task CancelJobAsync(Guid jobId, CancellationToken cancellationToken) =>
|
||||
(_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).CancelAsync(jobId, cancellationToken);
|
||||
|
||||
public Task RetryJobAsync(Guid jobId, CancellationToken cancellationToken) =>
|
||||
(_engine ?? throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"))).ResumeAsync(jobId, cancellationToken);
|
||||
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
if (_engine is not null) _engine.JobChanged -= OnJobChanged;
|
||||
|
||||
@@ -27,6 +27,9 @@ namespace Titano.App.Editor;
|
||||
/// version they were made from; a 409 (someone changed them meanwhile) reads the server's settings and merges again as
|
||||
/// the local archive does (<see cref="ProjectMerge"/>: the editor wins on members both changed). Nothing is written to a
|
||||
/// local archive. Analyses and renders are server jobs; their state and progress come from the server's events.
|
||||
/// Project settings name frames by position, so the cached frames must be the server's: a load that finds other frames
|
||||
/// throws <see cref="ProxiesOutdatedException"/>, and frames that change on the server while the sequence is open make
|
||||
/// it <see cref="IsOutdated"/> (read-only, nothing saved or rendered).
|
||||
/// </summary>
|
||||
public sealed class RemoteSequenceSource : ISequenceSource
|
||||
{
|
||||
@@ -42,7 +45,10 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
private readonly ConcurrentDictionary<Guid, byte> _foreign = new();
|
||||
private readonly CancellationTokenSource _stopping = new();
|
||||
private readonly Task _listening;
|
||||
private readonly bool _noEditRight;
|
||||
private Stored? _stored;
|
||||
private int _framesVersion = -1;
|
||||
private int _outdated;
|
||||
private int _disposed;
|
||||
|
||||
/// <param name="readOnly">The account may look at the sequence but not change it (no Edit right on the server).</param>
|
||||
@@ -53,7 +59,7 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
ArgumentNullException.ThrowIfNull(decoder);
|
||||
_remote = remote;
|
||||
_api = api;
|
||||
IsReadOnly = readOnly;
|
||||
_noEditRight = readOnly;
|
||||
_frames = remote.OpenFrames(decoder);
|
||||
_pixels = (IFrameSource)_frames;
|
||||
var stopping = _stopping.Token;
|
||||
@@ -62,7 +68,11 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
|
||||
public bool IsRemote => true;
|
||||
|
||||
public bool IsReadOnly { get; }
|
||||
public bool IsReadOnly => _noEditRight || IsOutdated;
|
||||
|
||||
public bool IsOutdated => Volatile.Read(ref _outdated) == 1;
|
||||
|
||||
public event Action? ReadOnlyChanged;
|
||||
|
||||
public event Action<Job>? JobChanged;
|
||||
|
||||
@@ -73,6 +83,8 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
{
|
||||
var dto = await Call(() => _api.GetSequenceAsync(Id, cancellationToken));
|
||||
var manifest = await Call(() => _api.GetManifestAsync(Id, cancellationToken));
|
||||
if (!SameFrames(manifest)) throw Outdated();
|
||||
Volatile.Write(ref _framesVersion, manifest.FramesVersion);
|
||||
var report = await Call(() => _api.GetAnalysisReportAsync(Id, cancellationToken));
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
@@ -129,7 +141,8 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
var (stored, version) = Volatile.Read(ref _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"));
|
||||
if (IsOutdated) throw new ProxiesOutdatedException(Loc.L("Editor.Error.FramesChanged"));
|
||||
if (_noEditRight) throw new InvalidOperationException(Loc.L("Editor.Error.RemoteReadOnly"));
|
||||
var hero = merged.HeroFrame == stored.HeroFrame ? (Guid?)null : HeroFrameId(merged);
|
||||
try
|
||||
{
|
||||
@@ -143,15 +156,22 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
// Changed on the server since this editor read it: merge again on top of the server's settings.
|
||||
if (attempt == SaveAttempts) throw new IOException(Loc.L("Editor.Error.SaveConflict"), ex);
|
||||
var manifest = await Call(() => _api.GetManifestAsync(Id, cancellationToken));
|
||||
if (!SameFrames(manifest)) throw Outdated();
|
||||
Volatile.Write(ref _stored, new Stored(Parse(manifest.SettingsJson), manifest.SettingsVersion));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// The server queues every job at the user's priority; another priority ("Add to queue") is set right after. A
|
||||
/// render embeds the project, whose frame positions mean nothing once the frames changed: refused while outdated.
|
||||
/// </remarks>
|
||||
public async Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
if (request.Kind == JobKind.Render && IsOutdated) throw new ProxiesOutdatedException(Loc.L("Editor.Error.FramesChanged"));
|
||||
var dto = await Call(() => _api.CreateJobAsync(new CreateJobRequest(JobWire.Kind(request.Kind), request.Targets, request.ParametersJson), cancellationToken));
|
||||
if (request.Priority != JobPriority.User) dto = await PrioritiseAsync(dto, request.Priority, cancellationToken);
|
||||
// The server's events may have reported the job already; its first state never replaces a later one.
|
||||
if (JobWire.FromDto(dto) is { } job && _jobs.TryAdd(job.Id, job)) JobChanged?.Invoke(job);
|
||||
return dto.Id;
|
||||
@@ -165,44 +185,65 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
return mine;
|
||||
}
|
||||
|
||||
public async Task CancelJobAsync(Guid jobId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (JobWire.FromDto(await _api.CancelJobAsync(jobId, cancellationToken)) is { } job) Publish(job);
|
||||
}
|
||||
|
||||
public async Task RetryJobAsync(Guid jobId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (JobWire.FromDto(await _api.RetryJobAsync(jobId, cancellationToken)) is { } job) Publish(job);
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _disposed, 1) == 1) return;
|
||||
await _stopping.CancelAsync();
|
||||
await _listening;
|
||||
_stopping.Dispose();
|
||||
if (_frames is IAsyncDisposable frames) await frames.DisposeAsync();
|
||||
_api.Dispose();
|
||||
try
|
||||
{
|
||||
await _stopping.CancelAsync();
|
||||
await _listening;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_stopping.Dispose();
|
||||
if (_frames is IAsyncDisposable frames) await frames.DisposeAsync();
|
||||
_api.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Follows the server's job events, reconnecting with a growing delay (events lost meanwhile are read back from the job).</summary>
|
||||
/// <summary>
|
||||
/// Follows the server's events until the editor closes, reconnecting with a growing delay (job states lost meanwhile
|
||||
/// are read back from the jobs). Nothing that fails on the way ends it.
|
||||
/// </summary>
|
||||
private async Task ListenAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var failures = 0;
|
||||
try
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
try
|
||||
{
|
||||
try
|
||||
await foreach (var e in _api.EventsAsync(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}");
|
||||
failures = 0;
|
||||
await OnEventAsync(e, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested) return;
|
||||
Log.Info("editor", $"Events of the server lost for {_remote.Sequence.DisplayTitle}: {ex.Message}");
|
||||
}
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
// The editor closed.
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested) return;
|
||||
Log.Info("editor", $"Jobs of {_remote.Sequence.DisplayTitle} could not be read again: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,6 +251,9 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
{
|
||||
switch (e)
|
||||
{
|
||||
case SequenceChangedEvent changed when changed.SequenceId == Id && changed.FramesVersion != Volatile.Read(ref _framesVersion):
|
||||
await CheckFramesAsync(cancellationToken).ConfigureAwait(false);
|
||||
break;
|
||||
// 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
|
||||
@@ -242,6 +286,37 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Frames added or removed on the server: whether this PC's frames are still the sequence's.</summary>
|
||||
private async Task CheckFramesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var manifest = await _api.GetManifestAsync(Id, cancellationToken).ConfigureAwait(false);
|
||||
if (SameFrames(manifest)) Volatile.Write(ref _framesVersion, manifest.FramesVersion);
|
||||
else MarkOutdated();
|
||||
}
|
||||
catch (Exception ex) when (ex is TitanoApiException or HttpRequestException or JsonException
|
||||
|| (ex is OperationCanceledException && !cancellationToken.IsCancellationRequested))
|
||||
{
|
||||
Log.Info("editor", $"The frames of {_remote.Sequence.DisplayTitle} could not be compared: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Sets a priority other than the user's on a job the server just queued; the job stays queued if that fails.</summary>
|
||||
private async Task<JobDto> PrioritiseAsync(JobDto dto, JobPriority priority, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _api.SetJobPriorityAsync(dto.Id, JobWire.Priority(priority), cancellationToken);
|
||||
}
|
||||
catch (Exception ex) when (ex is TitanoApiException or HttpRequestException)
|
||||
{
|
||||
// Already claimed (409) or refused: the job runs at the user's priority, which is never later than asked.
|
||||
Log.Info("editor", $"Job {dto.Id} keeps the user's priority on the server: {ex.Message}");
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>After a lost event socket: the tracked jobs as the server has them now.</summary>
|
||||
private async Task RefreshTrackedAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -255,6 +330,24 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
JobChanged?.Invoke(job);
|
||||
}
|
||||
|
||||
/// <summary>The server's frames are the cached ones, in the same order (frame positions in the project mean the same frames).</summary>
|
||||
private bool SameFrames(SequenceManifest manifest) =>
|
||||
manifest.Frames.OrderBy(f => f.Index).Select(f => f.Id).SequenceEqual(_remote.Frames.Select(f => f.Id));
|
||||
|
||||
/// <summary>The frames changed on the server: from now on the project is only shown.</summary>
|
||||
private ProxiesOutdatedException Outdated()
|
||||
{
|
||||
MarkOutdated();
|
||||
return new ProxiesOutdatedException(Loc.L("Editor.Error.FramesChanged"));
|
||||
}
|
||||
|
||||
private void MarkOutdated()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _outdated, 1) == 1) return;
|
||||
Log.Info("editor", $"The frames of {_remote.Sequence.DisplayTitle} changed on the server; its proxies are out of date");
|
||||
ReadOnlyChanged?.Invoke();
|
||||
}
|
||||
|
||||
private bool Concerns(Job job) => job.TargetIds.Contains(Id) && job.Kind is JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render;
|
||||
|
||||
/// <summary>The frame of the project's hero, or <see cref="Guid.Empty"/> (the first frame shows) without one.</summary>
|
||||
@@ -307,3 +400,9 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
/// <summary>The server's settings as last read or written, with the version a save must name.</summary>
|
||||
private sealed record Stored(ProjectSettings Project, int Version);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The proxies of a server sequence are for frames the server no longer has (added or removed since they were fetched):
|
||||
/// they must be fetched again before the sequence can be edited.
|
||||
/// </summary>
|
||||
public sealed class ProxiesOutdatedException(string message) : IOException(message);
|
||||
@@ -255,13 +255,14 @@ public sealed class AppServices : IAsyncDisposable
|
||||
var handlers = CreateJobHandlers(this);
|
||||
var kinds = handlers.Select(h => h.Kind).Distinct().ToArray();
|
||||
Engine = new JobEngine(database, handlers, new JobEngineOptions { WorkerId = WorkerId, Kinds = kinds });
|
||||
// Sync follows the engine's jobs before it runs any: a render resumed at start that finishes at once is still sent (Export "Sync").
|
||||
Sync.Update();
|
||||
// With no handler the engine must not run: an empty kind list would let workers claim (and fail) every job.
|
||||
var started = startEngine && handlers.Count > 0;
|
||||
if (started) await Engine.StartAsync(ct);
|
||||
Jobs = new EngineJobQueue(database, Engine, started);
|
||||
Log.Info("jobs", started ? $"Job engine started with {Engine.Options.Workers} worker(s) for {string.Join(", ", kinds)}" : "No job handlers registered; jobs stay queued");
|
||||
UpdateRenderNode();
|
||||
Sync.Update();
|
||||
}
|
||||
|
||||
/// <summary>Media Foundation (hardware first, software H.264; hardware as Settings › Rendering allows) then managed
|
||||
|
||||
@@ -47,14 +47,27 @@
|
||||
ToolTip="{l:Loc Tooltips.Editor.Back}" AutomationProperties.Name="{l:Loc Editor.Back}" Margin="-6,0,0,0" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" Margin="6,0,12,0" MaxWidth="320"
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
<!-- A server sequence edited with proxies: where it lives and its analysis or render running there, before the summary; all of it
|
||||
shares the space the actions leave and ends in an ellipsis. -->
|
||||
<!-- A server sequence edited with proxies: where it lives (read-only or out of date says so) and its analysis or render on the server,
|
||||
before the summary; all of it shares the space the actions leave and ends in an ellipsis. -->
|
||||
<DockPanel Grid.Column="2" VerticalAlignment="Center">
|
||||
<ui:StatusGlyph DockPanel.Dock="Left" Kind="Remote" Text="{Binding RemoteText}" ToolTip="{Binding RemoteToolTip}" FontSize="{StaticResource Size.Body}" Margin="0,0,12,0"
|
||||
VerticalAlignment="Center" Visibility="{Binding IsRemote, Converter={StaticResource BoolToVisibility}}" />
|
||||
<ui:StatusGlyph DockPanel.Dock="Left" Kind="Running" Text="{Binding ServerJobText}" ToolTip="{Binding ServerJobToolTip}" FontSize="{StaticResource Size.Body}" Margin="0,0,12,0"
|
||||
VerticalAlignment="Center" Typography.NumeralAlignment="Tabular"
|
||||
Visibility="{Binding ServerJobText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
MaxWidth="220" VerticalAlignment="Center" Visibility="{Binding IsRemote, Converter={StaticResource BoolToVisibility}}" />
|
||||
<!-- The server job: its bar, what it is and how far (the text gives way first), and Cancel, which always stays (BRIEF §11.5). -->
|
||||
<Grid DockPanel.Dock="Left" Margin="0,0,12,0" MaxWidth="300" VerticalAlignment="Center"
|
||||
Visibility="{Binding ServerJobText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ProgressBar Width="48" Maximum="1" Value="{Binding ServerJobProgress, Mode=OneWay}" VerticalAlignment="Center" Margin="0,0,8,0"
|
||||
AutomationProperties.Name="{Binding ServerJobText}" Visibility="{Binding HasServerJobProgress, Converter={StaticResource BoolToVisibility}}" />
|
||||
<ui:StatusGlyph Grid.Column="1" Kind="{Binding ServerJobKind}" Text="{Binding ServerJobText}" ToolTip="{Binding ServerJobToolTip}"
|
||||
FontSize="{StaticResource Size.Body}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
|
||||
<Button Grid.Column="2" Style="{StaticResource Button.IconSubtle}" Width="26" Height="26" Margin="4,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.Cancel}"
|
||||
Command="{Binding CancelServerJobCommand}" ToolTip="{Binding CancelServerJobToolTip}" ToolTipService.ShowOnDisabled="True"
|
||||
AutomationProperties.Name="{l:Loc Editor.ServerJob.Cancel}" />
|
||||
</Grid>
|
||||
<TextBlock Text="{Binding Summary}" Style="{StaticResource Text.Secondary}" FontSize="{StaticResource Size.Body}" VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{Binding Summary}" />
|
||||
</DockPanel>
|
||||
@@ -64,7 +77,7 @@
|
||||
ToolTipService.ShowOnDisabled="True" Margin="12,0,0,0" />
|
||||
<v:SplitButton x:Name="RenderButton" IsPrimary="True" Margin="12,0,0,0" Content="{Binding RenderText}" Command="{Binding RenderCommand}"
|
||||
ItemsSource="{Binding RenderChoices}" DisplayMemberPath="Label" SelectedItem="{Binding SelectedRenderChoice}" ToolTip="{Binding RenderToolTip}"
|
||||
ToolTipService.ShowOnDisabled="True" DropDownToolTip="{l:Loc Tooltips.Editor.RenderChoice}"
|
||||
ToolTipService.ShowOnDisabled="True" DropDownToolTip="{Binding RenderChoiceToolTip}"
|
||||
AutomationProperties.Name="{l:Loc Editor.RenderButton}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System.Net;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Editor;
|
||||
@@ -9,6 +10,9 @@ using Titano.Core.Export;
|
||||
using Titano.Core.Imaging.Decoders;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Data.Sync;
|
||||
using Titano.Protocol.Client;
|
||||
using Titano.Ui.Mvvm;
|
||||
|
||||
namespace Titano.App.Sections;
|
||||
@@ -16,7 +20,8 @@ namespace Titano.App.Sections;
|
||||
/// <summary>
|
||||
/// The Sequence section (BRIEF §12.3): opens the sequence the Library, Jobs or the Server screen chose into an
|
||||
/// <see cref="EditorViewModel"/> (from this PC's archive, or a server sequence with this PC's proxies) and closes the
|
||||
/// previous one after saving it; without a sequence it shows the empty state. A failed open is reported and leaves the
|
||||
/// previous one after saving it; without a sequence it shows the empty state. A server sequence whose proxies are
|
||||
/// missing or out of date fetches them first and opens once they are here. A failed open is reported and leaves the
|
||||
/// section usable; an edit that cannot be saved is never dropped without the user's confirmation.
|
||||
/// </summary>
|
||||
public sealed class SequenceViewModel : SectionViewModel
|
||||
@@ -26,6 +31,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
private Guid? _openId;
|
||||
private bool _isLoading;
|
||||
private Task _switch = Task.CompletedTask;
|
||||
private ProxyFetch? _fetch;
|
||||
|
||||
public SequenceViewModel(ShellViewModel shell)
|
||||
: base(SectionKey.Sequence, "Icon.Sequence")
|
||||
@@ -62,12 +68,36 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
public override string Title => _editor?.Title ?? Label;
|
||||
|
||||
/// <summary>Opens <paramref name="sequenceId"/> (the editor of another sequence is saved and closed first).</summary>
|
||||
public Task OpenAsync(Guid sequenceId)
|
||||
/// <param name="reload">Opens it again even when it is the open one (its proxies were fetched again).</param>
|
||||
public Task OpenAsync(Guid sequenceId, bool reload = false)
|
||||
{
|
||||
_switch = SwitchAsync(_switch, sequenceId);
|
||||
_switch = SwitchAsync(_switch, sequenceId, reload);
|
||||
return _switch;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches the proxies of server sequence <paramref name="remoteId"/> into this PC's cache (a download job, shown in
|
||||
/// the job bar and on the Jobs screen) and opens it in the editor once they are here, if it is still the sequence
|
||||
/// asked for.
|
||||
/// </summary>
|
||||
public async Task FetchProxiesAsync(Guid remoteId, string title)
|
||||
{
|
||||
var services = Shell.Services;
|
||||
var sync = services.Sync;
|
||||
if (sync.Server is not { } server || sync.Service is not { } service) throw new InvalidOperationException(Loc.L("Editor.Error.SignedOut"));
|
||||
if (services.Engine is not { } engine || services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
StopFetch();
|
||||
var fetch = new ProxyFetch(remoteId, title, engine);
|
||||
fetch.Handler = job => _dispatcher.BeginInvoke(() => OnFetchChanged(fetch, job));
|
||||
engine.JobChanged += fetch.Handler;
|
||||
_fetch = fetch;
|
||||
var job = await service.EnqueueDownloadAsync(engine, server, remoteId, title, SyncDownloadMode.Proxies, null);
|
||||
fetch.JobId = job.Id;
|
||||
Shell.Notify(Loc.L("Editor.Proxies.Fetching"), title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
// A download that ended before its id was known here is handled now.
|
||||
if (await db.Jobs.GetAsync(job.Id) is { State: JobState.Done or JobState.Failed or JobState.Cancelled } ended) OnFetchChanged(fetch, ended);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores the open sequence's last edit. When the save fails (archive offline, read-only, busy), asks whether to
|
||||
/// discard the edit (BRIEF §12.1: modals only for destructive confirmations).
|
||||
@@ -101,6 +131,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
public override void Dispose()
|
||||
{
|
||||
Shell.PropertyChanged -= OnShellChanged;
|
||||
StopFetch();
|
||||
Editor?.Dispose();
|
||||
base.Dispose();
|
||||
}
|
||||
@@ -118,25 +149,64 @@ 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), or only shown when the
|
||||
/// account may not change it.
|
||||
/// account may not change it. Null when the proxies are not here yet: they are being fetched (<see cref="FetchProxiesAsync"/>).
|
||||
/// </summary>
|
||||
private async Task<ISequenceSource> OpenSourceAsync(AppServices services, Guid sequenceId)
|
||||
private async Task<(ISequenceSource Source, string Title)?> OpenSourceAsync(AppServices services, Guid sequenceId)
|
||||
{
|
||||
if (services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
var processing = services.Processing?.Options;
|
||||
var decoder = processing?.Archive.Decoder ?? DecoderFactory.CreateClient(null);
|
||||
if (await db.Sequences.GetAsync(sequenceId) is not null)
|
||||
if (await db.Sequences.GetAsync(sequenceId) is { } row)
|
||||
{
|
||||
var local = new LocalSequenceSource(db, sequenceId, decoder, services.Engine, processing?.Archive);
|
||||
local.HeroChanged += OnHeroChanged;
|
||||
return local;
|
||||
return (local, row.DisplayTitle);
|
||||
}
|
||||
var sync = services.Sync;
|
||||
if (sync.Server is not { } server || sync.Service is not { } service || sync.ConnectEditor() is not { } api)
|
||||
throw new InvalidOperationException(Loc.L("Editor.Error.SignedOut"));
|
||||
// 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"));
|
||||
var api = sync.ConnectEditor() ?? throw new InvalidOperationException(Loc.L("Editor.Error.Missing"));
|
||||
return new RemoteSequenceSource(remote, api, decoder, readOnly: !sync.Policy.CanEdit);
|
||||
if (await Task.Run(() => service.OpenRemote(server, sequenceId)) is { } remote)
|
||||
return (new RemoteSequenceSource(remote, api, decoder, readOnly: !sync.Policy.CanEdit), remote.Sequence.DisplayTitle);
|
||||
using (api)
|
||||
{
|
||||
string title;
|
||||
try
|
||||
{
|
||||
title = (await api.GetSequenceAsync(sequenceId, CancellationToken.None)).DisplayTitle;
|
||||
}
|
||||
catch (TitanoApiException ex) when (ex.Status == HttpStatusCode.NotFound)
|
||||
{
|
||||
throw new InvalidOperationException(Loc.L("Editor.Error.Missing"), ex);
|
||||
}
|
||||
await FetchProxiesAsync(sequenceId, title);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The proxy download for an open waiting on it moved: opens the sequence once it is done, says why not when it failed.</summary>
|
||||
private void OnFetchChanged(ProxyFetch fetch, Job job)
|
||||
{
|
||||
if (!ReferenceEquals(fetch, _fetch) || job.Id != fetch.JobId || job.State is not (JobState.Done or JobState.Failed or JobState.Cancelled)) return;
|
||||
StopFetch();
|
||||
switch (job.State)
|
||||
{
|
||||
// Opened only when it is still the sequence asked for; otherwise the next visit opens it from the cache.
|
||||
case JobState.Done when Shell.CurrentSequenceId == fetch.RemoteId && IsSelected:
|
||||
_ = OpenAsync(fetch.RemoteId, reload: true);
|
||||
break;
|
||||
case JobState.Failed:
|
||||
Shell.Notify(Loc.L("Editor.Proxies.Failed"), job.Error ?? fetch.Title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"),
|
||||
() => Shell.Navigate(SectionKey.Jobs));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void StopFetch()
|
||||
{
|
||||
if (_fetch is not { } fetch) return;
|
||||
_fetch = null;
|
||||
if (fetch.Handler is { } handler) fetch.Engine.JobChanged -= handler;
|
||||
}
|
||||
|
||||
/// <summary>Set hero changed the frame the Library shows (any thread): its card loads the new thumbnail.</summary>
|
||||
@@ -158,10 +228,10 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SwitchAsync(Task previous, Guid sequenceId)
|
||||
private async Task SwitchAsync(Task previous, Guid sequenceId, bool reload)
|
||||
{
|
||||
await Settled(previous);
|
||||
if (sequenceId == _openId) return;
|
||||
if (sequenceId == _openId && !reload) return;
|
||||
// The open sequence keeps its editor while its last edit is neither stored nor deliberately discarded.
|
||||
if (!await ConfirmCloseAsync()) return;
|
||||
var services = Shell.Services;
|
||||
@@ -175,12 +245,26 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
await old.DisposeAsync();
|
||||
}
|
||||
_openId = sequenceId;
|
||||
var source = await OpenSourceAsync(services, sequenceId);
|
||||
if (await OpenSourceAsync(services, sequenceId) is not { } opened)
|
||||
{
|
||||
// The proxies are on their way; the sequence opens when they are here.
|
||||
_openId = null;
|
||||
return;
|
||||
}
|
||||
var (source, title) = opened;
|
||||
SequenceContent content;
|
||||
try
|
||||
{
|
||||
content = await source.LoadAsync(CancellationToken.None);
|
||||
}
|
||||
catch (ProxiesOutdatedException)
|
||||
{
|
||||
// The server's frames are no longer these proxies: fetch them again, then open.
|
||||
await source.DisposeAsync();
|
||||
_openId = null;
|
||||
await FetchProxiesAsync(sequenceId, title);
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
await source.DisposeAsync();
|
||||
@@ -207,4 +291,18 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
OnPropertyChanged(nameof(IsEmpty));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A proxy download an open waits on, with its engine subscription.</summary>
|
||||
private sealed class ProxyFetch(Guid remoteId, string title, JobEngine engine)
|
||||
{
|
||||
public Guid RemoteId { get; } = remoteId;
|
||||
|
||||
public string Title { get; } = title;
|
||||
|
||||
public JobEngine Engine { get; } = engine;
|
||||
|
||||
public Guid JobId { get; set; }
|
||||
|
||||
public Action<Job>? Handler { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ public delegate IRemoteSequenceApi RemoteSequenceApiFactory(Uri address, string
|
||||
/// <summary><see cref="IRemoteSequenceApi"/> over a signed-in <see cref="TitanoClient"/>, which it owns.</summary>
|
||||
public sealed class TitanoRemoteSequenceApi(TitanoClient client) : IRemoteSequenceApi
|
||||
{
|
||||
private static readonly string[] ActiveStates = [JobWire.State(JobState.Queued), JobWire.State(JobState.Running), JobWire.State(JobState.Paused)];
|
||||
private static readonly JobState[] ActiveStates = [JobState.Queued, JobState.Running, JobState.Paused];
|
||||
private static readonly JobKind[] EditorKinds = [JobKind.DeepAnalyse, JobKind.LightAnalyse, JobKind.Render];
|
||||
|
||||
public Task<SequenceDto> GetSequenceAsync(Guid id, CancellationToken cancellationToken) => client.GetSequenceAsync(id, cancellationToken);
|
||||
|
||||
@@ -27,13 +28,34 @@ public sealed class TitanoRemoteSequenceApi(TitanoClient client) : IRemoteSequen
|
||||
|
||||
public Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken) => client.GetJobAsync(id, cancellationToken);
|
||||
|
||||
/// <summary>Filtered by state and kind and read to the last page: a busy server queues thumbnails and proxies by the thousand.</summary>
|
||||
public async Task<IReadOnlyList<JobDto>> ListActiveJobsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var jobs = new List<JobDto>();
|
||||
foreach (var state in ActiveStates) jobs.AddRange((await client.ListJobsAsync(state, null, cancellationToken)).Items);
|
||||
foreach (var state in ActiveStates)
|
||||
{
|
||||
foreach (var kind in EditorKinds)
|
||||
{
|
||||
string? cursor = null;
|
||||
do
|
||||
{
|
||||
var page = await client.ListJobsAsync(JobWire.State(state), JobWire.Kind(kind), cursor, cancellationToken);
|
||||
jobs.AddRange(page.Items);
|
||||
cursor = page.NextCursor;
|
||||
}
|
||||
while (cursor is not null);
|
||||
}
|
||||
}
|
||||
return jobs;
|
||||
}
|
||||
|
||||
public Task<JobDto> CancelJobAsync(Guid id, CancellationToken cancellationToken) => client.CancelJobAsync(id, cancellationToken);
|
||||
|
||||
public Task<JobDto> RetryJobAsync(Guid id, CancellationToken cancellationToken) => client.RetryJobAsync(id, cancellationToken);
|
||||
|
||||
public Task<JobDto> SetJobPriorityAsync(Guid id, string priority, CancellationToken cancellationToken) =>
|
||||
client.SetJobPriorityAsync(id, priority, cancellationToken);
|
||||
|
||||
public IAsyncEnumerable<ServerEvent> EventsAsync(CancellationToken cancellationToken) => client.EventsAsync(cancellationToken);
|
||||
|
||||
public void Dispose() => client.Dispose();
|
||||
|
||||
@@ -146,19 +146,35 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
|
||||
private bool Allows(Permissions permission) => services.Server.User is { } user && (user.Permissions & (long)permission) != 0;
|
||||
|
||||
/// <summary>Export "Sync": a render of this PC that asked for it is sent to the server once done (<see cref="ExportSync"/>).</summary>
|
||||
/// <summary>
|
||||
/// Export "Sync": a render of this PC that asked for it is sent to the server once done (<see cref="ExportSync"/>),
|
||||
/// also when it ends while the session is down: the send is queued for the saved session's server and waits for it.
|
||||
/// </summary>
|
||||
private void OnJobChanged(Job job)
|
||||
{
|
||||
if (job is not { Kind: JobKind.Render, State: JobState.Done } || Service is not { } service || services.Database is not { } db || _renders is not { } engine)
|
||||
return;
|
||||
_ = SendRenderAsync(new ExportSync(db, service, engine), job);
|
||||
var signedIn = Server;
|
||||
_ = SendRenderAsync(new ExportSync(db, service, engine), job, signedIn ?? SavedServer(), signedIn is null || CanUpload);
|
||||
}
|
||||
|
||||
private async Task SendRenderAsync(ExportSync exports, Job job)
|
||||
/// <summary>Key of the server of the saved session (Disconnect keeps it); null without one.</summary>
|
||||
private string? SavedServer() =>
|
||||
services.Server.HasSavedSession && ServerAddress.TryParse(services.Settings.ServerUrl, out var address) ? SyncService.ServerKey(address) : null;
|
||||
|
||||
private static async Task SendRenderAsync(ExportSync exports, Job job, string? server, bool canUpload)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await exports.SendAsync(job, Server, CanUpload) is { } send) Log.Info("sync", $"{job.TargetLabel} will be sent to the server (job {send.Id})");
|
||||
switch (await exports.SendAsync(job, server, canUpload))
|
||||
{
|
||||
case { Send: { } send }:
|
||||
Log.Info("sync", $"{job.TargetLabel} will be sent to the server (job {send.Id})");
|
||||
break;
|
||||
case { Gate: var gate }:
|
||||
Log.Warning("sync", $"{job.TargetLabel} asked to be sent to the server but was not ({gate})");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,8 @@ namespace Titano.App.Shell;
|
||||
/// <c>Titano.exe --capture <dir></c>: renders every client screen at 1440×900 in the dark and light themes to
|
||||
/// <c><screen>-<theme>.png</c> from <see cref="SampleData"/> (first run on an empty index, then a populated
|
||||
/// one, then the sync table with transfers, a conflict and its confirmation, then the sequence editor on an archive
|
||||
/// sequence and on a server sequence with proxies), for visual review and phase reports (BRIEF §20.2), then exits.
|
||||
/// sequence and on a server sequence with proxies, its server job and a read-only account), for visual review and phase
|
||||
/// reports (BRIEF §20.2), then exits.
|
||||
/// </summary>
|
||||
public static class ScreenCapture
|
||||
{
|
||||
@@ -175,7 +176,8 @@ public static class ScreenCapture
|
||||
/// <summary>
|
||||
/// The sequence editor on the synthetic sunset: every section in both themes (<c>sequence-<tab>-<theme>.png</c>,
|
||||
/// the Camera tab with a keyframe selected, the Export tab as Export.html with the crop mask and no compare), then
|
||||
/// the preview overlays, the waveform, the "what changed" toast of Optimise all and the busy state.
|
||||
/// the preview overlays, the waveform, the "what changed" toast of Optimise all, the Export tab of the sequence once
|
||||
/// the server has it (Sync on) with two "Save both" copies to restore, and the busy state.
|
||||
/// </summary>
|
||||
private static async Task<int> CaptureEditorAsync(MainWindow window, ShellViewModel shell, SampleData sample, string directory)
|
||||
{
|
||||
@@ -215,6 +217,23 @@ public static class ScreenCapture
|
||||
foreach (var toast in window.Toasts.Toasts.ToList()) window.Toasts.Dismiss(toast);
|
||||
}
|
||||
|
||||
// The server has the sequence (Sync can be ticked) and two copies of this PC's settings were kept by "Save both".
|
||||
await sample.KeepEditorCopiesAsync(id);
|
||||
await editor.Session.ReloadAsync();
|
||||
await editor.RefreshSyncGateAsync();
|
||||
var export = editor.Tabs.OfType<ExportTab>().Single();
|
||||
export.SyncToServer = true;
|
||||
editor.SelectedTab = export;
|
||||
editor.IsCompare = false;
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-export-copies", theme);
|
||||
}
|
||||
export.SyncToServer = false;
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
editor.IsCompare = true;
|
||||
|
||||
// Last, as it stays: an analysis of the sequence running (settings disabled, viewing tools live).
|
||||
await sample.MarkAnalysingAsync(id);
|
||||
await editor.AttachJobsAsync();
|
||||
@@ -228,7 +247,10 @@ public static class ScreenCapture
|
||||
|
||||
/// <summary>
|
||||
/// A server sequence open with this PC's proxies (Sunrise over Superga, cached by the sync captures): the server in
|
||||
/// the header, the preview from the proxies, the project from the server (<c>sequence-remote-<theme>.png</c>).
|
||||
/// the header, the preview from the proxies, the project from the server (<c>sequence-remote</c>); its Export tab,
|
||||
/// where the server picks the encoder and keeps the renders (<c>sequence-remote-export</c>); a render running on the
|
||||
/// server with its bar and Cancel (<c>sequence-remote-running</c>); then, last as it stays, the sequence opened by an
|
||||
/// account without the Edit right (<c>sequence-remote-readonly</c>).
|
||||
/// </summary>
|
||||
private static async Task<int> CaptureRemoteEditorAsync(MainWindow window, ShellViewModel shell, SampleData sample, string directory)
|
||||
{
|
||||
@@ -242,11 +264,42 @@ public static class ScreenCapture
|
||||
return 0;
|
||||
}
|
||||
DismissToasts(window);
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
var export = editor.Tabs.OfType<ExportTab>().Single();
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
editor.IsCompare = true;
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-remote", theme);
|
||||
editor.SelectedTab = export;
|
||||
editor.IsCompare = false;
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-remote-export", theme);
|
||||
}
|
||||
|
||||
sample.RunServerRender();
|
||||
await editor.AttachJobsAsync();
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
editor.IsCompare = true;
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-remote-running", theme);
|
||||
}
|
||||
|
||||
sample.EndServerJobs();
|
||||
await sample.RestrictAccountAsync();
|
||||
await shell.Sequence.OpenAsync(id, reload: true);
|
||||
if (shell.Sequence.Editor is not { IsReadOnly: true } viewer)
|
||||
{
|
||||
Log.Warning("capture", "The server sequence did not open read-only");
|
||||
return written;
|
||||
}
|
||||
DismissToasts(window);
|
||||
viewer.SelectedTab = viewer.Exposure;
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
written += await SaveEditorAsync(window, viewer, directory, "sequence-remote-readonly", theme);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
@@ -653,7 +653,8 @@ public sealed class SyncService
|
||||
return path;
|
||||
}
|
||||
|
||||
internal static string SavedCopyName(DateTime localTime) =>
|
||||
/// <summary>The file name of a "Save both" copy kept at <paramref name="localTime"/>.</summary>
|
||||
public static string SavedCopyName(DateTime localTime) =>
|
||||
string.Create(CultureInfo.InvariantCulture, $"{SavedCopyPrefix}{localTime.ToString(SavedCopyTimeFormat, CultureInfo.InvariantCulture)}.json");
|
||||
|
||||
/// <summary>File name pattern of "Save both" copies in a sequence's <c>.titano</c> folder.</summary>
|
||||
|
||||
@@ -273,7 +273,11 @@ public sealed class TitanoClient : IDisposable
|
||||
// ---------------- Jobs and render nodes ----------------
|
||||
|
||||
public Task<Page<JobDto>> ListJobsAsync(string? state = null, string? cursor = null, CancellationToken ct = default) =>
|
||||
GetAsync($"api/v1/jobs?limit=200{Q("state", state)}{Q("cursor", cursor)}", ProtocolJson.Default.PageJobDto, ct);
|
||||
ListJobsAsync(state, null, cursor, ct);
|
||||
|
||||
/// <summary>A page of jobs, newest first, in <paramref name="state"/> and of <paramref name="kind"/> (wire names; null for any).</summary>
|
||||
public Task<Page<JobDto>> ListJobsAsync(string? state, string? kind, string? cursor, CancellationToken ct = default) =>
|
||||
GetAsync($"api/v1/jobs?limit=200{Q("state", state)}{Q("kind", kind)}{Q("cursor", cursor)}", ProtocolJson.Default.PageJobDto, ct);
|
||||
|
||||
public Task<JobDto> CreateJobAsync(CreateJobRequest request, CancellationToken ct = default) =>
|
||||
SendAsync(HttpMethod.Post, "api/v1/jobs", request, ProtocolJson.Default.CreateJobRequest, ProtocolJson.Default.JobDto, ct);
|
||||
|
||||
@@ -86,7 +86,14 @@ 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; }
|
||||
public bool IsReadOnly { get; set; }
|
||||
|
||||
public bool IsOutdated { get; private set; }
|
||||
|
||||
/// <summary>Jobs cancelled and retried through the source.</summary>
|
||||
public List<Guid> Cancelled { get; } = [];
|
||||
|
||||
public List<Guid> Retried { get; } = [];
|
||||
|
||||
/// <summary>Jobs <see cref="ListJobsAsync"/> returns.</summary>
|
||||
public List<Job> Jobs { get; } = [];
|
||||
@@ -138,6 +145,27 @@ internal sealed class FakeSequenceSource(SyntheticSequence sequence, SequenceCon
|
||||
|
||||
public event Action<Job>? JobChanged;
|
||||
|
||||
public event Action? ReadOnlyChanged;
|
||||
|
||||
/// <summary>The server's frames changed under the proxies (as a server sequence finds out).</summary>
|
||||
public void MarkOutdated()
|
||||
{
|
||||
IsOutdated = IsReadOnly = true;
|
||||
ReadOnlyChanged?.Invoke();
|
||||
}
|
||||
|
||||
public Task CancelJobAsync(Guid jobId, CancellationToken cancellationToken)
|
||||
{
|
||||
Cancelled.Add(jobId);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task RetryJobAsync(Guid jobId, CancellationToken cancellationToken)
|
||||
{
|
||||
Retried.Add(jobId);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task<IReadOnlyList<Job>> ListJobsAsync(CancellationToken cancellationToken) => Task.FromResult<IReadOnlyList<Job>>([.. Jobs]);
|
||||
|
||||
/// <summary>A job of the sequence changed (as the engine or the server reports it).</summary>
|
||||
|
||||
@@ -58,17 +58,19 @@ public sealed class ExportSyncTests(TestContext context)
|
||||
State = state,
|
||||
};
|
||||
|
||||
Assert.Null(await exports.SendAsync(Render(true), Server, canUpload: true), "the server does not have the sequence");
|
||||
Assert.Equal(ExportSyncGate.NotLinked, (await exports.SendAsync(Render(true), Server, canUpload: true))?.Gate, "the server does not have the sequence");
|
||||
await sync.LinkAsync(Server, Guid.CreateVersion7(), sequence.Id);
|
||||
Assert.Null(await exports.SendAsync(Render(false), Server, canUpload: true), "the export did not ask for it");
|
||||
Assert.Null(await exports.SendAsync(Render(true), null, canUpload: true), "signed out");
|
||||
Assert.Null(await exports.SendAsync(Render(true), Server, canUpload: false), "no Upload right");
|
||||
Assert.Equal(ExportSyncGate.SignedOut, (await exports.SendAsync(Render(true), null, canUpload: true))?.Gate, "no session, saved or open");
|
||||
Assert.Equal(ExportSyncGate.NoUpload, (await exports.SendAsync(Render(true), Server, canUpload: false))?.Gate, "no Upload right");
|
||||
Assert.Null(await exports.SendAsync(Render(true, JobState.Failed), Server, canUpload: true), "nothing was rendered");
|
||||
|
||||
var send = Assert.NotNull(await exports.SendAsync(Render(true), Server, canUpload: true));
|
||||
var result = Assert.NotNull(await exports.SendAsync(Render(true), Server, canUpload: true));
|
||||
Assert.Equal(ExportSyncGate.Available, result.Gate);
|
||||
var send = Assert.NotNull(result.Send);
|
||||
Assert.Equal(JobKind.UploadCommit, send.Kind);
|
||||
Assert.Equal(SyncTransferKind.SendExports, SyncService.TransferKind(send));
|
||||
Assert.SequenceEqual([sequence.Id], send.TargetIds);
|
||||
Assert.Equal(send.Id, (await exports.SendAsync(Render(true), Server, canUpload: true))!.Id, "a send already waiting takes the next render too");
|
||||
Assert.Equal(send.Id, (await exports.SendAsync(Render(true), Server, canUpload: true))?.Send?.Id, "a send already waiting takes the next render too");
|
||||
}
|
||||
}
|
||||
@@ -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"));
|
||||
|
||||
@@ -300,7 +300,7 @@ public sealed class RemoteSequenceSourceTests(TestContext context)
|
||||
File.WriteAllBytes(files[i]!, JpegEncoder.Encode(image, new JpegEncodeOptions { Quality = 90 }));
|
||||
}
|
||||
var remote = new RemoteSequence(Server, sequence, frames, files);
|
||||
var api = new FakeRemoteSequenceApi(sequence) { SettingsJson = new ProjectSettings().ToJson() };
|
||||
var api = new FakeRemoteSequenceApi(sequence, [.. frames.Select(f => f.Id)]) { SettingsJson = new ProjectSettings().ToJson() };
|
||||
return (new RemoteSequenceSource(remote, api, DecoderFactory.CreateClient(null), readOnly), api, remote);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user