Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

(feat) Delete several versions at once in the History tab (#228) (#413)

Asishdba99f68c9bb
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 38e30d35..5603abaf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Delete several versions at once** (#228): in the History tab, ⌘-click (Ctrl-click on
+ Windows and Linux) adds a version to the selection and Shift-click selects a run. With
+ more than one selected, the footer shows how many and when they were saved, and its
+ **Delete N versions…** button — or the same item in the right-click menu — deletes them
+ in one go, after one confirmation. The current version is never deleted: it stays, and the
+ footer says so.
- **Reset a note's velocity to the default**: in the piano roll's velocity lane, double-click a
note's stem — or right-click it and choose **Reset velocity** — to put the note back to the
default velocity (0.8, the one a first note gets). When the note is selected, the whole
diff --git a/FEATURES.md b/FEATURES.md
index d9b7ed8c..8a77f410 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -62,7 +62,8 @@ on a pool of render threads, export and freeze use every core, and an idle engin
- **Version history**: every save records a version inside the project. The browser's
**History** tab draws them as a branching tree (the current one has an orange dot), each
described by what it changed ("Added Bass · Tempo 120.00 → 124.00"); switch
- to any version, open one as a copy, or name, note, star and delete versions; a star button
+ to any version, open one as a copy, or name, note, star and delete versions (⌘/Ctrl-click and
+ Shift-click select several, deleted together from the footer or the context menu); a star button
in the tab's header lists starred versions only. Saving on top
of an older version branches. **Save Version with Note…** (⌥⌘S). The tab's menu deletes all
unnamed versions at once; Settings → Library turns history off (erasing it, after a warning). Versions share their
diff --git a/specs/069-history-multi-select/plan.md b/specs/069-history-multi-select/plan.md
new file mode 100644
index 00000000..5b25f11c
--- /dev/null
+++ b/specs/069-history-multi-select/plan.md
@@ -0,0 +1,44 @@
+# Implementation Plan: Delete several versions at once
+
+**Branch**: `069-history-multi-select` | **Date**: 2026-11-01 | **Spec**: [spec.md](spec.md)
+
+## Summary
+
+Switch the History tab's list to multiple selection and give a multiple selection its own
+footer and context menu, both offering **Delete N versions…**. Deleting reuses
+`IProjectHistory.DeleteMany`, which **Delete unnamed versions…** already uses, with one
+confirmation.
+
+## Technical Context
+
+**Language/Version**: C# / .NET 10, Avalonia.
+
+**Primary Dependencies**: none new.
+
+**Audio-Thread Impact**: None. The History tab runs on the UI thread, and deleting versions
+edits files in the project bundle the way the existing delete commands do.
+
+**Testing**: `HistoryTests` already cover `DeleteMany` (a batch holding the current version is
+refused whole; deleting a run links the survivors up and re-describes them); the design checks
+scan the new labels and menu; manual check in the running app (Ctrl/Shift-click, the
+selection's menu, the footer, the confirmation and the result).
+
+## Design
+
+- `HistoryView` — `_list` gets `SelectionMode.Multiple`. `Selected()` returns the selected
+ rows in list order and `Single()` the one row of a single selection.
+- `ShowSelection()` replaces the direct `ShowDetails` call. With more than one row selected,
+ `ShowMany()` builds the footer: the count, the saved time span, "The current version
+ stays." when the head is in the selection, and the delete button.
+- `ContextRequested` — a row inside a multiple selection opens `BuildManyMenu()` (MenuKit
+ header "N versions", a danger delete item); any other row is selected alone and opens its
+ usual `BuildMenu()`.
+- `DeleteSelected()` — a single version goes through the existing `Delete()`; several go
+ through one `ConfirmWindow` and one `DeleteMany()`, then the status bar reports the bytes
+ freed. The head is filtered out up front (`Deletable()`), so `DeleteMany` never refuses.
+- `Refresh()` — keeps every selected version that still exists selected.
+
+## Constitution Check
+
+UI-only, no engine change, no dependency, MenuKit header, sentence-case labels, destructive
+item in the danger ink.
diff --git a/specs/069-history-multi-select/spec.md b/specs/069-history-multi-select/spec.md
new file mode 100644
index 00000000..eecb04f4
--- /dev/null
+++ b/specs/069-history-multi-select/spec.md
@@ -0,0 +1,108 @@
+# Feature Specification: Delete several versions at once
+
+**Feature Branch**: `069-history-multi-select`
+
+**Created**: 2026-11-01
+
+**Status**: Implemented
+
+**Input**: GitHub issue nota-daw/nota#228: "The ability to select multiple versions with
+Ctrl+click and a range of versions with Shift+click and/or marquee selection would make it
+easier to delete a selection of versions with one action instead of deleting multiple
+versions one by one."
+
+## Nota Context
+
+**Feature area**:
+
+- [ ] Engine (C++, `src/native/nota.engine`)
+- [x] Managed app (C#, `src/managed/*`) — the History tab
+- [x] UI (Avalonia) — follow `DESIGN.md` (Studio)
+- [ ] Plugin hosting
+- [ ] Build / packaging / CI
+- [ ] Docs only
+
+**Nota docs to keep in mind**: [`ARCHITECTURE.md`](../../ARCHITECTURE.md),
+[`CONTRIBUTING.md`](../../CONTRIBUTING.md), [`DESIGN.md`](../../DESIGN.md),
+[`FEATURES.md`](../../FEATURES.md).
+
+**Existing behaviour this builds on**: the browser's History tab (`HistoryView`) lists the
+open project's versions as a tree. One version is selected at a time; its details and Switch /
+Open copy sit in the footer, and its context menu deletes it after a confirmation. The tab's
+options menu deletes every unnamed version at once. `IProjectHistory.DeleteMany` already
+deletes a batch of versions (refusing one that holds the current version), linking each
+survivor up to the nearest kept ancestor and freeing the audio only the deleted ones used.
+
+## User Scenarios & Testing
+
+### User Story 1 - Delete a hand-picked set of versions (Priority: P1)
+
+A producer's history holds dozens of versions; "Delete unnamed versions" keeps some they no
+longer want and deletes some they do. They pick the ones to go and delete them in one action.
+
+**Independent Test**: In a project with several versions, ⌘/Ctrl-click three of them, choose
+**Delete 3 versions…** in the footer and confirm; the three are gone, the rest of the tree is
+linked up, and the status bar reports how much was freed.
+
+**Acceptance Scenarios**:
+
+1. **Given** one version is selected, **When** the user ⌘/Ctrl-clicks another, **Then** both
+ are selected; ⌘/Ctrl-clicking a selected one deselects it.
+2. **Given** one version is selected, **When** the user Shift-clicks another, **Then** every
+ version between them is selected.
+3. **Given** more than one version is selected, **Then** the footer shows "N versions", the
+ time span they were saved in, and a **Delete N versions…** button.
+4. **When** the user right-clicks a selected row of a multiple selection, **Then** the menu is
+ headed "N versions" and offers **Delete N versions…**. Right-clicking a row outside the
+ selection selects just that row and shows its usual menu.
+5. **When** the user confirms the deletion, **Then** all the chosen versions are deleted in
+ one history edit and the status bar reads "Deleted N versions · X freed".
+
+### Edge Cases
+
+- **The current version is in the selection**: it can't be deleted. The footer says "The
+ current version stays.", the button and menu item count only the others, and the menu item
+ explains it in its tooltip. With only the current version and one other selected, the one
+ other version is deleted through the single-version confirmation.
+- **Only the current version would be deleted**: not possible — a selection of two always holds
+ another version.
+- **All saved in the same minute**: the time span shows that one time.
+- **Switch, double-click and Return** act on a single selected version only.
+- **A refresh** (save, star, rename) keeps every selected version that still exists selected.
+- **Starred only**: selecting and deleting work the same on the flat starred list.
+
+## Requirements
+
+### Functional Requirements
+
+- **FR-001**: The History list MUST support ⌘/Ctrl-click (toggle one) and Shift-click (a run)
+ selection; a plain click selects one version as before.
+- **FR-002**: With more than one version selected, the footer MUST show the count, the saved
+ time span and a delete button for them.
+- **FR-003**: The context menu of a row inside a multiple selection MUST act on the selection.
+- **FR-004**: Deleting MUST go through one confirmation and one `DeleteMany` call, and report
+ the bytes freed.
+- **FR-005**: The current version MUST NOT be deleted; the UI MUST say it stays.
+- **FR-006**: Labels MUST follow DESIGN.md (sentence case; destructive menu items in the
+ danger ink via the `danger` class).
+
+## Success Criteria
+
+- **SC-001**: Deleting N chosen versions takes one action and one confirmation, not N of each.
+
+## Assumptions
+
+- Marquee (drag) selection is not added: the issue asks for Ctrl- and Shift-click "and/or"
+ marquee, and the list's rows already take drags as clicks.
+- Batch star / name / note are out of scope; the issue is about deleting.
+- No change to `IProjectHistory`: `DeleteMany` and its smoke checks already cover the batch.
+
+## Nota Compliance Checklist
+
+- [x] Every new source file carries the AGPL-3.0-only SPDX header (no new source file)
+- [x] No new dependency
+- [x] Audio-thread impact: none — the History tab on the UI thread
+- [x] No new managed/native crossings
+- [x] Smoke-test impact: the batch delete is covered by `HistoryTests`; the design checks scan the new labels
+- [x] User-visible change → `CHANGELOG.md` `[Unreleased]` entry and FEATURES.md
+- [x] UI change → follows `DESIGN.md` (the footer's own layout, MenuKit header, danger delete item)
diff --git a/specs/069-history-multi-select/tasks.md b/specs/069-history-multi-select/tasks.md
new file mode 100644
index 00000000..b4e49cb3
--- /dev/null
+++ b/specs/069-history-multi-select/tasks.md
@@ -0,0 +1,15 @@
+# Tasks: Delete several versions at once
+
+**Input**: [spec.md](spec.md), [plan.md](plan.md)
+
+## Phase 1: User Story 1 — delete a hand-picked set (P1)
+
+- [x] T001 Multiple selection on the History list; Switch, double-click and Return act on a single selection; a refresh keeps the selection, in `src/managed/Nota.App/HistoryView.cs` (FR-001)
+- [x] T002 Footer for several versions — count, time span, "The current version stays.", Delete N versions… (FR-002, FR-005)
+- [x] T003 Context menu of a multiple selection, headed "N versions" (FR-003, FR-005, FR-006)
+- [x] T004 `DeleteSelected`: one confirmation, one `DeleteMany`, the freed bytes on the status bar (FR-004)
+
+## Phase 2: Polish
+
+- [x] T005 `CHANGELOG.md` `[Unreleased]` and `FEATURES.md` entries
+- [x] T006 `scripts/build-linux.sh` passes (engine, managed, smoke test incl. design checks)
diff --git a/src/managed/Nota.App/HistoryView.cs b/src/managed/Nota.App/HistoryView.cs
index 742e5a51..ded72173 100644
--- a/src/managed/Nota.App/HistoryView.cs
+++ b/src/managed/Nota.App/HistoryView.cs
@@ -5,7 +5,9 @@
// the way `git log --graph` draws branches (HistoryGraph lays it out). The current version
// carries a brass dot. Selecting a version shows its details in the footer with Switch and
// Open as copy; double-click switches; the context menu also renames, notes, stars and
-// deletes. Rebuilds whenever the window reports the history changed.
+// deletes. ⌘/Ctrl-click and Shift-click select several versions, which the footer and the
+// context menu then delete together (#228). Rebuilds whenever the window reports the
+// history changed.
using System;
using System.Collections.Generic;
@@ -42,7 +44,8 @@ internal sealed class HistoryView : UserControl
private readonly IProjectHistory _history;
private readonly IHistoryHost _host;
- private readonly ListBox _list = new() { Classes = { "browser" }, Padding = new Thickness(0, 0, 0, 6) };
+ // Multiple: a click selects one version, ⌘/Ctrl-click adds or removes one, Shift-click a run.
+ private readonly ListBox _list = new() { Classes = { "browser" }, Padding = new Thickness(0, 0, 0, 6), SelectionMode = SelectionMode.Multiple };
private readonly TextBlock _summary = new() { Classes = { "Mono" }, FontSize = 9, VerticalAlignment = VerticalAlignment.Center };
private readonly TextBlock _empty = new()
{
@@ -94,17 +97,24 @@ internal sealed class HistoryView : UserControl
_details.IsVisible = false;
_list.ItemTemplate = new Avalonia.Controls.Templates.FuncDataTemplate<HistoryRow>((row, _) => row is null ? new Control() : Row(row), supportsRecycling: false);
- _list.SelectionChanged += (_, _) => ShowDetails(_list.SelectedItem as HistoryRow);
- _list.DoubleTapped += (_, _) => { if (_list.SelectedItem is HistoryRow r && !r.IsHead) _ = Switch(r.Version); };
+ _list.SelectionChanged += (_, _) => ShowSelection();
+ _list.DoubleTapped += (_, _) => { if (Single() is { IsHead: false } r) _ = Switch(r.Version); };
_list.KeyDown += (_, e) =>
{
- if (e.Key == Key.Enter && _list.SelectedItem is HistoryRow { IsHead: false } r) { _ = Switch(r.Version); e.Handled = true; }
+ if (e.Key == Key.Enter && Single() is { IsHead: false } r) { _ = Switch(r.Version); e.Handled = true; }
};
_list.ContextRequested += (_, e) =>
{
if ((e.Source as StyledElement)?.DataContext is not HistoryRow row) return;
- _list.SelectedItem = row;
- BuildMenu(row).ShowAt(_list, showAtPointer: true);
+ // A right-click inside a multiple selection acts on all of it; anywhere else it
+ // selects the row under the pointer, as before.
+ var selected = Selected();
+ if (selected.Count > 1 && selected.Contains(row)) BuildManyMenu(selected).ShowAt(_list, showAtPointer: true);
+ else
+ {
+ _list.SelectedItem = row;
+ BuildMenu(row).ShowAt(_list, showAtPointer: true);
+ }
e.Handled = true;
};
@@ -124,7 +134,7 @@ internal sealed class HistoryView : UserControl
/// <summary>Re-reads the open project's history (after a save, switch, open or new).</summary>
public void Refresh()
{
- string? keep = (_list.SelectedItem as HistoryRow)?.Version.Id;
+ var keep = Selected().Select(r => r.Version.Id).ToHashSet();
_dir = _host.ProjectPath;
string? problem = null;
_state = ProjectHistoryState.Empty;
@@ -144,8 +154,9 @@ internal sealed class HistoryView : UserControl
.ToList()
: all;
_list.ItemsSource = rows;
- _list.SelectedItem = rows.FirstOrDefault(r => r.Version.Id == keep);
- ShowDetails(_list.SelectedItem as HistoryRow);
+ for (int i = 0; i < rows.Count; i++)
+ if (keep.Contains(rows[i].Version.Id)) _list.Selection.Select(i);
+ ShowSelection();
_empty.Text = problem
?? (_dir is null ? Loc.T("Save the project to start its history.")
@@ -239,6 +250,29 @@ internal sealed class HistoryView : UserControl
}
}
+ // --- selection -----------------------------------------------------------
+
+ /// <summary>The selected rows, newest first (list order).</summary>
+ private List<HistoryRow> Selected()
+ {
+ var rows = _list.ItemsSource as IReadOnlyList<HistoryRow> ?? [];
+ return _list.Selection.SelectedIndexes.Where(i => i >= 0 && i < rows.Count).Order().Select(i => rows[i]).ToList();
+ }
+
+ /// <summary>The selected row when exactly one is selected.</summary>
+ private HistoryRow? Single()
+ {
+ var selected = Selected();
+ return selected.Count == 1 ? selected[0] : null;
+ }
+
+ private void ShowSelection()
+ {
+ var selected = Selected();
+ if (selected.Count > 1) ShowMany(selected);
+ else ShowDetails(selected.Count == 1 ? selected[0] : null);
+ }
+
// --- details footer ------------------------------------------------------
private void ShowDetails(HistoryRow? row)
@@ -293,6 +327,35 @@ internal sealed class HistoryView : UserControl
_details.Child = stack;
}
+ // Several versions selected: how many, when they were saved, and one button that deletes
+ // them. The current version is never deleted, so a selection holding it says it stays.
+ private void ShowMany(IReadOnlyList<HistoryRow> rows)
+ {
+ _details.IsVisible = true;
+ var deletable = Deletable(rows);
+
+ var name = new TextBlock { Text = Loc.Plural(rows.Count, "{0} version", "{0} versions"), Classes = { "Name" }, TextTrimming = TextTrimming.CharacterEllipsis };
+ name.BindResource(TextBlock.ForegroundProperty, "Brush.TextPrimary");
+ string first = LongTime(rows.Min(r => r.Version.CreatedAt)), last = LongTime(rows.Max(r => r.Version.CreatedAt));
+ var metaText = new TextBlock { Text = first == last ? first : $"{first} – {last}", Classes = { "Value" }, TextWrapping = TextWrapping.Wrap };
+ metaText.BindResource(TextBlock.ForegroundProperty, "Brush.TextSecondary");
+ var stack = new StackPanel { Spacing = 4, Children = { name, metaText } };
+ if (deletable.Count < rows.Count)
+ stack.Children.Add(new TextBlock { Text = Loc.T("The current version stays."), Classes = { "Caption" }, TextWrapping = TextWrapping.Wrap });
+
+ var deleteBtn = new Button
+ {
+ Content = ButtonText(DeleteManyLabel(deletable.Count)),
+ IsEnabled = deletable.Count > 0,
+ HorizontalAlignment = HorizontalAlignment.Stretch, HorizontalContentAlignment = HorizontalAlignment.Center,
+ Margin = new Thickness(0, 4, 0, 0),
+ };
+ ToolTip.SetTip(deleteBtn, Loc.T("Delete the selected versions and the audio only they use"));
+ deleteBtn.Click += (_, _) => _ = DeleteSelected(deletable);
+ stack.Children.Add(deleteBtn);
+ _details.Child = stack;
+ }
+
// Button captions trim instead of the button clipping when the browser is narrow.
private static TextBlock ButtonText(string text) => new() { Text = text, TextTrimming = TextTrimming.CharacterEllipsis };
@@ -334,6 +397,27 @@ internal sealed class HistoryView : UserControl
return menu;
}
+ // The context menu of a multiple selection: delete them all (the current version stays).
+ private MenuFlyout BuildManyMenu(IReadOnlyList<HistoryRow> rows)
+ {
+ var deletable = Deletable(rows);
+ var menu = new MenuFlyout();
+ menu.Items.Add(MenuKit.Header(Loc.Plural(rows.Count, "{0} version", "{0} versions"), null, ""));
+ menu.Items.Add(new Separator());
+ var del = new MenuItem { Header = DeleteManyLabel(deletable.Count), Icon = MenuKit.Icon(GlyphKind.Trash), IsEnabled = deletable.Count > 0 };
+ del.Classes.Add("danger");
+ if (deletable.Count < rows.Count) ToolTip.SetTip(del, Loc.T("The current version stays"));
+ del.Click += (_, _) => _ = DeleteSelected(deletable);
+ menu.Items.Add(del);
+ return menu;
+ }
+
+ // Every selected version but the current one, which can't be deleted.
+ private static List<ProjectVersion> Deletable(IEnumerable<HistoryRow> rows)
+ => rows.Where(r => !r.IsHead).Select(r => r.Version).ToList();
+
+ private static string DeleteManyLabel(int count) => count == 1 ? Loc.T("Delete version…") : Loc.Plural(count, "Delete {0} version…", "Delete {0} versions…");
+
private MenuFlyout BuildOptionsMenu()
{
var menu = new MenuFlyout();
@@ -372,6 +456,19 @@ internal sealed class HistoryView : UserControl
_host.ReportStatus(Loc.F("{0} · {1} freed", Loc.Plural(versions.Count, "Deleted {0} version", "Deleted {0} versions"), NotaNum.Bytes(freed)));
}
+ private async Task DeleteSelected(IReadOnlyList<ProjectVersion> versions)
+ {
+ if (versions.Count == 1) { await Delete(versions[0]); return; }
+ if (TopLevel.GetTopLevel(this) is not Window owner || _dir is null || versions.Count == 0) return;
+ bool ok = await new ConfirmWindow(Loc.T("Delete versions"),
+ Loc.Plural(versions.Count, "Delete {0} version? Audio that only it uses is deleted from the project folder too. This can't be undone.", "Delete {0} versions? Audio that only they use is deleted from the project folder too. This can't be undone."),
+ Loc.T("Delete"), Loc.T("Cancel")).ShowDialog<bool>(owner);
+ if (!ok) return;
+ long freed = 0;
+ Apply(() => freed = _history.DeleteMany(_dir, versions.Select(v => v.Id).ToList()));
+ _host.ReportStatus(Loc.F("{0} · {1} freed", Loc.Plural(versions.Count, "Deleted {0} version", "Deleted {0} versions"), NotaNum.Bytes(freed)));
+ }
+
private async Task Prompt(string title, string prompt, string? initial, Action<string> apply)
{
if (TopLevel.GetTopLevel(this) is not Window owner) return;
diff --git a/src/managed/Nota.App/Languages/fr.json b/src/managed/Nota.App/Languages/fr.json
index eb5a9512..d3ad22db 100644
--- a/src/managed/Nota.App/Languages/fr.json
+++ b/src/managed/Nota.App/Languages/fr.json
@@ -3645,6 +3645,18 @@
"Delete {0} unnamed versions…": {
"one": "Supprimer {0} version sans nom…",
"other": "Supprimer {0} versions sans nom…"
+ },
+ "The current version stays.": "La version actuelle reste.",
+ "Delete the selected versions and the audio only they use": "Supprimer les versions sélectionnées et l’audio que seules elles utilisent",
+ "The current version stays": "La version actuelle reste",
+ "Delete {0} versions…": {
+ "one": "Supprimer {0} version…",
+ "other": "Supprimer {0} versions…"
+ },
+ "Delete versions": "Supprimer les versions",
+ "Delete {0} versions? Audio that only they use is deleted from the project folder too. This can't be undone.": {
+ "one": "Supprimer {0} version ? L’audio qu’elle seule utilise est aussi supprimé du dossier du projet. Cette action est irréversible.",
+ "other": "Supprimer {0} versions ? L’audio que seules elles utilisent est aussi supprimé du dossier du projet. Cette action est irréversible."
}
}
}