fix(app): editor review fixes for saving, undo, preview, commands and layout

- Undo/redo snapshots take outside changes (advice, merged edits) on Replace;
  a drag, click or key press ends a merged run; Reset to Auto is its own step.
- A failed save stays pending and is retried with backoff; closing or switching
  asks before discarding it; the local source throws unless the index took it.
- Opening a sequence survives any failure; the window title follows the editor;
  the job bar hides when idle in the editor.
- Render, Add to queue and Batch re-read their state; disabled commands say why;
  Analyse is disabled while queued and announces its cost and Ctrl+Shift+A.
- Preview: 1:1 and wheel zoom render the source's own pixels, the view keeps its
  place across resolutions, crop mask result mode, unreadable frames say so,
  labelled tools, keyboard focus on open, tools hidden on Export lose their effect.
- Preparation re-solves from measured series (no re-decode per slider step) with
  a half-precision frame cache.
- Exposure flicker and waveform charts, Time plan chart, Camera crop margins,
  sortable frame table, wrapped findings, responsive preset cards, render-done
  follow-up, Jobs history filtered on the sequence.

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-03 10:36:50 +00:00
1 parent 596b748c5c
commit 25e85aee57
32 files changed
+1612 -369

No files matched your search

+51 -27
View File
@@ -21,7 +21,7 @@
AutomationProperties.Name="{l:Loc Editor.Loading}" />
<!-- Editor.html: header, then the preview, filmstrip and section tabs on the left and the section's settings on the right. -->
<Grid x:Name="EditorRoot" DataContext="{Binding Editor}" Margin="16,0,16,12"
<Grid x:Name="EditorRoot" DataContext="{Binding Editor}" Margin="16,0,16,12" IsVisibleChanged="OnEditorVisibleChanged"
Visibility="{Binding Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<Grid.InputBindings>
<KeyBinding Key="Z" Modifiers="Control" Command="{Binding UndoCommand}" />
@@ -29,6 +29,7 @@
<KeyBinding Key="D0" Modifiers="Control" Command="{Binding FitCommand}" />
<KeyBinding Key="D1" Modifiers="Control" Command="{Binding ActualSizeCommand}" />
<KeyBinding Key="R" Modifiers="Control" Command="{Binding RenderCommand}" />
<KeyBinding Key="A" Modifiers="Control+Shift" Command="{Binding AnalyseCommand}" />
</Grid.InputBindings>
<Grid.RowDefinitions>
<RowDefinition Height="52" />
@@ -47,14 +48,15 @@
<TextBlock Grid.Column="1" Text="{Binding Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" Margin="6,0,12,0" MaxWidth="320"
TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Column="2" Text="{Binding Summary}" Style="{StaticResource Text.Secondary}" FontSize="{StaticResource Size.Body}" VerticalAlignment="Center"
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" />
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{Binding Summary}" />
<StackPanel Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="12,0,0,0">
<Button Content="{l:Loc Editor.Analyse}" Command="{Binding AnalyseCommand}" ToolTip="{l:Loc Tooltips.Editor.Analyse}" ToolTipService.ShowOnDisabled="True" />
<Button Content="{l:Loc Editor.OptimiseAll}" Command="{Binding OptimiseAllCommand}" ToolTip="{l:Loc Tooltips.Editor.OptimiseAll}"
<Button Content="{l:Loc Editor.Analyse}" Command="{Binding AnalyseCommand}" ToolTip="{Binding AnalyseToolTip}" ToolTipService.ShowOnDisabled="True" />
<Button Content="{l:Loc Editor.OptimiseAll}" Command="{Binding OptimiseAllCommand}" ToolTip="{Binding OptimiseAllToolTip}"
ToolTipService.ShowOnDisabled="True" Margin="12,0,0,0" />
<v:SplitButton IsPrimary="True" Margin="12,0,0,0" Content="{Binding RenderText}" Command="{Binding RenderCommand}" ItemsSource="{Binding RenderChoices}"
DisplayMemberPath="Label" SelectedItem="{Binding SelectedRenderChoice}" ToolTip="{Binding RenderToolTip}"
DropDownToolTip="{l:Loc Tooltips.Editor.RenderChoice}" AutomationProperties.Name="{l:Loc Editor.RenderButton}" />
<v:SplitButton x:Name="RenderButton" IsPrimary="True" Margin="12,0,0,0" Content="{Binding RenderText}" Command="{Binding RenderCommand}"
ItemsSource="{Binding RenderChoices}" DisplayMemberPath="Label" SelectedItem="{Binding SelectedRenderChoice}" ToolTip="{Binding RenderToolTip}"
ToolTipService.ShowOnDisabled="True" DropDownToolTip="{l:Loc Tooltips.Editor.RenderChoice}"
AutomationProperties.Name="{l:Loc Editor.RenderButton}" />
</StackPanel>
</Grid>
@@ -94,35 +96,57 @@
</Grid.RowDefinitions>
<v:PreviewViewport x:Name="Preview" Source="{Binding PreviewImage}" OriginalSource="{Binding OriginalImage}" IsCompareEnabled="{Binding IsCompare}"
WipeLabel="{Binding WipeLabel}" ZoomMode="{Binding ZoomMode, Mode=TwoWay}" ShowVectors="{Binding ShowVectors}"
MotionVectors="{Binding MotionVectors}" VectorScale="{Binding VectorScale}" ShowRegions="{Binding ShowRegions}"
RegionBoundary="{Binding RegionBoundary}" ShowCropMask="{Binding ShowCropMask}" CropRect="{Binding CropRect}" InfoText="{Binding InfoText}"
WipeLabel="{Binding WipeLabel}" ZoomMode="{Binding ZoomMode, Mode=TwoWay}" ShowVectors="{Binding ViewVectors}"
MotionVectors="{Binding MotionVectors}" VectorScale="{Binding VectorScale}" ShowRegions="{Binding ViewRegions}"
RegionBoundary="{Binding RegionBoundary}" ShowCropMask="{Binding ShowCropMask}" CropRect="{Binding CropRect}"
CropMaskMode="{Binding CropMaskMode}" InfoText="{Binding InfoText}" ToolTip="{l:Loc Tooltips.Editor.Preview.View}"
AutomationProperties.Name="{l:Loc Editor.Preview}" SizeChanged="OnPreviewSizeChanged">
<v:PreviewViewport.ToolsContent>
<StackPanel Orientation="Horizontal" DataContext="{Binding DataContext, ElementName=EditorRoot}">
<!-- Tools give the keyboard back to the preview after a click, so Space keeps playing (OnToolClicked). -->
<StackPanel Orientation="Horizontal" DataContext="{Binding DataContext, ElementName=EditorRoot}" ButtonBase.Click="OnToolClicked">
<ToggleButton Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding IsCompare}" ui:ButtonIcon.Glyph="{StaticResource Icon.Compare}"
ToolTip="{l:Loc Tooltips.Editor.Preview.Compare}" AutomationProperties.Name="{l:Loc Editor.Preview.Compare}" />
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding ShowVectors}" ui:ButtonIcon.Glyph="{StaticResource Icon.Vectors}"
ToolTip="{l:Loc Tooltips.Editor.Preview.Vectors}" AutomationProperties.Name="{l:Loc Editor.Preview.Vectors}" />
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding ShowRegions}" ui:ButtonIcon.Glyph="{StaticResource Icon.Regions}"
ToolTip="{l:Loc Tooltips.Editor.Preview.Regions}" AutomationProperties.Name="{l:Loc Editor.Preview.Regions}" />
Content="{l:Loc Editor.Preview.Compare}" ToolTip="{l:Loc Tooltips.Editor.Preview.Compare}" />
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
IsChecked="{Binding ShowVectors}" ui:ButtonIcon.Glyph="{StaticResource Icon.Vectors}" Content="{l:Loc Editor.Preview.Vectors}"
ToolTip="{l:Loc Tooltips.Editor.Preview.Vectors}" />
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
IsChecked="{Binding ShowRegions}" ui:ButtonIcon.Glyph="{StaticResource Icon.Regions}" Content="{l:Loc Editor.Preview.Regions}"
ToolTip="{l:Loc Tooltips.Editor.Preview.Regions}" />
<ToggleButton Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding ShowCropMask}" ui:ButtonIcon.Glyph="{StaticResource Icon.CropMask}"
ToolTip="{l:Loc Tooltips.Editor.Preview.CropMask}" AutomationProperties.Name="{l:Loc Editor.Preview.CropMask}" />
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding IsActualSize}" ui:ButtonIcon.Glyph="{StaticResource Icon.ActualSize}"
ToolTip="{l:Loc Tooltips.Editor.Preview.ActualSize}" AutomationProperties.Name="{l:Loc Editor.Preview.ActualSize}" />
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PreviewTool}" ui:ButtonIcon.Glyph="{StaticResource Icon.Fullscreen}" Click="OnFullScreen"
ToolTip="{l:Loc Tooltips.Editor.Preview.FullScreen}" AutomationProperties.Name="{l:Loc Editor.Preview.FullScreen}" />
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PreviewTool}" ui:ButtonIcon.Glyph="{StaticResource Icon.Play}" Command="{Binding PlayCommand}"
ToolTip="{Binding PlayToolTip}" AutomationProperties.Name="{l:Loc Editor.Preview.Play}" />
<Button Style="{StaticResource Button.Base}" Height="30" Padding="10,0" Background="{DynamicResource Brush.Chrome}"
ui:ButtonIcon.Glyph="{StaticResource Icon.Play}" Content="{l:Loc Editor.Preview.Clip}" Command="{Binding PreviewClipCommand}"
ToolTip="{l:Loc Tooltips.Editor.Preview.Clip}" Visibility="{Binding IsExportTab, Converter={StaticResource BoolToVisibility}}" />
Content="{l:Loc Editor.Preview.CropMask}" ToolTip="{l:Loc Tooltips.Editor.Preview.CropMask}" />
<!-- "What I lose" (dimmed) or "how it will look" (hidden) outside the crop (BRIEF §12.3). -->
<ToggleButton Visibility="{Binding ShowCropMask, Converter={StaticResource BoolToVisibility}}" Style="{StaticResource ToggleButton.PreviewToolIcon}"
IsChecked="{Binding IsCropResult}" ui:ButtonIcon.Glyph="{StaticResource Icon.Eye}" ToolTip="{Binding CropModeToolTip}"
AutomationProperties.Name="{l:Loc Editor.Preview.CropResult}" />
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
IsChecked="{Binding IsActualSize}" Content="{l:Loc Editor.Preview.ActualSize}" ToolTip="{l:Loc Tooltips.Editor.Preview.ActualSize}" />
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PreviewToolIcon}"
ui:ButtonIcon.Glyph="{StaticResource Icon.Fullscreen}" Click="OnFullScreen" ToolTip="{l:Loc Tooltips.Editor.Preview.FullScreen}"
AutomationProperties.Name="{l:Loc Editor.Preview.FullScreen}" />
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PlayTool}"
Command="{Binding PlayCommand}" ToolTip="{Binding PlayToolTip}" AutomationProperties.Name="{Binding PlayName}" />
<Button Content="{l:Loc Editor.Preview.Clip}" Command="{Binding PreviewClipCommand}" ToolTip="{Binding ClipToolTip}"
Visibility="{Binding IsExportTab, Converter={StaticResource BoolToVisibility}}">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource Button.PreviewTool}">
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Play}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsPlaying}" Value="True">
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Pause}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</StackPanel>
</v:PreviewViewport.ToolsContent>
</v:PreviewViewport>
<!-- The frame on screen cannot be read: one sentence instead of another frame's picture. -->
<TextBlock Text="{Binding PreviewMessage}" Style="{StaticResource Text.Secondary}" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False" Visibility="{Binding PreviewMessage, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<v:Filmstrip Grid.Row="1" Margin="0,10,0,0" Source="{Binding Thumbnails}" CurrentIndex="{Binding CurrentIndex, Mode=TwoWay}" Markers="{Binding Markers}"
AutomationProperties.Name="{l:Loc Editor.Filmstrip}" />
ToolTip="{l:Loc Tooltips.Editor.Filmstrip}" AutomationProperties.Name="{l:Loc Editor.Filmstrip}" />
<TabControl Grid.Row="2" Margin="0,10,0,0" ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab}" AutomationProperties.Name="{l:Loc Editor.Sections}">
<TabControl.Resources>
+51 -7
View File
@@ -4,6 +4,7 @@ using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Titano.App.Editor;
using Titano.App.Shell;
using Titano.Core.Diagnostics;
@@ -16,35 +17,54 @@ public partial class SequenceView : UserControl
private static readonly DependencyProperty SavesBeforeClosingProperty =
DependencyProperty.RegisterAttached("SavesBeforeClosing", typeof(bool), typeof(SequenceView), new PropertyMetadata(false));
public SequenceView() => InitializeComponent();
public SequenceView()
{
InitializeComponent();
// A drag, a click or a key press is one undo step even when it moves a slider many times (ProjectHistory runs);
// handled events too, because sliders and repeat buttons mark theirs handled.
EditorRoot.AddHandler(Thumb.DragCompletedEvent, new DragCompletedEventHandler((_, _) => EndEditRun()), handledEventsToo: true);
EditorRoot.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler((_, _) => EndEditRun()), handledEventsToo: true);
EditorRoot.AddHandler(KeyUpEvent, new KeyEventHandler((_, _) => EndEditRun()), handledEventsToo: true);
}
private EditorViewModel? Editor => (DataContext as SequenceViewModel)?.Editor;
/// <summary>
/// The project is saved a moment after each edit; closing the window first stores the last edit (once per window,
/// so the editor's save is kept even when another section is showing).
/// The project is saved a moment after each edit; closing the window first stores the last edit, and asks before
/// discarding one that cannot be stored (once per window, so it holds even when another section is showing).
/// </summary>
private void OnLoaded(object sender, RoutedEventArgs e)
{
FocusPreview();
if (Window.GetWindow(this) is not { } window || (bool)window.GetValue(SavesBeforeClosingProperty)) return;
window.SetValue(SavesBeforeClosingProperty, true);
var (saved, closed) = (false, false);
var (saved, asking, closed) = (false, false, false);
window.Closing += OnClosing;
window.Closed += (_, _) => closed = true;
async void OnClosing(object? s, CancelEventArgs args)
{
if (saved || args.Cancel || window.DataContext is not ShellViewModel { Sequence: { HasPendingSave: true } section }) return;
saved = true;
args.Cancel = true;
if (asking) return;
asking = true;
var close = true;
try
{
await section.CloseAsync();
close = await section.ConfirmCloseAsync();
if (close) await section.CloseAsync();
}
catch (Exception ex)
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("editor", "The last edit was not saved before closing", ex);
}
finally
{
asking = false;
}
// "Keep editing": the window stays open with the edit still pending.
if (!close) return;
saved = true;
// An application shutdown closes the window without waiting.
if (!closed) window.Close();
}
@@ -66,6 +86,29 @@ public partial class SequenceView : UserControl
e.Handled = true;
}
/// <summary>An opened editor takes the keyboard, so its shortcuts work without clicking into it first.</summary>
private void OnEditorVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue is true) FocusPreview();
}
/// <summary>A tool clicked with the mouse hands the keyboard back to the preview (Space keeps playing); keyboard users keep their focus.</summary>
private void OnToolClicked(object sender, RoutedEventArgs e)
{
if (InputManager.Current.MostRecentInputDevice is MouseDevice) Preview.Focus();
}
private void FocusPreview()
{
if (Editor is null) return;
Dispatcher.BeginInvoke(() =>
{
if (Preview.IsVisible && !IsKeyboardFocusWithin) Keyboard.Focus(Preview);
}, DispatcherPriority.Input);
}
private void EndEditRun() => Editor?.Session.EndEditRun();
/// <summary>The preview renders at the size it is shown, in device pixels.</summary>
private void OnPreviewSizeChanged(object sender, SizeChangedEventArgs e)
{
@@ -81,5 +124,6 @@ public partial class SequenceView : UserControl
var window = new FullScreenPreview(editor) { Owner = Window.GetWindow(this) };
window.ShowDialog();
editor.PreviewEdge = restore;
Preview.Focus();
}
}
+46 -8
View File
@@ -1,7 +1,7 @@
using System.ComponentModel;
using System.IO;
using System.Windows.Input;
using Titano.App.Editor;
using Titano.App.Infrastructure;
using Titano.App.Shell;
using Titano.Core.Diagnostics;
using Titano.Core.Export;
@@ -14,7 +14,8 @@ namespace Titano.App.Sections;
/// <summary>
/// The Sequence section (BRIEF §12.3): opens the sequence the Library (or Jobs) chose into an <see cref="EditorViewModel"/>
/// and closes the previous one after saving it; without a sequence it shows the empty state.
/// and closes the previous one after saving it; without a sequence it shows the empty state. A failed open is reported
/// and leaves the section usable; an edit that cannot be saved is never dropped without the user's confirmation.
/// </summary>
public sealed class SequenceViewModel : SectionViewModel
{
@@ -51,7 +52,7 @@ public sealed class SequenceViewModel : SectionViewModel
public bool IsEmpty => _editor is null && !_isLoading;
/// <summary>The open sequence has an edit not stored yet (the save follows each change after a moment).</summary>
/// <summary>The open sequence has an edit not stored yet (the save follows each change after a moment, and retries after a failure).</summary>
public bool HasPendingSave => _editor?.Session.HasPendingSave == true;
/// <summary>"Titano — Harbour sunset" while a sequence is open.</summary>
@@ -64,10 +65,30 @@ public sealed class SequenceViewModel : SectionViewModel
return _switch;
}
/// <summary>Saves and closes the open sequence.</summary>
/// <summary>
/// Stores the open sequence's last edit. When the save fails (archive offline, read-only, busy), asks whether to
/// discard the edit (BRIEF §12.1: modals only for destructive confirmations).
/// </summary>
/// <returns>True when the editor may close: everything is stored or the user chose to discard.</returns>
public async Task<bool> ConfirmCloseAsync()
{
if (Editor is not { } editor || await editor.Session.FlushAsync()) return true;
return Shell.Services.Dialogs.Confirm(new ConfirmRequest
{
Heading = Loc.L("Editor.Unsaved.Title"),
Message = Loc.L("Editor.Unsaved.Message", editor.Title, editor.Session.LastSaveError?.Message ?? string.Empty),
SafeText = Loc.L("Editor.Unsaved.Keep"),
SafeToolTip = Loc.L("Tooltips.Editor.Unsaved.Keep"),
ActionText = Loc.L("Editor.Unsaved.Discard"),
ActionToolTip = Loc.L("Tooltips.Editor.Unsaved.Discard"),
IsDestructive = true,
});
}
/// <summary>Closes the open sequence (after <see cref="ConfirmCloseAsync"/>, which stores its last edit).</summary>
public async Task CloseAsync()
{
await _switch;
await Settled(_switch);
if (Editor is not { } editor) return;
Editor = null;
_openId = null;
@@ -91,10 +112,25 @@ public sealed class SequenceViewModel : SectionViewModel
if (e.PropertyName == nameof(ShellViewModel.CurrentSequenceId) && IsSelected) OnActivated();
}
/// <summary>Waits for <paramref name="task"/>; its failure was reported where it happened.</summary>
private static async Task Settled(Task task)
{
try
{
await task;
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Debug("editor", $"An earlier open of the editor failed: {ex.Message}");
}
}
private async Task SwitchAsync(Task previous, Guid sequenceId)
{
await previous;
await Settled(previous);
if (sequenceId == _openId) return;
// The open sequence keeps its editor while its last edit is neither stored nor deliberately discarded.
if (!await ConfirmCloseAsync()) return;
var services = Shell.Services;
IsLoading = true;
OnPropertyChanged(nameof(IsEmpty));
@@ -117,9 +153,11 @@ public sealed class SequenceViewModel : SectionViewModel
Editor = editor;
await editor.AttachJobsAsync();
}
catch (Exception ex) when (ex is InvalidDataException or InvalidOperationException or IOException or UnauthorizedAccessException)
catch (Exception ex) when (ex is not OutOfMemoryException)
{
_openId = null;
// Whatever failed (index, decoder set-up, advisor, the job list), the section stays usable: an editor that
// opened stays open, otherwise the next Open tries again.
if (Editor is null) _openId = null;
Log.Warning("editor", $"Sequence {sequenceId} could not be opened", ex);
Shell.ReportError(ex);
}