diff --git a/deploy/releases-repo/README.md b/deploy/releases-repo/README.md index 746792f4..f6df9bf8 100644 --- a/deploy/releases-repo/README.md +++ b/deploy/releases-repo/README.md @@ -41,13 +41,15 @@ for community review. Development happens elsewhere; please use the issues here `Get-FileHash .\Titano-Setup-.exe -Algorithm SHA256` and compare the value with the line for that file in `SHA256SUMS` of the same release. 3. Run the setup. It installs for the current user into `%LOCALAPPDATA%\Programs\Titano` without administrator - rights; choose *All users* to install into `Program Files` (Windows asks for permission). + rights; choose *All users* to install into `Program Files` (Windows asks for permission). The *Server* component + runs as a Windows service, so choosing it installs for all users, in a folder inside `Program Files`. - **Upgrade:** Titano checks this repository at start (you can turn this off in Settings › Updates) and shows a notice when a new version exists. *Download* fetches the setup, verifies it against `SHA256SUMS` and shows it in Explorer; run it to upgrade in place. Your archive, settings and index are kept. - **Uninstall:** Windows Settings › Apps › Installed apps › Titano › Uninstall. Your photos and archive are never - touched; the program data folder (`%LOCALAPPDATA%\Titano`) is removed only if you tick the option to do so. + touched; the program data in `%LOCALAPPDATA%\Titano` is removed only if you tick the option to do so, and only the + part no other installed Titano program still uses. A Titano Server service of that folder is stopped and removed. - **Silent install** (IT deployment): `Titano-Setup-.exe /S [/DIR="D:\Apps\Titano"] [/ALLUSERS] [/COMPONENTS=Titano,Uploader,Server] [/NODESKTOP] [/NOSTARTMENU] [/LANG=it]`. Silent uninstall: `"%LOCALAPPDATA%\Programs\Titano\Uninstall Titano.exe" /uninstall /S`. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index e0699b32..cfdc756a 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -36,7 +36,7 @@ Dependencies point one way: `Core` ← `Core.Windows`, `Data`, `Protocol` ← `S | `Advice` | `Advisor`: recommendations with localisable reasons, apply/optimise, sequence presets | | `Motion` | FFT, phase correlation, pyramids, optical flow, motion blur, stabiliser, virtual camera, interpolation, stacking | | `Math` (namespace `Titano.Core.Mathematics`) | Splines, LOWESS, statistics, solar position, 3×3 colour matrices | -| `Project` | `ProjectSettings` (Auto/manual values), export presets | +| `Project` | `ProjectSettings` (Auto/manual values), export presets, `ProjectBundle` (the `.titano` project file: sequence reference and settings) | | `Render` | Render plan (timing modes), preparation pass, geometry, `RenderPipeline`, self-test suite | | `Export` | Preset resolution, encoder selection with fallbacks, output naming | | `Video` (+ `Mp4`, `Avi`, `Bitstream`, `Yuv`, `Managed`) | `IVideoEncoderProvider`, MP4 muxer and inspector, AVI-MJPEG, NV12/P010, managed encoders (MJPEG-AVI, GIF, APNG, image sequences) | @@ -57,7 +57,7 @@ Dependencies point one way: `Core` ← `Core.Windows`, `Data`, `Protocol` ← `S | `Repositories` | `TitanoDatabase` facade: archives, sequences, frames, tags, renders, jobs, cards, users, tokens, uploads, render nodes, settings, audit; `DatabaseBackups` (daily `VACUUM INTO` copies of an SQLite index kept ×3, restore staged for the next start and carried out before the index opens, so it also recovers one that no longer opens) | | `Jobs` | `JobEngine` (its number of workers can change while it runs), `IJobHandler`, `IJobHandlerProvider`, `JobContext` (progress, checkpoints, follow-up jobs) | | `Archiving` | `ArchiveService` (create/adopt/open, archive settings written to `archive.json` then the index), `ArchiveIndexer` (scan, rebuild), `ArchiveIngest` (uploads and imports), `ImportService`, `ArchiveVerifier`, `ArchiveImages`, `FrameTiers` (decode tier, `PreviewOnly`/`Undecodable` flags and preview size of frames, written to sidecar and index by the light analysis, deep analysis, renders and image passes), `GprCompanions` (the JPEG of each GoPro GPR, found in the index when an import kept it in another sequence), `ArchiveMaintenance`, `MassRenamer`, `SequenceTrash` (delete into the archive's hidden trash with a dry run, restore; the folder moves back when the index step fails), job handlers | -| `Processing` | `ProcessingService`, `SequenceAnalyser`, `SequenceRender`, `ProjectStore`, `RenderNodeClient`, job handlers | +| `Processing` | `ProcessingService`, `SequenceAnalyser`, `SequenceRender`, `ProjectStore`, `ProjectBundles` (a `.titano` file for a sequence, and the sequence a file names), `RenderNodeClient`, job handlers | | `Sync` | `SyncService` (sync table of one server: compare, link by content, settle conflicts, enqueue transfers), `SyncRules` (status, settings merge and differences, no I/O), `SyncLinkStore` (`sync_links`, `sync_state`), `SyncTransfers` and `SyncJobHandler` (resumable, hash-verified uploads and downloads as jobs; downloads commit through the archive ingest), `SyncAgent` (background comparison, server events, backoff, offline proxies), `ProxyCache` and `RemoteSequence` (server sequences opened with proxies), `ISyncRemote` (the server calls; `TitanoSyncRemote` over `TitanoClient`) | ### 2.3 Titano.App areas @@ -67,12 +67,12 @@ Dependencies point one way: `Core` ← `Core.Windows`, `Data`, `Protocol` ← `S | `Shell` | `MainWindow` (rail and its shortcuts, taskbar progress), `ShellViewModel` (rail, sections, first run), `OsNotifications` (toasts as Windows notifications while the window is minimised or in the background), dialogs, `ErrorText` (the sentence of an error toast), `ScreenCapture` (`--capture` scenes), `SectionTemplates.xaml` (view model → view) | | `Sections` | One `XxxView.xaml` + `XxxViewModel` per screen: Welcome, Library, Sequence (editor), Import, Archive, Jobs, Server, Settings, About | | `Library` | Filter, facets, pager, timeline, saved views, quick and mass actions, remote cards and thumbnails, thumbnail cache, list export | -| `Editor` | `EditorSession` (project, undo/redo, saving, merges), `ISequenceSource` (`LocalSequenceSource`, `RemoteSequenceSource`), tabs (Frames, Exposure, Camera, Motion, Export), `PreviewRenderer`, `ExportPlanner`, `ExportSync`, `SavedCopies`, `SequenceJobs` | +| `Editor` | `EditorSession` (project, undo/redo, saving, merges), `ISequenceSource` (`LocalSequenceSource`, `RemoteSequenceSource`), tabs (Frames, Exposure, Camera, Motion, Export), `PreviewRenderer`, `ExportPlanner`, `ExportSync`, `SavedCopies`, `SequenceJobs`, `ProjectFiles` (save and open `.titano` project files) | | `Import` | `CardPool` (inserted cards, remembered cards, folders), camera profiles, plans and choices, destinations (archive, folder, server through `ServerImportSink`), card actions (verified delete, format, eject) | | `Archive` | `CurrentArchive`, `ArchiveTree`, figures for the charts, maintenance reports, mass rename and move, delete and trash dialogs (`SequenceDeletion`, `DeletePlans`), `ArchiveFailures` | | `Server` | `ServerSession`, `ConnectFlow` (trust on first use), `SyncHost` (sync engine, agent, metered hold, editor connections, Export Sync), sync table, `RemoteSequenceApi` | | `Jobs`, `Settings`, `About` | Job list and buffering, `JobNotices` (which job endings raise a toast; `JobEndings` lets a batch speak once); settings rows, encoder and format inventories, `ProcessingTuning` (Settings › Rendering and Analysis applied to each job), `InterfacePriority`, language catalog, naming preview; update check and download | -| `Infrastructure` | `AppServices` (composition root), `AppSettings`, `AppEnvironment` (installed or portable), `AppClock` (today's date, frozen by `--capture`), `StartWithWindows` (this copy's sign-in entry), `UiLanguage`, `LiveRegion`, `RenderNodeHost`, `DiagnosticsBundle`, `ShellActions` (BRIEF §8.6), device monitor | +| `Infrastructure` | `AppServices` (composition root), `AppSettings`, `AppEnvironment` (installed or portable), `AppClock` (today's date, frozen by `--capture`), `StartWithWindows` (this copy's sign-in entry), `UiLanguage`, `LiveRegion`, `RenderNodeHost`, `DiagnosticsBundle`, `ShellActions` (BRIEF §8.6), `SingleInstance` (one Titano per data folder; a later launch hands its file over a named pipe, or waits for a closing one to exit and starts in its place), device monitor | | `DesignTime` | `SampleData`: the archive, jobs and server the screenshots and smoke tests run on, dated from the fixed `SampleData.Now` | ### 2.4 Titano.Ui and Titano.Server @@ -95,7 +95,7 @@ Dependencies point one way: `Core` ← `Core.Windows`, `Data`, `Protocol` ← `S | Titano (desktop) | `App/Infrastructure/AppServices` | SQLite index in `%LOCALAPPDATA%\Titano` (or `.\data` when portable); `ArchiveService` with WIC first, then managed decoders; `ProcessingService` with Media Foundation, then managed encoders; one `JobEngine` with the handlers of both; thumbnails; `ServerSession`; `SyncHost` while signed in (sync engine and agent, upload and download handlers, metered hold, editors of server sequences); the render node while opted in and signed in; update check and download (`About/UpdateCheck`, `About/UpdateDownload`, `About/UpdateFlow`: the setup, or the portable zip for a portable copy, verified against `SHA256SUMS`, resumable, cancellable, failing after 60 s without data); diagnostics bundle; daily index backups and the restore staged in Settings › Advanced (`DatabaseBackups`) | | Titano Server | `Server/Hosting/ServerHost.Build` | Options from `server.json` + `TITANO_*`; PostgreSQL (or SQLite on Windows); `ArchiveModule` then `ProcessingModule` register job handler providers; `JobEngineHost` (renders only managed formats and MP4 jobs no render node can take, BRIEF §14.7); `RenderNodeService`/`RenderNodeMonitor`; `UploadService`; `EventHub` (WebSocket); embedded admin panel; LAN discovery beacon; Windows service host; daily backups of an SQLite index (`DatabaseBackupService`) | | Titano Uploader | `Uploader/App.xaml.cs` | `TitanoClient`, persisted queue, watch folders; no database | -| Titano Setup | `Setup/Program` | TPK1 payload extraction, registry, shortcuts, silent mode, uninstaller | +| Titano Setup | `Setup/Program` | TPK1 payload extraction, registry, shortcuts, file types named in setup's language, silent mode, uninstaller; only what starts a program its log or payload lists is changed: Windows services of those programs stopped once the programs have closed, started again (also after a failure) or deleted through the Service Control Manager (an elevated `/SERVICES … /NAMES` step when needed), sign-in entries of those programs removed, shared shortcuts handed to the product that keeps the program; the Server only for all users inside Program Files; "Remove my data" limited to the programs no other installed product uses | ### 2.6 Job kinds and their handlers diff --git a/i18n/en/Editor.resx b/i18n/en/Editor.resx index 8c4cc113..f6a59fbb 100644 --- a/i18n/en/Editor.resx +++ b/i18n/en/Editor.resx @@ -184,6 +184,15 @@ This frame cannot be read. Vectors original | corrected + Project file applied + The project file’s settings were not applied.long + The sequence of this project file is not in the library.long + Retry + Save project file + Project file saved + Project file folder + Undo + This file is not a Titano project or cannot be read.long Proxies not received Getting the proxies Auto diff --git a/i18n/en/Setup.resx b/i18n/en/Setup.resx index 651318ff..9a624382 100644 --- a/i18n/en/Setup.resx +++ b/i18n/en/Setup.resx @@ -31,6 +31,7 @@ Language Options Install for + Titano project Browse Version {0} · installed {1} Version {0} diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx index 1dd72df4..65d67fdd 100644 --- a/i18n/en/Tooltips.resx +++ b/i18n/en/Tooltips.resx @@ -211,6 +211,10 @@ Show or hide the shot data Overlay the motion to the next frame measured by the engine Drag the line to compare · drag to pan · wheel zooms · double-click 1:1 + Project files are for sequences in an archive on this PC + Apply the project file’s settings again + Save a .titano file that opens this sequence with these settings when double-clicked + Bring back the settings the sequence had before the file was opened · Ctrl+Z Your account can look at this server sequence but not change it Edited with proxies on this PC; changes are saved on {0} and analyses and renders run there Shown from {0}; your account can look at this sequence but not change it @@ -593,6 +597,7 @@ Auto: half the logical cores run jobs at once, each with its own number of threads Back to Auto: half the logical cores Install in Program Files for every account · asks for administrator approval + {0} · it runs as a Windows service, so it installs for all users in Program Files Return to the options without changing anything Choose the installation folder Close setup without changing anything @@ -605,15 +610,21 @@ Add shortcuts to the desktop Where the programs are installed · your data stays in its own folder Enter a full folder path that is not a drive root or a system folder + {0} runs as a Windows service, so choose a folder inside Program Files Copy the selected programs and register them with Windows Folder of the installed programs Install in your user folder · no administrator rights needed + {0} runs as a Windows service, so it installs for all users only Language of this setup Open the program when setup finishes Open the installed program Already installed here · uninstall it first to change folder or scope + Runs as a Windows service, so it installs for all users only · this copy is installed for you alone; uninstall it first to add it + Runs as a Windows service, so it installs inside Program Files only · this copy is installed elsewhere; uninstall it first to add it Select at least one program to install Also delete %LOCALAPPDATA%\Titano: database, backups, cache, settings, logs, the uploader queue and sign-in · photos in archives are kept + Also delete Titano’s database, backups, cache, settings and logs in %LOCALAPPDATA%\Titano · the Uploader’s files and photos in archives are kept + Also delete the Uploader’s queue, settings, sign-in and logs in %LOCALAPPDATA%\Titano · Titano’s files and photos in archives are kept Run the same step again Add the programs to the Start menu Remove programs, shortcuts and file types · your data is kept unless selected diff --git a/i18n/it/Editor.it.resx b/i18n/it/Editor.it.resx index b91e383a..1e8570ad 100644 --- a/i18n/it/Editor.it.resx +++ b/i18n/it/Editor.it.resx @@ -173,6 +173,15 @@ Questo fotogramma non si può leggere. Vettori originale | corretto + File di progetto applicato + Le impostazioni del file di progetto non sono state applicate.long + La sequenza di questo file di progetto non è nella libreria.long + Riprova + Salva file progetto + File di progetto salvato + Cartella file progetto + Annulla + Questo file non è un progetto Titano o non si può leggere.long Proxy non ricevuti Scaricamento dei proxy Auto diff --git a/i18n/it/Setup.it.resx b/i18n/it/Setup.it.resx index 57e525ae..2156a9e5 100644 --- a/i18n/it/Setup.it.resx +++ b/i18n/it/Setup.it.resx @@ -31,6 +31,7 @@ Lingua Opzioni Installa per + Progetto Titano Sfoglia Versione {0} · installata {1} Versione {0} diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx index ec22eb55..91f31e25 100644 --- a/i18n/it/Tooltips.it.resx +++ b/i18n/it/Tooltips.it.resx @@ -211,6 +211,10 @@ Mostra o nasconde i dati di scatto Sovrappone il movimento verso il fotogramma successivo misurato dal motore Trascina la linea per confrontare · trascina per spostare · la rotellina ingrandisce · doppio clic 1:1 + I file di progetto sono per le sequenze di un archivio su questo PC + Applica di nuovo le impostazioni del file di progetto + Salva un file .titano che, con un doppio clic, apre questa sequenza con queste impostazioni + Ripristina le impostazioni che la sequenza aveva prima di aprire il file · Ctrl+Z Il tuo account può vedere questa sequenza del server ma non modificarla Modificata con i proxy su questo PC; le modifiche si salvano su {0} e analisi e render vengono eseguiti lì Mostrata da {0}; il tuo account può vedere questa sequenza ma non modificarla @@ -593,6 +597,7 @@ Auto: metà dei core logici esegue attività insieme, ognuna con il proprio numero di thread Torna ad Auto: metà dei core logici Installa in Programmi per tutti gli account · chiede l'autorizzazione di amministratore + {0} · è un servizio di Windows, quindi si installa per tutti gli utenti in Programmi Torna alle opzioni senza modificare nulla Scegli la cartella di installazione Chiudi l'installazione senza modificare nulla @@ -605,15 +610,21 @@ Aggiungi collegamenti al desktop Dove vengono installati i programmi · i tuoi dati restano nella loro cartella Inserisci il percorso completo di una cartella che non sia la radice di un'unità o una cartella di sistema + {0} è un servizio di Windows, quindi scegli una cartella dentro Programmi Copia i programmi selezionati e registrali in Windows Cartella dei programmi installati Installa nella tua cartella utente · non servono diritti di amministratore + {0} è un servizio di Windows, quindi si installa solo per tutti gli utenti Lingua di questa installazione Apri il programma al termine dell'installazione Apri il programma installato Già installato qui · disinstallalo prima per cambiare cartella o ambito + È un servizio di Windows, quindi si installa solo per tutti gli utenti · questa copia è installata solo per te; disinstallala prima per aggiungerlo + È un servizio di Windows, quindi si installa solo dentro Programmi · questa copia è installata altrove; disinstallala prima per aggiungerlo Seleziona almeno un programma da installare Elimina anche %LOCALAPPDATA%\Titano: database, backup, cache, impostazioni, log, coda e accesso dell'uploader · le foto negli archivi restano + Elimina anche database, backup, cache, impostazioni e log di Titano in %LOCALAPPDATA%\Titano · i file dell'uploader e le foto negli archivi restano + Elimina anche coda, impostazioni, accesso e log dell'uploader in %LOCALAPPDATA%\Titano · i file di Titano e le foto negli archivi restano Esegui di nuovo lo stesso passaggio Aggiungi i programmi al menu Start Rimuovi programmi, collegamenti e tipi di file · i dati restano salvo diversa scelta diff --git a/src/Titano.App/App.xaml.cs b/src/Titano.App/App.xaml.cs index e9900ac1..52a7fee7 100644 --- a/src/Titano.App/App.xaml.cs +++ b/src/Titano.App/App.xaml.cs @@ -1,6 +1,7 @@ using System.Windows; using System.Windows.Threading; using Titano.App.DesignTime; +using Titano.App.Editor; using Titano.App.Infrastructure; using Titano.App.Shell; using Titano.Core.Diagnostics; @@ -12,11 +13,20 @@ namespace Titano.App; /// /// Titano desktop client. Local mode starts here: settings and language before the first window, then the window, /// then the index and the job engine () off the UI thread. --capture <dir> -/// renders every screen with synthetic data in a throw-away data folder and exits. +/// renders every screen with synthetic data in a throw-away data folder and exits. A file argument is a +/// .titano project file (Explorer passes it on a double-click) opened once the index is open. One Titano runs +/// per data folder: a second launch hands its file to the running one and exits, or, when the running one is closing, +/// waits for it to exit and starts with the file (). /// public partial class App : Application { + /// How long a launch waits for a Titano that is closing (it gives its services up to 10 s to stop). + private static readonly TimeSpan ClosingWait = TimeSpan.FromSeconds(30); + + private readonly TaskCompletionSource _started = new(TaskCreationOptions.RunContinuationsAsynchronously); private FileLogSink? _log; + private SingleInstance? _instance; + private bool _windowClosed; public AppEnvironment Environment { get; private set; } = null!; public AppSettings Settings { get; private set; } = null!; @@ -36,6 +46,32 @@ public partial class App : Application Log.SetSink(capture ? new TeeLogSink(_log, new StderrLogSink()) : _log); Log.Info("app", $"Titano {AppServices.VersionText} starting; data at {Environment.DataDirectory}"); + var projectFile = capture ? null : ProjectFileArgument(e.Args); + if (!capture) + { + _instance = SingleInstance.TryAcquire(Environment.DataDirectory); + if (_instance is null) + { + if (SingleInstance.HandOver(Environment.DataDirectory, projectFile is null ? [] : [projectFile])) + { + Log.Info("app", "Titano already runs on this data folder; arguments handed over"); + Shutdown(); + return; + } + // No answer: the running Titano is closing (it stops listening first). Start once it has exited. + _instance = SingleInstance.WaitForTurn(Environment.DataDirectory, ClosingWait); + if (_instance is null) + { + Log.Info("app", "Titano already runs on this data folder and did not answer"); + Shutdown(); + return; + } + Log.Info("app", "The previous Titano on this data folder has exited"); + } + // From now on: a launch while the window and the index open is kept until the shell can take it. + _instance.Listen(); + } + Settings = capture ? new AppSettings { Language = "en" } : AppSettings.Load(Environment.SettingsPath); UiLanguage.Apply(Settings.Language); ThemeManager.Initialize(this, capture ? AppTheme.Dark : Settings.Theme); @@ -64,12 +100,19 @@ public partial class App : Application _ = ScreenCapture.RunAsync(window, shell, sample!, dir); return; } + // Closing the main window ends Titano: later launches wait for it instead of handing over a file it cannot open. + window.Closed += (_, _) => + { + _windowClosed = true; + _instance?.StopListening(); + }; window.Show(); - _ = StartAsync(shell); + _instance?.Receive(args => Dispatcher.BeginInvoke(() => OnHandOver(shell, args))); + _ = StartAsync(shell, projectFile); } - /// Opens the index and the job engine after the window is visible, then fills the screens. - private async Task StartAsync(ShellViewModel shell) + /// Opens the index and the job engine after the window is visible, fills the screens, then opens the project file given. + private async Task StartAsync(ShellViewModel shell, string? projectFile) { try { @@ -80,10 +123,63 @@ public partial class App : Application { shell.ReportError(ex); } + finally + { + _started.TrySetResult(); + } + if (projectFile is not null) await OpenProjectFileAsync(shell, projectFile); + } + + /// A later launch: its window comes to the front here, and its project file opens. + private void OnHandOver(ShellViewModel shell, IReadOnlyList args) + { + if (_windowClosed) + { + Log.Warning("app", "A launch arrived while Titano was closing; its arguments are ignored"); + return; + } + if (MainWindow is { } window) + { + window.Show(); + if (window.WindowState == WindowState.Minimized) window.WindowState = WindowState.Normal; + window.Activate(); + } + if (ProjectFileArgument(args) is { } projectFile) _ = OpenProjectFileAsync(shell, projectFile); + } + + /// Opens a project file once the index is open; failures become the usual one-sentence toast. + private async Task OpenProjectFileAsync(ShellViewModel shell, string path) + { + await _started.Task; + try + { + await new ProjectFiles(shell).OpenAsync(path); + } + catch (Exception ex) + { + shell.ReportError(ex); + } + } + + /// The first argument that is not an option, as a full path (the hand-over crosses working folders). + private static string? ProjectFileArgument(IReadOnlyList args) + { + if (args.FirstOrDefault(a => !a.StartsWith("--", StringComparison.Ordinal) && a.Length > 0) is not { } file) return null; + try + { + return System.IO.Path.GetFullPath(file); + } + catch (Exception ex) when (ex is ArgumentException or NotSupportedException or System.IO.PathTooLongException) + { + Log.Warning("app", $"Ignoring argument '{file}'", ex); + return null; + } } public void SaveSettings() { + // A launch that handed over to the running Titano exits before loading any settings. + if (Settings is null) return; try { Settings.Save(Environment.SettingsPath); @@ -96,6 +192,8 @@ public partial class App : Application protected override void OnExit(ExitEventArgs e) { + // The mutex stays until the services have stopped, so a launch now waits for this one to exit. + _instance?.StopListening(); SaveSettings(); if (MainWindow?.DataContext is ShellViewModel shell) shell.Dispose(); try @@ -108,6 +206,7 @@ public partial class App : Application { Log.Warning("app", "Services stopped with an error", ex); } + _instance?.Dispose(); Log.Info("app", "Titano exiting"); _log?.Dispose(); if (Environment.IsCapture) Environment.DeleteCaptureData(); diff --git a/src/Titano.App/Editor/EditorPanels.xaml b/src/Titano.App/Editor/EditorPanels.xaml index f29069e1..bf1d3b5f 100644 --- a/src/Titano.App/Editor/EditorPanels.xaml +++ b/src/Titano.App/Editor/EditorPanels.xaml @@ -293,6 +293,9 @@ + +