fix(uploader): Start with Windows shows what Task Manager left when the settings open

The Uploader runs for the whole sign-in session and read its sign-in
entry only at start, so an entry Task Manager turned off meanwhile still
showed as ticked. Opening the settings panel now reads it again.

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-12 16:34:12 +00:00
1 parent 7606957276
commit fe4a9eacc4
3 files changed
+41 -4

No files matched your search

+6 -3
View File
@@ -41,13 +41,16 @@ public sealed class SampleData
], ],
}; };
/// <summary>A view model over in-memory sample services; settings changes are discarded.</summary> /// <summary>
public MainViewModel CreateViewModel() /// A view model over in-memory sample services; settings changes are discarded. <paramref name="startup"/> stands for
/// the sign-in entry (an in-memory one, on, by default).
/// </summary>
public MainViewModel CreateViewModel(IStartupRegistration? startup = null)
{ {
var memory = new ProcessedFileMemory(); var memory = new ProcessedFileMemory();
_session.BandwidthLimit = Settings.BandwidthLimit; _session.BandwidthLimit = Settings.BandwidthLimit;
_vm = new MainViewModel(new UploaderServices( _vm = new MainViewModel(new UploaderServices(
Settings, () => { }, _session, _queue, new SampleEngine(_queue), new SampleStartup(), new UploaderDialogs(), Settings, () => { }, _session, _queue, new SampleEngine(_queue), startup ?? new SampleStartup(), new UploaderDialogs(),
new WatchFolderService(memory, _queue.ContainsPath), memory, string.Empty)); new WatchFolderService(memory, _queue.ContainsPath), memory, string.Empty));
foreach (var w in _vm.WatchFolders) w.IsAvailable = true; foreach (var w in _vm.WatchFolders) w.IsAvailable = true;
// A disconnected drive: its chip shows the hollow ring and wraps to a second line. // A disconnected drive: its chip shows the hollow ring and wraps to a second line.
+7 -1
View File
@@ -156,7 +156,13 @@ public sealed class MainViewModel : LocalizedViewModel
public bool IsSettingsOpen public bool IsSettingsOpen
{ {
get => _isSettingsOpen; get => _isSettingsOpen;
set => Set(ref _isSettingsOpen, value); set
{
if (!Set(ref _isSettingsOpen, value) || !value) return;
// The Uploader runs for the whole session: Task Manager may have turned its sign-in entry off meanwhile.
_startWithWindows = _s.Startup.IsEnabled;
OnPropertyChanged(nameof(StartWithWindows));
}
} }
// ---------------- Target ---------------- // ---------------- Target ----------------
@@ -125,6 +125,34 @@ public sealed class UploaderScreenSmokeTests
} }
}); });
[Test]
public Task StartWithWindowsShowsWhatTaskManagerLeftWhenTheSettingsOpen() => ScreenHost.RunAsync(() =>
{
UiLanguage.Apply("en");
var startup = new SignInEntry { IsEnabled = true };
var vm = new SampleData().CreateViewModel(startup);
Assert.True(vm.StartWithWindows);
// The Uploader runs for the whole session: Task Manager turns its entry off meanwhile, and the box follows when
// the settings open.
startup.IsEnabled = false;
var changed = new List<string?>();
vm.PropertyChanged += (_, e) => changed.Add(e.PropertyName);
vm.OpenSettingsCommand.Execute(null);
Assert.False(vm.StartWithWindows, "shown as Task Manager left it");
Assert.Contains(nameof(MainViewModel.StartWithWindows), changed);
vm.CloseSettingsCommand.Execute(null);
return Task.CompletedTask;
});
/// <summary>A sign-in entry another program (Task Manager) can turn off.</summary>
private sealed class SignInEntry : Titano.Uploader.Infrastructure.IStartupRegistration
{
public bool IsEnabled { get; set; }
public void SetEnabled(bool enabled) => IsEnabled = enabled;
}
/// <summary>A <see cref="MainWindow"/> on <see cref="SampleData"/>, shown off screen like <c>--capture</c>.</summary> /// <summary>A <see cref="MainWindow"/> on <see cref="SampleData"/>, shown off screen like <c>--capture</c>.</summary>
private sealed class UploaderScreen : IDisposable private sealed class UploaderScreen : IDisposable
{ {