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) Automatic section names, Reset to default, Esc cancels a rename (#106) (#394)
Chris Laupamab80b2cadf409
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a17a0328..90366a91 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,6 +23,15 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.## [Unreleased]### Added+- **Automatic section names and Reset to default** (#106): new arrangement sections are named+ "Section N" for their place in the song — left to right, custom-named sections counted — and+ renumber when sections are added, moved, duplicated or deleted; custom names stay as typed.+ In the rename box Return keeps the name (an empty name goes back to automatic) and Esc+ cancels without an undo step; a caption says whether the name is automatic or custom.+ **Reset to default** — in the rename box, the section's right-click menu and the command+ palette (*Reset section name*, for the section at the playhead) — restores the automatic+ name. Undo / redo bring back both the name and its mode. Sections named in earlier versions+ keep their names; MCP `list_sections` reports which names are automatic.- **Dock the Mixer in the main window** (#39): View → Mixer (⌘⇧M / Ctrl+Shift+M) now showsthe full Mixer — strips, Stereo map and the pan law footer — as a panel under Arrangement,Session or Modular, above the Devices / Clip panel; either, both or neither can be shown.diff --git a/FEATURES.md b/FEATURES.mdindex 8f53b8df..ed53839d 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -133,6 +133,13 @@ docks as a panel under any of the three, or floats in its own window — seewhole bars). Its menu loops the section, selects it as a time range across every track,duplicates it or deletes it. Each edit is one undo step. Saved with the project (MCP`list_sections` / `set_sections`); View ▸ Toggle sections hides it.+ - **Automatic section names** — a new section is named "Section N" for its place in the+ song, left to right, custom-named sections counted, and renumbers as sections are added,+ moved or deleted; a custom name never changes on its own. Renaming: Return keeps the name+ (an empty one goes back to automatic), Esc cancels; the box says whether the name is+ automatic or custom. **Reset to default** (in the rename box, the section's menu and the+ command palette's *Reset section name*, for the section at the playhead) brings the+ automatic name back. Undo / redo restore both the name and its mode.- **Resizable tracks and track list** — drag a track's bottom edge (header or lane) toset its height, 30–256 px, with a light snap to Compact / Standard / Large; amulti-selection resizes together, ⌥-drag resizes every track, double-click resets.diff --git a/specs/058-section-automatic-names/checklists/requirements.md b/specs/058-section-automatic-names/checklists/requirements.mdnew file mode 100644index 00000000..c270f482--- /dev/null+++ b/specs/058-section-automatic-names/checklists/requirements.md@@ -0,0 +1,36 @@+# Specification Quality Checklist: Section renaming — cancel edits and restore automatic names++**Purpose**: Validate specification completeness and quality before proceeding to planning+**Created**: 2026-10-30+**Feature**: [spec.md](../spec.md)++## Content Quality++- [x] No implementation details (languages, frameworks, APIs)+- [x] Focused on user value and business needs+- [x] Written for non-technical stakeholders+- [x] All mandatory sections completed++## Requirement Completeness++- [x] No [NEEDS CLARIFICATION] markers remain+- [x] Requirements are testable and unambiguous+- [x] Success criteria are measurable+- [x] Success criteria are technology-agnostic (no implementation details)+- [x] All acceptance scenarios are defined+- [x] Edge cases are identified+- [x] Scope is clearly bounded+- [x] Dependencies and assumptions identified++## Feature Readiness++- [x] All functional requirements have clear acceptance criteria+- [x] User scenarios cover primary flows+- [x] Feature meets measurable outcomes defined in Success Criteria+- [x] No implementation details leak into specification++## Notes++- The Assumptions section names the storage choice (empty name = automatic) because it is what+ makes undo / save of the naming mode free; it is the one deliberate implementation note.+- Out of scope: user-rebindable shortcuts (Nota has none yet); legacy "Section N" texts stay custom.diff --git a/specs/058-section-automatic-names/plan.md b/specs/058-section-automatic-names/plan.mdnew file mode 100644index 00000000..85d73133--- /dev/null+++ b/specs/058-section-automatic-names/plan.md@@ -0,0 +1,59 @@+# Implementation Plan: Section renaming — cancel edits and restore automatic names++**Branch**: `cursor/section-automatic-names-d981` | **Date**: 2026-10-30 | **Spec**: [spec.md](spec.md)++## Summary++Represent automatic naming as an empty stored name and derive "Section N" from the section's+position when it is shown. The engine already stores section names in its undoable project+snapshot (specs/016), so text and mode undo, redo, save and load together with no engine, ABI or+file-format change. The rename flyout gains a mode caption and a Reset button; the section menu+and the command palette gain Reset.++## Technical Context++**Language/Version**: C# / .NET 10, Avalonia 12+**Testing**: `tests/Nota.SmokeTest` (engine-backed), `scripts/build-linux.sh`+**Constraints**: no audio-thread impact; one logical change.++## Constitution Check++- I. Real-time safety — no engine or audio-thread change. PASS+- II. Boundary discipline — no new C ABI; managed code only. PASS+- III. Licensing — no dependency; new file carries the SPDX header. PASS+- IV. Verification — smoke tests added; build script run before the PR. PASS+- VI. Docs in sync — `FEATURES.md`, `CHANGELOG.md`, Shortcuts pane, MCP descriptions. PASS++## Audio-thread impact and architecture rules++None of the work runs on the audio thread. The naming rules, the rename flyout, the menu,+the palette command, MCP and Remote are managed UI / control-thread code.++- **No allocation, locks, I/O or logging on the audio thread (AR-6)**: nothing new reaches it.+ `SectionNames` allocates strings, but only on the UI / MCP threads.+- **Structural edits publish a new graph snapshot (AR-5)**: a rename or reset still goes through+ `Engine::setSections`, which copies the `Graph` and publishes it. That path is unchanged.+- **Only the C ABI crosses managed/native (AR-7)**: no new ABI. `nota_engine_set_sections` /+ `nota_engine_section_*` are used as before.+- **No JUCE outside `pluginhost/`**: untouched.+- **Transport is the only source of musical time**: the palette command reads the view's+ playhead position, which the Transport already reports, and only reads it.++## Design++- `Nota.Application/Engine/SectionNames.cs` (new): `IsAutomatic(name)`, `Automatic(index)`,+ `Display(name, index)`, `Normalize(typed)` (trim; whitespace → ""), `Displayed(list)`.+- `ArrangementView.Sections.cs`: new sections get `""`; the lane draws `Display`; the rename+ flyout shows caption + placeholder + Reset; Enter commits `Normalize(text)`, Escape / dismiss+ discard; menu gains "Reset to default name"; `ResetSectionNameAtPlayhead()` for the palette.+- `CommandCatalog` + `MainWindow.Commands.cs`: `arrangement.resetSectionName`, no default key.+- `MainWindow.Remote.cs`: Remote gets displayed names.+- `Nota.Mcp/Tools/ProjectTools.cs`: `Section` gains `Automatic`; list returns displayed names;+ descriptions explain empty name = automatic.+- Shortcuts pane: Esc / Return rows for the rename box.++## Project Structure++Source touched: `src/managed/Nota.Application/{Engine/SectionNames.cs, Palette/CommandCatalog.cs}`,+`src/managed/Nota.App/{ArrangementView.Sections.cs, MainWindow.Commands.cs, MainWindow.Remote.cs, PreferencesWindow.cs}`,+`src/managed/Nota.Mcp/Tools/ProjectTools.cs`, `tests/Nota.SmokeTest/{SectionNamingTests.cs, Program.cs}`.diff --git a/specs/058-section-automatic-names/spec.md b/specs/058-section-automatic-names/spec.mdnew file mode 100644index 00000000..0714719f--- /dev/null+++ b/specs/058-section-automatic-names/spec.md@@ -0,0 +1,160 @@+# Feature Specification: Section renaming — cancel edits and restore automatic names++**Feature Branch**: `cursor/section-automatic-names-d981`++**Created**: 2026-10-30++**Status**: Implemented++**Input**: GitHub issue [#106](https://github.com/nota-daw/nota/issues/106): "Escape cancels an+uncommitted section rename; Enter commits. Add Reset to Default that restores automatic naming+mode. Number automatic names left-to-right across all sections, including custom-named ones,+preserve stable identities and support undo/redo of both text and naming mode."++## Nota Context *(fill in — drives plan and tasks)*++**Feature area** *(pick the main one)*:++- [ ] Engine (C++, `src/native/nota.engine`) — real-time audio rules apply, see `ARCHITECTURE.md` AR table+- [x] Managed app (C#, `src/managed/*`) — domain, application, infrastructure, presentation+- [x] UI (Avalonia, `src/managed/Nota.Presentation`) — follow `DESIGN.md` (Ember)+- [ ] Plugin hosting (`pluginhost/`) — the only place JUCE is allowed+- [ ] Build / packaging / CI (`scripts/`, `.github/`) — see `BUILD.md`+- [ ] Docs only++**Nota docs to keep in mind**: [`ARCHITECTURE.md`](../../ARCHITECTURE.md),+[`CONTRIBUTING.md`](../../CONTRIBUTING.md), [`DESIGN.md`](../../DESIGN.md),+[`FEATURES.md`](../../FEATURES.md), [`specs/016`](../016-device-param-section-undo/spec.md)+(sections as undoable project data).++## User Scenarios & Testing *(mandatory)*++### User Story 1 - Back out of a rename (Priority: P1)++A producer double-clicks a section, starts typing, changes their mind and presses Escape. The+section keeps exactly the name it had — custom or automatic — and no undo step is recorded.+Enter commits what was typed as one undo step.++**Independent Test**: rename a section, press Escape — the name is unchanged and Undo has+nothing new; rename again, press Enter — the name changes and one Undo restores it.++**Acceptance Scenarios**:++1. **Given** a section named "Chorus", **When** the user types "Bridge" and presses Escape,+ **Then** it is still "Chorus" and no undo step was added.+2. **Given** an automatically named section, **When** the user types and presses Escape,+ **Then** it stays automatic (it keeps renumbering with its position).+3. **Given** any section, **When** the user types "Bridge" and presses Enter, **Then** it is+ named "Bridge" and one Undo restores the previous name and naming mode.+4. **Given** the rename box, **When** the user clears it (or leaves only spaces) and presses+ Enter, **Then** the section returns to automatic naming.++### User Story 2 - Reset to the default name (Priority: P1)++A custom-named section can be returned to automatic naming in one step: a **Reset to default**+button in the rename box, a **Reset to default name** entry in the section's context menu, and+a **Reset section name** command in the command palette (for the section under the playhead).++**Independent Test**: name the second of three sections "Chorus", reset it — it reads+"Section 2" again; Undo brings "Chorus" back, Redo resets it again.++**Acceptance Scenarios**:++1. **Given** a custom-named section, **When** the user picks Reset, **Then** it shows its+ automatic name for its position and later renumbers with it.+2. **Given** an automatically named section, **When** the user opens its menu, **Then** the+ Reset entry is disabled (nothing to reset).+3. **Given** a reset, **When** the user undoes it, **Then** the previous custom name and custom+ mode come back; Redo returns it to automatic.+4. **Given** the playhead inside a custom-named section, **When** the user runs **Reset section+ name** from the command palette, **Then** that section is reset; with no section under the+ playhead the command says so and changes nothing.++### User Story 3 - Accurate automatic numbering (Priority: P1)++Automatic names are "Section 1", "Section 2", … by each section's position in the whole+arrangement, left to right, counting custom-named sections too. If the second section is+"Chorus", the third is still "Section 3". Automatic names follow inserts, deletes, duplicates+and moves; custom names never change on their own.++**Acceptance Scenarios**:++1. **Given** sections [auto, "Chorus", auto], **Then** they read "Section 1", "Chorus",+ "Section 3".+2. **Given** that list, **When** a new section is drawn before the first, **Then** the+ automatic ones read "Section 2" and "Section 4" and the new one "Section 1".+3. **Given** an automatic section, **When** it is duplicated, **Then** the copy is automatic+ too; a custom section's copy keeps the custom name.+4. Numbering does not depend on zoom, scroll, the lane being hidden or the selection.++### User Story 4 - The rename box says which kind of name it is (Priority: P2)++The rename box tells automatic and custom names apart without adding anything to the+arrangement: for an automatic section the box is empty with the automatic name as its+placeholder and an "Automatic name" caption; for a custom one the name is selected and the+caption reads "Custom name".++### Edge Cases++- Leading / trailing spaces of a typed name are trimmed; a name that is all spaces is automatic.+- Closing the rename box by clicking elsewhere discards the edit (same as Escape).+- Enter with the text unchanged records no undo step.+- A section reloaded by undo / MCP while the rename box is open is found again by its span; if+ it no longer exists, the edit is dropped.+- Typing exactly the automatic name (e.g. "Section 3") makes it a custom name — the user chose+ it; Reset is how to get back to automatic.+- Projects saved by earlier builds stored every name as text, including "Section N" defaults:+ those load as custom names (nothing is reinterpreted); Reset makes them automatic.+- MCP: `set_sections` with an empty name makes an automatic section; `list_sections` returns+ the displayed name and whether it is automatic. Nota Remote shows the displayed names.++## Requirements *(mandatory)*++### Functional Requirements++- **FR-001**: Escape (and dismissing the rename box) MUST leave the section's name and naming+ mode unchanged and record no undo step.+- **FR-002**: Enter MUST commit the typed name as one undo step; an empty or whitespace-only+ name MUST return the section to automatic naming.+- **FR-003**: A section MUST be either automatic or custom; that state MUST be part of the+ project (saved, loaded, undone and redone with the name).+- **FR-004**: An automatic section MUST display "Section N", N its 1-based position among all+ sections ordered by start, counting custom-named sections.+- **FR-005**: New sections (drawn, "Add section here") MUST start automatic; a duplicate MUST+ keep its source's naming mode.+- **FR-006**: Reset MUST be offered in the rename box, the section context menu and the command+ palette, MUST make the section automatic as one undo step, and MUST be reachable by keyboard.+- **FR-007**: The rename box MUST show whether the current name is automatic or custom.+- **FR-008**: Sections MUST keep their identity (span and order in the project) when their+ displayed name changes; renumbering MUST NOT rewrite stored data.+- **FR-009**: MCP and Nota Remote MUST see the displayed names.++## Success Criteria *(mandatory)*++- **SC-001**: Escape after any rename edit leaves the project byte-identical and the undo+ history unchanged.+- **SC-002**: Resetting a custom name takes one action from the section's menu or rename box.+- **SC-003**: For any arrangement, every automatic name equals "Section" + its position.+- **SC-004**: One Undo after a rename or reset restores both the previous text and mode.++## Assumptions++- Automatic naming is stored as an empty name, so no engine, C ABI or file-format change is+ needed: the engine already keeps names in its undoable project snapshot.+- Nota has no user-rebindable shortcuts (Settings → Shortcuts is a reference list), so+ "assignable in shortcut settings" is out of scope; Reset is reachable from the command+ palette and by keyboard inside the rename box. A rebinding system is a separate feature.+- Older projects' stored "Section N" texts stay custom (see Edge Cases).+- The user manual lives in the separate `nota-docs` repository. Its Arrangement, command+ palette, MCP and shortcuts pages are updated there as a follow-up (nota-docs skill), not in+ this repository's change.++## Nota Compliance Checklist *(review before implementation; re-check in tasks.md)*++- [x] Every new source file will carry the AGPL-3.0-only SPDX header — one new test file, with header+- [x] No new dependency+- [x] Audio-thread impact considered — none: managed UI and data only+- [x] Managed/native crossings go through the pure C ABI in `nota_engine.h` only (AR-7) — unchanged+- [x] Smoke-test impact assessed: naming rules, reset undo/redo, save/load and MCP covered in `tests/Nota.SmokeTest`+- [x] User-visible change → `CHANGELOG.md` `[Unreleased]` entry planned+- [x] UI change → follows `DESIGN.md` (Ember design language)diff --git a/specs/058-section-automatic-names/tasks.md b/specs/058-section-automatic-names/tasks.mdnew file mode 100644index 00000000..fef312c4--- /dev/null+++ b/specs/058-section-automatic-names/tasks.md@@ -0,0 +1,30 @@+# Tasks: Section renaming — cancel edits and restore automatic names++**Input**: [spec.md](spec.md), [plan.md](plan.md)++## Phase 1 — Naming rules (US3, FR-003/004/008)++- [x] T001 Add `SectionNames` helper in `src/managed/Nota.Application/Engine/SectionNames.cs`+- [x] T002 Smoke tests for numbering, normalisation, reset undo/redo, save/load in `tests/Nota.SmokeTest/SectionNamingTests.cs`, registered in `Program.cs`++## Phase 2 — Arrangement lane (US1, US2, US4)++- [x] T003 New sections start automatic; duplicate keeps mode; lane and menu header draw displayed names (`ArrangementView.Sections.cs`)+- [x] T004 Rename flyout: caption, placeholder, Reset button; Enter commits normalised text, Escape / dismiss discard+- [x] T005 Context-menu "Reset to default name" (disabled when automatic)+- [x] T006 Palette command `arrangement.resetSectionName` (catalog + binding)++## Phase 3 — Other surfaces (FR-009)++- [x] T007 Nota Remote gets displayed names (`MainWindow.Remote.cs`)+- [x] T008 MCP `list_sections` / `set_sections`: displayed name + `automatic`, descriptions++## Phase 4 — Docs and verification++- [x] T009 Shortcuts pane rows (Return / Esc in rename box)+- [x] T010 `FEATURES.md`, `CHANGELOG.md`+- [x] T011 `scripts/build-linux.sh` passes++## Compliance re-check++- [x] SPDX header on the new files; no dependency; no audio-thread or ABI changediff --git a/src/managed/Nota.App/ArrangementView.Sections.cs b/src/managed/Nota.App/ArrangementView.Sections.csindex f2d736db..a56bdad6 100644--- a/src/managed/Nota.App/ArrangementView.Sections.cs+++ b/src/managed/Nota.App/ArrangementView.Sections.cs@@ -107,24 +107,30 @@ public sealed partial class ArrangementViewSectionsChanged?.Invoke();}- // A new section is named for the slot it lands in, so a session gets Section 1..n without- // a dialog in the way; renaming is one double-click.- private string NextSectionName()+ // Position in start order, ties kept in list order — what an automatic name counts+ // (specs/058). Computed, not sorted in place, so it also holds mid-drag.+ private int SectionIndex(ArrangementSection s){- for (int i = 1; ; i++)+ int self = _sections.IndexOf(s), n = 0;+ for (int i = 0; i < _sections.Count; i++){- string candidate = "Section " + i.ToString(NotaNum.Culture);- if (!_sections.Any(s => string.Equals(s.Name, candidate, StringComparison.Ordinal))) return candidate;+ var x = _sections[i];+ if (i != self && (x.StartBeat < s.StartBeat || (x.StartBeat == s.StartBeat && i < self))) n++;}+ return n;}+ /// <summary>The name a section shows: its own, or "Section N" for its position when automatic.</summary>+ public string SectionDisplayName(ArrangementSection s) => SectionNames.Display(s.Name, SectionIndex(s));++ // A new section is automatic ("Section N", renumbering with its position), so a session+ // gets Section 1..n without a dialog in the way; renaming is one double-click.private ArrangementSection AddSection(double startBeat, double lengthBeats){var s = new ArrangementSection{StartBeat = Math.Max(0, startBeat),LengthBeats = Math.Max(_beatsPerBar, lengthBeats),- Name = NextSectionName(),};_sections.Add(s);return s;@@ -150,15 +156,34 @@ public sealed partial class ArrangementViewreturn Math.Max(0, Math.Round(beat / bar) * bar);}+ // Enter commits; Escape or a click elsewhere drops the edit. An automatic section opens+ // empty with its automatic name as the placeholder, so Enter on an empty box keeps (or+ // returns to) automatic naming, and the caption says which kind of name Enter will store.private void RenameSection(Control anchor, ArrangementSection s){- var box = new TextBox { Text = s.Name, Width = 160, FontSize = 12 };- var flyout = new Flyout { Content = box, Placement = PlacementMode.Bottom };+ bool automatic = SectionNames.IsAutomatic(s.Name);+ string automaticName = SectionNames.Automatic(SectionIndex(s));+ var box = new TextBox { Text = automatic ? "" : s.Name, PlaceholderText = automaticName, Width = 180, FontSize = 12 };+ var caption = new TextBlock { Classes = { "Caption" }, VerticalAlignment = VerticalAlignment.Center };+ void Caption() => caption.Text = SectionNames.IsAutomatic(box.Text) ? "Automatic name" : "Custom name";+ Caption();+ box.TextChanged += (_, _) => Caption();++ var reset = new Button { Content = "Reset to default", Classes = { "ghost" }, FontSize = 11, Height = 22, Padding = new Thickness(6, 0), IsEnabled = !automatic };+ ToolTip.SetTip(reset, $"Back to the automatic name ({automaticName}), which follows the section's position");+ var footer = new DockPanel { Margin = new Thickness(0, 6, 0, 0) };+ DockPanel.SetDock(reset, Dock.Right);+ footer.Children.Add(reset);+ footer.Children.Add(caption);++ var flyout = new Flyout { Content = new StackPanel { Children = { box, footer } }, Placement = PlacementMode.Bottom };+ reset.Click += (_, _) => { ResetSectionName(s); flyout.Hide(); };box.KeyDown += (_, ke) =>{if (ke.Key == Key.Enter){- if (Live(s) is { } live) { live.Name = box.Text ?? ""; SectionsEdited(); }+ string name = SectionNames.Normalize(box.Text);+ if (Live(s) is { } live && live.Name != name) { live.Name = name; SectionsEdited(); }flyout.Hide(); ke.Handled = true;}else if (ke.Key == Key.Escape) { flyout.Hide(); ke.Handled = true; }@@ -167,6 +192,26 @@ public sealed partial class ArrangementViewDispatcher.UIThread.Post(() => { box.SelectAll(); box.Focus(); }, DispatcherPriority.Input);}+ /// <summary>Return a section to automatic naming — one undo step, none if it already is.</summary>+ private void ResetSectionName(ArrangementSection s)+ {+ if (Live(s) is not { } live || SectionNames.IsAutomatic(live.Name)) return;+ live.Name = "";+ SectionsEdited();+ }++ /// <summary>Reset the name of the section under the playhead (command palette). Returns+ /// what happened, for the status bar.</summary>+ public string ResetSectionNameAtPlayhead()+ {+ var s = SectionList.LastOrDefault(x => x.StartBeat <= _playheadBeats && _playheadBeats < x.StartBeat + x.LengthBeats);+ if (s is null) return "No section at the playhead";+ if (SectionNames.IsAutomatic(s.Name)) return $"{SectionDisplayName(s)} already has its automatic name";+ string was = s.Name, now = SectionNames.Automatic(SectionIndex(s));+ ResetSectionName(s);+ return $"\u201C{was}\u201D is {now} again";+ }+// ---- the lane ---------------------------------------------------------private sealed class SectionsControl : Control@@ -342,8 +387,12 @@ public sealed partial class ArrangementView_o.SectionsEdited(); // one step: the copy arrives already named});MenuKit.AddGroups(flyout.Items,- new Control[] { MenuKit.Header(s.Name.Length > 0 ? s.Name : "Section", null, $"Section · {bars} bar{(bars == 1 ? "" : "s")}") },- new Control[] { MenuKit.Item("Rename…", GlyphKind.Edit, () => _o.RenameSection(this, s)) },+ new Control[] { MenuKit.Header(_o.SectionDisplayName(s), null, $"Section · {bars} bar{(bars == 1 ? "" : "s")}") },+ new Control[]+ {+ MenuKit.Item("Rename…", GlyphKind.Edit, () => _o.RenameSection(this, s)),+ MenuKit.Item("Reset to default name", GlyphKind.Cycle, () => _o.ResetSectionName(s), enabled: !SectionNames.IsAutomatic(s.Name)),+ },new Control[]{MenuKit.Item("Loop section", GlyphKind.Cycle, () => _o.SetLoopRegion(s.StartBeat, s.StartBeat + s.LengthBeats)), // raises LoopChanged itself@@ -393,7 +442,7 @@ public sealed partial class ArrangementViewctx.FillRectangle(warm ? WarmEdge : ColdEdge, new Rect(r.X, r.Y, 2, r.Height));if (r.Width > 22){- var ft = new FormattedText(s.Name, CultureInfo.InvariantCulture,+ var ft = new FormattedText(_o.SectionDisplayName(s), CultureInfo.InvariantCulture,FlowDirection.LeftToRight, Typeface.Default, 9, warm ? WarmInk : ColdInk){ MaxTextWidth = Math.Max(8, r.Width - 10), Trimming = TextTrimming.CharacterEllipsis };ctx.DrawText(ft, new Point(r.X + 7, r.Y + (r.Height - ft.Height) / 2));diff --git a/src/managed/Nota.App/MainWindow.Commands.cs b/src/managed/Nota.App/MainWindow.Commands.csindex 3969373c..4883144b 100644--- a/src/managed/Nota.App/MainWindow.Commands.cs+++ b/src/managed/Nota.App/MainWindow.Commands.cs@@ -80,6 +80,7 @@ public partial class MainWindowB("view.popOutDetail", () => OnToggleDetailWindow(this, e));B("view.toggleOverview", () => OnMenuToggleOverview(this, e));B("view.toggleSections", () => OnMenuToggleSections(this, e));+ B("edit.resetSectionName", () => { string status = Timeline.ResetSectionNameAtPlayhead(); if (_vm is not null) _vm.StatusText = status; });B("view.follow", () => OnMenuToggleFollow(this, e));B("view.showPlayhead", ShowPlayhead);B("view.clipNames", () => OnMenuCycleClipNames(this, e));diff --git a/src/managed/Nota.App/MainWindow.Remote.cs b/src/managed/Nota.App/MainWindow.Remote.csindex ee9334d7..9dfa0aa3 100644--- a/src/managed/Nota.App/MainWindow.Remote.cs+++ b/src/managed/Nota.App/MainWindow.Remote.cs@@ -136,7 +136,7 @@ public partial class MainWindow : IRemoteHostint IRemoteHost.ProjectKeyCode => _vm?.Transport.KeyCode ?? -1;IReadOnlyList<(string Name, double StartBeat)> IRemoteHost.Sections =>- Timeline.SectionList.OrderBy(s => s.StartBeat).Select(s => (s.Name, s.StartBeat)).ToList();+ Timeline.SectionList.Select((s, i) => (SectionNames.Display(s.Name, i), s.StartBeat)).ToList();bool IRemoteHost.Recording => _vm?.Transport.RecordOn ?? false;bool IRemoteHost.LoopOn => _vm?.Transport.LoopOn ?? false;diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.csindex 609a0563..9024571b 100644--- a/src/managed/Nota.App/PreferencesWindow.cs+++ b/src/managed/Nota.App/PreferencesWindow.cs@@ -1521,7 +1521,8 @@ public sealed partial class PreferencesWindow : NotaWindow("Drag the track-list edge", "Widen or narrow the track headers · double-click resets"),("Drag sections lane", "Mark a new section over the dragged bars"),("Click section", "Jump the playhead to its start"),- ("Double-click section", "Rename it"),+ ("Double-click section", "Rename it · right-click → Reset to default name for its automatic Section N"),+ ("Return · Esc (renaming a section)", "Keep the name (empty = automatic) · cancel"),("Drag section · its edge", "Move / resize it, snapped to bars"),("Drag overview strip", "Drag sideways to scroll · up / down to zoom out / in"),("Drag overview edge", "Zoom by resizing the viewport window"),diff --git a/src/managed/Nota.Application/Engine/SectionNames.cs b/src/managed/Nota.Application/Engine/SectionNames.csnew file mode 100644index 00000000..dda56a8a--- /dev/null+++ b/src/managed/Nota.Application/Engine/SectionNames.cs@@ -0,0 +1,28 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Automatic section names (specs/058). A section whose stored name is empty is automatic: it+// reads "Section N", N its position among all sections in start order, custom-named ones+// counted. The mode lives in the name itself, so the engine's undo snapshot and project.json+// carry it with no extra field, and renumbering never rewrites stored data.++using System.Globalization;++namespace Nota.Application;++public static class SectionNames+{+ public static bool IsAutomatic(string? name) => string.IsNullOrWhiteSpace(name);++ /// <summary>The automatic name for the section at <paramref name="index"/> (0-based, start order).</summary>+ public static string Automatic(int index) => "Section " + (index + 1).ToString(CultureInfo.InvariantCulture);++ public static string Display(string? name, int index) => IsAutomatic(name) ? Automatic(index) : name!;++ /// <summary>What a typed name stores: trimmed, and "" (automatic) when nothing is left.</summary>+ public static string Normalize(string? typed) => typed?.Trim() ?? "";++ /// <summary>Displayed names of sections already in start order.</summary>+ public static IReadOnlyList<string> Displayed(IReadOnlyList<SectionInfo> sections)+ => sections.Select((s, i) => Display(s.Name, i)).ToList();+}diff --git a/src/managed/Nota.Application/Palette/CommandCatalog.cs b/src/managed/Nota.Application/Palette/CommandCatalog.csindex 49376688..bc5d4620 100644--- a/src/managed/Nota.Application/Palette/CommandCatalog.cs+++ b/src/managed/Nota.Application/Palette/CommandCatalog.cs@@ -62,6 +62,7 @@ public static class CommandCatalogC("view.popOutDetail", "Open devices in a window", "View", "", "detach float pop out"),C("view.toggleOverview", "Toggle overview", "View", "", "minimap", view: "Arrangement"),C("view.toggleSections", "Toggle sections", "View", "", "markers locators", view: "Arrangement"),+ C("edit.resetSectionName", "Reset section name", "Edit", "", "default automatic rename section at playhead", view: "Arrangement"),C("view.follow", "Follow playhead", "View", "", "scroll"),C("view.showPlayhead", "Show playhead", "View", Shortcut.None('P'), "find locate scroll reveal cursor position", view: "Arrangement"),C("view.clipNames", "Cycle clip names", "View", "", "labels", view: "Arrangement"),diff --git a/src/managed/Nota.Mcp/Tools/ProjectTools.cs b/src/managed/Nota.Mcp/Tools/ProjectTools.csindex 16ed0914..5fcd480c 100644--- a/src/managed/Nota.Mcp/Tools/ProjectTools.cs+++ b/src/managed/Nota.Mcp/Tools/ProjectTools.cs@@ -54,19 +54,32 @@ public sealed class ProjectTools(IAudioEngine engine, IEngineDispatch dispatch,[McpServerTool(Name = "redo"), Description("Redo the last undone edit. Returns whether anything was redone.")]public Task<bool> Redo() => Mutate(() => E.Redo());- public sealed record Section(double StartBeat, double LengthBeats, string Name);+ public sealed record Section(double StartBeat, double LengthBeats, string Name, bool Automatic = false);++ private Section[] Listed()+ {+ var all = E.Sections;+ return all.Select((s, i) => new Section(s.StartBeat, s.LengthBeats, SectionNames.Display(s.Name, i), SectionNames.IsAutomatic(s.Name))).ToArray();+ }[McpServerTool(Name = "list_sections"), Description("List the arrangement's song sections (the named spans on the Sections lane — Intro, Verse, Drop …) in start order: "- + "start and length in beats, and the name.")]- public Task<Section[]> ListSections() => Read(() => E.Sections.Select(s => new Section(s.StartBeat, s.LengthBeats, s.Name)).ToArray());+ + "start and length in beats, the name as shown, and whether it is automatic (\"Section N\" for its position, "+ + "renumbered as sections are added, moved or removed) rather than a custom name.")]+ public Task<Section[]> ListSections() => Read(Listed);[McpServerTool(Name = "set_sections"), Description("Replace the arrangement's song sections with this list (pass [] to remove them all). Each needs startBeat >= 0 and "- + "lengthBeats > 0; they are sorted by start, and a span with no length is dropped. One undo step. Returns the list as stored.")]+ + "lengthBeats > 0; they are sorted by start, and a span with no length is dropped. A section with automatic = true "+ + "or an empty or whitespace-only name gets the automatic name \"Section N\" for its position. Any other name is stored "+ + "exactly as given, surrounding spaces included, so listing and setting the same list changes nothing. "+ + "One undo step. Returns the list as stored.")]public Task<Section[]> SetSections(Section[] sections) => Mutate(() =>{- E.SetSections(sections.Select(s => new SectionInfo(s.StartBeat, s.LengthBeats, s.Name ?? "")).ToList());- return E.Sections.Select(s => new Section(s.StartBeat, s.LengthBeats, s.Name)).ToArray();+ // A nonblank custom name is kept verbatim. Trimming belongs to the rename box; doing it+ // here would rewrite a legacy " Chorus " on a list → set round trip and add an undo step.+ E.SetSections(sections.Select(s => new SectionInfo(s.StartBeat, s.LengthBeats,+ s.Automatic || SectionNames.IsAutomatic(s.Name) ? "" : s.Name)).ToList());+ return Listed();});}diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 2e771367..92338131 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -400,6 +400,7 @@ if (args.Length >= 1 && args[0] == "--paramundo"){Console.WriteLine("-- param + section undo --");foreach (var (ok, label) in ParamSectionUndoTests.Run()) Check(ok, label);+ foreach (var (ok, label) in SectionNamingTests.Run()) Check(ok, label);Console.WriteLine(failures == 0 ? "PARAMUNDO PASSED" : $"PARAMUNDO FAILED ({failures})");return failures == 0 ? 0 : 1;}@@ -15327,6 +15328,8 @@ foreach (var (ok, label) in MixUndoTests.Run()) Check(ok, label);Console.WriteLine("-- param + section undo --");foreach (var (ok, label) in ParamSectionUndoTests.Run()) Check(ok, label);+Console.WriteLine("-- section names --");+foreach (var (ok, label) in SectionNamingTests.Run()) Check(ok, label);Console.WriteLine("-- device remove undo --");foreach (var (ok, label) in DeviceRemoveUndoTests.Run()) Check(ok, label);Console.WriteLine("-- device copy + rack undo --");diff --git a/tests/Nota.SmokeTest/SectionNamingTests.cs b/tests/Nota.SmokeTest/SectionNamingTests.csnew file mode 100644index 00000000..748f47d7--- /dev/null+++ b/tests/Nota.SmokeTest/SectionNamingTests.cs@@ -0,0 +1,112 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Automatic section names (specs/058-section-automatic-names): an empty name is automatic and+// reads "Section N" for its position, custom names counted; typed names are trimmed and a blank+// one is automatic; a reset is one step whose undo brings the custom name back; the mode+// survives save / load; MCP lists the shown name and the mode and round-trips them.+// Runs with `dotnet run --project tests/Nota.SmokeTest -- --paramundo` and the full run.++using Nota.Application;+using Nota.Infrastructure;+using McpSection = Nota.Mcp.Tools.ProjectTools.Section;++namespace Nota.SmokeTest;++internal static class SectionNamingTests+{+ public static IEnumerable<(bool ok, string label)> Run()+ {+ foreach (var r in Rules()) yield return r;+ foreach (var r in ResetUndo()) yield return r;+ foreach (var r in Files()) yield return r;+ foreach (var r in Mcp()) yield return r;+ }++ private static IEnumerable<(bool, string)> Rules()+ {+ var list = new[] { new SectionInfo(0, 8, ""), new SectionInfo(8, 8, "Chorus"), new SectionInfo(16, 8, "") };+ yield return (SectionNames.Displayed(list).SequenceEqual(new[] { "Section 1", "Chorus", "Section 3" }),+ "section names: automatic ones count custom-named sections too (Section 1 · Chorus · Section 3)");++ var inserted = new[] { new SectionInfo(0, 4, "") }.Concat(list.Select(s => s with { StartBeat = s.StartBeat + 4 })).ToArray();+ yield return (SectionNames.Displayed(inserted).SequenceEqual(new[] { "Section 1", "Section 2", "Chorus", "Section 4" }),+ "section names: a section added in front renumbers the automatic ones, the custom one stays");++ yield return (SectionNames.Normalize(" Drop ") == "Drop" && SectionNames.Normalize(" ") == "" && SectionNames.Normalize(null) == ""+ && SectionNames.IsAutomatic(" ") && !SectionNames.IsAutomatic("Section 3"),+ "section names: typed names are trimmed, a blank one is automatic, typed \"Section 3\" is custom");+ }++ private static IEnumerable<(bool, string)> ResetUndo()+ {+ using var eng = new NotaEngine();+ eng.SetSections(new[] { new SectionInfo(0, 8, ""), new SectionInfo(8, 8, "Chorus") }, checkpoint: false);+ eng.ClearUndoHistory();++ eng.SetSections(new[] { new SectionInfo(0, 8, ""), new SectionInfo(8, 8, "") });+ bool reset = SectionNames.Displayed(eng.Sections)[1] == "Section 2" && eng.CanUndo;+ eng.Undo();+ bool back = eng.Sections[1].Name == "Chorus" && !eng.CanUndo;+ eng.Redo();+ yield return (reset && back && SectionNames.IsAutomatic(eng.Sections[1].Name),+ "section names: a reset is one step; undo restores the custom name, redo the automatic one");++ eng.ClearUndoHistory();+ eng.SetSections(new[] { new SectionInfo(0, 8, ""), new SectionInfo(8, 8, "") });+ yield return (!eng.CanUndo, "section names: resetting an automatic section records no step");+ }++ private static IEnumerable<(bool, string)> Files()+ {+ string dir = Path.Combine(Path.GetTempPath(), "nota-section-names-" + Guid.NewGuid().ToString("N"));+ try+ {+ using var eng = new NotaEngine();+ ProjectTemplate.ApplyDefault(eng);+ var want = new[] { new SectionInfo(0, 16, ""), new SectionInfo(16, 16, "Verse"), new SectionInfo(32, 16, "") };+ eng.SetSections(want);+ new ProjectStore().Save(eng, new TransportState(120, 1, false, false), dir);+ using var e2 = new NotaEngine();+ new ProjectStore().Load(e2, dir);+ yield return (e2.Sections.SequenceEqual(want)+ && SectionNames.Displayed(e2.Sections).SequenceEqual(new[] { "Section 1", "Verse", "Section 3" }),+ "section names: automatic and custom names survive save / load");+ }+ finally { try { if (Directory.Exists(dir)) Directory.Delete(dir, recursive: true); } catch (IOException) { } }+ }++ private static IEnumerable<(bool, string)> Mcp()+ {+ using var eng = new NotaEngine();+ var proj = new Nota.Mcp.Tools.ProjectTools(eng, new SyncDispatch(), new NoRefresh());+ eng.ClearUndoHistory();+ var stored = proj.SetSections(new[]+ {+ new McpSection(16, 8, "Drop"),+ new McpSection(0, 8, "ignored", Automatic: true),+ new McpSection(24, 8, " "),+ }).GetAwaiter().GetResult();+ bool listed = stored.SequenceEqual(new[]+ {+ new McpSection(0, 8, "Section 1", true),+ new McpSection(16, 8, "Drop", false),+ new McpSection(24, 8, "Section 3", true),+ });+ bool raw = eng.Sections.Select(s => s.Name).SequenceEqual(new[] { "", "Drop", "" });++ proj.SetSections(proj.ListSections().GetAwaiter().GetResult()).GetAwaiter().GetResult();+ bool roundTrip = eng.Sections.Select(s => s.Name).SequenceEqual(new[] { "", "Drop", "" });+ eng.Undo();+ yield return (listed && raw && roundTrip && eng.Sections.Count == 0 && !eng.CanUndo,+ "section names: MCP lists shown names with the automatic flag and a list → set round-trip changes nothing");++ // A legacy custom name can carry surrounding spaces. Listing it and setting that list+ // back must not trim it, and must not record a step.+ eng.SetSections(new[] { new SectionInfo(0, 8, " Chorus ") }, checkpoint: false);+ eng.ClearUndoHistory();+ proj.SetSections(proj.ListSections().GetAwaiter().GetResult()).GetAwaiter().GetResult();+ yield return (!eng.CanUndo && eng.Sections.Count == 1 && eng.Sections[0].Name == " Chorus ",+ "section names: MCP list → set keeps a padded custom name and records no step");+ }+}