fix(workspace): join the phase 5c packages at their seams

The local render, the send home, the clean-up, the settings page and the
folder move were built apart; together they left gaps:

- A local render to an image sequence writes a folder, which the send
  took for a missing file. The archive home now files the folder whole
  (checked by its listing hash, as the render recorded it) and the
  clean-up removes a sent folder; a server, which takes one file per
  render, refuses it with Errors.Workspace.SendSequence.
- Rename, delete and Remove local copy are refused while the folder is
  being moved, so no project folder changes under the move.
- Settings > Workspace shows the folder, usage, Move... and Change...
  again when a move ends (WorkspaceHost.MoveEnded).
- Empty... uses the Settings typed confirmation; the separate trash
  dialog, never shown, is removed. The move plan counts unsent renders
  with the clean-up's helper.
- Tests: the follow-up send now runs in the render tests; an end-to-end
  archive-home test (originals, version on render, local render, send
  with project and version, clean-up) and an image-sequence send test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-04 16:23:54 +01:00
1 parent 6daf5fa056
commit 09fcff4eb2
13 files changed
+210 -226

No files matched your search

@@ -765,6 +765,14 @@ public sealed class SettingsViewModel : SectionViewModel
WorkspaceRows.Refresh();
}
/// <summary>A move of the workspace folder ended (any thread): the page shows the folder in use, what it takes, and Move… and Change… again.</summary>
private void OnWorkspaceMoveEnded() => System.Windows.Application.Current?.Dispatcher.BeginInvoke(() =>
{
WorkspaceRows.Refresh();
CommandManager.InvalidateRequerySuggested();
if (_page == SettingsPage.Workspace) _ = WorkspaceRows.MeasureAsync();
});
// ---------------- Server ----------------
public EditableField DefaultServer { get; }
@@ -875,6 +883,7 @@ public sealed class SettingsViewModel : SectionViewModel
}
LoadCertificates();
Shell.Services.Server.PropertyChanged += OnServerChanged;
Shell.Services.Workspace.MoveEnded += OnWorkspaceMoveEnded;
if (System.Windows.Application.Current is { } app) _interfacePriority = new InterfacePriority(app, () => _s.BackgroundPriority);
_ = LoadArchiveAsync();
switch (Shell.Services.StagedRestore)
@@ -908,6 +917,7 @@ public sealed class SettingsViewModel : SectionViewModel
{
Loc.CultureChanged -= OnCultureChanged;
Shell.Services.Server.PropertyChanged -= OnServerChanged;
Shell.Services.Workspace.MoveEnded -= OnWorkspaceMoveEnded;
_selfTest?.Cancel();
_interfacePriority?.Dispose();
base.Dispose();
+10 -15
View File
@@ -74,6 +74,12 @@ public sealed partial class WorkspaceHost
}
}
/// <summary>
/// A move of the workspace folder followed here ended, however it ended (any thread): the folder in use may have changed,
/// and the workspace is no longer held for it (Settings › Workspace shows the folder and what it takes again).
/// </summary>
public event Action? MoveEnded;
/// <summary>
/// A move stopped before it ended: the folder in use holds its journal and no move job waits, runs or is paused. Null
/// when there is none (a move under way is no move to take up). A move job waiting at start is followed from now on,
@@ -230,8 +236,10 @@ public sealed partial class WorkspaceHost
if (job.Kind != JobKind.WorkspaceMove || job.State is not (JobState.Done or JobState.Failed or JobState.Cancelled)) return;
lock (_gate)
{
if (_moveJob == job.Id) _moveJob = Guid.Empty;
if (_moveJob != job.Id) return;
_moveJob = Guid.Empty;
}
MoveEnded?.Invoke();
}
/// <summary>A project as the move's plan lists it, read from the workspace alone (its versions not sent, its ledger, its changes).</summary>
@@ -244,7 +252,7 @@ public sealed partial class WorkspaceHost
try
{
var status = await Sync.StatusAsync(folder.ProjectId, null, cancellationToken).ConfigureAwait(false);
var renders = UnsentRenders(project);
var renders = WorkspaceCleaner.UnsentRenders(project);
return new WorkspaceMoveProject(folder.ProjectId, entry.Name, folder.Files, folder.Bytes, status.Ahead + status.Damaged + renders > 0 || status.Conflict is not null,
status.Modified && !status.ReadOnly);
}
@@ -253,18 +261,5 @@ public sealed partial class WorkspaceHost
Log.Info("workspace", $"Where project {folder.ProjectId} stands could not be read for the move's plan: {ex.Message}");
return new WorkspaceMoveProject(folder.ProjectId, entry.Name, folder.Files, folder.Bytes, true, false);
}
static int UnsentRenders(WorkspaceProject project)
{
try
{
return project.ReadRenders().Unsent.Count;
}
catch (InvalidDataException)
{
// A ledger this Chronos cannot read: what it lists is not known to be at the home.
return 1;
}
}
}
}
@@ -707,6 +707,7 @@ public sealed partial class WorkspaceHost
/// <exception cref="HomeUnavailableException">The home cannot be reached now: the name stays.</exception>
public Task<string> RenameAsync(Guid projectId, string name, CancellationToken cancellationToken = default) => Task.Run(async () =>
{
EnsureNotMoving();
var project = Existing(projectId);
var renamed = await HomeOfProject(projectId).RenameAsync(projectId, name, cancellationToken).ConfigureAwait(false);
using (await project.LockAsync(LockWait, cancellationToken).ConfigureAwait(false))
@@ -732,6 +733,7 @@ public sealed partial class WorkspaceHost
{
var (sequenceId, removed) = await Task.Run(async () =>
{
EnsureNotMoving();
var project = Existing(projectId);
var workspace = project.ReadBundle().Workspace!;
if (workspace.IsMain) throw new ProjectException(ProjectError.MainCannotBeDeleted, "The Main project cannot be deleted.");
@@ -816,6 +818,8 @@ public sealed partial class WorkspaceHost
{
var sequenceId = await Task.Run(async () =>
{
// A move takes every project folder as it stands: none goes to the trash meanwhile.
EnsureNotMoving();
var project = Existing(projectId);
var entry = await EntryOrUnreadableAsync(project, cancellationToken).ConfigureAwait(false);
if (entry.Newer) throw Unreadable(entry);
@@ -1,109 +0,0 @@
using System.Globalization;
using System.Windows.Input;
using Chronos.App.Archiving;
using Chronos.App.Infrastructure;
using Chronos.Core.Diagnostics;
using Chronos.Core.Localization;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Workspace;
/// <summary>One entry of the workspace's trash as Empty… lists it: "name · 1.2 GB · 04/11/2026".</summary>
public sealed class WorkspaceTrashRowViewModel(WorkspaceTrashItem item)
{
public WorkspaceTrashItem Item { get; } = item;
public string Text => Loc.L("Settings.Workspace.TrashPlan.Item", Item.Name, Formatting.Bytes(Item.Bytes),
Formatting.Date(Item.Trashed) + " " + Formatting.TimeOfDay(Item.Trashed));
}
/// <summary>
/// Settings › Workspace › Trash › Empty… (phase 5c): the plan (every entry of the workspace's trash, their number and size,
/// <see cref="WorkspaceTrashPlan"/>), then Erase for good, which enables only once the user typed the number of entries; the
/// emptying erases exactly the entries listed, and is refused when the trash changed since (the plan is shown again then).
/// Keep closes it, erasing nothing.
/// </summary>
public sealed class WorkspaceTrashDialogViewModel : ArchiveDialogViewModel
{
private readonly Func<WorkspaceTrashPlan, Task<WorkspaceTrashResult>> _empty;
private readonly Action<WorkspaceTrashResult>? _emptied;
private string _typed = string.Empty;
/// <param name="empty">Erases the plan's entries (<see cref="WorkspaceHost.EmptyTrashAsync"/>).</param>
/// <param name="emptied">Told what was erased, once the dialog closes on it (the page measures the workspace again).</param>
public WorkspaceTrashDialogViewModel(WorkspaceTrashPlan plan, Func<WorkspaceTrashPlan, Task<WorkspaceTrashResult>> empty, Action<WorkspaceTrashResult>? emptied,
Action<ArchiveDialogViewModel> close)
: base(close)
{
ArgumentNullException.ThrowIfNull(plan);
ArgumentNullException.ThrowIfNull(empty);
Plan = plan;
_empty = empty;
_emptied = emptied;
Rows = [.. plan.Items.Select(i => new WorkspaceTrashRowViewModel(i))];
EraseCommand = new AsyncRelayCommand(EraseAsync, () => CanErase);
}
public WorkspaceTrashPlan Plan { get; }
public IReadOnlyList<WorkspaceTrashRowViewModel> Rows { get; }
public string Heading => Loc.L("Settings.Workspace.TrashPlan.Title");
public string Message => Loc.L("Settings.Workspace.TrashPlan.Message");
/// <summary>"Entries: 3".</summary>
public string ItemsText => Loc.L("Settings.Workspace.TrashPlan.Items", Formatting.Count(Plan.Items.Count));
/// <summary>"Size: 1.2 GB".</summary>
public string SizeText => Loc.L("Settings.Workspace.TrashPlan.Size", Formatting.Bytes(Plan.Bytes));
/// <summary>What the user types to confirm: the number of entries, in plain digits.</summary>
public string Confirmation => Plan.Items.Count.ToString(CultureInfo.InvariantCulture);
/// <summary>"Type the number of entries, 3, to confirm".</summary>
public string TypedPrompt => Loc.L("Settings.Workspace.TrashPlan.Type", Confirmation);
/// <summary>What the user typed; Erase for good enables once it is <see cref="Confirmation"/>.</summary>
public string Typed
{
get => _typed;
set
{
if (!Set(ref _typed, value ?? string.Empty)) return;
OnPropertyChanged(nameof(CanErase));
CommandManager.InvalidateRequerySuggested();
}
}
/// <summary>The trash holds something, the number typed matches, and nothing runs.</summary>
public bool CanErase => !IsBusy && !Plan.IsEmpty && string.Equals(_typed.Trim(), Confirmation, StringComparison.Ordinal);
public ICommand EraseCommand { get; }
public string EraseToolTip => Plan.IsEmpty ? Loc.L("Tooltips.Settings.Workspace.EmptyTrash.Disabled") : Loc.L("Tooltips.Settings.Workspace.TrashPlan.Action");
public string KeepToolTip => Loc.L("Tooltips.Settings.Workspace.TrashPlan.Keep");
private async Task EraseAsync()
{
if (!CanErase) return;
ClearError();
IsBusy = true;
OnPropertyChanged(nameof(CanErase));
try
{
var result = await _empty(Plan);
IsBusy = false;
Close();
_emptied?.Invoke(result);
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("workspace", "The workspace's trash was not emptied", ex);
ShowMessage(WorkspaceText.Failure(ex), ex.Message);
IsBusy = false;
OnPropertyChanged(nameof(CanErase));
}
}
}
@@ -1,58 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:ws="clr-namespace:Chronos.App.Workspace">
<!-- Settings › Workspace › Trash › Empty… (phase 5c), in-window, with the dialog kit of the Archive screen. -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Chronos;component/Archive/ArchiveDialogs.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- The plan of emptying the workspace's trash: every entry, their number and size, then the number typed before Erase for good enables. -->
<DataTemplate DataType="{x:Type ws:WorkspaceTrashDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="560" MaxHeight="560">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Heading}" />
<TextBlock Grid.Row="1" Text="{Binding Message}" Margin="0,8,0,0" Foreground="{DynamicResource Brush.TextMuted}" TextWrapping="Wrap" LineHeight="18" />
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,12,0,8">
<TextBlock Text="{Binding ItemsText}" Typography.NumeralAlignment="Tabular" ToolTip="{Binding ItemsText}" />
<TextBlock Text="{Binding SizeText}" Margin="16,0,0,0" Typography.NumeralAlignment="Tabular" ToolTip="{Binding SizeText}" />
</StackPanel>
<ListBox Grid.Row="3" ItemsSource="{Binding Rows}" MinHeight="96" AutomationProperties.Name="{l:Loc Settings.Workspace.Trash}" KeyboardNavigation.TabNavigation="Continue">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Text}" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type ws:WorkspaceTrashRowViewModel}">
<TextBlock Text="{Binding Text}" Height="32" Padding="0,8,0,0" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text}" FlowDirection="LeftToRight"
Typography.NumeralAlignment="Tabular" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="4" Margin="0,16,0,0">
<TextBlock Text="{Binding TypedPrompt}" Foreground="{DynamicResource Brush.TextMuted}" TextWrapping="Wrap" />
<TextBox Margin="0,6,0,0" Text="{Binding Typed, UpdateSourceTrigger=PropertyChanged}" ui:Field.Placeholder="{Binding Confirmation}" ToolTip="{Binding TypedPrompt}"
AutomationProperties.Name="{Binding TypedPrompt}" />
</StackPanel>
<DockPanel Grid.Row="5" Margin="0,18,0,0">
<Button DockPanel.Dock="Right" Content="{l:Loc Editor.Project.Keep}" Command="{Binding CloseCommand}" ToolTip="{Binding KeepToolTip}" IsCancel="True"
IsDefault="True" MinWidth="96" />
<!-- Erasing for good: enabled once the number of entries is typed, never the default button. -->
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Destructive}" Content="{l:Loc Settings.Workspace.TrashPlan.Action}" Command="{Binding EraseCommand}"
ToolTip="{Binding EraseToolTip}" ToolTipService.ShowOnDisabled="True" MinWidth="96" Margin="0,0,8,0" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" Margin="0,0,12,0" />
</DockPanel>
</Grid>
</Border>
</DataTemplate>
</ResourceDictionary>