From 25653c052ba85b1f91c96e338ad7cfe831368208 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Oct 2026 22:53:24 +0000 Subject: [PATCH] feat(app): server sync table, conflict resolution, sync options and Library sync glyphs SyncHost runs the sync agent of the signed-in session and gives transfer jobs their connection; the Server screen lists every sequence of this PC and of the server with its state and actions (upload, download originals, open with proxies, keep mine / take server / save both, pause, resume), filter chips, search, Upload all local and the comparison footer. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- i18n/en/Library.resx | 3 + i18n/en/Server.resx | 55 +++ i18n/en/Tooltips.resx | 37 ++ i18n/it/Library.it.resx | 3 + i18n/it/Server.it.resx | 54 +++ i18n/it/Tooltips.it.resx | 37 ++ src/Titano.App/Infrastructure/AppServices.cs | 21 +- src/Titano.App/Infrastructure/AppSettings.cs | 6 + src/Titano.App/Library/SequenceItem.cs | 13 +- src/Titano.App/Sections/LibraryViewModel.cs | 2 +- src/Titano.App/Sections/ServerView.xaml | 108 +++++- src/Titano.App/Sections/ServerViewModel.cs | 35 +- src/Titano.App/Server/SyncHost.cs | 137 +++++++ src/Titano.App/Server/SyncRow.cs | 58 +++ src/Titano.App/Server/SyncTableViewModel.cs | 366 +++++++++++++++++++ src/Titano.App/Server/SyncText.cs | 147 ++++++++ 16 files changed, 1072 insertions(+), 10 deletions(-) create mode 100644 src/Titano.App/Server/SyncHost.cs create mode 100644 src/Titano.App/Server/SyncRow.cs create mode 100644 src/Titano.App/Server/SyncTableViewModel.cs create mode 100644 src/Titano.App/Server/SyncText.cs diff --git a/i18n/en/Library.resx b/i18n/en/Library.resx index 8d365087..b4bac4f4 100644 --- a/i18n/en/Library.resx +++ b/i18n/en/Library.resx @@ -61,8 +61,11 @@ Title Analysed Analysing + Conflict + Newer here Proxies Remote + Newer on server Synced View Grid diff --git a/i18n/en/Server.resx b/i18n/en/Server.resx index 512ef763..9e2ada8b 100644 --- a/i18n/en/Server.resx +++ b/i18n/en/Server.resx @@ -5,12 +5,19 @@ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 nas.local:8443invariant + Sync projects automatically Certificate Forget Keep Titano trusts this certificate for this server. Forgetting it disconnects, and the next connection asks again.long Server certificate TLS {0} trusted {1} + Cancel + {0}: {1} here, {2} on the serverlong; {0} setting path, {1} value on this PC, {2} value on the server + The server copy of {0} will be replaced by this PC's settings.long; {0} sequence title + Keep this PC's settings? + This PC's settings of {0} will be replaced by the server copy.long; {0} sequence title + Take the server's settings? Connect Disconnect Not connected to a server @@ -71,6 +78,7 @@ The current password is wrong.long This upload belongs to a render job.long Servers found + Keep proxies offline Account Server Status @@ -93,6 +101,53 @@ Connecting… Disconnected Not connected + Download originals + Keep mine + Open with proxies + Pause + Resume + Save both + Sync settings + Take server + Upload + Server archive {1} · {0} sequencelong; {0} sequence count, {1} archive size + Server archive {1} · {0} sequenceslong; {0} sequence count, {1} archive size + The server copy changed again; compare and choose again.long + This PC + Sequence + Server + State + Nothing to compare yet + {0} export{0} count + {0} exports{0} count + All · {0}{0} count + Conflicts · {0}{0} count + Local only · {0}{0} count + Remote · {0}{0} count + Last sync {0} · manifest diff {1} slong; {0} time of day, {1} seconds + No sequence matches + —invariant + Open admin panel + originals + proxies + {0} upload queued{0} count + {0} uploads queued{0} count + {0} received{0} percent + Not compared · retrying + Search + settings differ + downloading + in sync + newer here + local only + paused + proxies only + remote + newer on server + uploading + waiting + Sequences + Upload all local Trust Cancel {0} uses a certificate Titano does not know yet. Compare the fingerprint with the one in the server's admin panel before you trust it.long diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx index 7ca6cbe4..8995adcf 100644 --- a/i18n/en/Tooltips.resx +++ b/i18n/en/Tooltips.resx @@ -74,13 +74,16 @@ Filter by analysis, proxies, verification or warnings Analysed: exposure, flicker and motion are measured An analysis job is running on this sequence + Settings changed here and on the server; choose on the Server screen Some frames are missing or unreadable; open the sequence for details + This PC has originals or settings the server does not have yet No proxies yet; editing reads the originals Not analysed yet JPEG proxies built for fast editing Lives on the server; this PC has proxies at most Rendered once Rendered {0:N0} times + The server has originals or settings this PC does not have yet The same on this PC and on the server {0:N0} warning; open the sequence for details {0:N0} warnings; open the sequence for details @@ -97,14 +100,18 @@ Connection, sync and render node · Ctrl+6 Preferences of this PC · Ctrl+, Address of the Titano Server; https is assumed · Enter connects + Send and take project settings as they change; settings changed on both sides wait for your choice in the table below Show the full fingerprint, or forget the trust Fingerprint trusted on first use; a change blocks the connection and asks you again + Close without changing either copy + The settings that differ: this PC's value, then the server's Identify the server, confirm a new certificate, then sign in · Enter Close the session and work with the local archive only; you stay signed in Do not connect; nothing is sent to this server SHA-256 fingerprint of the server certificate Forget this certificate; the next connection asks again Servers found on this network and used before + Keep JPEG proxies of every server sequence on this PC to edit without the originals; uses space in the cache folder Keep trusting this certificate Close without signing in · Esc Sent only to this server; Titano keeps a session token, never the password @@ -118,6 +125,36 @@ Sign in; the token is stored encrypted for this Windows user · Enter Sign out; the token is removed from this PC Connection to the server + Size and sequences of the server archive + Fetch the originals to this PC, verified by hash ({0}){0} size + All sequences on this PC and on the server + Settings differ between this PC and the server + Only on this PC + Only on the server + Overwrite the server copy with this PC's settings + When this PC last compared every sequence with the server, and how long it took + Open the web admin in your browser (admins only) + Open the editor on the proxies; the render runs on the server + Pause this transfer; it resumes where it stopped + Resume this transfer where it stopped + The last comparison failed: {0}. It is retried automatically.{0} reason + Take the server copy and keep this PC's settings as a dated copy of the project + Filter the table by sequence title + Settings changed both here and on the server; choose which to keep + Originals or proxies are arriving from the server + Same originals and settings on this PC and on the server + This PC has originals or settings the server does not have yet + Only on this PC; upload it to keep it on the server too + The transfer is paused; resume it to continue + On the server; this PC keeps its proxies for editing + Only on the server + The server has originals or settings this PC does not have yet + Originals are being sent to the server + The transfer waits for its turn in the job queue + Send or take the settings changed on one side + Replace this PC's settings with the server copy + Copy originals and settings to the server ({0}){0} size + Send every local-only sequence to the server ({0} sequences, {1}){0} count, {1} size Trust this certificate for this server and continue to sign in Use this address Graphics adapter and Media Foundation encoders found diff --git a/i18n/it/Library.it.resx b/i18n/it/Library.it.resx index cbf7ca1a..29240386 100644 --- a/i18n/it/Library.it.resx +++ b/i18n/it/Library.it.resx @@ -61,8 +61,11 @@ Titolo Analizzata In analisi + Conflitto + Più recente qui Proxy Remota + Più recente sul server Sincronizzata Vista Griglia diff --git a/i18n/it/Server.it.resx b/i18n/it/Server.it.resx index fb5bdb68..b5bd92ab 100644 --- a/i18n/it/Server.it.resx +++ b/i18n/it/Server.it.resx @@ -4,12 +4,19 @@ 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Sincronia automatica progetti Certificato Dimentica Mantieni Titano considera attendibile questo certificato per questo server. Se lo dimentichi la connessione si chiude e la prossima volta te lo chiederà di nuovo. Certificato del server TLS {0} attendibile dal {1} + Annulla + {0}: {1} qui, {2} sul server + La copia sul server di {0} sarà sostituita dalle impostazioni di questo PC. + Tenere le impostazioni di questo PC? + Le impostazioni di {0} su questo PC saranno sostituite dalla copia del server. + Usare le impostazioni del server? Connetti Disconnetti Non connesso a un server @@ -70,6 +77,7 @@ La password attuale è errata. Questo caricamento appartiene a un job di rendering. Server trovati + Proxy disponibili offline Account Server Stato @@ -92,6 +100,52 @@ Connessione… Disconnesso Non connesso + Scarica originali + Tieni le mie + Apri con i proxy + Pausa + Riprendi + Salva entrambe + Sincronizza + Usa il server + Carica + Archivio del server {1} · {0} sequenza + Archivio del server {1} · {0} sequenze + La copia sul server è cambiata di nuovo; confronta e scegli di nuovo. + Questo PC + Sequenza + Server + Stato + Ancora nulla da confrontare + {0} esportazione + {0} esportazioni + Tutte · {0} + Conflitti · {0} + Solo locali · {0} + Sul server · {0} + Ultima sincronia {0} · confronto {1} s + Nessuna sequenza corrisponde + Apri pannello admin + originali + proxy + {0} caricamento in coda + {0} caricamenti in coda + {0} ricevuto + Confronto non riuscito · riprovo + Cerca + impostazioni diverse + in scaricamento + sincronizzata + più recente qui + solo locale + in pausa + solo proxy + sul server + più recente sul server + in caricamento + in attesa + Sequenze + Carica tutte le locali Considera attendibile Annulla {0} usa un certificato che Titano non conosce ancora. Confronta l'impronta con quella del pannello di amministrazione del server prima di considerarlo attendibile. diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx index c81ad08f..cd171b20 100644 --- a/i18n/it/Tooltips.it.resx +++ b/i18n/it/Tooltips.it.resx @@ -74,13 +74,16 @@ Filtra per analisi, proxy, verifica o avvisi Analizzata: esposizione, flicker e movimento sono misurati Un'attività di analisi è in corso su questa sequenza + Impostazioni cambiate qui e sul server; scegli nella schermata Server Alcuni fotogrammi mancano o sono illeggibili; apri la sequenza per i dettagli + Questo PC ha originali o impostazioni che il server non ha ancora Ancora nessun proxy; la modifica legge gli originali Non ancora analizzata Proxy JPEG pronti per una modifica veloce Si trova sul server; questo PC ne ha al massimo i proxy Esportata una volta Esportata {0:N0} volte + Il server ha originali o impostazioni che questo PC non ha ancora Uguale su questo PC e sul server {0:N0} avviso; apri la sequenza per i dettagli {0:N0} avvisi; apri la sequenza per i dettagli @@ -97,14 +100,18 @@ Connessione, sincronizzazione e nodo di rendering · Ctrl+6 Preferenze di questo PC · Ctrl+, Indirizzo del Titano Server; si presume https · Invio per connettersi + Invia e ricevi le impostazioni dei progetti quando cambiano; quelle cambiate da entrambe le parti attendono la tua scelta nella tabella sotto Mostra l'impronta completa o revoca la fiducia Impronta accettata al primo utilizzo; se cambia, la connessione si blocca e te lo chiede di nuovo + Chiudi senza modificare nessuna delle due copie + Le impostazioni diverse: il valore di questo PC, poi quello del server Identifica il server, conferma un certificato nuovo e poi accedi · Invio Chiude la sessione e lavora solo con l'archivio locale; l'accesso resta salvato Non connetterti; a questo server non viene inviato nulla Impronta SHA-256 del certificato del server Dimentica questo certificato; alla prossima connessione verrà chiesto di nuovo Server trovati in questa rete e usati in precedenza + Tieni su questo PC i proxy JPEG di ogni sequenza del server per lavorare senza gli originali; usa spazio nella cartella cache Continua a considerare attendibile questo certificato Chiude senza accedere · Esc Inviata solo a questo server; Titano conserva un token di sessione, mai la password @@ -118,6 +125,36 @@ Accedi; il token viene salvato cifrato per questo utente di Windows · Invio Esci; il token viene rimosso da questo PC Connessione al server + Dimensione e sequenze dell'archivio del server + Scarica gli originali su questo PC, verificati con l'hash ({0}) + Tutte le sequenze di questo PC e del server + Le impostazioni differiscono tra questo PC e il server + Solo su questo PC + Solo sul server + Sovrascrivi la copia del server con le impostazioni di questo PC + Quando questo PC ha confrontato per l'ultima volta tutte le sequenze con il server, e quanto ha impiegato + Apri l'amministrazione web nel browser (solo amministratori) + Apri l'editor sui proxy; il rendering avviene sul server + Metti in pausa questo trasferimento; riprende da dove si è fermato + Riprendi questo trasferimento da dove si è fermato + L'ultimo confronto non è riuscito: {0}. Viene ripetuto automaticamente. + Usa la copia del server e conserva le impostazioni di questo PC come copia datata del progetto + Filtra la tabella per titolo della sequenza + Le impostazioni sono cambiate sia qui sia sul server; scegli quali tenere + Originali o proxy in arrivo dal server + Stessi originali e impostazioni su questo PC e sul server + Questo PC ha originali o impostazioni che il server non ha ancora + Solo su questo PC; caricala per averla anche sul server + Il trasferimento è in pausa; riprendilo per continuare + Sul server; questo PC ne conserva i proxy per modificarla + Solo sul server + Il server ha originali o impostazioni che questo PC non ha ancora + Originali in invio al server + Il trasferimento attende il suo turno nella coda delle attività + Invia o ricevi le impostazioni cambiate da una sola parte + Sostituisci le impostazioni di questo PC con la copia del server + Copia originali e impostazioni sul server ({0}) + Invia al server ogni sequenza solo locale ({0} sequenze, {1}) Considera attendibile questo certificato per questo server e prosegui con l'accesso Usa questo indirizzo Scheda grafica ed encoder Media Foundation trovati diff --git a/src/Titano.App/Infrastructure/AppServices.cs b/src/Titano.App/Infrastructure/AppServices.cs index 5ed5098f..9184d2b4 100644 --- a/src/Titano.App/Infrastructure/AppServices.cs +++ b/src/Titano.App/Infrastructure/AppServices.cs @@ -29,7 +29,7 @@ namespace Titano.App.Infrastructure; /// archive engine (WIC first, then managed decoders), the analysis and render engine (the same decoders; Media /// Foundation, then managed encoders), the one of this PC with the handlers of /// , thumbnails, the server session, the render node, the encoder inventory and the -/// update check. Started after the window shows, stopped when the app exits. The last archive is reopened at start and +/// update check, and the sync with the signed-in server (). Started after the window shows, stopped when the app exits. The last archive is reopened at start and /// rescanned every (BRIEF §7: polling, no file-system watchers). The render node runs while /// the user offers this PC () and a server session is open. /// @@ -52,6 +52,7 @@ public sealed class AppServices : IAsyncDisposable SaveSettingsAction = saveSettings; Dialogs = dialogs; ArchiveSetup = new EngineArchiveSetup(this); + Sync = new SyncHost(this); Server = new ServerSession(settings, saveSettings, new TitanoServerApiFactory(), new DpapiTokenProtector()); Encoders = new MediaFoundationInventory(); CheckForUpdateAsync = ct => UpdateCheck.FetchAsync(Http.Value, ProductLinks.LatestReleaseApi, VersionText, ct); @@ -81,9 +82,13 @@ public sealed class AppServices : IAsyncDisposable _server = value; _server.PropertyChanged += OnServerChanged; UpdateRenderNode(); + Sync.Update(); } } + /// Sync with the signed-in server: engine, job connection, background comparison. + public SyncHost Sync { get; } + public IEncoderInventory Encoders { get; set; } /// Latest public release (GitHub Releases API of the releases repository, BRIEF §18). @@ -111,7 +116,10 @@ public sealed class AppServices : IAsyncDisposable /// The job handlers of this PC's engine — the single registration list; a kind without a handler stays /// queued (it is never claimed here). public static IReadOnlyList CreateJobHandlers(AppServices services) => - [.. services.Archives?.CreateJobHandlers() ?? [], .. services.Processing?.CreateJobHandlers() ?? []]; + [ + .. services.Archives?.CreateJobHandlers() ?? [], .. services.Processing?.CreateJobHandlers() ?? [], + .. services.Sync.Service?.CreateJobHandlers(services.Sync) ?? [], + ]; /// Queues a scan of unless one is already waiting or running. public async Task QueueScanAsync(Archive archive, bool full, CancellationToken ct = default) @@ -174,6 +182,7 @@ public sealed class AppServices : IAsyncDisposable _server.PropertyChanged -= OnServerChanged; await _nodeSwitch; await StopRenderNodeAsync(); + await Sync.DisposeAsync(); (Jobs as IDisposable)?.Dispose(); if (Engine is not null) await Engine.DisposeAsync(); Thumbnails?.Dispose(); @@ -209,6 +218,7 @@ public sealed class AppServices : IAsyncDisposable var archive = new ArchiveServiceOptions { Decoder = DecoderFactory.CreateClient(new WicDecoderProvider()) }; Archives = new ArchiveService(database, archive); Processing = new ProcessingService(database, ProcessingOptions(archive)); + Sync.Open(database, Archives, archive); var handlers = CreateJobHandlers(this); var kinds = handlers.Select(h => h.Kind).Distinct().ToArray(); Engine = new JobEngine(database, handlers, new JobEngineOptions { WorkerId = WorkerId, Kinds = kinds }); @@ -218,6 +228,7 @@ public sealed class AppServices : IAsyncDisposable Jobs = new EngineJobQueue(database, Engine, started); Log.Info("jobs", started ? $"Job engine started with {Engine.Options.Workers} worker(s) for {string.Join(", ", kinds)}" : "No job handlers registered; jobs stay queued"); UpdateRenderNode(); + Sync.Update(); } /// Media Foundation (hardware first, software H.264) then managed encoders; frames spill into the cache folder @@ -235,7 +246,11 @@ public sealed class AppServices : IAsyncDisposable }, }; - private void OnServerChanged(object? sender, PropertyChangedEventArgs e) => UpdateRenderNode(); + private void OnServerChanged(object? sender, PropertyChangedEventArgs e) + { + UpdateRenderNode(); + Sync.Update(); + } /// Waits for the previous switch, then runs the node for the current session, or stops it. private async Task SwitchRenderNodeAsync(Task previous) diff --git a/src/Titano.App/Infrastructure/AppSettings.cs b/src/Titano.App/Infrastructure/AppSettings.cs index 59385ce1..dcf5bb47 100644 --- a/src/Titano.App/Infrastructure/AppSettings.cs +++ b/src/Titano.App/Infrastructure/AppSettings.cs @@ -111,6 +111,12 @@ public sealed class AppSettings /// Let the server send render jobs to this PC (BRIEF §14.7). public bool RenderNodeOptIn { get; set; } + /// Keep the proxies of every server sequence without local originals in the cache (BRIEF §12.7). + public bool KeepProxiesOffline { get; set; } + + /// Send and take project settings changed on one side without asking (Server.html). + public bool SyncSettingsAutomatically { get; set; } = true; + // ---- Jobs ---- /// "Clear done": finished jobs older than this are hidden from the Jobs list (they stay in the history). public DateTimeOffset? JobsClearedAt { get; set; } diff --git a/src/Titano.App/Library/SequenceItem.cs b/src/Titano.App/Library/SequenceItem.cs index f1ed8d64..ef467181 100644 --- a/src/Titano.App/Library/SequenceItem.cs +++ b/src/Titano.App/Library/SequenceItem.cs @@ -147,6 +147,16 @@ public sealed class SequenceItem : ObservableObject OnPropertyChanged(nameof(PrimaryStatus)); } + /// Where a local copy stands against the server (the sync engine writes the state); null while it is only here. + public static CardStatus? SyncStatus(SyncState state) => state switch + { + SyncState.InSync => new CardStatus(StatusKind.Synced, Loc.L("Library.Status.Synced"), Loc.L("Tooltips.Library.Status.Synced")), + SyncState.LocalAhead => new CardStatus(StatusKind.Synced, Loc.L("Library.Status.LocalAhead"), Loc.L("Tooltips.Library.Status.LocalAhead")), + SyncState.ServerAhead => new CardStatus(StatusKind.Remote, Loc.L("Library.Status.ServerAhead"), Loc.L("Tooltips.Library.Status.ServerAhead")), + SyncState.Conflict => new CardStatus(StatusKind.Warning, Loc.L("Library.Status.Conflict"), Loc.L("Tooltips.Library.Status.Conflict")), + _ => null, + }; + /// Card status row: analysed, proxies, renders, sync, warnings (Main.html). public static IReadOnlyList BuildStatuses(Sequence s, bool analysing) { @@ -168,8 +178,7 @@ public sealed class SequenceItem : ObservableObject if (s.RenderedCount > 0) list.Add(new CardStatus(StatusKind.Rendered, Formatting.Count(s.RenderedCount), Loc.Plural("Tooltips.Library.Status.Rendered", s.RenderedCount))); - if (s.SyncState == SyncState.InSync) - list.Add(new CardStatus(StatusKind.Synced, Loc.L("Library.Status.Synced"), Loc.L("Tooltips.Library.Status.Synced"))); + if (SyncStatus(s.SyncState) is { } sync) list.Add(sync); if ((s.Status & SequenceStatus.HasErrors) != 0) list.Add(new CardStatus(StatusKind.Error, Formatting.Count(Math.Max(1, s.WarningCount)), Loc.L("Tooltips.Library.Status.Errors"))); else if (s.WarningCount > 0 || (s.Status & SequenceStatus.HasWarnings) != 0) diff --git a/src/Titano.App/Sections/LibraryViewModel.cs b/src/Titano.App/Sections/LibraryViewModel.cs index f1072311..a70ed8d7 100644 --- a/src/Titano.App/Sections/LibraryViewModel.cs +++ b/src/Titano.App/Sections/LibraryViewModel.cs @@ -497,7 +497,7 @@ public sealed class LibraryViewModel : SectionViewModel { if (await _db.Sequences.GetAsync(item.Id) is { } fresh) item.Update(fresh); } - if (job.Kind is JobKind.Scan or JobKind.Rebuild or JobKind.Import or JobKind.Adopt or JobKind.Move or JobKind.UploadCommit) await RefreshAsync(); + if (job.Kind is JobKind.Scan or JobKind.Rebuild or JobKind.Import or JobKind.Adopt or JobKind.Move or JobKind.UploadCommit or JobKind.Download) await RefreshAsync(); } catch (DatabaseException ex) { diff --git a/src/Titano.App/Sections/ServerView.xaml b/src/Titano.App/Sections/ServerView.xaml index 4ad2e471..c4d1d067 100644 --- a/src/Titano.App/Sections/ServerView.xaml +++ b/src/Titano.App/Sections/ServerView.xaml @@ -15,9 +15,12 @@ + + + - + @@ -112,9 +115,112 @@ + + + + + + + + + + + + + + + +