Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(feat) Describe what each project version changed
Egor Khindikaynen51489eed081f
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.mdindex c926d8d4..f2cb925a 100644--- a/ARCHITECTURE.md+++ b/ARCHITECTURE.md@@ -180,6 +180,9 @@ Checking a version out writes its top-level files back (manifest last) and movesthe next save on top of an older version branches. A save's prune keeps every binary someversion references, and prunes nothing if the history can't be read. Deleting a versionre-parents its children and collects objects and binaries nothing needs any more.+Each version also stores what it changed against its parent (`VersionDiff`, from the two+manifests: tracks added / removed / renamed, tempo, meter, and per track arrangement, sound+or mix), which the History tab words via `VersionSummary`.`analysis/` holds a cache of imported audio — each file's waveform overview (min/max per512 frames) and detected tempo, as `<content fingerprint>.npk` — so re-importing a filediff --git a/CHANGELOG.md b/CHANGELOG.mdindex 31997766..2eeec13c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -22,7 +22,8 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.- **Version history:** every save keeps a version of the project, and the new **History**tab in the browser shows them as a tree. Switch back to any version, or open one as aseparate copy; saving on top of an older version starts a new branch, so nothing is lost.- Name, note, star and delete versions from the right-click menu. **File → Save Version with+ Each version describes itself — "Added Bass · Tempo 120.00 → 124.00", "Mix of Vocals" — so+ the list reads without notes. Name, note, star and delete versions from the right-click menu. **File → Save Version withNote…** (⌥⌘S) asks what changed. Versions share their audio, so a version costs only what itadds. **Save As** takes the whole history to the new project.diff --git a/FEATURES.md b/FEATURES.mdindex a2ca1707..ffa51535 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -46,7 +46,8 @@ JUCE module; the engine core is JUCE-free.- **Project**: create / open / save (`.nota`), autosaves, undo/redo for every editingoperation.- **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 a brass dot); switch+ **History** tab draws them as a branching tree (the current one has a brass dot), each+ described by what it changed ("Added Bass · Tempo 120.00 → 124.00"); switchto any version, open one as a copy, or name, note, star and delete versions. Saving on topof an older version branches. **Save Version with Note…** (⌥⌘S). Versions share theiraudio, so each costs only what it adds; **Save As** carries the history along.diff --git a/src/managed/Nota.App/HistoryView.cs b/src/managed/Nota.App/HistoryView.csindex ca86ed6f..57a84334 100644--- a/src/managed/Nota.App/HistoryView.cs+++ b/src/managed/Nota.App/HistoryView.cs@@ -163,7 +163,10 @@ internal sealed class HistoryView : UserControl}Grid.SetColumn(when, 4);grid.Children.Add(when);- ToolTip.SetTip(grid, v.Note is { Length: > 0 } note ? $"{Title(v)} · {note}" : Title(v));+ var tip = new List<string> { Title(v) };+ if (Changes(v) is { Length: > 0 } changes && changes != Title(v)) tip.Add(changes);+ if (v.Note is { Length: > 0 } note && note != Title(v)) tip.Add(note);+ ToolTip.SetTip(grid, string.Join("\n", tip));return grid;}@@ -212,6 +215,12 @@ internal sealed class HistoryView : UserControlmetaText.BindResource(TextBlock.ForegroundProperty, "Brush.TextSecondary");var stack = new StackPanel { Spacing = 4, Children = { name, metaText } };+ if (Changes(v) is { Length: > 0 } changes && changes != Title(v))+ {+ var what = new TextBlock { Text = changes, Classes = { "Caption" }, TextWrapping = TextWrapping.Wrap, MaxHeight = 48 };+ what.BindResource(TextBlock.ForegroundProperty, "Brush.TextSecondary");+ stack.Children.Add(what);+ }if (v.Note is { Length: > 0 } note && note != Title(v)) // the title already shows a one-line notestack.Children.Add(new TextBlock { Text = note, Classes = { "Caption" }, TextWrapping = TextWrapping.Wrap, MaxHeight = 64 });if (!v.CanOpen)@@ -311,9 +320,15 @@ internal sealed class HistoryView : UserControl// --- text ----------------------------------------------------------------- // The row's name: the label, else the note's first line, else its number in save order.+ // The row's name: the label, else the note's first line, else what changed, else its+ // number in save order.private string Title(ProjectVersion v)- => v.Label ?? v.Note?.Split('\n')[0] ?? (_numbers.TryGetValue(v.Id, out int n) ? $"Version {n}" : "Version");+ => v.Label ?? v.Note?.Split('\n')[0] ?? VersionSummary.Headline(v.Changes, NotaNum.Bpm)+ ?? (_numbers.TryGetValue(v.Id, out int n) ? $"Version {n}" : "Version");++ // Everything the version changed, as one line ("" when unknown or nothing nameable).+ private static string Changes(ProjectVersion v)+ => v.Changes is null ? "" : string.Join(" · ", VersionSummary.Parts(v.Changes, NotaNum.Bpm));// "14:32" today, "1 Oct" this year, "1 Oct 2025" before.private static string ShortTime(DateTimeOffset t)diff --git a/src/managed/Nota.Application/Ports/IProjectHistory.cs b/src/managed/Nota.Application/Ports/IProjectHistory.csindex d295c540..007cba34 100644--- a/src/managed/Nota.Application/Ports/IProjectHistory.cs+++ b/src/managed/Nota.Application/Ports/IProjectHistory.cs@@ -3,6 +3,41 @@namespace Nota.Application;+/// <summary>A track renamed between two versions.</summary>+public sealed record TrackRename(string From, string To);++/// <summary>What a version changed against its parent, worked out from the two manifests+/// when it is recorded. Track names stand for tracks; "Master" for the master bus. The+/// History tab turns it into a one-line description ("Added Bass · Tempo 120.00 → 124.00").</summary>+public sealed record VersionChanges+{+ /// <summary>The first version: no parent to compare with.</summary>+ public bool First { get; init; }+ public int TrackCount { get; init; }+ public IReadOnlyList<string> TracksAdded { get; init; } = [];+ public IReadOnlyList<string> TracksRemoved { get; init; } = [];+ public IReadOnlyList<TrackRename> TracksRenamed { get; init; } = [];+ public double? TempoFrom { get; init; }+ public double? TempoTo { get; init; }+ /// <summary>Time signature before / after ("4/4").</summary>+ public string? MeterFrom { get; init; }+ public string? MeterTo { get; init; }+ /// <summary>Tracks whose clips, notes, session slots or automation changed.</summary>+ public IReadOnlyList<string> Edited { get; init; } = [];+ /// <summary>Tracks whose instrument, devices or modulation changed.</summary>+ public IReadOnlyList<string> Sound { get; init; } = [];+ /// <summary>Tracks whose volume, pan, mute, solo or sends changed.</summary>+ public IReadOnlyList<string> Mix { get; init; } = [];+ /// <summary>Audio files no earlier version of this branch had (recordings, imports, bounces).</summary>+ public int NewAudio { get; init; }+ /// <summary>Other parts of the project that changed: "sections", "midi map", "layout", "freeze".</summary>+ public IReadOnlyList<string> Other { get; init; } = [];++ public bool IsEmpty => !First && TracksAdded.Count == 0 && TracksRemoved.Count == 0 && TracksRenamed.Count == 0+ && TempoTo is null && MeterTo is null && Edited.Count == 0 && Sound.Count == 0+ && Mix.Count == 0 && NewAudio == 0 && Other.Count == 0;+}+/// <summary>One saved version of a project — a node of the history tree.</summary>/// <param name="Parent">The version this one was saved on top of (null for the root).</param>/// <param name="AddedBytes">Disk space this version added when it was saved (new audio,@@ -12,7 +47,11 @@ namespace Nota.Application;public sealed record ProjectVersion(string Id, string? Parent, DateTimeOffset CreatedAt,string? Label, string? Note, bool Starred,- string AppVersion, int ProjectFormat, long AddedBytes, bool CanOpen);+ string AppVersion, int ProjectFormat, long AddedBytes, bool CanOpen)+{+ /// <summary>What changed against the parent; null when it couldn't be worked out.</summary>+ public VersionChanges? Changes { get; init; }+}/// <summary>A project's history: every version (oldest first) and the one the working/// copy was last saved as or switched to.</summary>diff --git a/src/managed/Nota.Infrastructure/Persistence/ProjectHistory.cs b/src/managed/Nota.Infrastructure/Persistence/ProjectHistory.csindex e72380e2..2cce9baa 100644--- a/src/managed/Nota.Infrastructure/Persistence/ProjectHistory.cs+++ b/src/managed/Nota.Infrastructure/Persistence/ProjectHistory.cs@@ -74,6 +74,8 @@ public sealed partial class ProjectHistory : IProjectHistorypublic SortedDictionary<string, string> Files { get; set; } = new(StringComparer.Ordinal);/// <summary>Bundle-relative binaries the manifest references (samples/…, plugin-states/…).</summary>public List<string> Binaries { get; set; } = new();+ /// <summary>What changed against the parent (null for versions recorded before this existed).</summary>+ public VersionChanges? Changes { get; set; }}// --- IProjectHistory ---------------------------------------------------@@ -84,6 +86,7 @@ public sealed partial class ProjectHistory : IProjectHistory{var doc = Load(bundleDir);if (doc is null) return ProjectHistoryState.Empty;+ Backfill(bundleDir, doc);return new ProjectHistoryState(doc.Versions.Select(ToVersion).ToList(), doc.Head);}}@@ -117,6 +120,8 @@ public sealed partial class ProjectHistory : IProjectHistoryAddedBytes = added,Files = snap.Files,Binaries = snap.Binaries,+ Changes = Changes(bundleDir, head, snap.Files, snap.Binaries,+ snap.Contents.GetValueOrDefault(snap.Files[ProjectService.ManifestName])),};doc.Versions.Add(node);doc.Head = node.Id;@@ -460,7 +465,47 @@ public sealed partial class ProjectHistory : IProjectHistoryprivate static ProjectVersion ToVersion(Node n)=> new(n.Id, n.Parent, n.CreatedAt, n.Label, n.Note, n.Starred, n.AppVersion, n.ProjectFormat, n.AddedBytes,- CanOpen: n.ProjectFormat <= ProjectService.CurrentFormatVersion);+ CanOpen: n.ProjectFormat <= ProjectService.CurrentFormatVersion) { Changes = n.Changes };++ // --- change summaries --------------------------------------------------++ // What `files` + `binaries` (a version's content; `manifest` its project.json bytes)+ // changed against `parent`. Null if a manifest can't be read.+ private static VersionChanges? Changes(string bundleDir, Node? parent, IReadOnlyDictionary<string, string> files,+ IReadOnlyCollection<string> binaries, byte[]? manifest)+ {+ try+ {+ manifest ??= files.TryGetValue(ProjectService.ManifestName, out var h) ? ReadObject(bundleDir, h) : null;+ if (manifest is null) return null;+ var after = JsonNode.Parse(manifest);+ if (parent is null) return VersionDiff.First(after);+ var before = parent.Files.TryGetValue(ProjectService.ManifestName, out var ph) && ReadObject(bundleDir, ph) is { } pb+ ? JsonNode.Parse(pb) : null;+ if (before is null) return null;+ var changedFiles = files.Keys.Union(parent.Files.Keys)+ .Where(f => f != ProjectService.ManifestName+ && files.GetValueOrDefault(f) != parent.Files.GetValueOrDefault(f));+ var known = parent.Binaries.ToHashSet(StringComparer.Ordinal);+ int newAudio = binaries.Count(b => b.StartsWith(BundleContent.SamplesDir + "/", StringComparison.Ordinal) && !known.Contains(b));+ return VersionDiff.Compare(before, after, changedFiles, newAudio);+ }+ catch (Exception e) when (e is JsonException or IOException or InvalidOperationException) { return null; }+ }++ // Versions recorded before change summaries existed get one now (once: it is stored).+ private static void Backfill(string bundleDir, HistoryDoc doc)+ {+ bool any = false;+ foreach (var n in doc.Versions.Where(v => v.Changes is null))+ {+ n.Changes = Changes(bundleDir, Find(doc, n.Parent), n.Files, n.Binaries, manifest: null);+ any |= n.Changes is not null;+ }+ if (!any) return;+ try { Store(bundleDir, doc); }+ catch (Exception e) when (e is IOException or UnauthorizedAccessException) { /* read-only: work it out again next time */ }+ }private static string NewId(HistoryDoc doc){diff --git a/src/managed/Nota.Infrastructure/Persistence/VersionDiff.cs b/src/managed/Nota.Infrastructure/Persistence/VersionDiff.csnew file mode 100644index 00000000..5ba818f4--- /dev/null+++ b/src/managed/Nota.Infrastructure/Persistence/VersionDiff.cs@@ -0,0 +1,143 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// What a project version changed against its parent, from the two manifests (raw JSON, so+// it works across format versions): tracks added / removed / renamed, tempo and meter, and+// per track whether the arrangement (clips, notes, automation), the sound (instrument,+// devices, modulation) or the mix (volume, pan, mute, solo, sends) moved. Tracks have no+// stable id in the manifest, so they are matched by type + name, nearest position first.++using System;+using System.Collections.Generic;+using System.IO;+using System.Linq;+using System.Text.Json.Nodes;++namespace Nota.Infrastructure;++internal static class VersionDiff+{+ private static readonly string[] EditKeys = ["midiClips", "audioClips", "sessionSlots", "automation"];+ private static readonly string[] SoundKeys = ["instrument", "midiEffects", "devices", "modulators", "cvLinks", "frozenState"];+ private static readonly string[] MixKeys = ["volume", "pan", "mute", "solo", "sends"];++ // Sidecars a user would recognise, by file name.+ private static readonly Dictionary<string, string> OtherNames = new(StringComparer.Ordinal)+ {+ ["sections.json"] = "sections",+ ["midimap.json"] = "MIDI map",+ ["modular-layout.json"] = "modular layout",+ ["freeze-links.json"] = "freeze",+ };++ /// <summary>The first version of a project.</summary>+ public static VersionChanges First(JsonNode? manifest)+ => new() { First = true, TrackCount = Tracks(manifest).Count };++ /// <param name="changedFiles">Top-level files (besides the manifest) whose content differs.</param>+ /// <param name="newAudio">Samples the parent didn't reference.</param>+ public static VersionChanges Compare(JsonNode? before, JsonNode? after, IEnumerable<string> changedFiles, int newAudio)+ {+ var oldTracks = Tracks(before);+ var newTracks = Tracks(after);++ // Pair tracks of the same type and name, preferring the closest position.+ var pairs = new List<(JsonObject Old, JsonObject New)>();+ var freeOld = Enumerable.Range(0, oldTracks.Count).ToList();+ var addedIdx = new List<int>();+ for (int n = 0; n < newTracks.Count; n++)+ {+ int match = freeOld+ .Where(o => Key(oldTracks[o]) == Key(newTracks[n]))+ .OrderBy(o => Math.Abs(o - n))+ .DefaultIfEmpty(-1).First();+ if (match < 0) { addedIdx.Add(n); continue; }+ freeOld.Remove(match);+ pairs.Add((oldTracks[match], newTracks[n]));+ }++ // An added and a removed track of the same type at the same position is a rename.+ var renamed = new List<TrackRename>();+ foreach (int n in addedIdx.ToList())+ {+ int o = freeOld.FirstOrDefault(i => i == n && Type(oldTracks[i]) == Type(newTracks[n]), -1);+ if (o < 0) continue;+ renamed.Add(new TrackRename(Name(oldTracks[o], o), Name(newTracks[n], n)));+ pairs.Add((oldTracks[o], newTracks[n]));+ freeOld.Remove(o);+ addedIdx.Remove(n);+ }++ var edited = new List<string>();+ var sound = new List<string>();+ var mix = new List<string>();+ foreach (var (o, n) in pairs)+ {+ string name = Name(n, newTracks.IndexOf(n));+ if (Differs(o, n, EditKeys)) edited.Add(name);+ if (Differs(o, n, SoundKeys)) sound.Add(name);+ if (Differs(o, n, MixKeys)) mix.Add(name);+ }+ // The master bus: its devices, volume and volume automation.+ if (!JsonNode.DeepEquals(before?["master"]?["devices"], after?["master"]?["devices"])) sound.Add("Master");+ if (!Same(before?["transport"]?["masterVolume"], after?["transport"]?["masterVolume"])) mix.Add("Master");+ if (!JsonNode.DeepEquals(before?["masterVolumeAutomation"], after?["masterVolumeAutomation"])) edited.Add("Master");++ double? bpmBefore = Num(before?["transport"]?["bpm"]), bpmAfter = Num(after?["transport"]?["bpm"]);+ bool tempo = bpmBefore is { } b && bpmAfter is { } a && Math.Abs(a - b) > 1e-6;+ string? meterBefore = Meter(before), meterAfter = Meter(after);+ bool meter = meterBefore != meterAfter;++ return new VersionChanges+ {+ TrackCount = newTracks.Count,+ TracksAdded = addedIdx.Select(i => Name(newTracks[i], i)).ToList(),+ TracksRemoved = freeOld.Select(i => Name(oldTracks[i], i)).ToList(),+ TracksRenamed = renamed,+ TempoFrom = tempo ? bpmBefore : null,+ TempoTo = tempo ? bpmAfter : null,+ MeterFrom = meter ? meterBefore : null,+ MeterTo = meter ? meterAfter : null,+ Edited = edited,+ Sound = sound,+ Mix = mix,+ NewAudio = newAudio,+ Other = changedFiles+ .Select(f => OtherNames.TryGetValue(f, out var label) ? label : Path.GetFileNameWithoutExtension(f))+ .Distinct().ToList(),+ };+ }++ private static List<JsonObject> Tracks(JsonNode? manifest)+ => (manifest?["tracks"] as JsonArray)?.OfType<JsonObject>().ToList() ?? new();++ private static int Type(JsonObject t) => (int)(Num(t["type"]) ?? 0);++ private static string Key(JsonObject t) => $"{Type(t)}|{t["name"]?.GetValue<string>()}";++ // A track's display name; unnamed ones are called by kind and position, as the app does.+ private static string Name(JsonObject t, int index)+ => t["name"]?.GetValue<string>() is { Length: > 0 } n ? n+ : (Type(t) switch { 0 => "Audio", 2 => "Return", 3 => "Group", _ => "MIDI" }) + " " + (index + 1);++ private static bool Differs(JsonObject a, JsonObject b, string[] keys)+ => keys.Any(k => !Same(a[k], b[k]));++ // Equal JSON, treating a missing value and its default (null / false / 0 / empty list) alike.+ private static bool Same(JsonNode? a, JsonNode? b) => JsonNode.DeepEquals(Normal(a), Normal(b));++ private static JsonNode? Normal(JsonNode? n) => n switch+ {+ JsonArray { Count: 0 } => null,+ JsonValue v when v.TryGetValue(out bool flag) && !flag => null,+ _ => n,+ };++ private static double? Num(JsonNode? n) => n is JsonValue v && v.TryGetValue(out double d) ? d : null;++ private static string? Meter(JsonNode? manifest)+ {+ var t = manifest?["transport"];+ return t is null ? null : $"{Num(t["timeSigNumerator"]) ?? 4}/{Num(t["timeSigDenominator"]) ?? 4}";+ }+}diff --git a/src/managed/Nota.Presentation/ViewModels/VersionSummary.cs b/src/managed/Nota.Presentation/ViewModels/VersionSummary.csnew file mode 100644index 00000000..694d3ad4--- /dev/null+++ b/src/managed/Nota.Presentation/ViewModels/VersionSummary.cs@@ -0,0 +1,46 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Words for what a project version changed ("Added Bass · Tempo 120.00 → 124.00 · Edited+// Lead"), most telling first, for the History tab's rows and details.++using Nota.Application;++namespace Nota.Presentation;++public static class VersionSummary+{+ /// <summary>The changes as short phrases, most telling first. Empty when nothing a user+ /// would name changed (a transport toggle, a plug-in's window size).</summary>+ /// <param name="tempo">Formats a tempo (the app's fixed-precision BPM).</param>+ public static IReadOnlyList<string> Parts(VersionChanges c, Func<double, string> tempo)+ {+ var parts = new List<string>();+ if (c.First)+ {+ parts.Add(c.TrackCount == 0 ? "First save" : $"First save · {Count(c.TrackCount, "track")}");+ return parts;+ }+ if (c.TracksAdded.Count > 0) parts.Add("Added " + Names(c.TracksAdded));+ if (c.TracksRemoved.Count > 0) parts.Add("Removed " + Names(c.TracksRemoved));+ foreach (var r in c.TracksRenamed.Take(2)) parts.Add($"{r.From} → {r.To}");+ if (c.TempoFrom is { } tf && c.TempoTo is { } tt) parts.Add($"Tempo {tempo(tf)} → {tempo(tt)}");+ if (c.MeterFrom is { } mf && c.MeterTo is { } mt) parts.Add($"{mf} → {mt}");+ if (c.NewAudio > 0) parts.Add(c.NewAudio == 1 ? "New audio" : $"{c.NewAudio} new audio files");+ if (c.Edited.Count > 0) parts.Add("Edited " + Names(c.Edited));+ if (c.Sound.Count > 0) parts.Add("Devices on " + Names(c.Sound));+ if (c.Mix.Count > 0) parts.Add(c.Mix.Count > 2 ? $"Mix of {Count(c.Mix.Count, "track")}" : "Mix of " + Names(c.Mix));+ foreach (var o in c.Other) parts.Add(char.ToUpperInvariant(o[0]) + o[1..]);+ return parts;+ }++ /// <summary>A row-length headline: the first two phrases, or null when there are none.</summary>+ public static string? Headline(VersionChanges? c, Func<double, string> tempo)+ => c is null ? null : Parts(c, tempo) is { Count: > 0 } p ? string.Join(" · ", p.Take(2)) : null;++ // "Bass", "Bass, Pad", "Bass, Pad +3".+ private static string Names(IReadOnlyList<string> names)+ => names.Count <= 2 ? string.Join(", ", names) : $"{names[0]}, {names[1]} +{names.Count - 2}";++ private static string Count(int n, string noun) => $"{n} {noun}{(n == 1 ? "" : "s")}";+}diff --git a/tests/Nota.SmokeTest/HistoryTests.cs b/tests/Nota.SmokeTest/HistoryTests.csindex 0d9d8bc6..e6949e53 100644--- a/tests/Nota.SmokeTest/HistoryTests.cs+++ b/tests/Nota.SmokeTest/HistoryTests.cs@@ -9,6 +9,7 @@using Nota.Application;using Nota.Infrastructure;+using Nota.Presentation;namespace Nota.SmokeTest;@@ -43,6 +44,76 @@ internal static class HistoryTests"a child is never drawn below its parent");}+ /// <summary>What each version changed (VersionDiff) and how it reads (VersionSummary).</summary>+ public static IEnumerable<(bool Ok, string Label)> RunSummary()+ {+ string tmp = Path.GetTempPath();+ string wav = Path.Combine(tmp, "nota_smoke_summary_sine.wav");+ WavWriter.WriteSine(wav, seconds: 0.5, freq: 440, sampleRate: 44100);+ string dir = Path.Combine(tmp, "nota-smoke-summary-" + Guid.NewGuid().ToString("N") + ".nota");+ IProjectHistory history = new ProjectHistory("0.0.0-test");+ static string Bpm(double b) => b.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture);+ try+ {+ using var e = new NotaEngine();+ double bpm = 120;+ VersionChanges Step(Action edit)+ {+ edit();+ ProjectService.Save(ProjectService.Capture(e, new TransportState(bpm, 1.0, false, false), new List<string>()), dir, e);+ return history.Commit(dir)!.Changes!;+ }++ int lead = e.AddInstrumentTrack();+ var c1 = Step(() => e.SetTrackName(lead, "Lead"));+ yield return (c1 is { First: true, TrackCount: 1 } && VersionSummary.Headline(c1, Bpm) == "First save · 1 track",+ $"the first version reads \"{VersionSummary.Headline(c1, Bpm)}\"");++ int bass = 0;+ var c2 = Step(() => { bass = e.AddInstrumentTrack(); e.SetTrackName(bass, "Bass"); bpm = 124; });+ yield return (c2.TracksAdded.SequenceEqual(["Bass"]) && c2.TempoFrom == 120 && c2.TempoTo == 124 && c2.Edited.Count == 0,+ $"an added track and a tempo change are seen ({string.Join(" · ", VersionSummary.Parts(c2, Bpm))})");+ yield return (VersionSummary.Headline(c2, Bpm) == "Added Bass · Tempo 120.00 → 124.00", "…and lead the headline");++ int vox = 0;+ var c3 = Step(() => { vox = e.AddAudioTrack(); e.SetTrackName(vox, "Vox"); });+ var c4 = Step(() => e.AddAudioClipEx(vox, wav, 0, 0, 0, 1f));+ yield return (c4.NewAudio == 1 && c4.Edited.SequenceEqual(["Vox"]) && c4.TracksAdded.Count == 0,+ $"a new clip is new audio on an edited track ({string.Join(" · ", VersionSummary.Parts(c4, Bpm))})");++ var c5 = Step(() => e.SetTrackVolume(bass, 0.5f));+ yield return (c5.Mix.SequenceEqual(["Bass"]) && c5.Edited.Count == 0 && c5.Sound.Count == 0, "a fader move is a mix change");++ var c6 = Step(() => e.SetTrackName(lead, "Strings"));+ yield return (c6.TracksRenamed.Count == 1 && c6.TracksRenamed[0] == new TrackRename("Lead", "Strings")+ && c6.TracksAdded.Count == 0 && c6.TracksRemoved.Count == 0, "a renamed track reads as a rename");++ var c7 = Step(() => { e.RemoveTrack(vox); File.WriteAllText(Path.Combine(dir, "sections.json"), "[]"); });+ yield return (c7.TracksRemoved.SequenceEqual(["Vox"]) && c7.Other.SequenceEqual(["sections"]),+ $"a removed track and edited sections are seen ({string.Join(" · ", VersionSummary.Parts(c7, Bpm))})");++ // Versions recorded before summaries existed get one on the next read.+ string versions = Path.Combine(dir, ".history", "versions.json");+ var json = System.Text.Json.Nodes.JsonNode.Parse(File.ReadAllText(versions))!;+ foreach (var v in json["versions"]!.AsArray()) v!.AsObject().Remove("changes");+ File.WriteAllText(versions, json.ToJsonString());+ var back = history.Read(dir).Versions;+ yield return (back.All(v => v.Changes is not null) && back[1].Changes!.TracksAdded.SequenceEqual(["Bass"]),+ "older versions get their summary worked out on read");+ yield return (File.ReadAllText(versions).Contains("\"changes\""), "…and keep it");+ }+ finally+ {+ try { Directory.Delete(dir, true); } catch { }+ try { File.Delete(wav); } catch { }+ }++ var many = new VersionChanges { Edited = ["A", "B", "C", "D"], Mix = ["A", "B", "C"] };+ yield return (string.Join(" · ", VersionSummary.Parts(many, Bpm)) == "Edited A, B +2 · Mix of 3 tracks",+ "long lists fold into a count");+ yield return (VersionSummary.Headline(new VersionChanges(), Bpm) is null, "nothing nameable → no headline");+ }+public static IEnumerable<(bool Ok, string Label)> Run(){string tmp = Path.GetTempPath();diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 1530e81c..f9c2b0eb 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -147,6 +147,7 @@ if (args.Length >= 1 && args[0] == "--history")Console.WriteLine("-- project: version history --");foreach (var (ok, label) in HistoryTests.Run()) Check(ok, label);foreach (var (ok, label) in HistoryTests.RunGraph()) Check(ok, label);+ foreach (var (ok, label) in HistoryTests.RunSummary()) Check(ok, label);Console.WriteLine(failures == 0 ? "HISTORY PASSED" : $"HISTORY FAILED ({failures})");return failures == 0 ? 0 : 1;}@@ -13603,6 +13604,7 @@ foreach (var (ok, label) in BundleContentTests.Run()) Check(ok, label);Console.WriteLine("-- project: version history --");foreach (var (ok, label) in HistoryTests.Run()) Check(ok, label);foreach (var (ok, label) in HistoryTests.RunGraph()) Check(ok, label);+foreach (var (ok, label) in HistoryTests.RunSummary()) Check(ok, label);// --- get plug-ins: registry index, install/uninstall from local archives ---Console.WriteLine("-- get plug-ins: registry store --");