feat(app): library, jobs, settings, server, welcome and about screens

Local-mode composition root (SQLite index, one JobEngine fed by a single
handler registration list), keyset-paged library with thumbnail cache and
hover scrub, live job list with throttled updates and the shell job bar,
settings with live template validation and encoder self-test, server
connection with trust-on-first-use and DPAPI token, first-run welcome,
About with update check, and --capture screenshots with synthetic data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 12:26:58 +00:00
1 parent 446daeae2b
commit ffbea7cb74
94 files changed
+10130 -374

No files matched your search

+47 -20
View File
@@ -1,37 +1,45 @@
using System.Globalization;
using System.Windows;
using System.Windows.Threading;
using Titano.App.DesignTime;
using Titano.App.Infrastructure;
using Titano.App.Shell;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Ui.Mvvm;
using Titano.Ui.Theming;
namespace Titano.App;
/// <summary>
/// Titano desktop client. Local mode starts here: settings and language before the first window, then the window,
/// then the index and the job engine (<see cref="AppServices"/>) off the UI thread. <c>--capture &lt;dir&gt;</c>
/// renders every screen with synthetic data in a throw-away data folder and exits.
/// </summary>
public partial class App : Application
{
private FileLogSink? _log;
public AppEnvironment Environment { get; private set; } = null!;
public AppSettings Settings { get; private set; } = null!;
public AppServices Services { get; private set; } = null!;
public static new App Current => (App)Application.Current;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Environment = AppEnvironment.Detect();
var captureIndex = Array.IndexOf(e.Args, "--capture");
var capture = captureIndex >= 0;
// Capture never reads or writes the user's data folder.
Environment = capture ? AppEnvironment.ForCapture() : AppEnvironment.Detect();
_log = new FileLogSink(Environment.LogDirectory, "titano");
var capture = Array.IndexOf(e.Args, "--capture") >= 0;
// Capture runs in CI: mirror the log to stderr so failures are visible in the job output.
Log.SetSink(capture ? new TeeLogSink(_log, new StderrLogSink()) : _log);
Log.Info("app", $"Titano {typeof(App).Assembly.GetName().Version} starting; data at {Environment.DataDirectory}");
Log.Info("app", $"Titano {AppServices.VersionText} starting; data at {Environment.DataDirectory}");
Settings = AppSettings.Load(Environment.SettingsPath);
ApplyLanguage(Settings.Language);
ThemeManager.Initialize(this, Settings.Theme);
Settings = capture ? new AppSettings { Language = "en" } : AppSettings.Load(Environment.SettingsPath);
UiLanguage.Apply(Settings.Language);
ThemeManager.Initialize(this, capture ? AppTheme.Dark : Settings.Theme);
AppResources.Merge(this);
DispatcherUnhandledException += OnUnhandledException;
AppDomain.CurrentDomain.UnhandledException += (_, args) => Log.Error("app", "Unhandled exception", args.ExceptionObject as Exception);
@@ -41,30 +49,37 @@ public partial class App : Application
args.SetObserved();
};
var shell = new ShellViewModel(Settings);
var dialogs = new AppDialogs();
Services = new AppServices(Environment, Settings, SaveSettings, dialogs);
SampleData? sample = capture ? SampleData.Configure(Services) : null;
var shell = new ShellViewModel(Services);
AsyncRelayCommand.Failed += ex => shell.ReportError(ex);
var window = new MainWindow(shell);
dialogs.Owner = window;
MainWindow = window;
var captureIndex = Array.IndexOf(e.Args, "--capture");
if (capture)
{
var dir = captureIndex + 1 < e.Args.Length ? e.Args[captureIndex + 1] : "screenshots";
ScreenCapture.Run(window, shell, dir);
_ = ScreenCapture.RunAsync(window, shell, sample!, dir);
return;
}
window.Show();
_ = StartAsync(shell);
}
/// <summary>Switches the UI language at run time (BRIEF §16) and remembers the choice.</summary>
public void ApplyLanguage(string? code)
/// <summary>Opens the index and the job engine after the window is visible, then fills the screens.</summary>
private async Task StartAsync(ShellViewModel shell)
{
var culture = Languages.BestMatch(code is null ? CultureInfo.CurrentUICulture : CultureInfo.GetCultureInfo(code));
CultureInfo.DefaultThreadCurrentUICulture = culture;
CultureInfo.CurrentUICulture = culture;
Loc.SetCulture(culture);
foreach (Window w in Windows)
w.FlowDirection = Loc.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
try
{
await Services.OpenAsync(Environment.DatabasePath);
await shell.StartAsync();
}
catch (Exception ex)
{
shell.ReportError(ex);
}
}
public void SaveSettings()
@@ -73,7 +88,7 @@ public partial class App : Application
{
Settings.Save(Environment.SettingsPath);
}
catch (System.IO.IOException ex)
catch (Exception ex) when (ex is System.IO.IOException or UnauthorizedAccessException)
{
Log.Warning("app", "Settings not saved", ex);
}
@@ -82,8 +97,20 @@ public partial class App : Application
protected override void OnExit(ExitEventArgs e)
{
SaveSettings();
if (MainWindow?.DataContext is ShellViewModel shell) shell.Dispose();
try
{
// Data and engine code continue on the thread pool, so waiting here cannot deadlock the dispatcher.
if (Services is not null && !Services.DisposeAsync().AsTask().Wait(TimeSpan.FromSeconds(10)))
Log.Warning("app", "Services did not stop within 10 s");
}
catch (AggregateException ex)
{
Log.Warning("app", "Services stopped with an error", ex);
}
Log.Info("app", "Titano exiting");
_log?.Dispose();
if (Environment.IsCapture) Environment.DeleteCaptureData();
base.OnExit(e);
}