feat(editor): open server sequences with proxies, hero frame to the index, export sync and saved copies
Server sequences that are not in the local index open through a RemoteSequenceSource: proxies from the cache, project from the server's settings with their version (a 409 merges again), analysis report from the server, analyses and renders posted as server jobs (one per preset) and followed through the server's events. Set hero now reaches the index (SequenceEdit.HeroFrameId) so the Library card shows it. The Export tab gains the Sync option (remembered in the project) and restores "Save both" copies through undo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
36 files changed
+1307
-116
No files matched your search
@@ -45,11 +45,16 @@
|
||||
<data name="Editor.Chart.Target" xml:space="preserve"><value>target curve</value></data>
|
||||
<data name="Editor.Chart.Waveform" xml:space="preserve"><value>Waveform</value></data>
|
||||
<data name="Editor.Chart.WaveformOf" xml:space="preserve"><value>luma of frame {0}</value></data>
|
||||
<data name="Editor.Copy.Restored" xml:space="preserve"><value>Project restored</value></data>
|
||||
<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.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.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>
|
||||
@@ -79,12 +84,15 @@
|
||||
<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.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>
|
||||
<data name="Editor.Export.SaveTo" xml:space="preserve"><value>Save to</value></data>
|
||||
<data name="Editor.Export.SequenceFolder" xml:space="preserve"><value>Sequence exports/</value></data>
|
||||
<data name="Editor.Export.Size" xml:space="preserve"><value>Estimated size</value></data>
|
||||
<data name="Editor.Export.Software" xml:space="preserve"><value>software</value></data>
|
||||
<data name="Editor.Export.Sync" xml:space="preserve"><value>Sync</value></data>
|
||||
<data name="Editor.Export.Time" xml:space="preserve"><value>Estimated time</value></data>
|
||||
<data name="Editor.Export.Unavailable" xml:space="preserve"><value>No encoder here</value></data>
|
||||
<data name="Editor.Export.Width" xml:space="preserve"><value>Width</value></data>
|
||||
@@ -174,6 +182,7 @@
|
||||
<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>
|
||||
<data name="Editor.Render.QueuedServer" xml:space="preserve"><value>Render queued on {0}</value></data>
|
||||
<data name="Editor.Render.Reveal" xml:space="preserve"><value>Show in folder</value></data>
|
||||
<data name="Editor.RenderButton" xml:space="preserve"><value>Render</value></data>
|
||||
<data name="Editor.Reset" xml:space="preserve"><value>Reset</value></data>
|
||||
@@ -181,6 +190,7 @@
|
||||
<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.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>
|
||||
<data name="Editor.Shot.Iso" xml:space="preserve"><value>ISO {0}</value><comment>invariant</comment></data>
|
||||
|
||||
+12
-1
@@ -114,6 +114,7 @@
|
||||
<data name="Tooltips.Editor.Chart.Seek" xml:space="preserve"><value>Click or drag to show that frame</value></data>
|
||||
<data name="Tooltips.Editor.Chart.Waveform" xml:space="preserve"><value>Luma waveform of the frame on screen: exposure and clipping at a glance</value></data>
|
||||
<data name="Tooltips.Editor.Chart.WaveformView" xml:space="preserve"><value>Luma of the corrected frame across the picture: white at the top, black at the bottom</value></data>
|
||||
<data name="Tooltips.Editor.Copy.Undo" xml:space="preserve"><value>Bring back the project as it was before the restore · Ctrl+Z</value></data>
|
||||
<data name="Tooltips.Editor.Export.AddToQueue" xml:space="preserve"><value>Add this render to the queue and keep editing</value></data>
|
||||
<data name="Tooltips.Editor.Export.ApplyPreset" xml:space="preserve"><value>Apply this sequence preset to every section · {0}</value></data>
|
||||
<data name="Tooltips.Editor.Export.Batch" xml:space="preserve"><value>Queue every ticked preset as one job; the sequence is prepared once</value></data>
|
||||
@@ -124,6 +125,7 @@
|
||||
<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.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>
|
||||
<data name="Tooltips.Editor.Export.FrameRateAuto" xml:space="preserve"><value>Auto: the preset’s {0} fps</value></data>
|
||||
<data name="Tooltips.Editor.Export.FrameRateReset" xml:space="preserve"><value>Return to the preset’s frame rate</value></data>
|
||||
@@ -134,7 +136,14 @@
|
||||
<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.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>
|
||||
<data name="Tooltips.Editor.Export.SyncNoUpload" xml:space="preserve"><value>Your account cannot send files to the server</value></data>
|
||||
<data name="Tooltips.Editor.Export.SyncNotLinked" xml:space="preserve"><value>The server does not have this sequence: upload it from the Server screen first</value></data>
|
||||
<data name="Tooltips.Editor.Export.SyncRemote" xml:space="preserve"><value>Renders of a server sequence are made on the server and stay there</value></data>
|
||||
<data name="Tooltips.Editor.Export.SyncSignedOut" xml:space="preserve"><value>Connect to the server first to send renders to it</value></data>
|
||||
<data name="Tooltips.Editor.Export.Width" xml:space="preserve"><value>Output width in pixels; empty uses the preset or the source · Enter applies, Esc reverts</value></data>
|
||||
<data name="Tooltips.Editor.Exposure.Deflicker" xml:space="preserve"><value>Removes frame-to-frame brightness flicker; off keeps the camera’s own exposure</value></data>
|
||||
<data name="Tooltips.Editor.Exposure.HolyGrail" xml:space="preserve"><value>Turns ISO, shutter and aperture steps into smooth ramps; off keeps the jumps</value></data>
|
||||
@@ -148,7 +157,7 @@
|
||||
<data name="Tooltips.Editor.Filmstrip" xml:space="preserve"><value>Click or drag to show a frame; markers show exposure steps, warnings and keyframes</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Exclude" xml:space="preserve"><value>Leave this frame out of every render; the photo is not deleted</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Finding" xml:space="preserve"><value>Show the first frame concerned</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Hero" xml:space="preserve"><value>Make this the hero frame; the editor opens on it</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Hero" xml:space="preserve"><value>Use the frame as the sequence thumbnail</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Include" xml:space="preserve"><value>Use this frame in renders again</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Sort" xml:space="preserve"><value>Sort by this column; click again to reverse</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Table" xml:space="preserve"><value>Click a row to show the frame</value></data>
|
||||
@@ -183,6 +192,7 @@
|
||||
<data name="Tooltips.Editor.Preview.ShotData" xml:space="preserve"><value>Show or hide the shot data</value></data>
|
||||
<data name="Tooltips.Editor.Preview.Vectors" xml:space="preserve"><value>Overlay the motion to the next frame measured by the engine</value></data>
|
||||
<data name="Tooltips.Editor.Preview.View" xml:space="preserve"><value>Drag the line to compare · drag to pan · wheel zooms · double-click 1:1</value></data>
|
||||
<data name="Tooltips.Editor.Remote" xml:space="preserve"><value>Edited with proxies on this PC; changes are saved on {0} and analyses and renders run there</value></data>
|
||||
<data name="Tooltips.Editor.Render" xml:space="preserve"><value>Render with the selected preset; progress in the job bar · Ctrl+R</value></data>
|
||||
<data name="Tooltips.Editor.Render.NameError" xml:space="preserve"><value>Fix the file name first: {0}</value></data>
|
||||
<data name="Tooltips.Editor.Render.NoFrames" xml:space="preserve"><value>Every frame is excluded: include some in the Frames tab</value></data>
|
||||
@@ -192,6 +202,7 @@
|
||||
<data name="Tooltips.Editor.RenderChoice" xml:space="preserve"><value>Choose another preset</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.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>
|
||||
|
||||
@@ -44,11 +44,16 @@
|
||||
<data name="Editor.Chart.Target" xml:space="preserve"><value>curva obiettivo</value></data>
|
||||
<data name="Editor.Chart.Waveform" xml:space="preserve"><value>Forma d’onda</value></data>
|
||||
<data name="Editor.Chart.WaveformOf" xml:space="preserve"><value>luma del fotogramma {0}</value></data>
|
||||
<data name="Editor.Copy.Restored" xml:space="preserve"><value>Progetto ripristinato</value></data>
|
||||
<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.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.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>
|
||||
@@ -74,12 +79,15 @@
|
||||
<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.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>
|
||||
<data name="Editor.Export.SaveTo" xml:space="preserve"><value>Salva in</value></data>
|
||||
<data name="Editor.Export.SequenceFolder" xml:space="preserve"><value>exports/ della sequenza</value></data>
|
||||
<data name="Editor.Export.Size" xml:space="preserve"><value>Dimensione stimata</value></data>
|
||||
<data name="Editor.Export.Software" xml:space="preserve"><value>software</value></data>
|
||||
<data name="Editor.Export.Sync" xml:space="preserve"><value>Sincronizza</value></data>
|
||||
<data name="Editor.Export.Time" xml:space="preserve"><value>Tempo stimato</value></data>
|
||||
<data name="Editor.Export.Unavailable" xml:space="preserve"><value>Nessun encoder qui</value></data>
|
||||
<data name="Editor.Export.Width" xml:space="preserve"><value>Larghezza</value></data>
|
||||
@@ -164,6 +172,7 @@
|
||||
<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>
|
||||
<data name="Editor.Render.QueuedServer" xml:space="preserve"><value>Render in coda su {0}</value></data>
|
||||
<data name="Editor.Render.Reveal" xml:space="preserve"><value>Mostra nella cartella</value></data>
|
||||
<data name="Editor.RenderButton" xml:space="preserve"><value>Renderizza</value></data>
|
||||
<data name="Editor.Reset" xml:space="preserve"><value>Ripristina</value></data>
|
||||
@@ -171,6 +180,7 @@
|
||||
<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.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>
|
||||
<data name="Editor.Stack.Median" xml:space="preserve"><value>Mediana</value></data>
|
||||
|
||||
@@ -114,6 +114,7 @@
|
||||
<data name="Tooltips.Editor.Chart.Seek" xml:space="preserve"><value>Clic o trascina per mostrare quel fotogramma</value></data>
|
||||
<data name="Tooltips.Editor.Chart.Waveform" xml:space="preserve"><value>Forma d’onda della luma del fotogramma a schermo: esposizione e clipping a colpo d’occhio</value></data>
|
||||
<data name="Tooltips.Editor.Chart.WaveformView" xml:space="preserve"><value>Luma del fotogramma corretto lungo l’immagine: bianco in alto, nero in basso</value></data>
|
||||
<data name="Tooltips.Editor.Copy.Undo" xml:space="preserve"><value>Riporta il progetto com’era prima del ripristino · Ctrl+Z</value></data>
|
||||
<data name="Tooltips.Editor.Export.AddToQueue" xml:space="preserve"><value>Mette in coda questo render; puoi continuare a modificare</value></data>
|
||||
<data name="Tooltips.Editor.Export.ApplyPreset" xml:space="preserve"><value>Applica questo preset di sequenza a tutte le sezioni · {0}</value></data>
|
||||
<data name="Tooltips.Editor.Export.Batch" xml:space="preserve"><value>Mette in coda i preset spuntati come un unico lavoro; la sequenza si prepara una volta</value></data>
|
||||
@@ -124,6 +125,7 @@
|
||||
<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.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>
|
||||
<data name="Tooltips.Editor.Export.FrameRateAuto" xml:space="preserve"><value>Auto: i {0} fps del preset</value></data>
|
||||
<data name="Tooltips.Editor.Export.FrameRateReset" xml:space="preserve"><value>Torna ai fotogrammi al secondo del preset</value></data>
|
||||
@@ -134,7 +136,14 @@
|
||||
<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.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>
|
||||
<data name="Tooltips.Editor.Export.SyncNoUpload" xml:space="preserve"><value>Il tuo account non può inviare file al server</value></data>
|
||||
<data name="Tooltips.Editor.Export.SyncNotLinked" xml:space="preserve"><value>Il server non ha questa sequenza: caricala prima dalla schermata Server</value></data>
|
||||
<data name="Tooltips.Editor.Export.SyncRemote" xml:space="preserve"><value>I render di una sequenza del server si fanno sul server e restano lì</value></data>
|
||||
<data name="Tooltips.Editor.Export.SyncSignedOut" xml:space="preserve"><value>Connettiti prima al server per inviargli i render</value></data>
|
||||
<data name="Tooltips.Editor.Export.Width" xml:space="preserve"><value>Larghezza in pixel; vuoto usa il preset o la sorgente · Invio applica, Esc annulla</value></data>
|
||||
<data name="Tooltips.Editor.Exposure.Deflicker" xml:space="preserve"><value>Elimina lo sfarfallio di luminosità tra fotogrammi; spento lascia l’esposizione della fotocamera</value></data>
|
||||
<data name="Tooltips.Editor.Exposure.HolyGrail" xml:space="preserve"><value>Trasforma i salti di ISO, tempo e diaframma in rampe morbide; spento li lascia</value></data>
|
||||
@@ -148,7 +157,7 @@
|
||||
<data name="Tooltips.Editor.Filmstrip" xml:space="preserve"><value>Clic o trascina per mostrare un fotogramma; i segni indicano salti di esposizione, avvisi e fotogrammi chiave</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Exclude" xml:space="preserve"><value>Lascia fuori questo fotogramma da ogni render; la foto non viene eliminata</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Finding" xml:space="preserve"><value>Mostra il primo fotogramma interessato</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Hero" xml:space="preserve"><value>Rende questo fotogramma la copertina; l’editor si apre qui</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Hero" xml:space="preserve"><value>Usa il fotogramma come copertina della sequenza</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Include" xml:space="preserve"><value>Usa di nuovo questo fotogramma nei render</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Sort" xml:space="preserve"><value>Ordina per questa colonna; un altro clic inverte</value></data>
|
||||
<data name="Tooltips.Editor.Frames.Table" xml:space="preserve"><value>Fai clic su una riga per mostrare il fotogramma</value></data>
|
||||
@@ -183,6 +192,7 @@
|
||||
<data name="Tooltips.Editor.Preview.ShotData" xml:space="preserve"><value>Mostra o nasconde i dati di scatto</value></data>
|
||||
<data name="Tooltips.Editor.Preview.Vectors" xml:space="preserve"><value>Sovrappone il movimento verso il fotogramma successivo misurato dal motore</value></data>
|
||||
<data name="Tooltips.Editor.Preview.View" xml:space="preserve"><value>Trascina la linea per confrontare · trascina per spostare · la rotellina ingrandisce · doppio clic 1:1</value></data>
|
||||
<data name="Tooltips.Editor.Remote" xml:space="preserve"><value>Modificata con i proxy su questo PC; le modifiche si salvano su {0} e analisi e render vengono eseguiti lì</value></data>
|
||||
<data name="Tooltips.Editor.Render" xml:space="preserve"><value>Renderizza con il preset scelto; avanzamento nella barra dei lavori · Ctrl+R</value></data>
|
||||
<data name="Tooltips.Editor.Render.NameError" xml:space="preserve"><value>Correggi prima il nome del file: {0}</value></data>
|
||||
<data name="Tooltips.Editor.Render.NoFrames" xml:space="preserve"><value>Tutti i fotogrammi sono esclusi: includine alcuni nella scheda Fotogrammi</value></data>
|
||||
@@ -192,6 +202,7 @@
|
||||
<data name="Tooltips.Editor.RenderChoice" xml:space="preserve"><value>Scegli un altro preset</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.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>
|
||||
|
||||
@@ -48,6 +48,9 @@ public sealed class SampleData
|
||||
|
||||
private SampleData(AppServices services) => _services = services;
|
||||
|
||||
/// <summary>The server-only sequence whose proxies <see cref="CacheProxiesAsync"/> keeps on this PC (Sunrise over Superga).</summary>
|
||||
public Guid ProxiedSequenceId => _sunrise;
|
||||
|
||||
/// <summary>Points the services at fakes (server, encoders, update check) for an empty first-run state.</summary>
|
||||
public static SampleData Configure(AppServices services)
|
||||
{
|
||||
@@ -61,6 +64,7 @@ public sealed class SampleData
|
||||
services.Devices = new SampleDeviceMonitor();
|
||||
var sample = new SampleData(services);
|
||||
services.Sync.RemoteFactory = (_, _, _) => sample._remote;
|
||||
services.Sync.EditorFactory = (_, _, _) => sample._remote;
|
||||
return sample;
|
||||
}
|
||||
|
||||
@@ -617,13 +621,15 @@ public sealed class SampleData
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sample server's sequences for the sync table: listings, manifests (frames hashed from their index, so
|
||||
/// unhashed sample frames match them by count; renders as many as the listing says), settings edits and proxies
|
||||
/// (generated JPEGs); uploads and originals are not part of the screenshots.
|
||||
/// 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.
|
||||
/// </summary>
|
||||
private sealed class SampleSyncRemote : ISyncRemote
|
||||
private sealed class SampleSyncRemote : ISyncRemote, IRemoteSequenceApi
|
||||
{
|
||||
private readonly Dictionary<Guid, (SequenceDto Dto, string? Settings, Guid[] Frames)> _sequences = [];
|
||||
private readonly Dictionary<Guid, JobDto> _jobs = [];
|
||||
|
||||
public string Server => ServerAddress;
|
||||
|
||||
@@ -707,6 +713,26 @@ public sealed class SampleData
|
||||
yield break;
|
||||
}
|
||||
|
||||
public Task<string?> GetAnalysisReportAsync(Guid id, CancellationToken cancellationToken) => Task.FromResult<string?>(null);
|
||||
|
||||
public Task<JobDto> CreateJobAsync(CreateJobRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var job = new JobDto(Guid.CreateVersion7(), request.Kind, request.Target, null, "queued", "user", 0, 0, null, null, null, null, 0, null,
|
||||
DateTimeOffset.UtcNow, null, null);
|
||||
lock (_jobs) _jobs[job.Id] = job;
|
||||
return Task.FromResult(job);
|
||||
}
|
||||
|
||||
public Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_jobs) return Task.FromResult(_jobs[id]);
|
||||
}
|
||||
|
||||
public Task<IReadOnlyList<JobDto>> ListActiveJobsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
lock (_jobs) return Task.FromResult<IReadOnlyList<JobDto>>([.. _jobs.Values]);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:v="clr-namespace:Titano.Ui.Visuals;assembly=Titano.Ui"
|
||||
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
|
||||
xmlns:shell="clr-namespace:Titano.App.Shell"
|
||||
xmlns:e="clr-namespace:Titano.App.Editor">
|
||||
@@ -288,10 +289,15 @@
|
||||
<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" />
|
||||
<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 HasHistory, Converter={StaticResource BoolToVisibility}}" />
|
||||
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"
|
||||
ToolTip="{Binding HistoryText}" />
|
||||
</DockPanel>
|
||||
<!-- This PC's settings kept by "Save both" (sync conflicts): the newest, or another from the menu, becomes the project as one undo step. -->
|
||||
<v:SplitButton Margin="0,8,0,0" HorizontalAlignment="Left" Content="{Binding RestoreText}" Command="{Binding RestoreCommand}" ItemsSource="{Binding SavedCopies}" DisplayMemberPath="Label"
|
||||
SelectedItem="{Binding SelectedCopy}" ToolTip="{Binding RestoreToolTip}" ToolTipService.ShowOnDisabled="True"
|
||||
DropDownToolTip="{l:Loc Tooltips.Editor.Export.RestoreChoice}" AutomationProperties.Name="{l:Loc Editor.Export.RestoreName}"
|
||||
Visibility="{Binding HasSavedCopies, Converter={StaticResource BoolToVisibility}}" />
|
||||
</StackPanel>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Focusable="False">
|
||||
<StackPanel IsEnabled="{Binding Editor.IsEditable}" ToolTip="{Binding Editor.BusyToolTip}" ToolTipService.ShowOnDisabled="True">
|
||||
@@ -399,8 +405,17 @@
|
||||
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}" />
|
||||
<ComboBox Grid.Row="8" Grid.Column="1" ItemsSource="{Binding SaveChoices}" SelectedItem="{Binding SelectedSave}" DisplayMemberPath="Label"
|
||||
ToolTip="{Binding SaveToolTip}" AutomationProperties.Name="{l:Loc Editor.Export.SaveTo}" />
|
||||
<Grid Grid.Row="8" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<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}" />
|
||||
<!-- 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" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Border Style="{StaticResource Border.Card}" Margin="0,12,0,0" Padding="12,10">
|
||||
|
||||
@@ -51,6 +51,9 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
|
||||
public ISequenceSource Source { get; }
|
||||
|
||||
/// <summary>A server sequence edited with proxies: saved, analysed and rendered on the server.</summary>
|
||||
public bool IsRemote => Source.IsRemote;
|
||||
|
||||
public SequenceContent Content { get; private set; }
|
||||
|
||||
public SequenceContext Context { get; private set; }
|
||||
@@ -133,6 +136,25 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
public ArchiveJobRequest RenderRequest(ExportSettings export, bool useProxies = false) =>
|
||||
ProcessingJobs.Render(Content.Sequence, export, Content.SourceWidth, Content.SourceHeight, Project with { Export = export }, useProxies);
|
||||
|
||||
/// <summary>
|
||||
/// The jobs that render <paramref name="export"/> and its batch: one job on this PC (the sequence is prepared once),
|
||||
/// one per preset on a server, where a render node uploads one file per job (BRIEF §14.7).
|
||||
/// </summary>
|
||||
public IReadOnlyList<ArchiveJobRequest> RenderRequests(ExportSettings export) => IsRemote
|
||||
? ProcessingJobs.RenderEach(Content.Sequence, export, Content.SourceWidth, Content.SourceHeight, Project with { Export = export })
|
||||
: [RenderRequest(export)];
|
||||
|
||||
/// <summary>
|
||||
/// Makes a "Save both" copy of this PC's settings the project, as one undoable step; false when it stores the same values.
|
||||
/// </summary>
|
||||
/// <exception cref="System.IO.InvalidDataException">The copy cannot be read.</exception>
|
||||
public async Task<bool> RestoreAsync(SavedCopy copy)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(copy);
|
||||
var restored = await Task.Run(() => SavedCopies.Read(copy));
|
||||
return Edit(_ => restored);
|
||||
}
|
||||
|
||||
/// <summary>The export of the project with preset <paramref name="presetId"/> chosen (own values, no batch).</summary>
|
||||
public ExportSettings ExportFor(string presetId) =>
|
||||
Project.Export with { Preset = Project.Export.Preset.WithManual(presetId), Overrides = new ExportOverrides(), Batch = [] };
|
||||
|
||||
@@ -84,6 +84,11 @@ public abstract class EditorTab : LocalizedViewModel
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Whether this sequence can send its renders to the server changed (<see cref="EditorViewModel.SyncGate"/>).</summary>
|
||||
public virtual void OnSyncGateChanged()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
foreach (var row in Rows) row.Dispose();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Jobs;
|
||||
using Titano.Core.Advice;
|
||||
using Titano.Core.Export;
|
||||
using Titano.Core.Localization;
|
||||
@@ -28,6 +29,24 @@ 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>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>"Render running on Studio NAS · 1,240 / 3,600 · 11.3 fps · 3 min left".</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) };
|
||||
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)));
|
||||
return string.Join(Separator, parts);
|
||||
}
|
||||
|
||||
/// <summary>"3,600 frames · 24 fps · 2 min 30 s · 3840×2160 · source 8192×5464": what the export makes of the sequence (Export.html header).</summary>
|
||||
public static string OutputSummary(SequenceContent content, ExportPlan plan)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
private IThumbnailSource _thumbnails;
|
||||
private int _playLimit;
|
||||
private double? _analysisSecondsPerFrame;
|
||||
private ExportSyncGate _syncGate = ExportSyncGate.SignedOut;
|
||||
private bool _disposed;
|
||||
|
||||
public EditorViewModel(ShellViewModel shell, EditorSession session, IReadOnlyList<IVideoEncoderProvider> encoders, EncoderHost host)
|
||||
@@ -107,7 +108,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
session.ProjectChanged += OnProjectChanged;
|
||||
session.ContentChanged += OnContentChanged;
|
||||
session.SaveFailed += OnSaveFailed;
|
||||
if (shell.Services.Jobs is { } jobs) jobs.JobChanged += OnJobChanged;
|
||||
session.Source.JobChanged += OnJobChanged;
|
||||
shell.Services.Sync.Changed += OnSyncChanged;
|
||||
UpdateMarkers();
|
||||
RequestCorrections();
|
||||
RequestPlan();
|
||||
@@ -122,6 +124,25 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
|
||||
public string Title => Session.Content.Sequence.DisplayTitle;
|
||||
|
||||
/// <summary>A server sequence edited with proxies (the header says where it lives).</summary>
|
||||
public bool IsRemote => Session.IsRemote;
|
||||
|
||||
/// <summary>"Studio NAS" beside the title of a server sequence.</summary>
|
||||
public string? RemoteText => IsRemote ? Shell.Services.Server.ServerName ?? Loc.L("Server.Label.Server") : null;
|
||||
|
||||
public string? RemoteToolTip => IsRemote ? Loc.L("Tooltips.Editor.Remote", RemoteText ?? string.Empty) : null;
|
||||
|
||||
/// <summary>"Render · 46 %" while an analysis or render of a server sequence runs on the server (the job bar shows this PC's jobs).</summary>
|
||||
public string? ServerJobText => ServerJob is { } job ? EditorText.ServerJob(job) : null;
|
||||
|
||||
/// <summary>Frames, speed and time left of the server job.</summary>
|
||||
public string? ServerJobToolTip => ServerJob is { } job ? EditorText.ServerJobDetail(job, RemoteText ?? string.Empty) : null;
|
||||
|
||||
/// <summary>The Export "Sync" option: available, or why not.</summary>
|
||||
public ExportSyncGate SyncGate { get => _syncGate; private set => Set(ref _syncGate, value); }
|
||||
|
||||
private Job? ServerJob => IsRemote ? _jobs.Values.Where(j => j.State == JobState.Running).OrderBy(j => j.Started).FirstOrDefault() : null;
|
||||
|
||||
/// <summary>
|
||||
/// "3,600 frames · Canon EOS R5 · 2 s interval · 2 h 00 m · 3 warnings"; on the Export tab what the video will be:
|
||||
/// "3,600 frames · 24 fps · 2 min 30 s · 3840×2160 · source 8192×5464" (Export.html).
|
||||
@@ -364,7 +385,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
null when _planned => Loc.L("Tooltips.Editor.Render.NoSource"),
|
||||
null => Loc.L("Tooltips.Editor.Render.Planning"),
|
||||
{ NameError: { } error } => Loc.L("Tooltips.Editor.Render.NameError", error),
|
||||
{ Setup.Encoder.IsReady: false } plan => plan.Setup.Encoder.Notices.LastOrDefault() is { } notice
|
||||
// The server picks its encoder (a render node, or its managed fallback): this PC's encoders do not decide.
|
||||
{ Setup.Encoder.IsReady: false } plan when !IsRemote => plan.Setup.Encoder.Notices.LastOrDefault() is { } notice
|
||||
? Loc.L(notice.Key, [.. notice.Args])
|
||||
: Loc.L("Editor.Export.Unavailable"),
|
||||
{ Setup.Plan.Frames.Count: 0 } => Loc.L("Tooltips.Editor.Render.NoFrames"),
|
||||
@@ -399,13 +421,17 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// <summary>"Optimise section": the advisor's heavier decisions, reported in a toast (what changed, from what to what).</summary>
|
||||
public void Optimise(AdvisorSection section) => Report(Session.Optimise(section));
|
||||
|
||||
/// <summary>Queues a render of the project's export (with its batch presets when <paramref name="batch"/>).</summary>
|
||||
/// <summary>
|
||||
/// Queues a render of the project's export (with its batch presets when <paramref name="batch"/>): on this PC's
|
||||
/// engine, or one server job per preset for a server sequence.
|
||||
/// </summary>
|
||||
public async Task RenderAsync(JobPriority priority, bool batch)
|
||||
{
|
||||
var export = batch ? Session.Project.Export : Session.Project.Export with { Batch = [] };
|
||||
var request = Session.RenderRequest(export) with { Priority = priority };
|
||||
await Session.SubmitAsync(request);
|
||||
Shell.Notify(Loc.L("Editor.Render.Queued"), request.Label, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
var requests = Session.RenderRequests(export);
|
||||
foreach (var request in requests) await Session.SubmitAsync(request with { Priority = priority });
|
||||
if (IsRemote) Shell.Notify(Loc.L("Editor.Render.QueuedServer", RemoteText ?? string.Empty), requests[0].Label);
|
||||
else Shell.Notify(Loc.L("Editor.Render.Queued"), requests[0].Label, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
}
|
||||
|
||||
/// <summary>Re-reads the enabled state of every command (the async ones keep their own event).</summary>
|
||||
@@ -452,14 +478,29 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
Task[] Work() => [_preview.Idle, _corrections.Idle, _plans.Idle, .. Tabs.OfType<ExportTab>().Select(t => t.EstimatesIdle)];
|
||||
}
|
||||
|
||||
/// <summary>Loads the jobs of this sequence already queued or running (busy state) and the speed of the last analysis.</summary>
|
||||
/// <summary>
|
||||
/// Loads the jobs of this sequence already queued or running (busy state), the speed of the last analysis and
|
||||
/// whether the Export "Sync" option applies.
|
||||
/// </summary>
|
||||
public async Task AttachJobsAsync()
|
||||
{
|
||||
if (Shell.Services.Jobs is not { } jobs) return;
|
||||
var page = await jobs.ListAsync(null, 200);
|
||||
foreach (var job in page.Items) Track(job);
|
||||
foreach (var job in page.Items.OrderBy(j => j.Finished)) LearnAnalysisSpeed(job);
|
||||
var jobs = await Session.Source.ListJobsAsync(CancellationToken.None);
|
||||
foreach (var job in jobs) Track(job);
|
||||
foreach (var job in jobs.OrderBy(j => j.Finished)) LearnAnalysisSpeed(job);
|
||||
OnBusyChanged();
|
||||
await RefreshSyncGateAsync();
|
||||
}
|
||||
|
||||
/// <summary>Reads again whether this sequence can send its renders to the signed-in server (session, link, rights).</summary>
|
||||
public async Task RefreshSyncGateAsync()
|
||||
{
|
||||
var sync = Shell.Services.Sync;
|
||||
var server = sync.Server;
|
||||
var linked = !IsRemote && server is not null && sync.Service is { } service
|
||||
&& await service.LinkOfAsync(server, Session.Content.Sequence.Id) is not null;
|
||||
if (_disposed) return;
|
||||
SyncGate = ExportSync.Gate(IsRemote, server, linked, sync.CanUpload);
|
||||
foreach (var tab in Tabs) tab.OnSyncGateChanged();
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
@@ -473,7 +514,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
Session.ProjectChanged -= OnProjectChanged;
|
||||
Session.ContentChanged -= OnContentChanged;
|
||||
Session.SaveFailed -= OnSaveFailed;
|
||||
if (Shell.Services.Jobs is { } jobs) jobs.JobChanged -= OnJobChanged;
|
||||
Session.Source.JobChanged -= OnJobChanged;
|
||||
Shell.Services.Sync.Changed -= OnSyncChanged;
|
||||
foreach (var tab in Tabs) tab.Dispose();
|
||||
base.Dispose();
|
||||
await Session.DisposeAsync();
|
||||
@@ -757,6 +799,22 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>The session, the sync links or the rights changed (any thread): whether the Export "Sync" option applies.</summary>
|
||||
private void OnSyncChanged() => _dispatcher.BeginInvoke(() => _ = OnSyncChangedAsync());
|
||||
|
||||
private async Task OnSyncChangedAsync()
|
||||
{
|
||||
if (_disposed) return;
|
||||
try
|
||||
{
|
||||
await RefreshSyncGateAsync();
|
||||
}
|
||||
catch (Data.DatabaseException ex)
|
||||
{
|
||||
Log.Warning("editor", "The sync state of the sequence could not be read", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void Track(Job job)
|
||||
{
|
||||
if (!job.TargetIds.Contains(Session.Content.Sequence.Id) || job.Kind is not (JobKind.DeepAnalyse or JobKind.LightAnalyse or JobKind.Render)) return;
|
||||
@@ -777,13 +835,17 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
{
|
||||
await Session.ReloadAsync();
|
||||
}
|
||||
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or UnauthorizedAccessException)
|
||||
catch (Exception ex) when (ex is System.IO.IOException or System.IO.InvalidDataException or InvalidOperationException or UnauthorizedAccessException
|
||||
or System.Net.Http.HttpRequestException or Protocol.Client.TitanoApiException)
|
||||
{
|
||||
Shell.ReportError(ex);
|
||||
return;
|
||||
}
|
||||
if (render is null || _disposed) return;
|
||||
var output = Session.Content.Renders.FirstOrDefault(r => render.Started is not { } started || r.Created >= started)?.OutputPath;
|
||||
// A server's render stays on the server: nothing to show in Explorer.
|
||||
var output = Session.Content.Renders.FirstOrDefault(r => render.Started is not { } started || r.Created >= started)?.OutputPath is { Length: > 0 } path
|
||||
? path
|
||||
: null;
|
||||
Shell.ShowToast(new Toast
|
||||
{
|
||||
Title = Loc.L("Editor.Render.Done"),
|
||||
@@ -802,6 +864,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
OnPropertyChanged(nameof(BusyToolTip));
|
||||
OnPropertyChanged(nameof(AnalyseToolTip));
|
||||
OnPropertyChanged(nameof(OptimiseAllToolTip));
|
||||
OnPropertyChanged(nameof(ServerJobText));
|
||||
OnPropertyChanged(nameof(ServerJobToolTip));
|
||||
foreach (var tab in Tabs) tab.OnBusyChanged();
|
||||
RefreshCommands();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.IO;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Data.Processing;
|
||||
using Titano.Data.Sync;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>Whether the Export "Sync" option can be used, or why not (its tooltip says which).</summary>
|
||||
public enum ExportSyncGate
|
||||
{
|
||||
Available,
|
||||
|
||||
/// <summary>A server sequence: its renders are made on the server and stay there.</summary>
|
||||
Remote,
|
||||
|
||||
/// <summary>No server session is open.</summary>
|
||||
SignedOut,
|
||||
|
||||
/// <summary>The server does not have this sequence.</summary>
|
||||
NotLinked,
|
||||
|
||||
/// <summary>The account may not send files to the server.</summary>
|
||||
NoUpload,
|
||||
}
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
public sealed class ExportSync(TitanoDatabase db, SyncService sync, JobEngine engine)
|
||||
{
|
||||
/// <summary>The option's state for a sequence.</summary>
|
||||
/// <param name="server">Key of the signed-in server; null while signed out.</param>
|
||||
/// <param name="linked">The server has the sequence (a sync link joins them).</param>
|
||||
public static ExportSyncGate Gate(bool isRemote, string? server, bool linked, bool canUpload) =>
|
||||
isRemote ? ExportSyncGate.Remote
|
||||
: server is null ? ExportSyncGate.SignedOut
|
||||
: !linked ? ExportSyncGate.NotLinked
|
||||
: !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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
private static bool Wanted(Job job)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ProcessingJobs.ReadRender(job.ParametersJson).Export.SyncToServer;
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,8 @@ public sealed class ExportTab : EditorTab
|
||||
private readonly AsyncRelayCommand _renderNow;
|
||||
private readonly AsyncRelayCommand _addToQueue;
|
||||
private readonly AsyncRelayCommand _batch;
|
||||
private readonly AsyncRelayCommand _restore;
|
||||
private SavedCopy? _selectedCopy;
|
||||
private IReadOnlyList<PresetCard> _cards = [];
|
||||
private IReadOnlyList<CodecChoice> _codecChoices = [];
|
||||
private IReadOnlyList<Choice> _encoders = [];
|
||||
@@ -122,11 +124,13 @@ public sealed class ExportTab : EditorTab
|
||||
_addToQueue = new AsyncRelayCommand(() => Editor.RenderAsync(JobPriority.Normal, batch: false), () => Editor.CanRender);
|
||||
_batch = new AsyncRelayCommand(() => Editor.RenderAsync(JobPriority.User, batch: true), () => Editor.CanRender && Batch.Count > 0);
|
||||
HistoryCommand = new RelayCommand(OpenHistory);
|
||||
RevealLastCommand = new RelayCommand(() => ShellActions.Reveal(Editor.Session.Content.Renders[0].OutputPath), () => Editor.Session.Content.Renders.Count > 0);
|
||||
RevealLastCommand = new RelayCommand(() => ShellActions.Reveal(Editor.Session.Content.Renders[0].OutputPath), () => CanReveal);
|
||||
_restore = new AsyncRelayCommand(RestoreAsync, () => !Editor.IsBusy && SelectedCopy is not null);
|
||||
ResetFrameRateCommand = new RelayCommand(() => EditOverrides(o => o with { FrameRate = null }));
|
||||
Width = new EditableField(string.Empty, ValidateSize, v => EditOverrides(o => o with { Width = ParseSize(v) }), () => Loc.L("Tooltips.Editor.Export.Width"));
|
||||
Height = new EditableField(string.Empty, ValidateSize, v => EditOverrides(o => o with { Height = ParseSize(v) }), () => Loc.L("Tooltips.Editor.Export.Height"));
|
||||
NameTemplate = new EditableField(string.Empty, ValidateTemplate, v => EditExport(e => e with { NameTemplate = v }), () => Loc.L("Tooltips.Editor.Export.Name"));
|
||||
_selectedCopy = SavedCopies.FirstOrDefault();
|
||||
LoadCards();
|
||||
Refresh();
|
||||
}
|
||||
@@ -153,6 +157,62 @@ public sealed class ExportTab : EditorTab
|
||||
|
||||
public bool HasHistory => Editor.Session.Content.Renders.Count > 0;
|
||||
|
||||
/// <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 }, ..];
|
||||
|
||||
// ---- Export "Sync" (Export.html, next to Save to) ----
|
||||
|
||||
/// <summary>Send each render made on this PC to the server the sequence is linked to; remembered in the project.</summary>
|
||||
public bool SyncToServer
|
||||
{
|
||||
get => Export.SyncToServer;
|
||||
set
|
||||
{
|
||||
if (!_refreshing && value != Export.SyncToServer) EditExport(e => e with { SyncToServer = value });
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanSync => Editor.SyncGate == ExportSyncGate.Available;
|
||||
|
||||
/// <summary>What Sync does, or why it cannot be used for this sequence now.</summary>
|
||||
public string SyncToolTip => Loc.L(Editor.SyncGate switch
|
||||
{
|
||||
ExportSyncGate.Remote => "Tooltips.Editor.Export.SyncRemote",
|
||||
ExportSyncGate.SignedOut => "Tooltips.Editor.Export.SyncSignedOut",
|
||||
ExportSyncGate.NotLinked => "Tooltips.Editor.Export.SyncNotLinked",
|
||||
ExportSyncGate.NoUpload => "Tooltips.Editor.Export.SyncNoUpload",
|
||||
_ => "Tooltips.Editor.Export.Sync",
|
||||
});
|
||||
|
||||
/// <summary>A server sequence renders into its exports folder on the server.</summary>
|
||||
public bool CanChooseFolder => !Editor.IsRemote;
|
||||
|
||||
// ---- "Save both" copies of this PC's settings ----
|
||||
|
||||
public IReadOnlyList<SavedCopy> SavedCopies => Editor.Session.Content.SavedCopies;
|
||||
|
||||
public bool HasSavedCopies => SavedCopies.Count > 0;
|
||||
|
||||
/// <summary>The copy Restore makes the project: the newest unless another is chosen in the menu.</summary>
|
||||
public SavedCopy? SelectedCopy
|
||||
{
|
||||
get => _selectedCopy;
|
||||
set
|
||||
{
|
||||
if (!Set(ref _selectedCopy, value)) return;
|
||||
OnPropertyChanged(nameof(RestoreText));
|
||||
OnPropertyChanged(nameof(RestoreToolTip));
|
||||
_restore.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>"Restore · 03/10/2026 14:22".</summary>
|
||||
public string RestoreText => Loc.L("Editor.Export.Restore", SelectedCopy?.Label ?? string.Empty);
|
||||
|
||||
public string RestoreToolTip => Editor.IsBusy ? Loc.L("Tooltips.Editor.Busy") : Loc.L("Tooltips.Editor.Export.Restore", SelectedCopy?.Label ?? string.Empty);
|
||||
|
||||
public ICommand RestoreCommand => _restore;
|
||||
|
||||
public ICommand ResetFrameRateCommand { get; }
|
||||
|
||||
/// <summary>"Output · 4K archive".</summary>
|
||||
@@ -287,7 +347,9 @@ public sealed class ExportTab : EditorTab
|
||||
}
|
||||
}
|
||||
|
||||
public string SaveToolTip => Loc.L("Tooltips.Editor.Export.Folder", Export.Folder ?? Editor.Session.Content.ExportsFolder ?? string.Empty);
|
||||
public string SaveToolTip => Editor.IsRemote
|
||||
? 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;
|
||||
|
||||
@@ -370,6 +432,7 @@ public sealed class ExportTab : EditorTab
|
||||
public override void OnContentChanged()
|
||||
{
|
||||
LoadCards();
|
||||
if (SelectedCopy is null || !SavedCopies.Contains(SelectedCopy)) SelectedCopy = SavedCopies.FirstOrDefault();
|
||||
base.OnContentChanged();
|
||||
}
|
||||
|
||||
@@ -378,8 +441,16 @@ public sealed class ExportTab : EditorTab
|
||||
_renderNow.RaiseCanExecuteChanged();
|
||||
_addToQueue.RaiseCanExecuteChanged();
|
||||
_batch.RaiseCanExecuteChanged();
|
||||
_restore.RaiseCanExecuteChanged();
|
||||
OnPropertyChanged(nameof(AddToQueueToolTip));
|
||||
OnPropertyChanged(nameof(BatchToolTip));
|
||||
OnPropertyChanged(nameof(RestoreToolTip));
|
||||
}
|
||||
|
||||
public override void OnSyncGateChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(CanSync));
|
||||
OnPropertyChanged(nameof(SyncToolTip));
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
@@ -434,6 +505,26 @@ 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>
|
||||
private async Task RestoreAsync()
|
||||
{
|
||||
if (SelectedCopy is not { } copy) return;
|
||||
try
|
||||
{
|
||||
if (!await Editor.Session.RestoreAsync(copy))
|
||||
{
|
||||
Editor.Shell.Notify(Loc.L("Editor.Copy.Same"), copy.Label);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (InvalidDataException ex)
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
private void OpenHistory()
|
||||
{
|
||||
Editor.Shell.Jobs.Filter = Jobs.JobFilter.All;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using Titano.Protocol;
|
||||
using Titano.Protocol.Client;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// The server calls the editor of a server sequence makes (BRIEF §14.3): the sequence and its settings with their
|
||||
/// version, the analysis report, jobs and events. Failures are <see cref="TitanoApiException"/>s (404 gone, 409 settings
|
||||
/// changed meanwhile) or network exceptions. The editor disposes its connection when it closes.
|
||||
/// </summary>
|
||||
public interface IRemoteSequenceApi : IDisposable
|
||||
{
|
||||
Task<SequenceDto> GetSequenceAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>The settings JSON and its version, the frames and the renders.</summary>
|
||||
Task<SequenceManifest> GetManifestAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>A 409 <see cref="TitanoApiException"/> means the settings version moved on the server.</summary>
|
||||
Task<SequenceDto> UpdateSequenceAsync(Guid id, UpdateSequenceRequest request, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>The full deep-analysis report (<c>analysis.json</c>); null when the sequence was never deep-analysed.</summary>
|
||||
Task<string?> GetAnalysisReportAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
Task<JobDto> CreateJobAsync(CreateJobRequest request, CancellationToken cancellationToken);
|
||||
|
||||
Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Jobs waiting or running on the server.</summary>
|
||||
Task<IReadOnlyList<JobDto>> ListActiveJobsAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Server events until cancelled or the socket closes.</summary>
|
||||
IAsyncEnumerable<ServerEvent> EventsAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -9,11 +9,20 @@ namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// Where the sequence open in the editor lives: the local archive (<see cref="LocalSequenceSource"/>) or a server the
|
||||
/// client is connected to (a source that reads proxies and posts jobs to the API). The editor reads frames, saves the
|
||||
/// project and queues jobs only through this interface.
|
||||
/// client is connected to (<see cref="RemoteSequenceSource"/>: proxies from the cache, project and jobs through the
|
||||
/// API). The editor reads frames, saves the project, queues jobs and follows them only through this interface.
|
||||
/// </summary>
|
||||
public interface ISequenceSource : IAsyncDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The sequence lives on a server (BRIEF §14.5 "edit with proxies, render where the originals are"): its project is
|
||||
/// saved there and its renders and analyses run there, one job per preset.
|
||||
/// </summary>
|
||||
bool IsRemote { get; }
|
||||
|
||||
/// <summary>A job that may concern the sequence changed (any thread): this PC's engine, or the server's events.</summary>
|
||||
event Action<Job>? JobChanged;
|
||||
|
||||
/// <summary>Everything the editor shows of the sequence; read off the UI thread.</summary>
|
||||
/// <exception cref="InvalidDataException">The project cannot be read (corrupt, or written by a newer Titano).</exception>
|
||||
Task<SequenceContent> LoadAsync(CancellationToken cancellationToken);
|
||||
@@ -33,6 +42,9 @@ public interface ISequenceSource : IAsyncDisposable
|
||||
|
||||
/// <summary>Queues an analysis or render job for the sequence; returns the job id.</summary>
|
||||
Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken);
|
||||
|
||||
/// <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>A sequence as the editor opens it.</summary>
|
||||
@@ -41,7 +53,8 @@ public interface ISequenceSource : IAsyncDisposable
|
||||
/// <param name="Deep">The saved deep analysis when it describes the current frames, else null.</param>
|
||||
/// <param name="SourceWidth">Dominant oriented full-resolution width (0 when unknown).</param>
|
||||
/// <param name="ExportsFolder">Default output folder of renders; null when the sequence is not on this PC.</param>
|
||||
/// <param name="Renders">Finished renders, newest first.</param>
|
||||
/// <param name="Renders">Finished renders, newest first (an empty output path when the file is not on this PC).</param>
|
||||
/// <param name="SavedCopies">This PC's projects kept by "Save both" when a sync conflict was settled, newest first.</param>
|
||||
public sealed record SequenceContent(
|
||||
Sequence Sequence,
|
||||
IReadOnlyList<Frame> Frames,
|
||||
@@ -51,7 +64,8 @@ public sealed record SequenceContent(
|
||||
int SourceWidth,
|
||||
int SourceHeight,
|
||||
string? ExportsFolder,
|
||||
IReadOnlyList<Render> Renders)
|
||||
IReadOnlyList<Render> Renders,
|
||||
IReadOnlyList<SavedCopy> SavedCopies)
|
||||
{
|
||||
/// <summary>Flags of frames that never reach a render (as the render job skips them).</summary>
|
||||
public const FrameFlags NotRendered = FrameFlags.Missing | FrameFlags.Corrupt | FrameFlags.Excluded | FrameFlags.Undecodable;
|
||||
|
||||
@@ -20,33 +20,56 @@ namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// A sequence of an archive on this PC: rows from the index, originals decoded by the client's decoder chain, the
|
||||
/// project in <c>.titano/project.json</c> mirrored in the index's settings column, jobs on this PC's engine. Project
|
||||
/// writes follow the archive engine's protocol: under the sequence's lease file (so the server and the job engine wait
|
||||
/// for it), file first (atomically), then the index with its settings version as an optimistic check.
|
||||
/// project in <c>.titano/project.json</c> mirrored in the index's settings column (with its hero frame, which the
|
||||
/// Library shows), jobs on this PC's engine. Project writes follow the archive engine's protocol: under the sequence's
|
||||
/// lease file (so the server and the job engine wait for it), file first (atomically), then the index with its settings
|
||||
/// version as an optimistic check.
|
||||
/// </summary>
|
||||
public sealed class LocalSequenceSource(TitanoDatabase db, Guid sequenceId, ImageDecoder decoder, JobEngine? engine, ArchiveServiceOptions? lease = null)
|
||||
: ISequenceSource
|
||||
public sealed class LocalSequenceSource : ISequenceSource
|
||||
{
|
||||
private const int PageSize = 1000;
|
||||
private const int SaveAttempts = 3;
|
||||
private const int JobsListed = 200;
|
||||
|
||||
private readonly ArchiveServiceOptions _lease = lease ?? new ArchiveServiceOptions();
|
||||
private readonly TitanoDatabase _db;
|
||||
private readonly Guid _sequenceId;
|
||||
private readonly ImageDecoder _decoder;
|
||||
private readonly JobEngine? _engine;
|
||||
private readonly ArchiveServiceOptions _lease;
|
||||
private string?[] _files = [];
|
||||
private Guid[] _frameIds = [];
|
||||
private ArchivePaths? _paths;
|
||||
private SequencePaths? _folder;
|
||||
|
||||
public LocalSequenceSource(TitanoDatabase db, Guid sequenceId, ImageDecoder decoder, JobEngine? engine, ArchiveServiceOptions? lease = null)
|
||||
{
|
||||
_db = db;
|
||||
_sequenceId = sequenceId;
|
||||
_decoder = decoder;
|
||||
_engine = engine;
|
||||
_lease = lease ?? new ArchiveServiceOptions();
|
||||
if (engine is not null) engine.JobChanged += OnJobChanged;
|
||||
}
|
||||
|
||||
public bool IsRemote => false;
|
||||
|
||||
public event Action<Job>? JobChanged;
|
||||
|
||||
/// <summary>A save changed the frame the Library shows for the sequence: the stored row (any thread).</summary>
|
||||
public event Action<Sequence>? HeroChanged;
|
||||
|
||||
public async Task<SequenceContent> LoadAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var sequence = await db.Sequences.GetAsync(sequenceId, cancellationToken) ?? throw Missing();
|
||||
var archive = await db.Archives.GetAsync(sequence.ArchiveId, cancellationToken) ?? throw Missing();
|
||||
var sequence = await _db.Sequences.GetAsync(_sequenceId, cancellationToken) ?? throw Missing();
|
||||
var archive = await _db.Archives.GetAsync(sequence.ArchiveId, cancellationToken) ?? throw Missing();
|
||||
var frames = new List<Frame>();
|
||||
while (true)
|
||||
{
|
||||
var page = await db.Frames.ListBySequenceAsync(sequenceId, frames.Count > 0 ? frames[^1].Index : -1, PageSize, cancellationToken);
|
||||
var page = await _db.Frames.ListBySequenceAsync(_sequenceId, frames.Count > 0 ? frames[^1].Index : -1, PageSize, cancellationToken);
|
||||
frames.AddRange(page);
|
||||
if (page.Count < PageSize) break;
|
||||
}
|
||||
var renders = await db.Renders.ListBySequenceAsync(sequenceId, cancellationToken);
|
||||
var renders = await _db.Renders.ListBySequenceAsync(_sequenceId, cancellationToken);
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
var paths = new ArchivePaths(archive.RootPath);
|
||||
@@ -56,10 +79,10 @@ public sealed class LocalSequenceSource(TitanoDatabase db, Guid sequenceId, Imag
|
||||
{
|
||||
if ((frames[i].Flags & FrameFlags.Missing) == 0) files[i] = paths.FromRelative(frames[i].RelativePath);
|
||||
}
|
||||
(_paths, _folder, _files) = (paths, folder, files);
|
||||
(_paths, _folder, _files, _frameIds) = (paths, folder, files, [.. frames.Select(f => f.Id)]);
|
||||
var context = SequenceContext.FromFrames(frames);
|
||||
return new SequenceContent(sequence, frames, ReadProject(sequence, folder), LightAnalyzer.Analyze(frames), ReadReport(folder, frames.Count),
|
||||
context.SourceWidth, context.SourceHeight, folder.Exports, [.. renders.OrderByDescending(r => r.Created)]);
|
||||
context.SourceWidth, context.SourceHeight, folder.Exports, [.. renders.OrderByDescending(r => r.Created)], SavedCopies.List(folder.MetaDirectory));
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -72,7 +95,7 @@ public sealed class LocalSequenceSource(TitanoDatabase db, Guid sequenceId, Imag
|
||||
{
|
||||
// Thumbnails take an embedded preview when it is large enough (no RAW development for a filmstrip cell).
|
||||
var request = new DecodeRequest(file, maxLongEdge, purpose, ForcePreview: purpose == DecodePurpose.Thumbnail);
|
||||
return decoder.Decode(request, cancellationToken)?.Pixels;
|
||||
return _decoder.Decode(request, cancellationToken)?.Pixels;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
@@ -86,25 +109,27 @@ public sealed class LocalSequenceSource(TitanoDatabase db, Guid sequenceId, Imag
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
ArgumentNullException.ThrowIfNull(basis);
|
||||
var (paths, folder) = (_paths, _folder);
|
||||
var (paths, folder, frameIds) = (_paths, _folder, _frameIds);
|
||||
if (paths is null || folder is null) throw new InvalidOperationException("LoadAsync first.");
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
ArchiveVolume.EnsureWritable(paths);
|
||||
using var held = await LeaseFile.AcquireAsync(paths.LocksDirectory, $"seq-{sequenceId:N}", _lease.Owner, _lease.LeaseWait, _lease.LeaseDuration,
|
||||
using var held = await LeaseFile.AcquireAsync(paths.LocksDirectory, $"seq-{_sequenceId:N}", _lease.Owner, _lease.LeaseWait, _lease.LeaseDuration,
|
||||
cancellationToken);
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
var row = await db.Sequences.GetAsync(sequenceId, cancellationToken) ?? throw Missing();
|
||||
var row = await _db.Sequences.GetAsync(_sequenceId, cancellationToken) ?? throw Missing();
|
||||
var stored = ReadProject(row, folder);
|
||||
var merged = ProjectMerge.SameValues(stored, basis) ? project : ProjectMerge.Merge(basis, project, stored);
|
||||
var json = merged.ToJson();
|
||||
if (json == stored.ToJson()) return merged;
|
||||
AtomicFile.WriteAllText(folder.ProjectPath, json);
|
||||
var result = await db.Sequences.EditAsync(sequenceId, new SequenceEdit { SettingsJson = json }, row.SettingsVersion, cancellationToken);
|
||||
var edit = new SequenceEdit { SettingsJson = json, HeroFrameId = merged.HeroFrame == stored.HeroFrame ? null : HeroFrameId(merged, frameIds) };
|
||||
var result = await _db.Sequences.EditAsync(_sequenceId, edit, row.SettingsVersion, cancellationToken);
|
||||
switch (result.Outcome)
|
||||
{
|
||||
case SequenceEditOutcome.Updated:
|
||||
if (result.Sequence is { } updated && updated.HeroFrameId != row.HeroFrameId) HeroChanged?.Invoke(updated);
|
||||
return merged;
|
||||
case SequenceEditOutcome.NotFound:
|
||||
throw Missing();
|
||||
@@ -118,12 +143,19 @@ public sealed class LocalSequenceSource(TitanoDatabase db, Guid sequenceId, Imag
|
||||
|
||||
public async Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (engine is null) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
var job = await engine.EnqueueAsync(request, cancellationToken: cancellationToken);
|
||||
if (_engine is null) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
var job = await _engine.EnqueueAsync(request, cancellationToken: cancellationToken);
|
||||
return job.Id;
|
||||
}
|
||||
|
||||
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
|
||||
public async Task<IReadOnlyList<Job>> ListJobsAsync(CancellationToken cancellationToken) =>
|
||||
(await _db.Jobs.ListAsync(null, JobsListed, null, cancellationToken)).Items;
|
||||
|
||||
public ValueTask DisposeAsync()
|
||||
{
|
||||
if (_engine is not null) _engine.JobChanged -= OnJobChanged;
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>The settings in force: the index copy, else <c>project.json</c>, else defaults.</summary>
|
||||
/// <exception cref="InvalidDataException">The settings are not a project or come from a newer Titano.</exception>
|
||||
@@ -141,6 +173,10 @@ public sealed class LocalSequenceSource(TitanoDatabase db, Guid sequenceId, Imag
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The frame of the project's hero, or <see cref="Guid.Empty"/> (the first frame shows) without one.</summary>
|
||||
private static Guid HeroFrameId(ProjectSettings project, Guid[] frameIds) =>
|
||||
project.HeroFrame is { } hero && (uint)hero < (uint)frameIds.Length ? frameIds[hero] : Guid.Empty;
|
||||
|
||||
/// <summary>The saved deep report when it describes the current frames.</summary>
|
||||
private static DeepAnalysisReport? ReadReport(SequencePaths folder, int frameCount)
|
||||
{
|
||||
@@ -157,5 +193,7 @@ public sealed class LocalSequenceSource(TitanoDatabase db, Guid sequenceId, Imag
|
||||
}
|
||||
}
|
||||
|
||||
private void OnJobChanged(Job job) => JobChanged?.Invoke(job);
|
||||
|
||||
private static InvalidOperationException Missing() => new(Loc.L("Editor.Error.Missing"));
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using Titano.Core.Advice;
|
||||
using Titano.Core.Analysis;
|
||||
using Titano.Core.Analysis.Deep;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Imaging;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Core.Project;
|
||||
using Titano.Core.Render;
|
||||
using Titano.Data.Archiving.Jobs;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Data.Sync;
|
||||
using Titano.Protocol;
|
||||
using Titano.Protocol.Client;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// A server sequence opened with proxies (BRIEF §4.4, §14.5 "edit with proxies, render where the originals are"):
|
||||
/// frames and thumbnails from this PC's proxy cache (<see cref="RemoteSequence.OpenFrames"/>), the project from the
|
||||
/// server's settings with their version, the deep analysis from the server's report. Saves send the settings with the
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public sealed class RemoteSequenceSource : ISequenceSource
|
||||
{
|
||||
private const int SaveAttempts = 3;
|
||||
private static readonly TimeSpan MinBackoff = TimeSpan.FromSeconds(2);
|
||||
private static readonly TimeSpan MaxBackoff = TimeSpan.FromMinutes(1);
|
||||
|
||||
private readonly RemoteSequence _remote;
|
||||
private readonly IRemoteSequenceApi _api;
|
||||
private readonly IRenderFrameSource _frames;
|
||||
private readonly IFrameSource _pixels;
|
||||
private readonly ConcurrentDictionary<Guid, Job> _jobs = new();
|
||||
private readonly ConcurrentDictionary<Guid, byte> _foreign = new();
|
||||
private readonly CancellationTokenSource _stopping = new();
|
||||
private readonly Task _listening;
|
||||
private ProjectSettings? _stored;
|
||||
private int _version;
|
||||
|
||||
public RemoteSequenceSource(RemoteSequence remote, IRemoteSequenceApi api, ImageDecoder decoder)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(remote);
|
||||
ArgumentNullException.ThrowIfNull(api);
|
||||
ArgumentNullException.ThrowIfNull(decoder);
|
||||
_remote = remote;
|
||||
_api = api;
|
||||
_frames = remote.OpenFrames(decoder);
|
||||
_pixels = (IFrameSource)_frames;
|
||||
var stopping = _stopping.Token;
|
||||
_listening = Task.Run(() => ListenAsync(stopping), CancellationToken.None);
|
||||
}
|
||||
|
||||
public bool IsRemote => true;
|
||||
|
||||
public event Action<Job>? JobChanged;
|
||||
|
||||
/// <summary>The server sequence's id.</summary>
|
||||
public Guid Id => _remote.Sequence.Id;
|
||||
|
||||
public async Task<SequenceContent> LoadAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var dto = await Call(() => _api.GetSequenceAsync(Id, cancellationToken));
|
||||
var manifest = await Call(() => _api.GetManifestAsync(Id, cancellationToken));
|
||||
var report = await Call(() => _api.GetAnalysisReportAsync(Id, cancellationToken));
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
var project = Parse(manifest.SettingsJson);
|
||||
(_stored, _version) = (project, manifest.SettingsVersion);
|
||||
var frames = _remote.Frames;
|
||||
var sequence = _remote.Sequence with
|
||||
{
|
||||
Title = dto.Title,
|
||||
Tags = dto.Tags,
|
||||
Rating = dto.Rating,
|
||||
Notes = dto.Notes,
|
||||
Status = (SequenceStatus)dto.Status,
|
||||
RenderedCount = dto.RenderedCount,
|
||||
HeroFrameId = dto.HeroFrameId,
|
||||
WarningCount = dto.WarningCount,
|
||||
SettingsJson = manifest.SettingsJson,
|
||||
SettingsVersion = manifest.SettingsVersion,
|
||||
UpdatedAt = dto.UpdatedAt,
|
||||
};
|
||||
var context = SequenceContext.FromFrames(frames);
|
||||
var renders = manifest.Renders.OrderByDescending(r => r.Created).Select(r => new Render
|
||||
{
|
||||
Id = r.Id,
|
||||
SequenceId = Id,
|
||||
PresetName = r.PresetName,
|
||||
OutputPath = string.Empty,
|
||||
Codec = r.Codec,
|
||||
Width = r.Width,
|
||||
Height = r.Height,
|
||||
Fps = r.Fps,
|
||||
DurationSeconds = r.DurationSeconds,
|
||||
Bytes = r.Bytes,
|
||||
Created = r.Created,
|
||||
ProducedBy = r.ProducedBy,
|
||||
}).ToList();
|
||||
return new SequenceContent(sequence, frames, project, LightAnalyzer.Analyze(frames), Report(report, frames.Count), context.SourceWidth,
|
||||
context.SourceHeight, null, renders, []);
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
public async ValueTask<ImageBuffer?> DecodeAsync(int index, int maxLongEdge, DecodePurpose purpose, CancellationToken cancellationToken)
|
||||
{
|
||||
if ((uint)index >= (uint)_remote.Frames.Count) return null;
|
||||
return await Task.Run(() => _pixels.LoadAsync(index, maxLongEdge, cancellationToken).AsTask(), cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<ProjectSettings> SaveProjectAsync(ProjectSettings project, ProjectSettings basis, CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
ArgumentNullException.ThrowIfNull(basis);
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
var stored = _stored ?? throw new InvalidOperationException("LoadAsync first.");
|
||||
var merged = ProjectMerge.SameValues(stored, basis) ? project : ProjectMerge.Merge(basis, project, stored);
|
||||
if (ProjectMerge.SameValues(merged, stored)) return merged;
|
||||
var hero = merged.HeroFrame == stored.HeroFrame ? (Guid?)null : HeroFrameId(merged);
|
||||
try
|
||||
{
|
||||
var updated = await Call(() => _api.UpdateSequenceAsync(Id, new UpdateSequenceRequest(null, null, null, null, merged.ToJson(), _version, hero),
|
||||
cancellationToken));
|
||||
(_stored, _version) = (merged, updated.SettingsVersion);
|
||||
return merged;
|
||||
}
|
||||
catch (TitanoApiException ex) when (ex.Status == HttpStatusCode.Conflict)
|
||||
{
|
||||
// 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));
|
||||
(_stored, _version) = (Parse(manifest.SettingsJson), manifest.SettingsVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(request);
|
||||
var dto = await Call(() => _api.CreateJobAsync(new CreateJobRequest(JobWire.Kind(request.Kind), request.Targets, request.ParametersJson), 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;
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<Job>> ListJobsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var active = await Call(() => _api.ListActiveJobsAsync(cancellationToken));
|
||||
var mine = active.Select(JobWire.FromDto).OfType<Job>().Where(Concerns).ToList();
|
||||
foreach (var job in mine) _jobs[job.Id] = job;
|
||||
return mine;
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
await _stopping.CancelAsync();
|
||||
await _listening;
|
||||
_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>
|
||||
private async Task ListenAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var failures = 0;
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
await foreach (var e in _api.EventsAsync(cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
failures = 0;
|
||||
await OnEventAsync(e, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Info("editor", $"Events of the server lost for {_remote.Sequence.DisplayTitle}: {ex.Message}");
|
||||
}
|
||||
try
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromTicks(Math.Min(MaxBackoff.Ticks, MinBackoff.Ticks << Math.Min(failures++, 10))), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await RefreshTrackedAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OnEventAsync(ServerEvent e, CancellationToken cancellationToken)
|
||||
{
|
||||
switch (e)
|
||||
{
|
||||
case JobProgressEvent progress when _jobs.TryGetValue(progress.JobId, out var job):
|
||||
Publish(job with
|
||||
{
|
||||
State = JobState.Running,
|
||||
ProgressDone = progress.Done,
|
||||
ProgressTotal = progress.Total,
|
||||
ItemsPerSecond = progress.ItemsPerSecond,
|
||||
Eta = progress.EtaSeconds is { } eta ? TimeSpan.FromSeconds(eta) : null,
|
||||
});
|
||||
break;
|
||||
case JobStateEvent state when !_foreign.ContainsKey(state.JobId):
|
||||
await FetchAsync(state.JobId, cancellationToken).ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Reads a job the events named: tracked when it concerns this sequence, remembered as foreign otherwise.</summary>
|
||||
private async Task FetchAsync(Guid jobId, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (JobWire.FromDto(await _api.GetJobAsync(jobId, cancellationToken).ConfigureAwait(false)) is { } job && Concerns(job)) Publish(job);
|
||||
else _foreign[jobId] = 0;
|
||||
}
|
||||
catch (Exception ex) when (ex is TitanoApiException or HttpRequestException or JsonException
|
||||
|| (ex is OperationCanceledException && !cancellationToken.IsCancellationRequested))
|
||||
{
|
||||
Log.Info("editor", $"Job {jobId} could not be read: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>After a lost event socket: the tracked jobs as the server has them now.</summary>
|
||||
private async Task RefreshTrackedAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var job in _jobs.Values.Where(j => j.State is JobState.Queued or JobState.Running or JobState.Paused).ToList())
|
||||
await FetchAsync(job.Id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void Publish(Job job)
|
||||
{
|
||||
_jobs[job.Id] = job;
|
||||
JobChanged?.Invoke(job);
|
||||
}
|
||||
|
||||
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>
|
||||
private Guid HeroFrameId(ProjectSettings project) =>
|
||||
project.HeroFrame is { } hero && (uint)hero < (uint)_remote.Frames.Count ? _remote.Frames[hero].Id : Guid.Empty;
|
||||
|
||||
/// <exception cref="InvalidDataException">The settings are not a project or come from a newer Titano.</exception>
|
||||
private static ProjectSettings Parse(string? json)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(json)) return new ProjectSettings();
|
||||
try
|
||||
{
|
||||
return ProjectSettings.FromJson(json);
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
throw new InvalidDataException(Loc.L("Editor.Error.Project"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The server's deep report when it describes the frames this PC has.</summary>
|
||||
private DeepAnalysisReport? Report(string? json, int frameCount)
|
||||
{
|
||||
if (json is null) return null;
|
||||
try
|
||||
{
|
||||
var report = DeepAnalysisReport.FromJson(json);
|
||||
return report.FrameCount == frameCount ? report : null;
|
||||
}
|
||||
catch (Exception ex) when (ex is JsonException or InvalidDataException)
|
||||
{
|
||||
Log.Warning("editor", $"The analysis of {_remote.Sequence.DisplayTitle} on the server cannot be read", ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A sequence deleted on the server reads as gone, like a local one removed from the index.</summary>
|
||||
private static async Task<T> Call<T>(Func<Task<T>> call)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await call();
|
||||
}
|
||||
catch (TitanoApiException ex) when (ex.Status == HttpStatusCode.NotFound)
|
||||
{
|
||||
throw new InvalidOperationException(Loc.L("Editor.Error.Missing"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Project;
|
||||
using Titano.Data.Sync;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>This PC's project kept by "Save both" when a sync conflict was settled (BRIEF §12.7), local time of the choice.</summary>
|
||||
public sealed record SavedCopy(string Path, DateTime SavedAt)
|
||||
{
|
||||
/// <summary>"03/10/2026 14:22" in the user's format.</summary>
|
||||
public string Label => SavedAt.ToString("g", Loc.Culture);
|
||||
}
|
||||
|
||||
/// <summary>The "Save both" copies of a sequence: <c>.titano/project.this-pc-<time>.json</c> beside <c>project.json</c>.</summary>
|
||||
public static class SavedCopies
|
||||
{
|
||||
/// <summary>The copies in a sequence's <c>.titano</c> folder, newest first; none when the folder cannot be read.</summary>
|
||||
public static IReadOnlyList<SavedCopy> List(string metaDirectory)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(metaDirectory)) return [];
|
||||
return [.. Directory.EnumerateFiles(metaDirectory, SyncService.SavedCopyPattern)
|
||||
.Select(path => new SavedCopy(path, SyncService.SavedCopyTime(path) ?? File.GetLastWriteTime(path)))
|
||||
.OrderByDescending(c => c.SavedAt)];
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
Log.Warning("editor", $"The saved projects in {metaDirectory} cannot be listed", ex);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The project of a copy.</summary>
|
||||
/// <exception cref="InvalidDataException">The copy is gone, unreadable, or not a project of this Titano.</exception>
|
||||
public static ProjectSettings Read(SavedCopy copy)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(copy);
|
||||
try
|
||||
{
|
||||
return ProjectSettings.FromJson(File.ReadAllText(copy.Path));
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or JsonException)
|
||||
{
|
||||
throw new InvalidDataException(Loc.L("Editor.Error.SavedCopy", System.IO.Path.GetFileName(copy.Path)), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,14 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Style="{StaticResource Button.IconSubtle}" ui:ButtonIcon.Glyph="{StaticResource Icon.Back}" Command="{Binding BackCommand}"
|
||||
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" />
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="6,0,12,0">
|
||||
<TextBlock Text="{Binding Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" MaxWidth="320" TextTrimming="CharacterEllipsis" />
|
||||
<!-- A server sequence edited with proxies: where it lives, and its analysis or render running on the server. -->
|
||||
<ui:StatusGlyph Kind="Remote" Text="{Binding RemoteText}" ToolTip="{Binding RemoteToolTip}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center"
|
||||
Visibility="{Binding IsRemote, Converter={StaticResource BoolToVisibility}}" />
|
||||
<ui:StatusGlyph Kind="Running" Text="{Binding ServerJobText}" ToolTip="{Binding ServerJobToolTip}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center"
|
||||
Typography.NumeralAlignment="Tabular" Visibility="{Binding ServerJobText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="2" Text="{Binding Summary}" Style="{StaticResource Text.Secondary}" FontSize="{StaticResource Size.Body}" VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{Binding Summary}" />
|
||||
<StackPanel Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="12,0,0,0">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Editor;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Shell;
|
||||
@@ -7,18 +8,20 @@ using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Export;
|
||||
using Titano.Core.Imaging.Decoders;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Data.Archiving;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Ui.Mvvm;
|
||||
|
||||
namespace Titano.App.Sections;
|
||||
|
||||
/// <summary>
|
||||
/// The Sequence section (BRIEF §12.3): opens the sequence the Library (or Jobs) chose into an <see cref="EditorViewModel"/>
|
||||
/// and closes the previous one after saving it; without a sequence it shows the empty state. A failed open is reported
|
||||
/// and leaves the section usable; an edit that cannot be saved is never dropped without the user's confirmation.
|
||||
/// 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
|
||||
/// section usable; an edit that cannot be saved is never dropped without the user's confirmation.
|
||||
/// </summary>
|
||||
public sealed class SequenceViewModel : SectionViewModel
|
||||
{
|
||||
private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;
|
||||
private EditorViewModel? _editor;
|
||||
private Guid? _openId;
|
||||
private bool _isLoading;
|
||||
@@ -112,6 +115,35 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
if (e.PropertyName == nameof(ShellViewModel.CurrentSequenceId) && IsSelected) OnActivated();
|
||||
}
|
||||
|
||||
/// <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).
|
||||
/// </summary>
|
||||
private async Task<ISequenceSource> 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)
|
||||
{
|
||||
var local = new LocalSequenceSource(db, sequenceId, decoder, services.Engine, processing?.Archive);
|
||||
local.HeroChanged += OnHeroChanged;
|
||||
return local;
|
||||
}
|
||||
var sync = services.Sync;
|
||||
if (sync.Server is not { } server || sync.Service?.OpenRemote(server, sequenceId) is not { } remote) throw new InvalidOperationException(Loc.L("Editor.Error.Missing"));
|
||||
// An editor whose saves the server refuses would only lose edits.
|
||||
if (!sync.Policy.CanEdit) throw new InvalidOperationException(Loc.L("Editor.Error.RemoteReadOnly"));
|
||||
var api = sync.ConnectEditor() ?? throw new InvalidOperationException(Loc.L("Editor.Error.Missing"));
|
||||
return new RemoteSequenceSource(remote, api, decoder);
|
||||
}
|
||||
|
||||
/// <summary>Set hero changed the frame the Library shows (any thread): its card loads the new thumbnail.</summary>
|
||||
private void OnHeroChanged(Sequence row) => _dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (Shell.Library.Items.FirstOrDefault(i => i.Id == row.Id) is { } item) item.Update(row);
|
||||
});
|
||||
|
||||
/// <summary>Waits for <paramref name="task"/>; its failure was reported where it happened.</summary>
|
||||
private static async Task Settled(Task task)
|
||||
{
|
||||
@@ -142,11 +174,18 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
await old.DisposeAsync();
|
||||
}
|
||||
_openId = sequenceId;
|
||||
if (services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
var source = await OpenSourceAsync(services, sequenceId);
|
||||
SequenceContent content;
|
||||
try
|
||||
{
|
||||
content = await source.LoadAsync(CancellationToken.None);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await source.DisposeAsync();
|
||||
throw;
|
||||
}
|
||||
var processing = services.Processing?.Options;
|
||||
var source = new LocalSequenceSource(db, sequenceId, processing?.Archive.Decoder ?? DecoderFactory.CreateClient(null), services.Engine,
|
||||
processing?.Archive);
|
||||
var content = await source.LoadAsync(CancellationToken.None);
|
||||
var encoders = processing?.Encoders ?? [];
|
||||
var session = new EditorSession(source, content, [.. encoders.SelectMany(e => e.Capabilities)]);
|
||||
var editor = new EditorViewModel(Shell, session, encoders, processing?.Host ?? EncoderHost.Client);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using Titano.App.Editor;
|
||||
using Titano.Protocol;
|
||||
using Titano.Protocol.Client;
|
||||
|
||||
namespace Titano.App.Server;
|
||||
|
||||
/// <summary>Makes the connection of the editor of a server sequence for a signed-in session.</summary>
|
||||
public delegate IRemoteSequenceApi RemoteSequenceApiFactory(Uri address, string token, IReadOnlyCollection<string> trustedFingerprints);
|
||||
|
||||
/// <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 = ["queued", "running", "paused"];
|
||||
|
||||
public Task<SequenceDto> GetSequenceAsync(Guid id, CancellationToken cancellationToken) => client.GetSequenceAsync(id, cancellationToken);
|
||||
|
||||
public Task<SequenceManifest> GetManifestAsync(Guid id, CancellationToken cancellationToken) => client.GetManifestAsync(id, cancellationToken);
|
||||
|
||||
public Task<SequenceDto> UpdateSequenceAsync(Guid id, UpdateSequenceRequest request, CancellationToken cancellationToken) =>
|
||||
client.UpdateSequenceAsync(id, request, cancellationToken);
|
||||
|
||||
public Task<string?> GetAnalysisReportAsync(Guid id, CancellationToken cancellationToken) => client.GetAnalysisReportAsync(id, cancellationToken);
|
||||
|
||||
public Task<JobDto> CreateJobAsync(CreateJobRequest request, CancellationToken cancellationToken) => client.CreateJobAsync(request, cancellationToken);
|
||||
|
||||
public Task<JobDto> GetJobAsync(Guid id, CancellationToken cancellationToken) => client.GetJobAsync(id, cancellationToken);
|
||||
|
||||
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);
|
||||
return jobs;
|
||||
}
|
||||
|
||||
public IAsyncEnumerable<ServerEvent> EventsAsync(CancellationToken cancellationToken) => client.EventsAsync(cancellationToken);
|
||||
|
||||
public void Dispose() => client.Dispose();
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.IO;
|
||||
using Titano.App.Editor;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Data.Sync;
|
||||
using Titano.Protocol.Client;
|
||||
|
||||
@@ -14,9 +16,11 @@ public delegate ISyncRemote SyncRemoteFactory(Uri address, string token, IReadOn
|
||||
/// <summary>
|
||||
/// This PC's sync with the signed-in server (BRIEF §4.4, §14.5): the <see cref="SyncService"/> of the index, the
|
||||
/// connection of upload and download jobs (<see cref="ISyncConnector"/>), a <see cref="SyncAgent"/> that keeps the
|
||||
/// table current while a session is open, started and stopped in order as the session changes, and the
|
||||
/// <see cref="UploadHold"/> for metered connections. Options come from <see cref="AppSettings.SyncSettingsAutomatically"/>,
|
||||
/// <see cref="AppSettings.KeepProxiesOffline"/> and <see cref="AppSettings.PauseUploadsOnMetered"/>.
|
||||
/// table current while a session is open, started and stopped in order as the session changes, the
|
||||
/// <see cref="UploadHold"/> for metered connections, the connections of editors of server sequences
|
||||
/// (<see cref="ConnectEditor"/>) and the Export "Sync" of finished renders (<see cref="ExportSync"/>). Options come from
|
||||
/// <see cref="AppSettings.SyncSettingsAutomatically"/>, <see cref="AppSettings.KeepProxiesOffline"/> and
|
||||
/// <see cref="AppSettings.PauseUploadsOnMetered"/>.
|
||||
/// </summary>
|
||||
public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDisposable
|
||||
{
|
||||
@@ -26,11 +30,16 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
private Task _switch = Task.CompletedTask;
|
||||
private Credentials? _credentials;
|
||||
private (SyncAgent Agent, ISyncRemote Remote, Credentials Credentials)? _running;
|
||||
private JobEngine? _renders;
|
||||
|
||||
/// <summary>Connections over <see cref="TitanoClient"/>; screenshots substitute a fake server.</summary>
|
||||
public SyncRemoteFactory RemoteFactory { get; set; } = (address, token, trusted) =>
|
||||
new TitanoSyncRemote(new TitanoClient(address, new CertificatePinning(trusted), $"Titano ({Environment.MachineName})") { Token = token }, ownsClient: true);
|
||||
|
||||
/// <summary>Connections of editors of server sequences over <see cref="TitanoClient"/>; screenshots substitute a fake server.</summary>
|
||||
public RemoteSequenceApiFactory EditorFactory { get; set; } = (address, token, trusted) =>
|
||||
new TitanoRemoteSequenceApi(new TitanoClient(address, new CertificatePinning(trusted), $"Titano ({Environment.MachineName})") { Token = token });
|
||||
|
||||
/// <summary>The engine; null until the index is open.</summary>
|
||||
public SyncService? Service { get; private set; }
|
||||
|
||||
@@ -44,8 +53,10 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
public string? Server => Volatile.Read(ref _credentials) is { } c ? SyncService.ServerKey(c.Address) : null;
|
||||
|
||||
/// <summary>The options, and whether the account may change server sequences (without it this PC's edits are not sent).</summary>
|
||||
public SyncPolicy Policy => new(services.Settings.SyncSettingsAutomatically, services.Settings.KeepProxiesOffline,
|
||||
services.Server.User is { } user && (user.Permissions & (long)Permissions.Edit) != 0);
|
||||
public SyncPolicy Policy => new(services.Settings.SyncSettingsAutomatically, services.Settings.KeepProxiesOffline, Allows(Permissions.Edit));
|
||||
|
||||
/// <summary>The signed-in account may send files (originals, renders) to the server.</summary>
|
||||
public bool CanUpload => Allows(Permissions.Upload);
|
||||
|
||||
/// <summary>Pauses uploads while the connection is metered and the option is on.</summary>
|
||||
public UploadHold Uploads { get; } = new(services);
|
||||
@@ -74,9 +85,17 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
: null;
|
||||
Volatile.Write(ref _credentials, wanted);
|
||||
_switch = SwitchAsync(_switch, wanted);
|
||||
if (services.Engine is { } engine) Uploads.Attach(engine);
|
||||
if (services.Engine is not { } engine) return;
|
||||
Uploads.Attach(engine);
|
||||
if (ReferenceEquals(_renders, engine)) return;
|
||||
_renders = engine;
|
||||
engine.JobChanged += OnJobChanged;
|
||||
}
|
||||
|
||||
/// <summary>A connection for the editor of a sequence of the signed-in server; null while signed out.</summary>
|
||||
public IRemoteSequenceApi? ConnectEditor() =>
|
||||
Volatile.Read(ref _credentials) is { } c ? EditorFactory(c.Address, c.Token, c.Fingerprints) : null;
|
||||
|
||||
/// <summary>Compares now, once the session switch in progress settled; null while signed out.</summary>
|
||||
public async Task<SyncSnapshot?> RefreshAsync(CancellationToken ct = default)
|
||||
{
|
||||
@@ -116,10 +135,33 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
{
|
||||
Volatile.Write(ref _credentials, null);
|
||||
Uploads.Dispose();
|
||||
if (_renders is not null) _renders.JobChanged -= OnJobChanged;
|
||||
await _switch;
|
||||
await StopAsync();
|
||||
}
|
||||
|
||||
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>
|
||||
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);
|
||||
}
|
||||
|
||||
private async Task SendRenderAsync(ExportSync exports, Job job)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await exports.SendAsync(job, Server, CanUpload) is { } send) Log.Info("sync", $"{job.TargetLabel} will be sent to the server (job {send.Id})");
|
||||
}
|
||||
catch (Exception ex) when (ex is Data.DatabaseException or InvalidOperationException)
|
||||
{
|
||||
Log.Warning("sync", $"The render {job.TargetLabel} could not be queued for the server", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SwitchAsync(Task previous, Credentials? wanted)
|
||||
{
|
||||
await previous;
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace Titano.App.Shell;
|
||||
/// <summary>
|
||||
/// <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), for visual review and phase reports (BRIEF §20.2), then exits.
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public static class ScreenCapture
|
||||
{
|
||||
@@ -134,6 +135,7 @@ public static class ScreenCapture
|
||||
}
|
||||
|
||||
written += await CaptureEditorAsync(window, shell, sample, directory);
|
||||
written += await CaptureRemoteEditorAsync(window, shell, sample, directory);
|
||||
Log.Info("capture", $"{written} screenshot(s) written to {Path.GetFullPath(directory)}");
|
||||
if (written == 0) Environment.ExitCode = 1;
|
||||
}
|
||||
@@ -224,6 +226,31 @@ public static class ScreenCapture
|
||||
return written;
|
||||
}
|
||||
|
||||
/// <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>).
|
||||
/// </summary>
|
||||
private static async Task<int> CaptureRemoteEditorAsync(MainWindow window, ShellViewModel shell, SampleData sample, string directory)
|
||||
{
|
||||
var written = 0;
|
||||
var id = sample.ProxiedSequenceId;
|
||||
shell.OpenSequence(id);
|
||||
await shell.Sequence.OpenAsync(id);
|
||||
if (shell.Sequence.Editor is not { IsRemote: true } editor)
|
||||
{
|
||||
Log.Warning("capture", "The server sequence did not open in the editor");
|
||||
return 0;
|
||||
}
|
||||
DismissToasts(window);
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-remote", theme);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
private static async Task<int> SaveEditorAsync(Window window, EditorViewModel editor, string directory, string screen, AppTheme theme)
|
||||
{
|
||||
await Settle(window);
|
||||
|
||||
@@ -158,6 +158,12 @@ public sealed record ExportSettings
|
||||
|
||||
/// <summary>Presets queued together by "Render another preset" / batch.</summary>
|
||||
public IReadOnlyList<string> Batch { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Export "Sync": a render made on this PC is sent to the server the sequence is linked to once it is done. Off
|
||||
/// unless chosen, as renders travel on request (BRIEF §14.5).
|
||||
/// </summary>
|
||||
public bool SyncToServer { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Text;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Protocol;
|
||||
|
||||
namespace Titano.Data.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// Wire names of job kinds, states and priorities in API v1: kebab-case (<c>deep-analyse</c>) and lower-case
|
||||
/// (<c>running</c>). The server writes them; clients read the server's jobs back with <see cref="FromDto"/>.
|
||||
/// </summary>
|
||||
public static class JobWire
|
||||
{
|
||||
public static string Kind(JobKind kind)
|
||||
{
|
||||
var name = kind.ToString();
|
||||
var sb = new StringBuilder(name.Length + 4);
|
||||
for (var i = 0; i < name.Length; i++)
|
||||
{
|
||||
if (i > 0 && char.IsUpper(name[i])) sb.Append('-');
|
||||
sb.Append(char.ToLowerInvariant(name[i]));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static bool TryParseKind(string? text, out JobKind kind) => TryParse(text, Kind, out kind);
|
||||
|
||||
public static string State(JobState state) => state.ToString().ToLowerInvariant();
|
||||
|
||||
public static bool TryParseState(string? text, out JobState state) => TryParse(text, State, out state);
|
||||
|
||||
public static string Priority(JobPriority priority) => priority.ToString().ToLowerInvariant();
|
||||
|
||||
public static bool TryParsePriority(string? text, out JobPriority priority) => TryParse(text, Priority, out priority);
|
||||
|
||||
/// <summary>A server job as the client's job model; null for a kind or state this build does not know.</summary>
|
||||
public static Job? FromDto(JobDto dto)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(dto);
|
||||
if (!TryParseKind(dto.Kind, out var kind) || !TryParseState(dto.State, out var state)) return null;
|
||||
return new Job
|
||||
{
|
||||
Id = dto.Id,
|
||||
Kind = kind,
|
||||
TargetIds = dto.TargetIds,
|
||||
TargetLabel = dto.TargetLabel,
|
||||
State = state,
|
||||
Priority = TryParsePriority(dto.Priority, out var priority) ? priority : JobPriority.Normal,
|
||||
ProgressDone = dto.ProgressDone,
|
||||
ProgressTotal = dto.ProgressTotal,
|
||||
ItemsPerSecond = dto.ItemsPerSecond,
|
||||
Eta = dto.EtaSeconds is { } eta ? TimeSpan.FromSeconds(eta) : null,
|
||||
LogTail = dto.LogTail,
|
||||
NodeId = dto.NodeId,
|
||||
Attempts = dto.Attempts,
|
||||
Error = dto.Error,
|
||||
Created = dto.Created,
|
||||
Started = dto.Started,
|
||||
Finished = dto.Finished,
|
||||
};
|
||||
}
|
||||
|
||||
private static bool TryParse<T>(string? text, Func<T, string> name, out T value) where T : struct, Enum
|
||||
{
|
||||
foreach (var candidate in Enum.GetValues<T>())
|
||||
{
|
||||
if (string.Equals(name(candidate), text, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
value = candidate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
value = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public static class ProcessingJobs
|
||||
|
||||
/// <summary>The parameters of a render job and the export they select.</summary>
|
||||
/// <exception cref="InvalidDataException">The job has no valid render parameters.</exception>
|
||||
internal static (RenderJobParameters Parameters, ExportSettings Export) ReadRender(string? parametersJson)
|
||||
public static (RenderJobParameters Parameters, ExportSettings Export) ReadRender(string? parametersJson)
|
||||
{
|
||||
var parameters = ReadParameters(parametersJson);
|
||||
return (parameters, ReadExport(parameters.PresetJson));
|
||||
|
||||
@@ -48,14 +48,25 @@ internal sealed class ProjectStore(TitanoDatabase db, SequenceWriter writer)
|
||||
var row = await db.Sequences.GetAsync(sequence.Id, cancellationToken).ConfigureAwait(false) ?? sequence;
|
||||
var current = Read(row, folder);
|
||||
var before = current.ToJson();
|
||||
var after = edit(current).ToJson();
|
||||
var edited = edit(current);
|
||||
var after = edited.ToJson();
|
||||
if (after == before) return false;
|
||||
AtomicFile.WriteAllText(folder.ProjectPath, after);
|
||||
var result = await db.Sequences.EditAsync(sequence.Id, new SequenceEdit { SettingsJson = after }, row.SettingsVersion, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
// The Library shows the project's hero frame (advice fills it, a sync takes another PC's).
|
||||
var hero = edited.HeroFrame == current.HeroFrame ? (Guid?)null : await HeroFrameIdAsync(sequence.Id, edited.HeroFrame, cancellationToken).ConfigureAwait(false);
|
||||
var result = await db.Sequences.EditAsync(sequence.Id, new SequenceEdit { SettingsJson = after, HeroFrameId = hero }, row.SettingsVersion,
|
||||
cancellationToken).ConfigureAwait(false);
|
||||
// A conflict means the API changed the settings meanwhile: apply the edit again on top of them.
|
||||
if (result.Outcome != SequenceEditOutcome.Conflict || attempt == Attempts) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The id of the frame at <paramref name="index"/> (frame indices are positions), or <see cref="Guid.Empty"/> to clear the hero.</summary>
|
||||
private async Task<Guid> HeroFrameIdAsync(Guid sequenceId, int? index, CancellationToken cancellationToken)
|
||||
{
|
||||
if (index is not >= 0) return Guid.Empty;
|
||||
var frames = await db.Frames.ListBySequenceAsync(sequenceId, index.Value - 1, 1, cancellationToken).ConfigureAwait(false);
|
||||
return frames is [{ } frame] && frame.Index == index ? frame.Id : Guid.Empty;
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,12 @@ public sealed record SequenceEdit
|
||||
public int? Rating { get; init; }
|
||||
public string? Notes { get; init; }
|
||||
public string? SettingsJson { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The frame the Library shows for the sequence (the project's hero frame); <see cref="Guid.Empty"/> clears it, so
|
||||
/// the first frame shows. A frame of another sequence is ignored.
|
||||
/// </summary>
|
||||
public Guid? HeroFrameId { get; init; }
|
||||
}
|
||||
|
||||
public enum SequenceEditOutcome
|
||||
@@ -227,12 +233,17 @@ public sealed class SequenceRepository
|
||||
if (current is null) return new SequenceEditResult(SequenceEditOutcome.NotFound, null);
|
||||
if (expectedSettingsVersion is { } expected && expected != current.SettingsVersion)
|
||||
return new SequenceEditResult(SequenceEditOutcome.Conflict, current);
|
||||
var hero = current.HeroFrameId;
|
||||
if (edit.HeroFrameId == Guid.Empty) hero = null;
|
||||
else if (edit.HeroFrameId is { } frame && await session.ScalarAsync<long>("SELECT count(*) FROM frames WHERE id = $1 AND sequence_id = $2",
|
||||
[frame, id], cancellationToken).ConfigureAwait(false) > 0) hero = frame;
|
||||
var updated = current with
|
||||
{
|
||||
Title = edit.Title is null ? current.Title : NullIfEmpty(edit.Title),
|
||||
Notes = edit.Notes is null ? current.Notes : NullIfEmpty(edit.Notes),
|
||||
Rating = edit.Rating ?? current.Rating,
|
||||
SettingsJson = edit.SettingsJson ?? current.SettingsJson,
|
||||
HeroFrameId = hero,
|
||||
SettingsVersion = current.SettingsVersion + 1,
|
||||
UpdatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
|
||||
@@ -270,6 +270,10 @@ public sealed class SyncService
|
||||
/// <summary>A server sequence from the proxy cache, for the editor; null when its proxies were never fetched or were cleared.</summary>
|
||||
public RemoteSequence? OpenRemote(string server, Guid remoteId) => Proxies.Load(server, remoteId);
|
||||
|
||||
/// <summary>The link of a local sequence to a sequence of <paramref name="server"/>; null when the server does not have it.</summary>
|
||||
public Task<SyncLink?> LinkOfAsync(string server, Guid localId, CancellationToken cancellationToken = default) =>
|
||||
_links.FindByLocalAsync(server, localId, cancellationToken);
|
||||
|
||||
// ---------------- Engine ----------------
|
||||
|
||||
/// <summary>Server ids of the sequences an upload or download job is working on.</summary>
|
||||
@@ -649,7 +653,24 @@ public sealed class SyncService
|
||||
return path;
|
||||
}
|
||||
|
||||
internal static string SavedCopyName(DateTime localTime) => string.Create(CultureInfo.InvariantCulture, $"project.this-pc-{localTime:yyyyMMdd-HHmmss}.json");
|
||||
internal 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>
|
||||
public const string SavedCopyPattern = SavedCopyPrefix + "*.json";
|
||||
|
||||
private const string SavedCopyPrefix = "project.this-pc-";
|
||||
private const string SavedCopyTimeFormat = "yyyyMMdd-HHmmss";
|
||||
|
||||
/// <summary>When a "Save both" copy was kept (local time, from its name); null for a name of another shape.</summary>
|
||||
public static DateTime? SavedCopyTime(string fileName)
|
||||
{
|
||||
var name = Path.GetFileNameWithoutExtension(fileName);
|
||||
return name.StartsWith(SavedCopyPrefix, StringComparison.Ordinal)
|
||||
&& DateTime.TryParseExact(name[SavedCopyPrefix.Length..], SavedCopyTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out var time)
|
||||
? time
|
||||
: null;
|
||||
}
|
||||
|
||||
private async Task ForgetAsync(SyncLink link, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
@@ -99,6 +99,21 @@ public sealed class TitanoClient : IDisposable
|
||||
public Task<SequenceManifest> GetManifestAsync(Guid id, CancellationToken ct = default) =>
|
||||
GetAsync($"api/v1/sequences/{id}/manifest", ProtocolJson.Default.SequenceManifest, ct);
|
||||
|
||||
/// <summary>The full deep-analysis report of a sequence (<c>analysis.json</c>); null when it was never deep-analysed.</summary>
|
||||
public async Task<string?> GetAnalysisReportAsync(Guid sequenceId, CancellationToken ct = default)
|
||||
{
|
||||
using var response = await SendRawAsync(new HttpRequestMessage(HttpMethod.Get, $"api/v1/sequences/{sequenceId}/analysis/report"), ct).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await EnsureSuccessAsync(response, ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (TitanoApiException ex) when (ex.Status == HttpStatusCode.NotFound && ex.Error.Details == "analysis")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return await response.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public Task<Page<FrameDto>> ListFramesAsync(Guid sequenceId, string? cursor = null, int limit = 1000, CancellationToken ct = default) =>
|
||||
GetAsync($"api/v1/sequences/{sequenceId}/frames?limit={limit}{Q("cursor", cursor)}", ProtocolJson.Default.PageFrameDto, ct);
|
||||
|
||||
|
||||
@@ -32,14 +32,18 @@ public sealed record Page<T>(IReadOnlyList<T> Items, string? NextCursor, long? T
|
||||
/// <summary><c>POST /api/v1/sequences</c>.</summary>
|
||||
public sealed record CreateSequenceRequest(string? Title, string? CameraHint);
|
||||
|
||||
/// <summary><c>PATCH /api/v1/sequences/{id}</c>. <see cref="ExpectedSettingsVersion"/> enables conflict detection (409).</summary>
|
||||
/// <summary>
|
||||
/// <c>PATCH /api/v1/sequences/{id}</c>. <see cref="ExpectedSettingsVersion"/> enables conflict detection (409).
|
||||
/// <see cref="HeroFrameId"/> names the frame the sequence shows (one of its own; <see cref="Guid.Empty"/> clears it).
|
||||
/// </summary>
|
||||
public sealed record UpdateSequenceRequest(
|
||||
string? Title,
|
||||
IReadOnlyList<string>? Tags,
|
||||
int? Rating,
|
||||
string? Notes,
|
||||
string? SettingsJson,
|
||||
int? ExpectedSettingsVersion);
|
||||
int? ExpectedSettingsVersion,
|
||||
Guid? HeroFrameId = null);
|
||||
|
||||
public sealed record FrameDto(
|
||||
Guid Id,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Titano.Core.Model;
|
||||
using Titano.Core.Naming;
|
||||
using Titano.Data;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Data.Repositories;
|
||||
using Titano.Protocol;
|
||||
using Titano.Server.Jobs;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Protocol;
|
||||
|
||||
namespace Titano.Server.Api;
|
||||
@@ -48,43 +48,3 @@ public static class Dto
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Wire names of job kinds, states and priorities: kebab-case (<c>deep-analyse</c>) and lower-case (<c>running</c>).</summary>
|
||||
public static class JobWire
|
||||
{
|
||||
public static string Kind(JobKind kind)
|
||||
{
|
||||
var name = kind.ToString();
|
||||
var sb = new StringBuilder(name.Length + 4);
|
||||
for (var i = 0; i < name.Length; i++)
|
||||
{
|
||||
if (i > 0 && char.IsUpper(name[i])) sb.Append('-');
|
||||
sb.Append(char.ToLowerInvariant(name[i]));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static bool TryParseKind(string? text, out JobKind kind) => TryParse(text, Kind, out kind);
|
||||
|
||||
public static string State(JobState state) => state.ToString().ToLowerInvariant();
|
||||
|
||||
public static bool TryParseState(string? text, out JobState state) => TryParse(text, State, out state);
|
||||
|
||||
public static string Priority(JobPriority priority) => priority.ToString().ToLowerInvariant();
|
||||
|
||||
public static bool TryParsePriority(string? text, out JobPriority priority) => TryParse(text, Priority, out priority);
|
||||
|
||||
private static bool TryParse<T>(string? text, Func<T, string> name, out T value) where T : struct, Enum
|
||||
{
|
||||
foreach (var candidate in Enum.GetValues<T>())
|
||||
{
|
||||
if (string.Equals(name(candidate), text, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
value = candidate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
value = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data;
|
||||
using Titano.Data.Jobs;
|
||||
using Titano.Data.Processing;
|
||||
using Titano.Protocol;
|
||||
using Titano.Server.Jobs;
|
||||
|
||||
@@ -35,6 +35,7 @@ public static class SequenceEndpoints
|
||||
sequences.MapGet("/{id:guid}/manifest", ManifestAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/frames", FramesAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/analysis", AnalysisAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/analysis/report", ReportAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/stats", StatsAsync).Requires(Permissions.Read);
|
||||
sequences.MapGet("/{id:guid}/renders", RendersAsync).Requires(Permissions.Read);
|
||||
// Renders made on a client, sent on request (BRIEF §14.5); chunks go through /uploads.
|
||||
@@ -123,7 +124,15 @@ public static class SequenceEndpoints
|
||||
if (request.SettingsJson is not null && !IsJson(request.SettingsJson)) return ApiErrors.BadRequest(context, "invalid_settings");
|
||||
|
||||
var expected = request.ExpectedSettingsVersion ?? IfMatchVersion(context);
|
||||
var edit = new SequenceEdit { Title = request.Title, Tags = request.Tags, Rating = request.Rating, Notes = request.Notes, SettingsJson = request.SettingsJson };
|
||||
var edit = new SequenceEdit
|
||||
{
|
||||
Title = request.Title,
|
||||
Tags = request.Tags,
|
||||
Rating = request.Rating,
|
||||
Notes = request.Notes,
|
||||
SettingsJson = request.SettingsJson,
|
||||
HeroFrameId = request.HeroFrameId,
|
||||
};
|
||||
var result = await db.Sequences.EditAsync(id, edit, expected, context.RequestAborted);
|
||||
switch (result.Outcome)
|
||||
{
|
||||
@@ -212,6 +221,18 @@ public static class SequenceEndpoints
|
||||
_ => ApiErrors.NotFound(context, "analysis"),
|
||||
};
|
||||
|
||||
/// <summary>The full deep-analysis report (<c>.titano/analysis.json</c>) a client's editor shows for a server sequence.</summary>
|
||||
private static async Task<IResult> ReportAsync(HttpContext context, Guid id, TitanoDatabase db, ServerArchive archive)
|
||||
{
|
||||
if (await db.Sequences.GetAsync(id, context.RequestAborted) is not { } sequence) return ApiErrors.NotFound(context, "sequence");
|
||||
if (string.IsNullOrEmpty(sequence.Folder)) return ApiErrors.NotFound(context, "analysis");
|
||||
var path = new Core.Archiving.ArchivePaths(archive.Root).Sequence(sequence.Folder).AnalysisPath;
|
||||
var file = new FileInfo(path);
|
||||
if (!file.Exists || file.LinkTarget is not null || !ArchivePathGuard.IsInside(archive.Root, path)) return ApiErrors.NotFound(context, "analysis");
|
||||
var etag = string.Create(CultureInfo.InvariantCulture, $"a-{file.Length}-{file.LastWriteTimeUtc.Ticks}");
|
||||
return FileResponses.Serve(context, file, 0, file.Length, "application/json; charset=utf-8", "no-cache", etag) ?? ApiErrors.NotFound(context, "analysis");
|
||||
}
|
||||
|
||||
private static async Task<IResult> StatsAsync(HttpContext context, Guid id, TitanoDatabase db)
|
||||
{
|
||||
if (await db.Sequences.GetAsync(id, context.RequestAborted) is not { } s) return ApiErrors.NotFound(context, "sequence");
|
||||
|
||||
@@ -54,7 +54,7 @@ internal static class EditorFixture
|
||||
};
|
||||
var report = deep ? DeepAnalyzer.AnalyzeAsync(new Frames(sequence)).GetAwaiter().GetResult() : null;
|
||||
return new SequenceContent(row, frames, project ?? new ProjectSettings(), LightAnalyzer.Analyze(frames), report, sequence.Options.Width,
|
||||
sequence.Options.Height, null, []);
|
||||
sequence.Options.Height, null, [], []);
|
||||
}
|
||||
|
||||
/// <summary>Synthetic frames as the deep analysis reads them.</summary>
|
||||
@@ -83,6 +83,12 @@ internal sealed class FakeSequenceSource(SyntheticSequence sequence, SequenceCon
|
||||
|
||||
public List<ArchiveJobRequest> Submitted { get; } = [];
|
||||
|
||||
/// <summary>A server sequence: renders become one job per preset.</summary>
|
||||
public bool IsRemote { get; init; }
|
||||
|
||||
/// <summary>Jobs <see cref="ListJobsAsync"/> returns.</summary>
|
||||
public List<Job> Jobs { get; } = [];
|
||||
|
||||
public int Saves { get; private set; }
|
||||
|
||||
public int Decodes { get; private set; }
|
||||
@@ -128,5 +134,12 @@ internal sealed class FakeSequenceSource(SyntheticSequence sequence, SequenceCon
|
||||
return Task.FromResult(Guid.CreateVersion7());
|
||||
}
|
||||
|
||||
public event Action<Job>? JobChanged;
|
||||
|
||||
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>
|
||||
public void Report(Job job) => JobChanged?.Invoke(job);
|
||||
|
||||
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using Titano.Core.Diagnostics.Synthetic;
|
||||
using Titano.Data.Archiving;
|
||||
using Titano.Data.Processing;
|
||||
using Titano.Data.Repositories;
|
||||
using Titano.Data.Tests.Infrastructure;
|
||||
using Titano.Data.Tests.Processing;
|
||||
using Titano.Testing;
|
||||
|
||||
namespace Titano.Data.Tests.Repositories;
|
||||
|
||||
/// <summary>Client edits of a sequence row (<see cref="SequenceRepository.EditAsync"/>) on both dialects: the hero frame the Library shows.</summary>
|
||||
public abstract class SequenceEditTests(TestContext context) : RepositoryTest(context)
|
||||
{
|
||||
[Test]
|
||||
public async Task TheHeroFrameIsSetKeptAndCleared()
|
||||
{
|
||||
var db = await OpenTitanoAsync();
|
||||
var archive = TestData.Archive();
|
||||
await db.Archives.UpsertAsync(archive, Ct);
|
||||
var sequence = TestData.Sequence(archive.Id);
|
||||
await db.Sequences.UpsertAsync(sequence, Ct);
|
||||
var frames = Enumerable.Range(0, 5).Select(i => TestData.Frame(sequence.Id, i)).ToList();
|
||||
await db.Frames.BulkInsertAsync(frames, Ct);
|
||||
|
||||
var set = await db.Sequences.EditAsync(sequence.Id, new SequenceEdit { SettingsJson = "{\"heroFrame\":3}", HeroFrameId = frames[3].Id }, null, Ct);
|
||||
Assert.Equal(SequenceEditOutcome.Updated, set.Outcome);
|
||||
Assert.Equal(frames[3].Id, set.Sequence!.HeroFrameId);
|
||||
Assert.Equal(frames[3].Id, (await db.Sequences.GetAsync(sequence.Id, Ct))!.HeroFrameId);
|
||||
|
||||
var kept = await db.Sequences.EditAsync(sequence.Id, new SequenceEdit { Rating = 4 }, set.Sequence.SettingsVersion, Ct);
|
||||
Assert.Equal(frames[3].Id, kept.Sequence!.HeroFrameId, "an edit without a hero leaves it alone");
|
||||
|
||||
var cleared = await db.Sequences.EditAsync(sequence.Id, new SequenceEdit { HeroFrameId = Guid.Empty }, null, Ct);
|
||||
Assert.Null(cleared.Sequence!.HeroFrameId, "Guid.Empty goes back to the first frame");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AFrameOfAnotherSequenceIsNotAHero()
|
||||
{
|
||||
var db = await OpenTitanoAsync();
|
||||
var archive = TestData.Archive();
|
||||
await db.Archives.UpsertAsync(archive, Ct);
|
||||
var mine = TestData.Sequence(archive.Id, title: "Mine");
|
||||
var other = TestData.Sequence(archive.Id, title: "Other");
|
||||
await db.Sequences.UpsertAsync(mine, Ct);
|
||||
await db.Sequences.UpsertAsync(other, Ct);
|
||||
var own = TestData.Frame(mine.Id, 0);
|
||||
var foreign = TestData.Frame(other.Id, 0);
|
||||
await db.Frames.BulkInsertAsync([own, foreign], Ct);
|
||||
|
||||
await db.Sequences.EditAsync(mine.Id, new SequenceEdit { HeroFrameId = own.Id }, null, Ct);
|
||||
var result = await db.Sequences.EditAsync(mine.Id, new SequenceEdit { HeroFrameId = foreign.Id }, null, Ct);
|
||||
Assert.Equal(SequenceEditOutcome.Updated, result.Outcome);
|
||||
Assert.Equal(own.Id, result.Sequence!.HeroFrameId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AConflictLeavesTheHeroAsItWas()
|
||||
{
|
||||
var db = await OpenTitanoAsync();
|
||||
var archive = TestData.Archive();
|
||||
await db.Archives.UpsertAsync(archive, Ct);
|
||||
var sequence = TestData.Sequence(archive.Id);
|
||||
await db.Sequences.UpsertAsync(sequence, Ct);
|
||||
var frame = TestData.Frame(sequence.Id, 0);
|
||||
await db.Frames.BulkInsertAsync([frame], Ct);
|
||||
|
||||
var result = await db.Sequences.EditAsync(sequence.Id, new SequenceEdit { HeroFrameId = frame.Id }, sequence.SettingsVersion + 7, Ct);
|
||||
Assert.Equal(SequenceEditOutcome.Conflict, result.Outcome);
|
||||
Assert.Null((await db.Sequences.GetAsync(sequence.Id, Ct))!.HeroFrameId);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class SqliteSequenceEditTests(TestContext context) : SequenceEditTests(context)
|
||||
{
|
||||
protected override Backend Backend => Backend.SqliteMemory;
|
||||
}
|
||||
|
||||
[RequiresEnvironment(PgTestServer.Variable)]
|
||||
public sealed class PostgresSequenceEditTests(TestContext context) : SequenceEditTests(context)
|
||||
{
|
||||
protected override Backend Backend => Backend.Postgres;
|
||||
}
|
||||
|
||||
/// <summary>Project writes of the engine (advice, sync) carry the project's hero frame to the index, so the Library shows it.</summary>
|
||||
public sealed class ProjectStoreHeroTests(TestContext context)
|
||||
{
|
||||
[Test]
|
||||
public async Task AdviceThatPicksAHeroReachesTheIndex()
|
||||
{
|
||||
await using var fixture = await ProcessingFixture.CreateAsync(context);
|
||||
var sequence = await fixture.AddAsync(SyntheticSequence.Create(new SyntheticSequenceOptions { Width = 64, Height = 48, FrameCount = 6 }));
|
||||
var frames = await fixture.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fixture.Ct);
|
||||
var store = new ProjectStore(fixture.Db, new SequenceWriter(new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) }));
|
||||
|
||||
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { HeroFrame = 4 }, fixture.Ct));
|
||||
Assert.Equal(frames[4].Id, (await fixture.Db.Sequences.GetAsync(sequence.Id, fixture.Ct))!.HeroFrameId);
|
||||
|
||||
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.5 } }, fixture.Ct));
|
||||
Assert.Equal(frames[4].Id, (await fixture.Db.Sequences.GetAsync(sequence.Id, fixture.Ct))!.HeroFrameId, "other changes keep the hero");
|
||||
|
||||
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { HeroFrame = null }, fixture.Ct));
|
||||
Assert.Null((await fixture.Db.Sequences.GetAsync(sequence.Id, fixture.Ct))!.HeroFrameId);
|
||||
|
||||
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { HeroFrame = 99 }, fixture.Ct));
|
||||
Assert.Null((await fixture.Db.Sequences.GetAsync(sequence.Id, fixture.Ct))!.HeroFrameId, "an index past the last frame shows the first");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user