From e4bbf11da947b731627b55eb44cd69a538fc6bcf Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Oct 2026 09:29:58 +0000 Subject: [PATCH 1/5] fix(app): exit without waiting for the UI thread, close the editor with the shell, cancel sign-in safely DESK-1: SyncHost's dispose, session switch and stop now continue on the thread pool (ConfigureAwait(false)) and keep the running agent in one reference. A signed-in user whose archive is not polled no longer waits 10 s at every exit, after which the job engine and the index were never closed. DESK-7: ShellViewModel.Dispose disposes the Sequence section first, so the open editor stops its runners and closes its source before the engine and the index go. DESK-8: Cancel stays available while the server answers a sign-in. It now cancels the request; an answer that still arrives changes nothing (the connection flow ignores answers for a client it dropped), and a sign-in that completed just before the cancel was handled is signed out again. The form no longer sets a result after it closed, and an unexpected failure shows inline instead of escaping async void. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- src/Titano.App/Server/ConnectFlow.cs | 13 +- src/Titano.App/Server/ServerSession.cs | 12 +- src/Titano.App/Server/SyncHost.cs | 39 +++-- src/Titano.App/Shell/LoginDialog.xaml.cs | 46 ++++-- src/Titano.App/Shell/ShellViewModel.cs | 2 + .../Server/ServerSessionSignInTests.cs | 154 ++++++++++++++++++ .../Titano.App.Tests/Server/SyncHostTests.cs | 61 +++++++ .../Windows/ShellLifetimeTests.cs | 53 ++++++ 8 files changed, 345 insertions(+), 35 deletions(-) create mode 100644 tests/Titano.App.Tests/Server/ServerSessionSignInTests.cs create mode 100644 tests/Titano.App.Tests/Server/SyncHostTests.cs create mode 100644 tests/Titano.App.Tests/Windows/ShellLifetimeTests.cs diff --git a/src/Titano.App/Server/ConnectFlow.cs b/src/Titano.App/Server/ConnectFlow.cs index d024edfa..2dcfb9fb 100644 --- a/src/Titano.App/Server/ConnectFlow.cs +++ b/src/Titano.App/Server/ConnectFlow.cs @@ -131,23 +131,28 @@ public sealed class ConnectFlow(IServerApiFactory factory, ITrustStore trust) : return await IdentifyAsync(ct); } - /// Sends the credentials; only possible once the server is identified and trusted. + /// + /// Sends the credentials; only possible once the server is identified and trusted. An answer that arrives after the + /// flow moved on (disconnected, or connecting elsewhere) changes nothing. + /// public async Task SignInAsync(string username, string password, CancellationToken ct = default) { - if (Step is not (ConnectStep.AwaitingCredentials or ConnectStep.SigningIn) || _api is null) return Step; + if (Step is not (ConnectStep.AwaitingCredentials or ConnectStep.SigningIn) || _api is not { } api) return Step; if (string.IsNullOrWhiteSpace(username)) return Retry(ConnectError.BadCredentials); Set(ConnectStep.SigningIn, ConnectError.None); try { - var login = await _api.LoginAsync(username.Trim(), password, ct); + var login = await api.LoginAsync(username.Trim(), password, ct); + if (!ReferenceEquals(api, _api)) return Step; if (login.Token is null) return Retry(ConnectError.BadCredentials); // TitanoClient keeps the token itself; set it explicitly so every IServerApi behaves the same. - _api.Token = login.Token; + api.Token = login.Token; User = login.User; return Set(ConnectStep.Connected, ConnectError.None); } catch (Exception ex) when (Classify(ex, ct) is { } error) { + if (!ReferenceEquals(api, _api)) return Step; return error is ConnectError.BadCredentials ? Retry(error) : Fail(error); } } diff --git a/src/Titano.App/Server/ServerSession.cs b/src/Titano.App/Server/ServerSession.cs index 9f944024..7f588642 100644 --- a/src/Titano.App/Server/ServerSession.cs +++ b/src/Titano.App/Server/ServerSession.cs @@ -144,17 +144,23 @@ public sealed class ServerSession : ObservableObject, ITrustStore, IDisposable if (step != ConnectStep.AwaitingCredentials) return false; } + // The form may be cancelled while the server is still answering: that answer must not sign this PC in. + using var attempt = CancellationTokenSource.CreateLinkedTokenSource(ct); var signedIn = dialogs.SignIn(display, _settings.ServerUsername, async (user, password) => { - var result = await _flow.SignInAsync(user, password, ct); - return result == ConnectStep.Connected ? null : ErrorText(_flow.Error); + var result = await _flow.SignInAsync(user, password, attempt.Token); + // An answer the flow dropped (the form was cancelled meanwhile) carries no error of its own. + return result == ConnectStep.Connected ? null : ErrorText(_flow.Error is ConnectError.None ? ConnectError.Failed : _flow.Error); }); if (signedIn && IsConnected) { Remember(); return true; } - if (!IsConnected && _flow.Step == ConnectStep.AwaitingCredentials) _flow.Disconnect(); + await attempt.CancelAsync(); + // Signed in just before the cancel was handled: the session the user turned down ends on the server too. + if (IsConnected) await _flow.SignOutAsync(); + else if (_flow.Step is ConnectStep.AwaitingCredentials or ConnectStep.SigningIn) _flow.Disconnect(); return false; } finally diff --git a/src/Titano.App/Server/SyncHost.cs b/src/Titano.App/Server/SyncHost.cs index 13a0fbb5..abfaedcb 100644 --- a/src/Titano.App/Server/SyncHost.cs +++ b/src/Titano.App/Server/SyncHost.cs @@ -29,7 +29,7 @@ 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 Running? _running; private JobEngine? _renders; /// Connections over ; screenshots substitute a fake server. @@ -44,10 +44,10 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo public SyncService? Service { get; private set; } /// The background comparison of the signed-in server; null while signed out. - public SyncAgent? Agent => _running?.Agent; + public SyncAgent? Agent => Volatile.Read(ref _running)?.Agent; /// The agent's connection, for the table's own calls (conflict resolution); null while signed out. - public ISyncRemote? Remote => _running?.Remote; + public ISyncRemote? Remote => Volatile.Read(ref _running)?.Remote; /// Key of the signed-in server (); null while signed out. public string? Server => Volatile.Read(ref _credentials) is { } c ? SyncService.ServerKey(c.Address) : null; @@ -103,8 +103,8 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo /// Compares now, once the session switch in progress settled; null while signed out. public async Task RefreshAsync(CancellationToken ct = default) { - await _switch; - return Agent is { } agent ? await agent.RefreshAsync(ct) : null; + await _switch.ConfigureAwait(false); + return Agent is { } agent ? await agent.RefreshAsync(ct).ConfigureAwait(false) : null; } /// Compares again soon (an option changed, an edit on this PC). @@ -135,13 +135,17 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo return RemoteFactory(c.Address, c.Token, c.Fingerprints); } + /// + /// Stops the agent once the session switch in progress settled. The app's exit waits for this on the UI thread, so + /// nothing here, in the switch or in the stop continues on it. + /// public async ValueTask DisposeAsync() { Volatile.Write(ref _credentials, null); Uploads.Dispose(); if (_renders is not null) _renders.JobChanged -= OnJobChanged; - await _switch; - await StopAsync(); + await _switch.ConfigureAwait(false); + await StopAsync().ConfigureAwait(false); } private bool Allows(Permissions permission) => services.Server.User is { } user && (user.Permissions & (long)permission) != 0; @@ -183,11 +187,16 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo } } + /// + /// Switches are chained (each waits for the previous one) and continue on the thread pool: a switch still stopping + /// the old agent when the app exits must not need the UI thread its exit blocks. + /// private async Task SwitchAsync(Task previous, Credentials? wanted) { - await previous; - if (_running is { } running && wanted is { } same && running.Credentials.Address == same.Address && running.Credentials.Token == same.Token) return; - await StopAsync(); + await previous.ConfigureAwait(false); + if (Volatile.Read(ref _running) is { } running && wanted is { } same && running.Credentials.Address == same.Address && running.Credentials.Token == same.Token) + return; + await StopAsync().ConfigureAwait(false); if (wanted is not { } start || Service is not { } service) { Changed?.Invoke(); @@ -197,19 +206,21 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo var agent = new SyncAgent(service, remote, () => Policy, services.Engine); agent.Changed += () => Changed?.Invoke(); agent.Start(); - _running = (agent, remote, start); + Volatile.Write(ref _running, new Running(agent, remote, start)); Log.Info("sync", $"Comparing with {remote.Server}"); Changed?.Invoke(); } private async Task StopAsync() { - if (_running is not { } running) return; - _running = null; - await running.Agent.DisposeAsync(); + if (Interlocked.Exchange(ref _running, null) is not { } running) return; + await running.Agent.DisposeAsync().ConfigureAwait(false); running.Remote.Dispose(); Changed?.Invoke(); } private sealed record Credentials(Uri Address, string Token, IReadOnlyCollection Fingerprints); + + /// The agent of the signed-in session: one reference, so the UI thread never reads half of a switch. + private sealed record Running(SyncAgent Agent, ISyncRemote Remote, Credentials Credentials); } diff --git a/src/Titano.App/Shell/LoginDialog.xaml.cs b/src/Titano.App/Shell/LoginDialog.xaml.cs index b0adb296..6e374890 100644 --- a/src/Titano.App/Shell/LoginDialog.xaml.cs +++ b/src/Titano.App/Shell/LoginDialog.xaml.cs @@ -1,6 +1,7 @@ using System.Windows; using System.Windows.Automation; using System.Windows.Automation.Peers; +using Titano.Core.Diagnostics; using Titano.Ui.Controls; namespace Titano.App.Shell; @@ -9,16 +10,20 @@ namespace Titano.App.Shell; /// The login form (BRIEF §12.7). It calls back the connection with the credentials and stays open with the /// error sentence until the sign-in succeeds or the user cancels. The password never leaves the PasswordBox /// except for that call. A failed sign-in is announced to screen readers and marks the password box (error border, -/// sentence as its help text) until the next attempt. +/// sentence as its help text) until the next attempt. Cancel stays available while the server answers: the form +/// closes at once and the connection drops the answer. /// public sealed partial class LoginDialog : TitanoWindow { private readonly Func> _signIn; + private bool _pending; + private bool _closed; private LoginDialog(string server, string? username, Func> signIn) { _signIn = signIn; InitializeComponent(); + Closed += (_, _) => _closed = true; ServerText.Text = server; User.Text = username ?? string.Empty; Loaded += (_, _) => @@ -41,28 +46,41 @@ public sealed partial class LoginDialog : TitanoWindow private async void OnSignIn(object sender, RoutedEventArgs e) { + if (_pending) return; + _pending = true; SignIn.IsEnabled = false; Error.Visibility = Visibility.Collapsed; Field.SetError(Password, null); + string? error; try { - var error = await _signIn(User.Text, Password.Password); - if (error is null) - { - DialogResult = true; - return; - } - Error.Text = error; - Error.Visibility = Visibility.Visible; - Field.SetError(Password, error); - Password.Clear(); - Password.Focus(); - UIElementAutomationPeer.CreatePeerForElement(this)?.RaiseNotificationEvent( - AutomationNotificationKind.ActionCompleted, AutomationNotificationProcessing.ImportantMostRecent, error, "Titano.SignIn"); + error = await _signIn(User.Text, Password.Password); + } + catch (Exception ex) when (ex is not OutOfMemoryException) + { + // Cancel ended the request: nobody waits for this answer any more. + if (_closed && ex is OperationCanceledException) return; + Log.Warning("server", "Sign-in failed", ex); + error = ErrorText.For(ex); } finally { + _pending = false; SignIn.IsEnabled = true; } + // The form was cancelled or closed while the server answered: a result can no longer be set on it. + if (_closed) return; + if (error is null) + { + DialogResult = true; + return; + } + Error.Text = error; + Error.Visibility = Visibility.Visible; + Field.SetError(Password, error); + Password.Clear(); + Password.Focus(); + UIElementAutomationPeer.CreatePeerForElement(this)?.RaiseNotificationEvent( + AutomationNotificationKind.ActionCompleted, AutomationNotificationProcessing.ImportantMostRecent, error, "Titano.SignIn"); } } diff --git a/src/Titano.App/Shell/ShellViewModel.cs b/src/Titano.App/Shell/ShellViewModel.cs index 9e9df006..5ea0e3fd 100644 --- a/src/Titano.App/Shell/ShellViewModel.cs +++ b/src/Titano.App/Shell/ShellViewModel.cs @@ -292,6 +292,8 @@ public sealed class ShellViewModel : LocalizedViewModel public override void Dispose() { + // The editor first: it stops its runners and closes its source before the engine and the index under it go. + Sequence.Dispose(); Jobs.Dispose(); Library.Dispose(); Import.Dispose(); diff --git a/tests/Titano.App.Tests/Server/ServerSessionSignInTests.cs b/tests/Titano.App.Tests/Server/ServerSessionSignInTests.cs new file mode 100644 index 00000000..ad3c4fe1 --- /dev/null +++ b/tests/Titano.App.Tests/Server/ServerSessionSignInTests.cs @@ -0,0 +1,154 @@ +using System.Net; +using Titano.App.Infrastructure; +using Titano.App.Server; +using Titano.Protocol; +using Titano.Protocol.Client; +using Titano.Testing; + +namespace Titano.App.Tests.Server; + +/// The login form cancelled while the server is still answering (DESK-8): nothing signs this PC in afterwards. +public sealed class ServerSessionSignInTests +{ + [Test] + public async Task CancelEndsTheSignInStillWaitingForTheServer() + { + var server = new GatedServer { HonoursCancellation = true }; + var settings = new AppSettings(); + using var session = new ServerSession(settings, () => { }, server, new PlainProtector()); + Task? pending = null; + var dialogs = new Dialogs((_, _, signIn) => + { + pending = signIn("alberto", "secret"); + return false; + }); + + Assert.False(await session.ConnectAsync("nas.local:8443", dialogs)); + // The request the form left behind was cancelled, and the session dropped the connection it belonged to. + await Assert.ThrowsAsync(() => pending!); + Assert.False(session.IsConnected); + Assert.Equal(ConnectStep.Idle, session.Flow.Step); + Assert.Null(settings.ProtectedToken); + } + + [Test] + public async Task AnAnswerArrivingAfterCancelSignsNothingIn() + { + var server = new GatedServer { HonoursCancellation = false }; + var settings = new AppSettings(); + using var session = new ServerSession(settings, () => { }, server, new PlainProtector()); + Task? pending = null; + var dialogs = new Dialogs((_, _, signIn) => + { + pending = signIn("alberto", "secret"); + return false; + }); + + Assert.False(await session.ConnectAsync("nas.local:8443", dialogs)); + // The server accepts the password only now: the answer belongs to a connection that is gone. + server.Answer(); + Assert.NotNull(await pending!); + Assert.False(session.IsConnected); + Assert.Equal(ConnectStep.Idle, session.Flow.Step); + Assert.Null(session.Flow.Token); + Assert.Null(settings.ProtectedToken); + Assert.Null(settings.ServerUrl); + } + + [Test] + public async Task SignedInJustBeforeTheCancelSignsOutAgain() + { + var server = new GatedServer { HonoursCancellation = false }; + server.Answer(); + var settings = new AppSettings(); + using var session = new ServerSession(settings, () => { }, server, new PlainProtector()); + var dialogs = new Dialogs((_, _, signIn) => + { + // The server's answer was handled first, then the click on Cancel closed the form. + Assert.Null(signIn("alberto", "secret").GetAwaiter().GetResult()); + return false; + }); + + Assert.False(await session.ConnectAsync("nas.local:8443", dialogs)); + Assert.False(session.IsConnected); + Assert.Equal(1, server.Logouts); + Assert.Null(settings.ProtectedToken); + } + + [Test] + public async Task ASignInTheFormConfirmsIsRemembered() + { + var server = new GatedServer { HonoursCancellation = true }; + server.Answer(); + var settings = new AppSettings(); + using var session = new ServerSession(settings, () => { }, server, new PlainProtector()); + var dialogs = new Dialogs((_, _, signIn) => signIn("alberto", "secret").GetAwaiter().GetResult() is null); + + Assert.True(await session.ConnectAsync("nas.local:8443", dialogs)); + Assert.True(session.IsConnected); + Assert.Equal("token-1", settings.ProtectedToken); + Assert.Equal(0, server.Logouts); + } + + private sealed class Dialogs(Func>, bool> signIn) : IAppDialogs + { + public string? PickFolder(string title, string? initialFolder = null) => null; + public string? PickJsonFile(string title) => null; + public bool Confirm(ConfirmRequest request) => true; + public bool SignIn(string server, string? username, Func> callback) => signIn(server, username, callback); + } + + private sealed class PlainProtector : ITokenProtector + { + public string Protect(string token) => token; + public string? Unprotect(string protectedToken) => protectedToken; + } + + /// A server whose login answers only when the test says so. + private sealed class GatedServer : IServerApiFactory + { + private readonly TaskCompletionSource _answer = new(); + + /// The request ends when its token is cancelled (as over HTTP); otherwise the answer is already on its way. + public bool HonoursCancellation { get; init; } + + public int Logins { get; private set; } + public int Logouts { get; private set; } + + public void Answer() => _answer.TrySetResult(); + + public IServerApi Create(Uri baseAddress, IReadOnlyCollection trustedFingerprints) => new Client(this, baseAddress); + + private sealed class Client(GatedServer server, Uri baseAddress) : IServerApi + { + public Uri BaseAddress { get; } = baseAddress; + public string? Token { get; set; } + + public Task GetInfoAsync(CancellationToken ct) => + Task.FromResult(new ServerInfo("Studio NAS", "1.3.0", 1, [], null, [], new ServerLimits(0, 0))); + + public async Task LoginAsync(string username, string password, CancellationToken ct) + { + server.Logins++; + await (server.HonoursCancellation ? server._answer.Task.WaitAsync(ct) : server._answer.Task); + if (password != "secret") throw new TitanoApiException(HttpStatusCode.Unauthorized, new ApiError("bad_credentials", "Wrong")); + return new LoginResponse("token-" + server.Logins, User(username), false, DateTimeOffset.UtcNow.AddDays(1)); + } + + public Task MeAsync(CancellationToken ct) => Task.FromResult(User("alberto")); + + public Task LogoutAsync(CancellationToken ct) + { + server.Logouts++; + return Task.CompletedTask; + } + + public void Dispose() + { + } + + private static UserDto User(string name) => + new(Guid.Empty, name, null, "editor", 0, 5_000_000_000_000, 0, false, false, DateTimeOffset.UtcNow, null); + } + } +} diff --git a/tests/Titano.App.Tests/Server/SyncHostTests.cs b/tests/Titano.App.Tests/Server/SyncHostTests.cs new file mode 100644 index 00000000..bcaca983 --- /dev/null +++ b/tests/Titano.App.Tests/Server/SyncHostTests.cs @@ -0,0 +1,61 @@ +using System.Diagnostics; +using Titano.App.DesignTime; +using Titano.App.Infrastructure; +using Titano.App.Tests.Uploader; +using Titano.Testing; + +namespace Titano.App.Tests.Server; + +public sealed class SyncHostTests +{ + /// Dialogs that answer like a user who cancels everything. + private sealed class NoDialogs : IAppDialogs + { + public string? PickFolder(string title, string? initialFolder = null) => null; + public string? PickJsonFile(string title) => null; + public bool Confirm(ConfirmRequest request) => false; + public bool SignIn(string server, string? username, Func> signIn) => false; + } + + /// + /// DESK-1: a signed-in user whose archive is not polled (no archive, or offline at start) exits. Nothing before the + /// sync agent's stop leaves the UI thread, and the agent stops asynchronously: its continuation must not need the UI + /// thread that App.OnExit blocks, or the exit waits 10 s and never closes the engine and the index. + /// + [Test] + [WindowsOnly] + public void ExitWithASignedInSessionAndNoPollingDoesNotWaitForTheUiThread() + { + var environment = AppEnvironment.ForCapture(); + try + { + SingleThreadedContext.Run(async () => + { + var services = new AppServices(environment, new AppSettings { Language = "en" }, () => { }, new NoDialogs()); + var sample = SampleData.Configure(services); + // An index without the archive poller (OpenAsync never ran) and a saved session, as for a server-only user. + await sample.OpenEmptyAsync(); + await sample.FillAsync(); + services.Settings.RenderNodeOptIn = false; + await services.Server.RestoreAsync(); + Assert.True(services.Server.IsConnected, "session restored"); + var until = DateTime.UtcNow + TimeSpan.FromSeconds(10); + while (services.Sync.Agent is null) + { + Assert.True(DateTime.UtcNow < until, "sync agent not started"); + await Task.Delay(20); + } + + // App.OnExit blocks the UI thread until the services stop. + var clock = Stopwatch.StartNew(); + Assert.True(services.DisposeAsync().AsTask().Wait(TimeSpan.FromSeconds(10)), "services stopped"); + Assert.Less(clock.Elapsed.TotalSeconds, 5, "the exit waited for the UI thread"); + Assert.Null(services.Sync.Agent); + }); + } + finally + { + environment.DeleteCaptureData(); + } + } +} diff --git a/tests/Titano.App.Tests/Windows/ShellLifetimeTests.cs b/tests/Titano.App.Tests/Windows/ShellLifetimeTests.cs new file mode 100644 index 00000000..925b1b81 --- /dev/null +++ b/tests/Titano.App.Tests/Windows/ShellLifetimeTests.cs @@ -0,0 +1,53 @@ +using Titano.App.DesignTime; +using Titano.App.Infrastructure; +using Titano.App.Shell; +using Titano.Testing; +using Titano.Ui.Theming; + +namespace Titano.App.Tests.Windows; + +/// What the shell stops when the app exits (App.OnExit disposes it before the services). +[WindowsOnly] +[Serial] +[Timeout(120_000)] +public sealed class ShellLifetimeTests +{ + private sealed class NoDialogs : IAppDialogs + { + public string? PickFolder(string title, string? initialFolder = null) => null; + public string? PickJsonFile(string title) => null; + public bool Confirm(ConfirmRequest request) => false; + public bool SignIn(string server, string? username, Func> signIn) => false; + } + + /// DESK-7: the open editor goes with the shell, before the engine and the index under it. + [Test] + public Task DisposingTheShellClosesTheOpenEditor() => ScreenHost.RunAsync(async () => + { + var environment = AppEnvironment.ForCapture(); + UiLanguage.Apply("en"); + ThemeManager.Apply(AppTheme.Dark); + var services = new AppServices(environment, new AppSettings { Language = "en", FirstRunCompleted = true }, () => { }, new NoDialogs()); + try + { + var sample = SampleData.Configure(services); + var shell = new ShellViewModel(services); + await sample.OpenEmptyAsync(); + await shell.StartAsync(); + var id = await sample.FillEditorAsync(); + shell.OpenSequence(id); + await shell.Sequence.OpenAsync(id); + var editor = Assert.NotNull(shell.Sequence.Editor); + editor.PlayCommand.Execute(null); + Assert.True(editor.IsPlaying, "the editor plays"); + + shell.Dispose(); + Assert.False(editor.IsPlaying, "the editor's player stopped with the shell"); + } + finally + { + await services.DisposeAsync(); + environment.DeleteCaptureData(); + } + }); +} From ec297914db9ff55e57cc01d9117fca435cb1f806 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Oct 2026 09:30:42 +0000 Subject: [PATCH 2/5] fix(app): offer the usage counts consent only in builds with TitanoAdsEnabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RF-3: the anonymous usage counts checkbox (Welcome and Settings › General) promised a daily ping that does not exist; BRIEF §21 puts that consent inside monetization, which ships disabled until the human flips TitanoAdsEnabled=true. Directory.Build.props now defines the property (default false) and stamps it into every assembly as metadata; ProductFeatures.AdsEnabled reads it, and both checkboxes and the Settings search keyword follow it. The unused Shell.Welcome.Consent sentence is removed from every culture. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- Directory.Build.props | 8 ++++++++ i18n/ar/Shell.ar.resx | 1 - i18n/bg/Shell.bg.resx | 1 - i18n/cs/Shell.cs.resx | 1 - i18n/da/Shell.da.resx | 1 - i18n/de/Shell.de.resx | 1 - i18n/el/Shell.el.resx | 1 - i18n/en/Shell.resx | 1 - i18n/es/Shell.es.resx | 1 - i18n/et/Shell.et.resx | 1 - i18n/fi/Shell.fi.resx | 1 - i18n/fr/Shell.fr.resx | 1 - i18n/he/Shell.he.resx | 1 - i18n/hi/Shell.hi.resx | 1 - i18n/hr/Shell.hr.resx | 1 - i18n/hu/Shell.hu.resx | 1 - i18n/id/Shell.id.resx | 1 - i18n/it/Shell.it.resx | 1 - i18n/ja/Shell.ja.resx | 1 - i18n/ko/Shell.ko.resx | 1 - i18n/lt/Shell.lt.resx | 1 - i18n/lv/Shell.lv.resx | 1 - i18n/ms/Shell.ms.resx | 1 - i18n/nb/Shell.nb.resx | 1 - i18n/nl/Shell.nl.resx | 1 - i18n/pl/Shell.pl.resx | 1 - i18n/pt-BR/Shell.pt-BR.resx | 1 - i18n/pt-PT/Shell.pt-PT.resx | 1 - i18n/ro/Shell.ro.resx | 1 - i18n/ru/Shell.ru.resx | 1 - i18n/sk/Shell.sk.resx | 1 - i18n/sl/Shell.sl.resx | 1 - i18n/sv/Shell.sv.resx | 1 - i18n/th/Shell.th.resx | 1 - i18n/tr/Shell.tr.resx | 1 - i18n/uk/Shell.uk.resx | 1 - i18n/vi/Shell.vi.resx | 1 - i18n/zh-Hans/Shell.zh-Hans.resx | 1 - i18n/zh-Hant/Shell.zh-Hant.resx | 1 - src/Titano.App/Infrastructure/AppSettings.cs | 3 +++ .../Infrastructure/ProductFeatures.cs | 17 +++++++++++++++++ src/Titano.App/Sections/SettingsView.xaml | 4 +++- src/Titano.App/Sections/SettingsViewModel.cs | 5 ++++- src/Titano.App/Sections/WelcomeView.xaml | 6 ++++-- src/Titano.App/Sections/WelcomeViewModel.cs | 3 +++ 45 files changed, 42 insertions(+), 42 deletions(-) create mode 100644 src/Titano.App/Infrastructure/ProductFeatures.cs diff --git a/Directory.Build.props b/Directory.Build.props index cda20b1f..c0c906ca 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -43,6 +43,14 @@ + + + false + + + + + true diff --git a/i18n/ar/Shell.ar.resx b/i18n/ar/Shell.ar.resx index 528d0290..856a83b5 100644 --- a/i18n/ar/Shell.ar.resx +++ b/i18n/ar/Shell.ar.resx @@ -39,7 +39,6 @@ ضم مجلد موجود تغيير… اختيار… - ساعد في تحسين Titano بإحصاءات استخدام مجهولة متابعة مُكتشَف إنشاء أرشيف محلي diff --git a/i18n/bg/Shell.bg.resx b/i18n/bg/Shell.bg.resx index 5f26d1ef..9930dae6 100644 --- a/i18n/bg/Shell.bg.resx +++ b/i18n/bg/Shell.bg.resx @@ -31,7 +31,6 @@ Присъединяване на съществуваща папка Промяна… Избор… - Помогнете за подобряването на Titano с анонимна статистика за използването Продължаване Открит Създаване на локален архив diff --git a/i18n/cs/Shell.cs.resx b/i18n/cs/Shell.cs.resx index 2c4b79bc..f03fbdcc 100644 --- a/i18n/cs/Shell.cs.resx +++ b/i18n/cs/Shell.cs.resx @@ -35,7 +35,6 @@ Převzít existující složku Změnit… Vybrat… - Pomozte vylepšit Titano anonymními statistikami používání Pokračovat Nalezeno Vytvořit místní archiv diff --git a/i18n/da/Shell.da.resx b/i18n/da/Shell.da.resx index cfdc32ee..bd1958d4 100644 --- a/i18n/da/Shell.da.resx +++ b/i18n/da/Shell.da.resx @@ -31,7 +31,6 @@ Overtag en eksisterende mappe Skift… Vælg… - Hjælp med at forbedre Titano med anonym brugsstatistik Fortsæt Fundet Opret et lokalt arkiv diff --git a/i18n/de/Shell.de.resx b/i18n/de/Shell.de.resx index 142cbae4..82de2333 100644 --- a/i18n/de/Shell.de.resx +++ b/i18n/de/Shell.de.resx @@ -31,7 +31,6 @@ Vorhandenen Ordner einbinden Ändern… Auswählen… - Helfen Sie, Titano mit anonymer Nutzungsstatistik zu verbessern Weiter Gefunden Lokales Archiv erstellen diff --git a/i18n/el/Shell.el.resx b/i18n/el/Shell.el.resx index 2e3c714a..065ad238 100644 --- a/i18n/el/Shell.el.resx +++ b/i18n/el/Shell.el.resx @@ -31,7 +31,6 @@ Ενσωμάτωση υπάρχοντος φακέλου Αλλαγή… Επιλογή… - Βοηθήστε στη βελτίωση του Titano με ανώνυμα στατιστικά χρήσης Συνέχεια Βρέθηκε Δημιουργία τοπικής αρχειοθήκης diff --git a/i18n/en/Shell.resx b/i18n/en/Shell.resx index 47ad54db..0adc9e09 100644 --- a/i18n/en/Shell.resx +++ b/i18n/en/Shell.resx @@ -32,7 +32,6 @@ Adopt an existing folder Change… Choose… - Help improve Titano with anonymous usage countslong Continue Found Create a local archive diff --git a/i18n/es/Shell.es.resx b/i18n/es/Shell.es.resx index f6e87daa..9e4d85e9 100644 --- a/i18n/es/Shell.es.resx +++ b/i18n/es/Shell.es.resx @@ -31,7 +31,6 @@ Incorporar una carpeta existente Cambiar… Elegir… - Ayuda a mejorar Titano con recuentos de uso anónimos Continuar Encontrado Crear una fototeca local diff --git a/i18n/et/Shell.et.resx b/i18n/et/Shell.et.resx index a806fabd..c95b1c56 100644 --- a/i18n/et/Shell.et.resx +++ b/i18n/et/Shell.et.resx @@ -31,7 +31,6 @@ Võta olemasolev kaust üle Muuda… Vali… - Aidake Titanot anonüümse kasutusstatistikaga paremaks muuta Jätka Leitud Loo kohalik arhiiv diff --git a/i18n/fi/Shell.fi.resx b/i18n/fi/Shell.fi.resx index db730a16..9f31b8e1 100644 --- a/i18n/fi/Shell.fi.resx +++ b/i18n/fi/Shell.fi.resx @@ -31,7 +31,6 @@ Sisällytä nykyinen kansio Muuta… Valitse… - Auta kehittämään Titanoa nimettömillä käyttötilastoilla Jatka Löydetty Luo paikallinen arkisto diff --git a/i18n/fr/Shell.fr.resx b/i18n/fr/Shell.fr.resx index 52e8de32..a254b083 100644 --- a/i18n/fr/Shell.fr.resx +++ b/i18n/fr/Shell.fr.resx @@ -31,7 +31,6 @@ Adopter un dossier existant Modifier… Choisir… - Aider à améliorer Titano grâce à des statistiques d'utilisation anonymes Continuer Trouvé Créer une archive locale diff --git a/i18n/he/Shell.he.resx b/i18n/he/Shell.he.resx index e491455c..18e00362 100644 --- a/i18n/he/Shell.he.resx +++ b/i18n/he/Shell.he.resx @@ -35,7 +35,6 @@ אמץ תיקייה קיימת שנה… בחר… - עזור לשפר את Titano באמצעות נתוני שימוש אנונימיים המשך נמצא צור ארכיון מקומי diff --git a/i18n/hi/Shell.hi.resx b/i18n/hi/Shell.hi.resx index 3f18e088..bfc6588c 100644 --- a/i18n/hi/Shell.hi.resx +++ b/i18n/hi/Shell.hi.resx @@ -31,7 +31,6 @@ मौजूदा फ़ोल्डर अपनाएँ बदलें… चुनें… - अनाम उपयोग गणना भेजकर Titano को बेहतर बनाने में मदद करें जारी रखें मिला स्थानीय संग्रह बनाएँ diff --git a/i18n/hr/Shell.hr.resx b/i18n/hr/Shell.hr.resx index d8560c71..42363850 100644 --- a/i18n/hr/Shell.hr.resx +++ b/i18n/hr/Shell.hr.resx @@ -35,7 +35,6 @@ Usvoji postojeću mapu Promijeni… Odaberi… - Pomozite poboljšati Titano anonimnom statistikom korištenja Nastavi Pronađen Stvori lokalnu arhivu diff --git a/i18n/hu/Shell.hu.resx b/i18n/hu/Shell.hu.resx index 9261a318..557e7443 100644 --- a/i18n/hu/Shell.hu.resx +++ b/i18n/hu/Shell.hu.resx @@ -31,7 +31,6 @@ Meglévő mappa átvétele Módosítás… Kiválasztás… - Segítsen fejleszteni a Titanót névtelen használati statisztikával Folytatás Megtalálva Helyi archívum létrehozása diff --git a/i18n/id/Shell.id.resx b/i18n/id/Shell.id.resx index 12a3a20d..b74244da 100644 --- a/i18n/id/Shell.id.resx +++ b/i18n/id/Shell.id.resx @@ -31,7 +31,6 @@ Adopsi folder yang ada Ubah… Pilih… - Bantu tingkatkan Titano dengan hitungan penggunaan anonim Lanjutkan Ditemukan Buat arsip lokal diff --git a/i18n/it/Shell.it.resx b/i18n/it/Shell.it.resx index 4e62588a..d5b6e695 100644 --- a/i18n/it/Shell.it.resx +++ b/i18n/it/Shell.it.resx @@ -31,7 +31,6 @@ Adotta una cartella esistente Cambia… Scegli… - Aiuta a migliorare Titano con conteggi d'uso anonimi Continua Trovato Crea un archivio locale diff --git a/i18n/ja/Shell.ja.resx b/i18n/ja/Shell.ja.resx index 2342591b..1ed74d63 100644 --- a/i18n/ja/Shell.ja.resx +++ b/i18n/ja/Shell.ja.resx @@ -31,7 +31,6 @@ 既存のフォルダーを登録 変更… 選択… - 匿名の利用状況の集計を送信して Titano の改善に協力する 続行 検出済み ローカルアーカイブを作成 diff --git a/i18n/ko/Shell.ko.resx b/i18n/ko/Shell.ko.resx index 4fd7d651..afcaad3d 100644 --- a/i18n/ko/Shell.ko.resx +++ b/i18n/ko/Shell.ko.resx @@ -31,7 +31,6 @@ 기존 폴더 등록 변경… 선택… - 익명 사용 통계를 보내 Titano 개선에 도움 주기 계속 찾음 로컬 아카이브 만들기 diff --git a/i18n/lt/Shell.lt.resx b/i18n/lt/Shell.lt.resx index 121bc3e0..d7949b79 100644 --- a/i18n/lt/Shell.lt.resx +++ b/i18n/lt/Shell.lt.resx @@ -35,7 +35,6 @@ Perimti esamą aplanką Keisti… Pasirinkti… - Padėkite tobulinti Titano siųsdami anoniminę naudojimo statistiką Tęsti Rasta Kurti vietinį archyvą diff --git a/i18n/lv/Shell.lv.resx b/i18n/lv/Shell.lv.resx index 85119191..db58111c 100644 --- a/i18n/lv/Shell.lv.resx +++ b/i18n/lv/Shell.lv.resx @@ -35,7 +35,6 @@ Pārņemt esošu mapi Mainīt… Izvēlēties… - Palīdzēt uzlabot Titano ar anonīmu lietojuma statistiku Turpināt Atrasts Izveidot lokālu arhīvu diff --git a/i18n/ms/Shell.ms.resx b/i18n/ms/Shell.ms.resx index 558dad41..c753d096 100644 --- a/i18n/ms/Shell.ms.resx +++ b/i18n/ms/Shell.ms.resx @@ -31,7 +31,6 @@ Terima pakai folder sedia ada Tukar… Pilih… - Bantu tingkatkan Titano dengan kiraan penggunaan tanpa nama Teruskan Ditemui Cipta arkib setempat diff --git a/i18n/nb/Shell.nb.resx b/i18n/nb/Shell.nb.resx index a6997790..0e29cba2 100644 --- a/i18n/nb/Shell.nb.resx +++ b/i18n/nb/Shell.nb.resx @@ -31,7 +31,6 @@ Overta en eksisterende mappe Endre… Velg… - Hjelp med å forbedre Titano med anonym bruksstatistikk Fortsett Funnet Opprett et lokalt arkiv diff --git a/i18n/nl/Shell.nl.resx b/i18n/nl/Shell.nl.resx index 5ba5bb82..fc90d1e7 100644 --- a/i18n/nl/Shell.nl.resx +++ b/i18n/nl/Shell.nl.resx @@ -31,7 +31,6 @@ Een bestaande map opnemen Wijzigen… Kiezen… - Help Titano te verbeteren met anonieme gebruikstellingen Doorgaan Gevonden Een lokaal archief maken diff --git a/i18n/pl/Shell.pl.resx b/i18n/pl/Shell.pl.resx index c1f1542f..45d4c003 100644 --- a/i18n/pl/Shell.pl.resx +++ b/i18n/pl/Shell.pl.resx @@ -39,7 +39,6 @@ Dołącz istniejący folder Zmień… Wybierz… - Pomóż ulepszać Titano, wysyłając anonimowe statystyki użycia Kontynuuj Znaleziono Utwórz archiwum lokalne diff --git a/i18n/pt-BR/Shell.pt-BR.resx b/i18n/pt-BR/Shell.pt-BR.resx index 08ce87a8..ed06d9db 100644 --- a/i18n/pt-BR/Shell.pt-BR.resx +++ b/i18n/pt-BR/Shell.pt-BR.resx @@ -31,7 +31,6 @@ Adotar uma pasta existente Alterar… Escolher… - Ajude a melhorar o Titano com contagens de uso anônimas Continuar Encontrado Criar um acervo local diff --git a/i18n/pt-PT/Shell.pt-PT.resx b/i18n/pt-PT/Shell.pt-PT.resx index b8f0f008..123b9b94 100644 --- a/i18n/pt-PT/Shell.pt-PT.resx +++ b/i18n/pt-PT/Shell.pt-PT.resx @@ -31,7 +31,6 @@ Adotar uma pasta existente Alterar… Escolher… - Ajudar a melhorar o Titano com contagens de utilização anónimas Continuar Encontrados Criar um arquivo local diff --git a/i18n/ro/Shell.ro.resx b/i18n/ro/Shell.ro.resx index c5a6f846..a4938de9 100644 --- a/i18n/ro/Shell.ro.resx +++ b/i18n/ro/Shell.ro.resx @@ -35,7 +35,6 @@ Adoptare folder existent Modificare… Alegere… - Ajutați la îmbunătățirea Titano cu statistici de utilizare anonime Continuare Găsit Creare arhivă locală diff --git a/i18n/ru/Shell.ru.resx b/i18n/ru/Shell.ru.resx index 7ffd714f..30843e67 100644 --- a/i18n/ru/Shell.ru.resx +++ b/i18n/ru/Shell.ru.resx @@ -39,7 +39,6 @@ Присоединить имеющуюся папку Изменить… Выбрать… - Помогите улучшить Titano, отправляя анонимную статистику использования Продолжить Найден Создать локальный архив diff --git a/i18n/sk/Shell.sk.resx b/i18n/sk/Shell.sk.resx index 85ca138e..ddcfcb30 100644 --- a/i18n/sk/Shell.sk.resx +++ b/i18n/sk/Shell.sk.resx @@ -35,7 +35,6 @@ Prevziať existujúci priečinok Zmeniť… Vybrať… - Pomôžte zlepšiť Titano anonymnými štatistikami používania Pokračovať Nájdené Vytvoriť lokálny archív diff --git a/i18n/sl/Shell.sl.resx b/i18n/sl/Shell.sl.resx index 6b480c53..92d66260 100644 --- a/i18n/sl/Shell.sl.resx +++ b/i18n/sl/Shell.sl.resx @@ -35,7 +35,6 @@ Prevzemi obstoječo mapo Spremeni … Izberi … - Pomagajte izboljšati Titano z anonimno statistiko uporabe Nadaljuj Najdeno Ustvari lokalni arhiv diff --git a/i18n/sv/Shell.sv.resx b/i18n/sv/Shell.sv.resx index 70ca90d7..877b1a3a 100644 --- a/i18n/sv/Shell.sv.resx +++ b/i18n/sv/Shell.sv.resx @@ -31,7 +31,6 @@ Införliva en befintlig mapp Ändra… Välj… - Hjälp till att förbättra Titano med anonym användningsstatistik Fortsätt Hittad Skapa ett lokalt arkiv diff --git a/i18n/th/Shell.th.resx b/i18n/th/Shell.th.resx index 9ef16233..1dd34756 100644 --- a/i18n/th/Shell.th.resx +++ b/i18n/th/Shell.th.resx @@ -31,7 +31,6 @@ ลงทะเบียนโฟลเดอร์ที่มีอยู่ เปลี่ยน… เลือก… - ช่วยปรับปรุง Titano ด้วยสถิติการใช้งานแบบไม่ระบุตัวตน ดำเนินการต่อ พบแล้ว สร้างคลังภาพในเครื่อง diff --git a/i18n/tr/Shell.tr.resx b/i18n/tr/Shell.tr.resx index 5ac8e601..9d88e660 100644 --- a/i18n/tr/Shell.tr.resx +++ b/i18n/tr/Shell.tr.resx @@ -31,7 +31,6 @@ Mevcut klasörü dahil et Değiştir… Seç… - Anonim kullanım sayılarıyla Titano'nun gelişmesine yardım edin Devam Bulundu Yerel arşiv oluştur diff --git a/i18n/uk/Shell.uk.resx b/i18n/uk/Shell.uk.resx index c2193cf5..c1a444a3 100644 --- a/i18n/uk/Shell.uk.resx +++ b/i18n/uk/Shell.uk.resx @@ -39,7 +39,6 @@ Приєднати наявну папку Змінити… Вибрати… - Допомогти покращити Titano анонімною статистикою використання Продовжити Знайдено Створити локальний архів diff --git a/i18n/vi/Shell.vi.resx b/i18n/vi/Shell.vi.resx index b4d450de..f18d4deb 100644 --- a/i18n/vi/Shell.vi.resx +++ b/i18n/vi/Shell.vi.resx @@ -31,7 +31,6 @@ Tiếp nhận thư mục có sẵn Thay đổi… Chọn… - Giúp cải thiện Titano bằng số liệu sử dụng ẩn danh Tiếp tục Đã tìm thấy Tạo kho lưu trữ cục bộ diff --git a/i18n/zh-Hans/Shell.zh-Hans.resx b/i18n/zh-Hans/Shell.zh-Hans.resx index bd6f881a..2b6b3c52 100644 --- a/i18n/zh-Hans/Shell.zh-Hans.resx +++ b/i18n/zh-Hans/Shell.zh-Hans.resx @@ -31,7 +31,6 @@ 纳入现有文件夹 更改… 选择… - 发送匿名使用统计,帮助改进 Titano 继续 已发现 创建本地档案库 diff --git a/i18n/zh-Hant/Shell.zh-Hant.resx b/i18n/zh-Hant/Shell.zh-Hant.resx index c2d72e5a..c26fecc4 100644 --- a/i18n/zh-Hant/Shell.zh-Hant.resx +++ b/i18n/zh-Hant/Shell.zh-Hant.resx @@ -31,7 +31,6 @@ 納入現有資料夾 變更… 選擇… - 以匿名使用統計協助改善 Titano 繼續 已找到 建立本機典藏庫 diff --git a/src/Titano.App/Infrastructure/AppSettings.cs b/src/Titano.App/Infrastructure/AppSettings.cs index 21066cbe..a1773ce8 100644 --- a/src/Titano.App/Infrastructure/AppSettings.cs +++ b/src/Titano.App/Infrastructure/AppSettings.cs @@ -56,7 +56,10 @@ public sealed class AppSettings public string? Language { get; set; } public AppTheme Theme { get; set; } = AppTheme.Dark; public bool RailCollapsed { get; set; } + + /// The first-run consent of BRIEF §21; offered only by builds with . public bool AnonymousUsageCounts { get; set; } + public WindowPlacement? Window { get; set; } /// The first-run choice (local archive, adopted folder or server) was made. diff --git a/src/Titano.App/Infrastructure/ProductFeatures.cs b/src/Titano.App/Infrastructure/ProductFeatures.cs new file mode 100644 index 00000000..e150d321 --- /dev/null +++ b/src/Titano.App/Infrastructure/ProductFeatures.cs @@ -0,0 +1,17 @@ +using System.Reflection; + +namespace Titano.App.Infrastructure; + +/// Features a build switches on through MSBuild properties (Directory.Build.props), read from the assembly metadata. +public static class ProductFeatures +{ + /// + /// Monetization (BRIEF §21: ads, the anonymous usage counts consent, the licence) ships disabled until a build sets + /// TitanoAdsEnabled=true; until then nothing of it shows. + /// + public static bool AdsEnabled { get; } = Flag("TitanoAdsEnabled"); + + private static bool Flag(string key) => + typeof(ProductFeatures).Assembly.GetCustomAttributes().FirstOrDefault(a => a.Key == key)?.Value is { } value + && bool.TryParse(value, out var on) && on; +} diff --git a/src/Titano.App/Sections/SettingsView.xaml b/src/Titano.App/Sections/SettingsView.xaml index c19a884f..1547ac25 100644 --- a/src/Titano.App/Sections/SettingsView.xaml +++ b/src/Titano.App/Sections/SettingsView.xaml @@ -134,7 +134,9 @@ - + + diff --git a/src/Titano.App/Sections/SettingsViewModel.cs b/src/Titano.App/Sections/SettingsViewModel.cs index 45299c80..2e79ab42 100644 --- a/src/Titano.App/Sections/SettingsViewModel.cs +++ b/src/Titano.App/Sections/SettingsViewModel.cs @@ -43,7 +43,7 @@ public sealed class SettingsViewModel : SectionViewModel _s = shell.Services.Settings; AllPages = [ - new(SettingsPage.General, ["Settings.General.Language", "Settings.General.Theme", "Settings.General.Usage"]), + new(SettingsPage.General, ["Settings.General.Language", "Settings.General.Theme", .. ProductFeatures.AdsEnabled ? (string[])["Settings.General.Usage"] : []]), new(SettingsPage.Archive, ["Settings.Archive.Root", "Settings.Archive.Folders", "Settings.Archive.Files", "Settings.Archive.Proxies"]), new(SettingsPage.Rendering, ["Settings.Rendering.Quality", "Settings.Rendering.Memory", "Settings.Rendering.Parallelism", "Settings.Rendering.Hardware", "Settings.Rendering.Encoders"]), new(SettingsPage.Storage, ["Settings.Storage.Folder", "Settings.Storage.Thumbnails", "Settings.Storage.Limit"]), @@ -247,6 +247,9 @@ public sealed class SettingsViewModel : SectionViewModel } } + /// The usage counts consent belongs to monetization (BRIEF §21): only builds with it enabled offer it. + public bool ShowsUsageCounts => ProductFeatures.AdsEnabled; + public bool UsageCounts { get => _s.AnonymousUsageCounts; diff --git a/src/Titano.App/Sections/WelcomeView.xaml b/src/Titano.App/Sections/WelcomeView.xaml index 7ec7dc6f..8e58a9db 100644 --- a/src/Titano.App/Sections/WelcomeView.xaml +++ b/src/Titano.App/Sections/WelcomeView.xaml @@ -106,14 +106,16 @@ - + + HorizontalAlignment="Left" Foreground="{DynamicResource Brush.TextMuted}" + Visibility="{Binding ShowsUsageCounts, Converter={StaticResource BoolToVisibility}}" />