From e0644e53045c68ca07ec570a60ba00336fc50edc Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Wed, 4 Nov 2026 17:43:40 +0100 Subject: [PATCH] fix(settings): hold Change and Move while a switched move awaits Resume MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A move that switched to the folder in use but left part of its old folder showed Resume and a "resume it first" tooltip on Change… and Move…, yet both stayed enabled because no journal lies in the folder in use. Choosing another folder then would hide the Resume for good and leave the old folder's copy on disk. Change… and Move… now wait whenever a stopped move is found. Co-Authored-By: Claude Opus 5.5 --- src/Chronos.App/Settings/WorkspaceSettingsRows.cs | 10 ++++++++-- .../Settings/SettingsLogicTests.cs | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Chronos.App/Settings/WorkspaceSettingsRows.cs b/src/Chronos.App/Settings/WorkspaceSettingsRows.cs index 103c06e3..14d8172e 100644 --- a/src/Chronos.App/Settings/WorkspaceSettingsRows.cs +++ b/src/Chronos.App/Settings/WorkspaceSettingsRows.cs @@ -106,7 +106,7 @@ public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Fun public RelayCommand OpenCommand { get; } = new(open); /// Uses another folder, after its plan (WorkspaceFolderChange); none where the folder cannot change, nor while it moves. - public AsyncRelayCommand ChangeCommand => _change ??= new AsyncRelayCommand(() => ThenReadMoveAsync(change), () => change is not null && !IsMoving); + public AsyncRelayCommand ChangeCommand => _change ??= new AsyncRelayCommand(() => ThenReadMoveAsync(change), () => change is not null && !IsHeld); private AsyncRelayCommand? _change; @@ -116,7 +116,7 @@ public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Fun public string ChangeToolTip => MoveState ?? Loc.L("Tooltips.Settings.ChangeWorkspace"); /// Moves the folder with its projects, after its plan (WorkspaceFolderChange.MoveAsync); none where it cannot move, nor while it moves. - public AsyncRelayCommand MoveCommand => _move ??= new AsyncRelayCommand(() => ThenReadMoveAsync(services?.Move), () => services?.Move is not null && !IsMoving); + public AsyncRelayCommand MoveCommand => _move ??= new AsyncRelayCommand(() => ThenReadMoveAsync(services?.Move), () => services?.Move is not null && !IsHeld); private AsyncRelayCommand? _move; @@ -430,6 +430,12 @@ public sealed class WorkspaceSettingsRows(AppSettings settings, Action save, Fun /// A move holds the workspace, as read last (read once when not known since the last refresh). private bool IsMoving => _moving ??= services?.IsMoving() ?? false; + /// + /// Change… and Move… wait: a move holds the folder, or one stopped and Resume takes it up (also one that switched here + /// and left part of the folder it came from: another folder now would leave that part with no Resume). + /// + private bool IsHeld => _unfinished || IsMoving; + private async Task ResumeMoveAsync() { if (services?.ResumeMove is not { } resume) return; diff --git a/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs b/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs index 654a5ecb..c0ac58c0 100644 --- a/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs +++ b/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs @@ -722,6 +722,21 @@ public sealed class SettingsLogicTests Assert.True(rows.MoveCommand.CanExecute(null)); } + [Test] + public async Task AMoveThatSwitchedHereAndLeftPartOfItsOldFolderStillHoldsChangeAndMove() + { + // The folder in use holds no journal (the move switched to it), but the old folder still does: Resume clears it, + // and another folder chosen first would leave that part with no Resume. + var (_, rows, _) = WorkspaceRows(new FakeWorkspace(), move: () => Task.CompletedTask, isMoving: () => false, unfinished: () => true, + resume: () => Task.CompletedTask); + await rows.MeasureAsync(); + + Assert.True(rows.CanResumeMove); + Assert.Equal((Loc.L("Tooltips.Settings.Workspace.MoveUnfinished"), Loc.L("Tooltips.Settings.Workspace.MoveUnfinished")), (rows.ChangeToolTip, rows.MoveToolTip)); + Assert.False(rows.ChangeCommand.CanExecute(null)); + Assert.False(rows.MoveCommand.CanExecute(null)); + } + [Test] public void ADefaultMediaOrOpenPolicySetElsewhereReadsAsEverythingAppliesIt() {