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) Context menus in the Studio design, track menu edits in place (#241)
Egor Khindikaynend4cfb96d83d9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 30b893cb..3a7858a3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,6 +23,11 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.## [Unreleased]### Added+- **Recent instruments in Add track**: right-click a track (in Arrangement or Session) →+ **Add track** now lists the five instruments you added most recently under **Recent** —+ built-in or plug-in, from the browser, the menus or the AI tools. One click adds a track+ with that instrument right after the one you clicked. The list is yours, not the+ project's, and keeps a plug-in you uninstall out of sight until it is back.- **Edit several MIDI clips at once** (nota-daw/nota#48): select two or more MIDI clips — onone track or several — and double-click one of them (or right-click → **Edit selectedclips together**). The Clip editor shows all their notes on the arrangement's bars: fix a@@ -58,6 +63,16 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.- **Settings → Updates** can turn the automatic checks off, and shows the last check with a**Check now** button. Nothing downloads until you click Update.+### Changed+- **Context menus, redesigned**: every right-click menu in the app now follows the Studio+ look and one order. A menu for a track, clip, device, scene, pad or version starts with+ its name, colour and type; commands come in the same groups everywhere, with Copy, Cut,+ Paste and Duplicate always together and Delete last, in red. Icons are calm grey,+ shortcuts read the Mac way (⌘G, not ⌘+G), a chosen option is ticked, and a submenu shows+ its current value (Record input **Ext**, MIDI from **None**). The track menu sets the+ **colour** (all 27 shades and Auto) and the **height** (Compact · Standard · Large;+ Option-click for every track) in one click, without submenus. **Live freeze** is a switch+ that shows whether the track is live-frozen; switch it off to unfreeze.- **Performance gate for engine changes**: every pull request that touches the engine iscompared with its base branch on the same machine. Each built-in instrument and effect,busy mixes of 1 to 32 tracks, and sparse and silent sessions are rendered with both, anddiff --git a/DESIGN.html b/DESIGN.htmlindex 10e178c3..7567dc29 100644--- a/DESIGN.html+++ b/DESIGN.html@@ -500,6 +500,10 @@ td:first-child{color:var(--text-primary)}.menu span small{font-size:12px;color:var(--text-muted)}.menu span.hot{background:var(--accent);color:var(--text-on-accent)} .menu span.hot small{color:var(--text-on-accent)}.menu hr{border:0;height:1px;background:var(--rule);margin:4px}+.menu span small.k{font-family:var(--font-mono);font-size:11px}+.menu span.danger{color:var(--danger)} .menu span.danger.hot{color:var(--text-on-accent)}+.menu span.head{font-weight:600;color:var(--text-heading)} .menu span.head small{font-family:var(--font-mono);font-size:11px;color:var(--text-tertiary)}+.menu .sw{display:grid;grid-template-columns:repeat(9,16px);gap:2px;padding:4px 8px}.menu .sw i{width:12px;height:12px;margin:2px;border-radius:var(--r-badge)}.menu .sw i.on{outline:1px solid var(--text-primary);outline-offset:1px}/* transport */.transport{display:flex;align-items:center;gap:10px;height:44px;padding:0 8px;background:var(--panel);border-bottom:1px solid var(--seam);overflow-x:auto}.transport .name{flex:none;font:600 13px/1 var(--font-ui);color:var(--text-primary)}@@ -756,7 +760,7 @@ ul.plain{margin:0;padding-left:18px;color:var(--text-secondary)} ul.plain li{mar<figure><span class="btn off">Disabled</span>Panel · faint ink, no opacity</figure><figure><span class="listrow sel">Stone Vault</span>Selected row: 2 px accent tick</figure><figure><span class="tabs"><span class="sel">Devices</span><span>Clip</span></span>Selected tab: 2 px underline</figure>- <figure><span class="menu"><span>Duplicate<small>⌘D</small></span><span class="hot">Rename<small>⌘R</small></span><hr><span>Delete</span></span>Menu: raised, seam ring, accent hover</figure>+ <figure><span class="menu"><span class="head">Vocals<small>Audio · 3</small></span><hr><span class="sw"><i style="background:var(--track1)"></i><i style="background:var(--track2)"></i><i class="on" style="background:var(--track3)"></i><i style="background:var(--track4)"></i><i style="background:var(--track5)"></i><i style="background:var(--track6)"></i><i style="background:var(--track7)"></i><i style="background:var(--track8)"></i><i style="background:var(--track9)"></i></span><hr><span>Record input<small>Ext ›</small></span><hr><span>Copy<small class="k">⌘C</small></span><span class="hot">Duplicate<small class="k">⌘D</small></span><hr><span class="danger">Delete<small class="k">⌫</small></span></span>Menu: object header, inline colour row, value column, shortcuts ⌘C not ⌘+C, accent hover, danger last</figure></div><div class="row" style="margin-top:12px"><span class="field">Search</span><span class="field focus">Stone Vault</span></div><p class="note">Fields and readouts are wells with a 1px rule edge; focus turns the edge accent, no ring. Empty state: one Ink 5 line, centred, no illustration, no call-to-action button.</p>diff --git a/DESIGN.md b/DESIGN.mdindex 0d7e950a..160e6eeb 100644--- a/DESIGN.md+++ b/DESIGN.md@@ -707,10 +707,39 @@ Every region is **docked**: radius 0, no gutter, separated by 1 px seams (the wi### Menus, popovers, dialogs- **Menus, context menus, flyouts, drop-downs, tooltips:** raised, radius 3, a 1 px seam- ring. Menu items are 24 tall, radius 2; hover is a full accent fill with derived ink;- the shortcut on the right is muted ink (derived ink while highlighted); separators are- rules. **No blurred shadow:** Avalonia draws each popup in a window of its own, sized to- its content, so a blur would be clipped at the popup's edge.+ ring, padding 4, at least 200 wide. **No blurred shadow:** Avalonia draws each popup in a+ window of its own, sized to its content, so a blur would be clipped at the popup's edge.+- **Menu items** (the Nota `MenuItem` theme in `NotaTheme.axaml`, spec 034) are 24 tall,+ radius 2, in fixed columns that line up across a menu: icon (14, muted ink — never a+ tinted icon) · label · value · shortcut · caret. Hover or keyboard focus is a full accent+ fill with the derived ink on every part; disabled takes the disabled ink and no fill. A+ chosen choice is ticked with an accent check in the icon column (radio and checkbox+ items) — not a coloured dot. The **value** column shows a submenu's current choice in+ muted ink ("Record input Ext ›"), or a switch (18 × 10, accent while on — "Live+ freeze"), or a data colour chip (a tag's colour). **Shortcuts** are Geist Mono 11, muted,+ spelled the platform's way: `⌘G`, `⌘⇧G`, `⌫` on macOS (no "+"), `Ctrl+G` elsewhere+ (`MenuKit.Spell`). The **submenu caret** is a small chevron glyph set in from the edge.+- **Destructive items** (delete, remove, clear, discard, flatten) sit in the menu's last+ group in the danger ink (label and icon) — `MenuKit.Danger`; their hover is the same+ accent fill as every item. Danger is a semantic ink, not a second accent.+- **The object header.** A menu for something with a name — track, clip, device, chain,+ pad, macro, scene, Session slot, section, band, browser item, version — opens with a+ non-interactive header row: its colour chip when it has one, the name in 600, and a+ muted mono badge with its type and position or count ("Audio · 3", "3 tracks",+ "MIDI clip"). Items below don't repeat the noun ("Copy", not "Copy track"). A menu on+ empty space or a control (lane background, snap chip, metronome) has none.+- **Inline rows** put the most common property edit in the menu itself, one click, no+ submenu: the **colour grid** (the 9 track bases × base / light / dark, plus Auto; the+ current colour ringed in primary ink, the pointer or keyboard cursor in muted ink) and+ **segmented keys** (keys butted on seams, the chosen one in the accent — "Height:+ Compact · Standard · Large", Option-click for every track). They never highlight as a+ whole; arrows move inside them, Enter applies, and a pick closes the menu. Small muted+ **captions** ("Recent") head a group inside a menu.+- **Group order**, rules between groups: header → inline rows → naming and settings →+ the object's own actions → create / group → clipboard (Copy ⌘C · Cut ⌘X · Paste ⌘V ·+ Duplicate ⌘D, always in this order — `MenuKit.ClipboardGroup`) → destructive.+ `DesignTokenCheck.RunMenus` keeps menus on `MenuKit`: icons through `MenuKit.Icon`,+ destructive items through `MenuKit.Danger`, no Color / Track height submenus.- **Command palette** — the in-window modal: panel body, radius 4, seam ring and`Shadow.Modal`.- **Dialog windows** (`NotaWindow`): panel body; on macOS and Windows a 32 px raised headerdiff --git a/FEATURES.md b/FEATURES.mdindex e95092e2..61774d58 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -124,7 +124,8 @@ track count and closes with Escape.- **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.- The track menu's **Track height** sets a size for the selection or all tracks. Headers+ The track menu's **Height** keys (Compact · Standard · Large) size the selection in one+ click; ⌥-click sizes every track. Headersfit their height: one line (name, M / S / arm) when short, input, fader and pan on rowsof their own when tall. Drag the seam between headers and lanes to set the headerwidth (160–480 px). Both are saved with the project.@@ -183,7 +184,9 @@ track count and closes with Escape.- **Adding a track**: the `+ Instrument` / `+ Audio` / `+ Return` buttons above thearrangement, or the context menu — right-click the empty space below the tracks, or use`Add track ▸` in a track's own menu (the new track goes right after that track, or inside- it when it is a group).+ it when it is a group). `Add track ▸ Recent` (Arrangement and Session) lists the five+ instruments added most recently — built-in or plug-in, however they were added — and+ adds one in a click; the list is per user, and an uninstalled plug-in drops out of it.- **Several tracks at once**: ⇧-click headers to build a selection (or ⌘A with the headersfocused); ⌘C / ⌘X / ⌘V / ⌘D and Delete copy, cut, paste, duplicate and delete theselected tracks, and right-clicking the selection groups, colours or freezes them all —@@ -1067,6 +1070,14 @@ audio effects after it keep running and keep their settings; saved with the projknob or fader turns orange while you hover or drag it; mute is amber, solo blue,record-arm red; labels are in sentence case. Switching applies immediately, across everyopen window — including the custom-drawn arrangement, piano roll, mixer and device cards.+- **Right-click menus, one system** — every context menu opens with the object it acts on+ (name, colour, type and position: "Vocals · Audio · 3", "3 tracks", "MIDI clip") and lists+ its commands in one order: properties → settings → actions → create / group → Copy · Cut ·+ Paste · Duplicate → Delete, last and in red. Icons are neutral, a chosen option carries a+ tick, a submenu shows its current value (Record input **Ext**, MIDI from **None**) and+ shortcuts read ⌘G / ⌘⇧G on macOS, Ctrl+G elsewhere. The track menu sets the colour (27+ shades and Auto) and the height in one click, and shows **Live freeze** as a switch —+ on while the track is live-frozen, off to unfreeze.- **A single frameless window style**: centred title, drag by the header, the macOStraffic lights in a left inset (Windows gets its own title bar; Linux uses the systemframe). **Full screen** — the macOS green button, or View → Toggle Full Screen (F11)diff --git a/scripts/design-html.py b/scripts/design-html.pyindex 913fd69d..8900a19e 100755--- a/scripts/design-html.py+++ b/scripts/design-html.py@@ -274,6 +274,10 @@ td:first-child{color:var(--text-primary)}.menu span small{font-size:12px;color:var(--text-muted)}.menu span.hot{background:var(--accent);color:var(--text-on-accent)} .menu span.hot small{color:var(--text-on-accent)}.menu hr{border:0;height:1px;background:var(--rule);margin:4px}+.menu span small.k{font-family:var(--font-mono);font-size:11px}+.menu span.danger{color:var(--danger)} .menu span.danger.hot{color:var(--text-on-accent)}+.menu span.head{font-weight:600;color:var(--text-heading)} .menu span.head small{font-family:var(--font-mono);font-size:11px;color:var(--text-tertiary)}+.menu .sw{display:grid;grid-template-columns:repeat(9,16px);gap:2px;padding:4px 8px}.menu .sw i{width:12px;height:12px;margin:2px;border-radius:var(--r-badge)}.menu .sw i.on{outline:1px solid var(--text-primary);outline-offset:1px}/* transport */.transport{display:flex;align-items:center;gap:10px;height:44px;padding:0 8px;background:var(--panel);border-bottom:1px solid var(--seam);overflow-x:auto}.transport .name{flex:none;font:600 13px/1 var(--font-ui);color:var(--text-primary)}@@ -563,7 +567,7 @@ BODY=f'''</style><figure><span class="btn off">Disabled</span>Panel · faint ink, no opacity</figure><figure><span class="listrow sel">Stone Vault</span>Selected row: 2 px accent tick</figure><figure><span class="tabs"><span class="sel">Devices</span><span>Clip</span></span>Selected tab: 2 px underline</figure>- <figure><span class="menu"><span>Duplicate<small>⌘D</small></span><span class="hot">Rename<small>⌘R</small></span><hr><span>Delete</span></span>Menu: raised, seam ring, accent hover</figure>+ <figure><span class="menu"><span class="head">Vocals<small>Audio · 3</small></span><hr><span class="sw"><i style="background:var(--track1)"></i><i style="background:var(--track2)"></i><i class="on" style="background:var(--track3)"></i><i style="background:var(--track4)"></i><i style="background:var(--track5)"></i><i style="background:var(--track6)"></i><i style="background:var(--track7)"></i><i style="background:var(--track8)"></i><i style="background:var(--track9)"></i></span><hr><span>Record input<small>Ext ›</small></span><hr><span>Copy<small class="k">⌘C</small></span><span class="hot">Duplicate<small class="k">⌘D</small></span><hr><span class="danger">Delete<small class="k">⌫</small></span></span>Menu: object header, inline colour row, value column, shortcuts ⌘C not ⌘+C, accent hover, danger last</figure></div><div class="row" style="margin-top:12px"><span class="field">Search</span><span class="field focus">Stone Vault</span></div><p class="note">Fields and readouts are wells with a 1px rule edge; focus turns the edge accent, no ring. Empty state: one Ink 5 line, centred, no illustration, no call-to-action button.</p>diff --git a/specs/034-context-menus/checklists/requirements.md b/specs/034-context-menus/checklists/requirements.mdnew file mode 100644index 00000000..b7831a3f--- /dev/null+++ b/specs/034-context-menus/checklists/requirements.md@@ -0,0 +1,39 @@+# Specification Quality Checklist: Studio context menus++**Purpose**: Validate specification completeness and quality before proceeding to planning+**Created**: 2026-10-21+**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++- Both open questions resolved 2026-10-21: Live freeze becomes a switch (FR-009a); "Add track"+ gains a persisted "Recent" group (FR-012, FR-012a, User Story 5).+- Visual values (24 px rows, radius, glyph set, monospaced face) are design-system terms from+ `DESIGN.md`, not implementation choices; the Nota Context section names files on purpose,+ as the project template asks.+- Items marked incomplete require spec updates before `/speckit-clarify` or `/speckit-plan`diff --git a/specs/034-context-menus/contracts/menu-kit.md b/specs/034-context-menus/contracts/menu-kit.mdnew file mode 100644index 00000000..081d153c--- /dev/null+++ b/specs/034-context-menus/contracts/menu-kit.md@@ -0,0 +1,42 @@+# Contract: menu building blocks (`MenuKit`) and the `MenuItem` theme++Internal UI contract every context menu builds on. Signatures are indicative; the+behaviour is binding.++## MenuItem theme (`Theme/NotaTheme.axaml`)++| Part | Rule |+|---|---|+| Height / radius / padding | 24 · `Radius.Clip` (2) · 8,0 |+| Columns | icon 16 · label * · value-or-shortcut auto (12 left gap) · caret 12 — aligned across all items |+| Icon | `MenuKit.Icon(kind)` only; ink = item foreground (muted at rest via the icon presenter) |+| Shortcut | `MenuKit.Spell(InputGesture)` (maps the Avalonia gesture onto `Shortcut.ToPlatformString`) — `⌘G`, `⇧⌘G`, `⌫` on macOS; `Ctrl+G`, `Ctrl+Shift+G`, `Del` elsewhere; Geist Mono 11; `TextMuted` |+| Value | attached `MenuKit.Trailing` — a string (current value, `TextMuted`), a switch, or a data colour chip; shown before the shortcut and caret |+| Caret | `Glyph(ChevronRight, 8)`, `TextMuted`, inset by the caret column |+| Highlight | `Accent` fill; label, icon, shortcut, value, caret → `TextOnAccent`; 120 ms ease-out |+| Disabled | everything `TextDisabled`; no highlight |+| `.danger` | label + icon `Danger` at rest; highlight as above; disabled wins |+| `.inline` | no highlight, no icon/caret columns, content spans the width |+| Menu frame | `SurfaceRaised`, 1 px `Seam`, radius 3, padding 4, `MinWidth` 200; no blur |+| Separator | 1 px `Rule`, margin 4,4 |++## MenuKit API++| Member | Returns | Behaviour |+|---|---|---|+| `Item(header, icon?, click?, gesture?, enabled?)` | `MenuItem` | existing; labels are written sentence case at the call site (RunLabels) |+| `ValueItem(header, icon, value, submenu)` | `MenuItem` | submenu item showing the current value (FR-010) |+| `Danger(header, icon, click, gesture?)` | `MenuItem` | `.danger` item (FR-006) |+| `Header(name, colour?, badge)` | `MenuItem.inline` | non-interactive, 28 tall, name 600 truncating, badge mono muted (FR-007) |+| `ColourGrid(current, pick)` | `MenuItem.inline` | 9 × 3 swatches 14 px gap 4 + Auto; current ringed; click / Enter → `pick(index)` then close; arrows move (FR-008, FR-017) |+| `Segments(label, options, chosen, pick)` | `MenuItem.inline` | "Height" caption + segmented keys; chosen in accent; `pick(value, allModifier)` then close (FR-009) |+| `SwitchItem(header, icon, isOn, toggle)` | `MenuItem` | 18 × 10 switch in the value column; click anywhere toggles (FR-009a) |+| `ClipboardGroup(copy, cut, paste, duplicate, canPaste)` | `Control[]` | Copy ⌘C · Cut ⌘X · Paste ⌘V · Duplicate ⌘D in that order (FR-013) |+| `Icon(kind)` | `Control` | existing; neutral glyph 11 px |+| `Caption(text)` | `MenuItem.inline` | small muted heading inside a menu ("Recent") |+| `Swatch(brush)` | `Control` | 8 px data colour chip for the Trailing column (tag colours) |+| `AddGroups(items, groups…)` | — | adds non-empty groups with one rule between them |+| `AddRecent(submenu, items)` | — | "Recent" caption + items, nothing when empty |++Order inside a menu (FR-013): `Header` → inline rows → naming / settings → object actions+→ create / group → `ClipboardGroup` → `Danger` items, rules between groups.diff --git a/specs/034-context-menus/data-model.md b/specs/034-context-menus/data-model.mdnew file mode 100644index 00000000..f330ce1f--- /dev/null+++ b/specs/034-context-menus/data-model.md@@ -0,0 +1,29 @@+# Data Model: Studio context menus++Only one persisted entity is new; the rest are view-only descriptions of menu parts.++## RecentInstrument (persisted, app settings)++| Field | Type | Notes |+|---|---|---|+| `Kind` | string | `"builtin"` or `"plugin"` |+| `Id` | string | built-in device kind id (e.g. `volt`), or the plug-in's unique id from the scan |+| `Name` | string | display name at the time it was added ("Nota Volt", "Diva") |+| `FactoryPreset` | string? | factory preset id when the add came from a preset item; null otherwise |++Stored as `Settings.RecentInstruments : List<RecentInstrument>`, most recent first.++**Rules** (FR-012a):+- Identity = (`Kind`, `Id`, `FactoryPreset`). Recording an entry already present moves it to the top; no duplicates.+- Capacity 5; recording a sixth drops the oldest.+- Recorded on every instrument add by any route: browser drop / double-click / activate, "Add track ▸ Instrument" (Volt), "Add track ▸ Recent", instrument replace, MCP add tools.+- Read through `Visible(isInstalled)`: plug-in entries whose id is not in the current scan are hidden (not deleted — they come back if the plug-in returns).+- Missing / malformed list in an older settings file → empty list.++## View-only parts (not persisted)++- **MenuHeader**: colour (brush or none), name (truncates), badge text (mono, muted). From track / clip / device / chain / scene / version state at open time.+- **ColourGrid**: 9 × 3 palette indices + Auto (−1); `current` index; `pick(index)`.+- **SegmentRow**: options `(label, value)`; `chosen` value or none; `pick(value, allModifier)`.+- **SwitchItem**: label, icon, `isOn`, `toggle()`.+- **MenuItem roles**: plain · value (current value text) · danger · inline.diff --git a/specs/034-context-menus/plan.md b/specs/034-context-menus/plan.mdnew file mode 100644index 00000000..022aa871--- /dev/null+++ b/specs/034-context-menus/plan.md@@ -0,0 +1,164 @@+# Implementation Plan: Studio context menus++**Branch**: `034-context-menus` | **Date**: 2026-10-21 | **Spec**: [spec.md](spec.md)++**Input**: Feature specification from `specs/034-context-menus/spec.md`++## Summary++Every context menu in the app gets one Studio look and one order, and the track menu+gains inline rows. The look moves out of each call site into two shared places: a+**Nota `ControlTheme` for `MenuItem`** in `Theme/NotaTheme.axaml` (fixed icon · label ·+value-or-shortcut · caret columns, shortcut spelled `⌘G` in Geist Mono, a glyph caret,+neutral icons, `danger` and `inline` classes) and **new `MenuKit` building blocks**+(header row, colour grid, segmented row, switch item, value item, danger item, standard+clipboard group). Then each of the ~70 menu sites is moved onto those blocks and+re-ordered. Live freeze becomes a switch item; "Add track" gains a "Recent" group backed+by a new `Settings.RecentInstruments` list recorded wherever an instrument is added.+`DESIGN.md` § Menus and `DESIGN.html` describe the result; a new `RunMenus` guard keeps it.+Details and alternatives: [research.md](research.md).++## Nota: Read Before Planning++- **UI work** → [`DESIGN.md`](../../DESIGN.md) (Studio design language) and the `nota-design` skill — accent only for hover / chosen / switch on; danger ink is a semantic fill colour, not a second accent.+- **Anything** → [`CONTRIBUTING.md`](../../CONTRIBUTING.md): licensing, dependency policy, PR expectations.+- Engine rules ([`ARCHITECTURE.md`](../../ARCHITECTURE.md)) are untouched: no engine work.++## Technical Context++**Language/Version**: C# / .NET 10 (managed app only)++**Primary Dependencies**: Avalonia 12.1.4 + Avalonia.Themes.Fluent (existing). No new dependency.++**Storage**: app settings JSON (`Settings` → `SettingsService`), new `RecentInstruments` list (see [data-model.md](data-model.md)). Nothing in the project file.++**Audio-Thread Impact**: None — UI-only change; existing engine calls are reused, none added.++**Testing**: `scripts/build.sh` (smoke test must pass); new `DesignTokenCheck.RunMenus` guard and a `RecentInstrumentsTests` unit test in `tests/Nota.SmokeTest`; headless Avalonia shots of the menus' content in all four themes ([quickstart.md](quickstart.md)).++**Target Platform**: macOS, Linux, Windows (desktop app). Shortcut spelling differs per platform (`⌘G` / `Ctrl+G`).++**Project Type**: desktop app (Avalonia).++**Performance Goals**: a menu opens without a visible delay (< 50 ms to build, as today); the colour grid is 27 small borders, no measurable cost.++**Constraints**: no colour snapshots (theme switch live); no path geometry outside `Glyph.cs`; labels sentence case through `NotaText`; Avalonia popups cannot carry a blurred shadow.++**Scale/Scope**: ~70 menu sites in 44 files of `src/managed/Nota.App` (inventory below); `MenuKit.cs`, `NotaTheme.axaml`, `Settings.cs`, `DeviceInsertService.cs`, MCP instrument tools; `DESIGN.md`, `DESIGN.html`, `CHANGELOG.md`, `FEATURES.md`, user docs.++## Constitution Check++*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*++| Principle | Status |+|---|---|+| I. Real-time audio safety | Pass — no audio-thread code touched. |+| II. Boundary discipline | Pass — no C ABI change, no JUCE. |+| III. Licensing hygiene | Pass — new files carry the SPDX header; no dependency. The `MenuItem` theme is written fresh, not copied from Fluent's template. |+| IV. Verification gate | Pass — smoke test runs; a new `RunMenus` design guard and a recent-list unit test are added. |+| V. One logical change per PR | **Watch** — touching ~70 sites is large. Plan splits it into reviewable commits (foundation → track menus → Arrangement → Session/Modular → devices → rest) inside one PR, since a half-migrated app would look inconsistent; see Complexity Tracking. |+| VI. Docs in sync | Pass — CHANGELOG, DESIGN.md/.html, FEATURES.md (nota-features), user docs (nota-docs) planned; nota-shortcuts runs for the new Option/Alt-click on height keys (the Shortcuts pane lists mouse gestures). |+| VII. Spec-first | Pass — spec + clarifications done. |+| VIII. Safety rules not weakened | Pass. |++Post-design re-check: unchanged — Pass, with V tracked below.++## Project Structure++### Documentation (this feature)++```text+specs/034-context-menus/+├── plan.md # This file+├── research.md # Phase 0 output+├── data-model.md # Phase 1 output+├── quickstart.md # Phase 1 output+├── contracts/+│ └── menu-kit.md # MenuKit building blocks + MenuItem theme contract+└── tasks.md # Phase 2 output (/speckit-tasks)+```++### Source Code (repository root)++```text+src/managed/+├── Nota.Application/+│ ├── Settings.cs # + RecentInstruments list+│ └── RecentInstruments.cs # NEW: record / prune / read (pure, testable)+├── Nota.Presentation/+│ └── DeviceInsertService.cs # record a recent instrument on every instrument add+├── Nota.Mcp/Tools/+│ ├── InstrumentTools.cs # record recent on add_instrument_track / set instrument+│ └── PluginTools.cs # record recent on add_plugin_instrument+├── Nota.Application/Input/Shortcut.cs # + Spell(KeyGesture) → "⌘G" / "Ctrl+G"+└── Nota.App/+ ├── Theme/NotaTheme.axaml # MenuItem ControlTheme, .danger, .inline, menu widths+ ├── MenuKit.cs # header, colour grid, segments, switch, value, danger, clipboard group+ ├── MenuKit.Rows.cs # NEW: the inline row controls (colour grid, segments)+ ├── Controls/Glyph.cs # + any missing GlyphKind for menu icons (one-line comments)+ ├── ArrangementView.cs / .Tracks.cs / .Sizing.cs / .LaneControl.cs / .Sections.cs / .Automation.cs / .Controls.cs+ ├── MainWindow.Freeze.cs / .LiveFreeze.cs / .Updates.cs / .axaml.cs / .axaml+ ├── SessionView.Grid.cs / .Toolbar.cs / .Inspector.cs+ ├── ModularView.cs, BrowserView.cs, HistoryView.cs, PreviewPlayer.cs, SnapChip.cs, ClipEditorKit.cs+ ├── DeviceChainView.Clipboard.cs / .Shell.cs / .Fold.cs, DeviceCardKit.cs+ ├── DeviceCards/** (Rack, MacroPanel, Bodies, Instruments, Midi), Controls/Eq8Views.cs, Controls/DynamicEqCurve.cs+tests/Nota.SmokeTest/+├── DesignTokenCheck.Menus.cs # NEW: RunMenus guard+└── RecentInstrumentsTests.cs # NEW+DESIGN.md, scripts/design-html.py (→ DESIGN.html), CHANGELOG.md, FEATURES.md+```++**Structure Decision**: presentation lives in `Nota.App` (where every menu is built+today); the recent-instruments rule is plain logic in `Nota.Application` so both the UI+(`Nota.Presentation`) and the MCP server can record into it and the smoke test can unit+test it.++### Menu inventory (FR-014)++Each row is checked off in tasks.md against FR-001 – FR-013. "H" = gets a header row (FR-007).++| # | Site | Menu | H |+|---|---|---|---|+| 1 | `ArrangementView.cs` `ShowTrackMenu` | Track header | H |+| 2 | `ArrangementView.Tracks.cs` `ShowTracksMenu` | Multi-track selection | H |+| 3 | `ArrangementView.cs` `ShowFooterMenu` | Return / master footer | H |+| 4 | `ArrangementView.cs` `ShowEmptyAreaMenu` | Empty area below tracks | – |+| 5 | `ArrangementView.LaneControl.cs` `ShowClipMenu` | Clip (and multi-clip) | H |+| 6 | `ArrangementView.LaneControl.cs` `ShowLaneMenu` | Lane background / time selection | – |+| 7 | `ArrangementView.LaneControl.cs` `ShowAutoMenu` | Automation lane | H (parameter) |+| 8 | `ArrangementView.Automation.cs` `ShowAutoTargetMenu` | Automation target picker | – |+| 9 | `ArrangementView.Sections.cs` `ShowMenu` | Section marker | H |+| 10 | `ArrangementView.Controls.cs` `ShowMenu` | Arrangement header controls | – |+| 11 | `SessionView.Grid.cs` `ShowSlotMenu` | Session slot | H (with clip) |+| 12 | `SessionView.Grid.cs` `ShowHeaderMenu` | Session track header | H |+| 13 | `SessionView.Grid.cs` `ShowSceneMenu` | Scene | H |+| 14 | `SessionView.Grid.cs` `ShowAddTrackMenu` | Session add track | – |+| 15 | `SessionView.Toolbar.cs` (2) | Toolbar overflow / options | – |+| 16 | `SessionView.Inspector.cs` `Pick<T>` | Inspector pickers | – |+| 17 | `ModularView.cs` `ShowModulateMenu` | Knob modulate | H (parameter) |+| 18 | `ModularView.cs` `ShowConnectParamMenu`, `ShowCrossTrackParamMenu` | Modulator targets | – |+| 19 | `ModularView.cs` `Toolbar` | Modular toolbar | – |+| 20 | `DeviceChainView.Clipboard.cs` `ShowDeviceContextMenu` (+ `.Shell.cs` `HeaderMenu`, `.Fold.cs` `Menu`) | Device card / folded strip | H |+| 21 | `DeviceCards/Rack/RackCardView.cs` (5) | Rack add device / add chain / macro / map | H (chain, macro) |+| 22 | `DeviceCards/Rack/RackCardView.Drum.cs` (2) | Drum pad / add pad | H (pad) |+| 23 | `DeviceCards/Rack/MacroPanel.cs` (4) + `FillMapMenu` in Rhythm / Drum | Macro / map | H (macro) |+| 24 | `DeviceCards/Instruments/*` (Rhythm 3, Consort 3, Mosaic, Pendulum, Flux) | In-card menus | per menu |+| 25 | `DeviceCards/Bodies/*` (Ceiling, Vocoder, AutoShift 2, Chamber, DynamicEq, BeatRepeat, Valve, AutoGain, Prism, Shutter, Vintage), `Midi/ScaleMidiBody` | In-card option menus | – |+| 26 | `Controls/Eq8Views.cs`, `Controls/DynamicEqCurve.cs` `ShowBandMenu` | EQ band | H (band) |+| 27 | `DeviceCardKit.cs` `PresetPicker` | Preset list | – |+| 28 | `ClipEditorKit.cs` `ShowMenu` (+ ClipEditorView, AudioClipEditorView, PianoRollView.Expression callers) | Clip editor pickers | – |+| 29 | `BrowserView.cs` `BuildContextMenu`, `ShowOptionsMenu`, `ShowOverflowChips` | Browser item / options / chips | H (item) |+| 30 | `HistoryView.cs` `BuildMenu`, `BuildOptionsMenu` | History version / options | H (version) |+| 31 | `PreviewPlayer.cs` `ShowSourceMenu` | Preview source | – |+| 32 | `SnapChip.cs` `OpenMenu` | Snap grid | – |+| 33 | `MainWindow.Freeze.cs`, `.LiveFreeze.cs` (button menus), `BuildTrackFreezeMenu` | Freeze button / track freeze group | – |+| 34 | `MainWindow.Updates.cs` `UpdateMenu` | Update chip | – |+| 35 | `MainWindow.axaml.cs` `OnMetronomeContext`, `MainWindow.axaml` | Metronome / transport | – |++The tasks phase re-greps (`new MenuFlyout|new ContextMenu|<ContextMenu|<MenuFlyout|FillMapMenu`) so a site missed here is still caught; the `RunMenus` guard fails on any menu item built outside `MenuKit` conventions.++## Complexity Tracking++| Violation | Why Needed | Simpler Alternative Rejected Because |+|-----------|------------|-------------------------------------|+| Large PR (~45 files) against principle V | The user asked for every context menu to change together; the shared theme changes all menus at once anyway, so a split leaves menus half-migrated (new frame, old order/labels) between PRs | Splitting per view would ship an inconsistent app between merges; instead the PR is a sequence of self-contained commits (foundation first, then one view per commit) that review one at a time |diff --git a/specs/034-context-menus/quickstart.md b/specs/034-context-menus/quickstart.mdnew file mode 100644index 00000000..be836f6b--- /dev/null+++ b/specs/034-context-menus/quickstart.md@@ -0,0 +1,52 @@+# Quickstart: validating Studio context menus++## Prerequisites++- macOS dev machine with the repo built once (`scripts/build.sh`).+- Scratch data dir so settings (the recent-instruments list) don't touch the real ones:+ `export NOTA_DATA_DIR=/tmp/menus-data`.++## 1. Gate++```bash+scripts/build.sh+```++Expect green, including `DesignTokenCheck` (`RunMenus`, `RunIcons`, `RunLabels`,+`RunThemes`) and `RecentInstrumentsTests`.++## 2. Visual check (headless)++Menus are popups and do not render headless; build each menu's **content** into a+`Window` instead (see the project's UI-verify recipe: Avalonia.Headless ++`CaptureRenderedFrame`). Shoot, in Studio Dark / Studio Light / Ember Graphite /+Ember Paper:++- the track menu of an audio track (header, colour grid with the current colour ringed,+ Height segments with Standard chosen, Record input value, Live freeze switch off,+ clipboard group, Delete in danger ink), with one item forced to `:pointerover`;+- the same track live-frozen (switch on, Edit source, Flatten in danger ink);+- the multi-track menu (header "3 tracks");+- the clip, device, Session slot, scene, browser item and history version menus;+- "Add track" submenu with a populated "Recent" group.++Compare against [contracts/menu-kit.md](contracts/menu-kit.md) and `DESIGN.md` § Menus.++## 3. Behaviour (in the app)++| Step | Expected |+|---|---|+| Right-click a track, click a swatch | colour changes, menu closes, ⌘Z restores it (one step) |+| Click "Large" | track grows; Option-click "Compact" → every track compact |+| Select 3 tracks, right-click one, click a swatch | all three recoloured, one undo step |+| Live freeze switch on an instrument track | live-freezes as before; reopen → switch on; click → unfreezes |+| Add Volt, then a plug-in instrument from the browser; quit; relaunch | "Add track ▸ Recent" lists the plug-in, then Nota Volt |+| Click a Recent entry | new instrument track with it, after the clicked track |+| Arrow keys in the colour grid, Enter | moves the ring, applies, closes |+| Any menu on macOS | shortcuts read `⌘C`, never `⌘+C` |++## 4. Docs++`DESIGN.md` § Menus updated, `python3 scripts/design-html.py` regenerated, CHANGELOG+`[Unreleased]` entry, FEATURES.md (nota-features), user docs (nota-docs), Shortcuts pane+(nota-shortcuts) for Option-click on height keys.diff --git a/specs/034-context-menus/research.md b/specs/034-context-menus/research.mdnew file mode 100644index 00000000..4e4de340--- /dev/null+++ b/specs/034-context-menus/research.md@@ -0,0 +1,100 @@+# Research: Studio context menus++## R1 — Where the "⌘+G" spelling and the loose layout come from++**Finding**: menu items use Avalonia.Themes.Fluent's `MenuItem` template. Its+`PART_InputGestureText` formats `MenuItem.InputGesture` with Avalonia's own+`KeyGesture.ToString("p")`, which joins modifiers with "+" on macOS. Column widths, the+caret (a large `Path` chevron flush to the edge) and the icon slot size are fixed in that+template; `NotaTheme.axaml` only restyles colours and padding through+`/template/` selectors.++**Decision**: add a Nota `ControlTheme` for `MenuItem` (`TargetType="MenuItem"`, set as the+default theme in `NotaTheme.axaml`). Grid columns: icon 16 · label * · value/shortcut auto+· caret 12, padding 8,0, height 24. The shortcut cell shows+`Shortcut.Spell(InputGesture)` through a value converter (macOS: `⌘G`, `⇧⌘G`, `⌫`;+elsewhere `Ctrl+G`), Geist Mono 11, muted ink. The value cell shows the attached+`MenuKit.Value` string, muted ink. The caret is `Glyph(ChevronRight, 8)`. Keeps the+template parts the `MenuItem` code-behind expects (`PART_Popup`, header presenter).++**Rationale**: one place controls every menu; call sites keep using plain `MenuItem`.++**Alternatives considered**: (a) keep Fluent and override with more `/template/`+selectors — cannot change how the gesture string is built or replace the caret path;+(b) a custom `Popup` menu control — loses keyboard navigation, submenus and+accessibility that `MenuFlyout` gives for free. (c) Copying Fluent's template — avoided;+written fresh (licensing hygiene, and only the parts we need).++## R2 — Non-clickable rows (header, colour grid, segments) inside a MenuFlyout++**Finding**: `MenuFlyout` wraps any item that is not a `MenuItem` or `Separator` in a+`MenuItem` container, which then highlights on hover and closes on click.++**Decision**: the building blocks return a `MenuItem` with class `inline` (header, colour+grid, segmented row) whose `Header` is the row control. Theme styles for+`MenuItem.inline` drop the hover fill, hide icon/caret columns and let the row span the+width. `inline` rows set `Focusable` so keyboard focus can land; arrow keys inside the row+are handled by the row control (FR-017), Enter applies, the row then closes the flyout via+its owning `MenuFlyout.Hide()`. The header row additionally sets `IsHitTestVisible=false`+and `Focusable=false`.++**Alternatives considered**: a `Separator`-derived host (no keyboard focus); putting rows+in the flyout presenter's template (would apply to every menu).++## R3 — Colours, danger ink and theme following++**Decision**: swatches use `ArrangementView.TrackBrush(index)` (theme-following); ring =+1 px `TextPrimary` outline with 1 px gap; "Auto" is a 14 px key with an `Auto` caption.+Danger items use class `danger` → label and icon `Brush.Danger`; on highlight the normal+accent fill with `TextOnAccent` (DESIGN: hover is always the accent). Disabled `danger`+falls back to `TextDisabled`. All through `DynamicResource`, so a theme switch restyles.++## R4 — Live freeze as a switch++**Finding**: `MainWindow.Freeze.cs` `BuildTrackFreezeMenu` already knows the link state+(`LinkForSource` / `LinkForFrozen`). Live freeze = `LiveFreezeAsync`; unfreeze =+`UnfreezeLink(src)`.++**Decision**: `MenuKit.SwitchItem(label, icon, isOn, toggle)` draws the existing+`DeviceCardKit.Switch` (18 × 10) in the value column. Off → `LiveFreezeAsync(trackId)`;+on → `UnfreezeLink(src)`. While linked, Edit source (or Done / Discard mid-edit) and+Flatten follow as items; Flatten takes `danger` ink. The accent `GlyphIcon(…, accent:true)`+and the tinted `SnowflakeIcon` / `ChainLinkIcon` in menus become `MenuKit.Icon` (neutral).+The freeze button's own menus (`EnsureFreezeMenu`, `EnsureLiveFreezeMenu`) get the same+switch.++## R5 — Recent instruments: where to record, where to store++**Finding**: UI adds go through `Nota.Presentation/DeviceInsertService`+(`CreateInstrumentTrack`, `Insert`, `TryReplaceInstrument`, `RouteToTrack`) with a+`BrowserItem`; the plain "Instrument" track adds a Volt (`Engine.AddVoltSynthTrack` in+`MainWindow.AddTrack`); MCP adds go through `Nota.Mcp/Tools/InstrumentTools.cs` and+`PluginTools.cs`. `Settings` already keeps a similar list (`RecentProjects`).++**Decision**: `Settings.RecentInstruments : List<RecentInstrument>`; a small pure helper+`RecentInstruments.Record(list, entry)` (move-to-top, de-dupe by identity, cap 5) and+`Visible(list, isInstalled)` (drops missing plug-ins). Record from `DeviceInsertService`+(every instrument add / replace), `MainWindow.AddTrack(Instrument)` (Nota Volt), and the+MCP tools; save through the existing `ISettingsService`. "Add track ▸ Recent ▸ X" calls+`DeviceInsertService.CreateInstrumentTrack` with a `BrowserItem` rebuilt from the entry,+placed after the anchor track as "Add track" does today.++**Alternatives considered**: store in the project (rejected by clarification — the list is+per-user); record in the engine (no C ABI change wanted, and the engine does not know+browser identities).++## R6 — Guard test++**Decision**: `DesignTokenCheck.RunMenus` (source scan like `RunIcons`):+- no `Header = "Color"` / `"Track height"` submenus left;+- every `MenuItem.Icon =` is `MenuKit.Icon(...)` (no tinted icon controls in menus);+- no `InputGesture` rendered through anything but the theme (no hand-written "⌘+");+- destructive headers (`Delete`, `Remove`, `Clear`, `Discard`, `Flatten`) built via+ `MenuKit.Danger` or carrying the `danger` class.+An allow list (`MenuAllowList.txt`, shrink-only) covers justified exceptions.++## R7 — Labels++Header row names the object, so items drop the noun: "Copy", "Cut", "Paste", "Duplicate",+"Delete" in object menus; "Delete track" stays in menus without a header. All through+`NotaText.Label`; RunLabels already enforces sentence case.diff --git a/specs/034-context-menus/spec.md b/specs/034-context-menus/spec.mdnew file mode 100644index 00000000..3a56cd8a--- /dev/null+++ b/specs/034-context-menus/spec.md@@ -0,0 +1,239 @@+# Feature Specification: Studio context menus++**Feature Branch**: `034-context-menus`++**Created**: 2026-10-21++**Status**: Draft++**Input**: User description: "Redesign the track context menu (right-click on a track header in Arrangement) to match the Studio design language. Layout, top to bottom: (1) a header row with the track's colour chip, the track name (600 weight) and a muted mono badge with the track type and number ("Audio · 3"); (2) an inline colour row of the track colours, the chosen one ringed — replaces the "Color" submenu; (3) an inline "Height" row with segmented keys, the chosen one accent — replaces the "Track height" submenu; rule; (4) Rename… and Record input (submenu, current input shown muted on the right, e.g. "In 1–2"); rule; (5) Freeze track and Live freeze (with an 18×10 switch on the right, accent while on); rule; (6) Add track (submenu, then a "Recent" group of recently added instruments) and Group tracks ⌘G; rule; (7) Copy ⌘C, Cut ⌘X, Paste ⌘V (disabled when the clipboard is empty), Duplicate ⌘D; rule; (8) Delete track ⌫ in Danger ink. All icons neutral muted ink via Glyph (no blue freeze icons), small submenu carets inset from the edge, shortcuts in Geist Mono written the macOS way (⌘G, not ⌘+G). Menu 248 wide, items 24 tall radius 2, raised surface, seam ring, rules between groups, hover = full accent fill with derived ink. Update DESIGN.md § Menus for the new in-menu controls (swatch row, segments, switch) and the Danger destructive item." — extended by the user mid-specification: "Additionally: update all context menus in the program."++## 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+- [ ] Managed app (C#, `src/managed/*`) — domain, application, infrastructure, presentation+- [x] UI (Avalonia, `src/managed/Nota.Presentation`) — follow `DESIGN.md` (Studio)+- [ ] Plugin hosting (`pluginhost/`) — the only place JUCE is allowed+- [ ] Build / packaging / CI (`scripts/`, `.github/`) — see `BUILD.md`+- [ ] Docs only++The menus live in `src/managed/Nota.App`: about 72 `MenuFlyout` / `ContextMenu` sites in+44 files (Arrangement track / clip / lane / section / automation menus, Session grid and+toolbar, Modular, Browser, History, device cards and racks, macro panel, graph views,+preview player, snap chip, the main window). Shared pieces: `MenuKit.cs` (items, icons,+gestures) and the menu styles in `Theme/NotaTheme.axaml`. No engine change is expected.+A design mockup of the track menu was made in the conversation that started this spec.++**Nota docs to keep in mind** *(links relative to `specs/<slug>/`, where this file lands)*:+[`ARCHITECTURE.md`](../../ARCHITECTURE.md) (AR rules),+[`CONTRIBUTING.md`](../../CONTRIBUTING.md) (licensing, dependency policy, PR+expectations), [`BUILD.md`](../../BUILD.md), [`DESIGN.md`](../../DESIGN.md),+[`FEATURES.md`](../../FEATURES.md).++## Clarifications++### Session 2026-10-21++- Q: Live freeze is an action today (renders a frozen copy and links it to the source). Should it become an on/off switch? → A: Yes — a switch: on = the track is in a live-freeze link; switching it off unfreezes (wakes the source); switching it on runs Live freeze.+- Q: Should "Add track" list recently added instruments under a "Recent" heading, with a new persisted list? → A: Yes — add a "Recent" group backed by a persisted list.+- Q: Does the track menu's colour row show all 27 palette colours (9 bases × 3 shades) as a 9 × 3 grid, or only the 9 bases? → A: A 9 × 3 grid of all 27 colours plus "Auto", the current colour ringed.+- Q: Does the object header row appear in every menu for a named object (clip, device, rack chain, scene, Session slot, return) or only in track menus? → A: In every menu for a named object, device menus included.+- Q: Is "Recent" only recent instruments in "Add track", or also recent effects in add-device menus? → A: Instruments in "Add track" only; effects get no recent list.++## User Scenarios & Testing *(mandatory)*++### User Story 1 - Every context menu looks and reads the same (Priority: P1)++A producer right-clicks around the app — a track header, a clip, a device card header,+a Session slot, a browser item, a node in Modular. Every menu has the same frame, the+same item height and spacing, the same neutral icons in one column, shortcuts set the+same way on the right (`⌘G`, `⇧⌘G` on macOS; `Ctrl+G` elsewhere), small submenu carets+set in from the edge, rules between groups, and destructive commands (Delete, Remove,+Clear…) in red ink at the end of the menu.++**Why this priority**: This is the user's main complaint ("too simple, doesn't match+the program's design") and it touches every menu, so it gives the most value and lays+the foundation the other stories build on.++**Independent Test**: Open each context menu listed in the inventory (see FR-014) and+compare it against the menu rules in `DESIGN.md`; every menu passes the same checks+without any of the inline controls from Story 2.++**Acceptance Scenarios**:++1. **Given** any context menu, **When** it opens, **Then** its items are 24 px tall, the icon column, label column, shortcut column and submenu caret line up across all items, and every icon is drawn in the muted neutral ink (no coloured icons at rest).+2. **Given** a menu item with a shortcut on macOS, **When** the menu opens, **Then** the shortcut is written with the macOS symbols without separators (`⌘G`, `⇧⌘V`, `⌫`) in the monospaced face; **and** on Windows / Linux the same item reads `Ctrl+G`, `Ctrl+Shift+V`, `Del`.+3. **Given** a menu item that opens a submenu, **When** the menu opens, **Then** the caret is a small glyph set in from the menu's right edge, the same size as the shortcut text, never touching the edge.+4. **Given** a menu that contains a destructive command, **When** it opens, **Then** that command sits in the last group, its label and icon are drawn in the danger ink at rest, and on hover it takes the full accent fill with derived ink like every other item.+5. **Given** a disabled item (e.g. Paste with an empty clipboard), **When** the menu opens, **Then** the label, icon and shortcut all take the disabled ink step, and hovering it shows no fill.+6. **Given** any theme (Studio Dark, Studio Light, Ember Graphite, Ember Paper), **When** a menu opens, **Then** it follows the theme, and switching theme while the app runs restyles the next menu opened.++---++### User Story 2 - Change a track's colour and height in one click (Priority: P1)++A user right-clicks a track header to recolour it. The menu opens with the track's name+and type at the top, then a row of colour swatches — the current colour ringed — and a+row of height keys. One click on a swatch recolours the track; one click on a height key+resizes it. No submenus to travel through.++**Why this priority**: Colour and height are the most frequent track-menu edits, and+today each needs two levels of submenu (colour needs three). This is the centrepiece of+the requested mockup.++**Independent Test**: Right-click a track, click a swatch, confirm the track's colour+changes and the menu closes; reopen, click a height key, confirm the track's height+changes.++**Acceptance Scenarios**:++1. **Given** a track, **When** the user right-clicks its header, **Then** the menu opens with a header row showing the track's colour chip, its name and a muted badge with its type and position (e.g. "Audio · 3"); the header row is not clickable and never highlights.+2. **Given** the track menu is open, **When** the user looks at the colour row, **Then** every track colour of the palette (all bases and their light / dark shades) is shown as a swatch, plus an "Auto" choice, and the track's current colour is ringed.+3. **Given** the track menu is open, **When** the user clicks a swatch, **Then** the track takes that colour, the change is one undo step, and the menu closes.+4. **Given** the track menu is open, **When** the user looks at the height row, **Then** it shows the Compact, Standard and Large presets as segmented keys, the key matching the track's height in the accent; when the track has a custom (dragged) height no key is chosen.+5. **Given** the track menu is open, **When** the user clicks a height key, **Then** the track takes that height and the menu closes; **When** the user Option/Alt-clicks a height key, **Then** every track takes that height.+6. **Given** several tracks are selected, **When** the user right-clicks one of them, **Then** the header row reads the count ("3 tracks"), and a swatch or height key applies to all of them as one undo step.+7. **Given** the footer menu of a return or the master track, **When** it opens, **Then** it shows the same header row and colour row.++---++### User Story 3 - See the current state without opening submenus (Priority: P2)++A user wants to know where an audio track records from and whether it is frozen. The+track menu shows the current record input on the right of "Record input" (e.g.+"In 1–2", "Master", "Bass"), the current MIDI source on the right of "MIDI from" for an+instrument track, and the freeze state of the track.++**Why this priority**: Showing state in place removes a round trip into the submenu,+but the menu stays usable without it.++**Independent Test**: Set a track's record input to another track, open the menu, and+read that track's name on the right of "Record input" without opening the submenu.++**Acceptance Scenarios**:++1. **Given** an audio track recording from the hardware input, **When** its menu opens, **Then** "Record input" shows the input in muted ink on the right, before the caret.+2. **Given** an instrument track that takes MIDI from another track, **When** its menu opens, **Then** "MIDI from" shows that track's name on the right; with no source it shows "None".+3. **Given** a live-frozen track (either side of the link), **When** its menu opens, **Then** the "Live freeze" switch is on (accent), with "Edit source" and "Flatten (remove source)" below it; **When** the user clicks the switch, **Then** the link unfreezes and the source wakes.+4. **Given** a live track that can be live-frozen, **When** the user clicks the off "Live freeze" switch, **Then** the track is live-frozen exactly as the current command does.++---++### User Story 5 - Add a recently used instrument from the menu (Priority: P3)++A user who keeps adding Nota Volt tracks right-clicks a track, opens "Add track", and+picks Nota Volt from the "Recent" group; an instrument track with Volt lands right after+the clicked track.++**Why this priority**: A convenience on top of the redesign; the menu works without it.++**Independent Test**: Add two different instruments, restart the app, open "Add track"+and see both under "Recent", most recent first; click one and get a new track with it.++**Acceptance Scenarios**:++1. **Given** the user has added instruments before, **When** "Add track" opens, **Then** "Recent" lists up to 5 of them, most recent first, without duplicates.+2. **Given** a recent entry, **When** the user clicks it, **Then** a new instrument track with that instrument is added after the clicked track, as one undo step.+3. **Given** a fresh install, **When** "Add track" opens, **Then** no "Recent" heading is shown.+4. **Given** a recent plug-in that has since been uninstalled, **When** "Add track" opens, **Then** it is not listed.++---++### User Story 4 - Menus are ordered the same way everywhere (Priority: P2)++Whatever the user right-clicks, commands come in the same order of groups: object+header (where the object has a name) → inline properties → naming and settings →+object-specific actions → create / group → clipboard (Copy, Cut, Paste, Duplicate) →+destructive. Labels are short because the header names the object ("Copy", not+"Copy track").++**Why this priority**: Consistent order builds muscle memory across views, but each+menu is usable before the reorder.++**Independent Test**: Open the clip, device, Session slot and track menus and confirm+the clipboard group and the destructive group sit in the same relative places with the+same labels and shortcuts.++**Acceptance Scenarios**:++1. **Given** any menu with clipboard commands, **When** it opens, **Then** they appear in the order Copy, Cut, Paste, Duplicate, with the same shortcuts in every menu.+2. **Given** a menu for a named object (track, clip, device, scene, chain, return), **When** it opens, **Then** it starts with the header row naming the object, and its item labels do not repeat the object's noun.+3. **Given** a menu for something without a name (empty arrangement area, a graph background, a snap chip), **When** it opens, **Then** it has no header row.++---++### Edge Cases++- A track with a very long name: the header row truncates the name with an ellipsis and keeps the type badge whole.+- A track with a colour index outside the palette (older project) or "Auto": no swatch is ringed except "Auto" when the colour is automatic.+- A group track, a return or the master: rows that do not apply (record input, freeze, height for the master footer) are left out rather than shown disabled.+- A menu opened near the screen edge: the menu and its submenus stay fully on screen; the inline rows never get clipped.+- Keyboard use: arrow keys move through the items; the colour and height rows can be reached and operated with the keyboard (arrows within the row, Enter to apply), and Escape closes the menu.+- A destructive item that is disabled (e.g. Delete on the master): it takes the disabled ink, not the danger ink.+- A menu on a device card inside a narrow layout still uses the shared menu width rules; long submenu lists (record inputs with many tracks) scroll rather than run off-screen.++## Requirements *(mandatory)*++### Functional Requirements++- **FR-001**: Every context menu in the app MUST use the shared menu frame: raised surface, 1 px seam ring, radius 3, 4 px padding, no blurred shadow, and a minimum width of 200 px (248 px for the track menu with inline rows).+- **FR-002**: Every menu item MUST be 24 px tall with radius 2, a fixed icon column (icon drawn with the shared glyph set in the muted ink at rest), a label column, a right-aligned shortcut or value column, and a caret column for submenus; columns MUST line up across all items of one menu whether or not an item has an icon.+- **FR-003**: Hover and keyboard highlight MUST be a full accent fill with derived ink on label, icon, shortcut, value and caret, with the standard 120 ms colour transition; disabled items MUST take the disabled ink and never highlight.+- **FR-004**: Shortcuts in menus MUST be set in the monospaced face and spelled per platform: macOS symbols without separators (`⌘G`, `⇧⌘G`, `⌫`); `Ctrl+G` style on Windows / Linux. A menu MUST only show a shortcut that actually performs the same command.+- **FR-005**: Submenu carets MUST be a small glyph from the shared icon set, inset from the right edge, in the muted ink (derived ink while highlighted).+- **FR-006**: Destructive commands (delete, remove, clear, discard, flatten that removes a source) MUST sit in the last group of their menu and be drawn in the danger ink at rest.+- **FR-007**: Menus for a named object (track, multi-track selection, clip, multi-clip selection, device — including the device card header menu, rack chain, macro, scene, Session slot with a clip, return / master, browser item, history version) MUST start with a non-interactive header row: the object's colour chip where it has one, its name in the heading weight, and a muted monospaced badge with its type and position or count.+- **FR-008**: The track menu, the multi-track menu and the return / master footer menu MUST replace the "Color" submenu with an inline colour grid of 9 columns (bases) × 3 rows (base, light, dark shade) — all 27 palette colours — plus an "Auto" choice beside it, the current colour ringed; clicking applies the colour to every target track as one undo step and closes the menu.+- **FR-009**: The track and multi-track menus MUST replace the "Track height" submenu with an inline row of segmented keys for the Compact, Standard and Large presets; the chosen key in the accent; click applies to the target tracks, Option/Alt-click to all tracks; the "All tracks: …" items go away.+- **FR-009a**: "Live freeze" MUST be an item with an 18 × 10 switch on the right, shown on both sides of a link (source and frozen copy): on (accent) while the track is in a live-freeze link, off otherwise. Clicking it while off runs Live freeze (same render and progress as today); clicking it while on unfreezes the link (wakes the source, same as today's "Unfreeze (wake source)"). While linked, "Edit source" (or "Done — re-freeze" / "Discard edits" mid-edit) and "Flatten (remove source)" stay as items under the switch; Flatten counts as destructive (FR-006) only in its ink, not its position. On a track that cannot be live-frozen (return, group, master, a track frozen in place) the switch row is left out.+- **FR-010**: Items that open a choice submenu with a current value (Record input, MIDI from, and similar elsewhere) MUST show the current value in muted ink to the left of the caret.+- **FR-011**: Every context-menu icon MUST be neutral at rest; the coloured freeze / live-freeze icons and any other tinted menu icons go away (state colour is shown by the inline controls or the header row, not by icons).+- **FR-012**: The "Add track" submenu MUST list the track kinds the app can add (instrument, audio, return) with short labels ("Instrument", "Audio", "Return"), followed by a "Recent" heading listing up to 5 recently added instruments (built-in and plug-in), most recent first; clicking one adds an instrument track with that instrument at the same place a plain "Instrument" would land. With no history the "Recent" group is left out.+- **FR-012a**: The recent-instruments list MUST be persisted in the app's settings (not in the project), survive restarts, be updated whenever an instrument is added to a track by any route (menu, browser drag, double-click, MCP tool), hold no duplicates (re-adding moves an entry to the top), and drop entries whose plug-in is no longer installed.+- **FR-013**: Within each menu the groups MUST follow the order: header → inline properties → naming and settings → object-specific actions → create / group → clipboard (Copy, Cut, Paste, Duplicate) → destructive; labels MUST NOT repeat the object noun already named by the header, and MUST stay sentence case.+- **FR-014**: The feature MUST cover every context menu in the app; the plan MUST include an inventory of all of them (file, trigger, purpose) and each one MUST be checked off against FR-001 – FR-013.+- **FR-015**: New in-menu controls (header row, colour row, segmented row, value column, danger item) MUST be shared building blocks, not built per menu, and MUST follow the theme live (no colour snapshots).+- **FR-016**: All existing commands, their behaviour, undo grouping and enable/disable rules MUST stay as they are; this feature changes presentation, order and labels only — plus the Option/Alt-click on height keys, the Live freeze switch (FR-009a) and the recent-instruments list (FR-012, FR-012a).+- **FR-017**: The inline rows MUST be operable with the keyboard: arrow keys move between swatches / keys, Enter applies, Escape closes the menu.+- **FR-018**: `DESIGN.md` § Menus MUST describe the header row, the inline colour and segmented rows, the value column, the danger item and the group order, and `DESIGN.html` MUST show a specimen menu.++### Key Entities++- **Context menu**: a floating list opened by right-click on an object or area; has an optional header, groups of items divided by rules.+- **Menu item**: icon, label, optional shortcut or current value, optional submenu caret; states rest / highlight / disabled; optional destructive role.+- **Header row**: the object's colour chip, name and type / position badge; not interactive.+- **Inline property row**: a colour row (swatches + Auto) or a segmented row (presets) that applies a value with one click.+- **Recent instruments**: an ordered, de-duplicated list of up to 5 instrument identities (built-in kind or plug-in id and name), stored in app settings, most recent first.++## Success Criteria *(mandatory)*++### Measurable Outcomes++- **SC-001**: 100 % of the app's context menus (the full inventory) pass the menu checklist in `DESIGN.md` § Menus in all four themes.+- **SC-002**: Changing a track's colour takes one right-click and one click (down from three levels of menu travel today); changing its height takes one right-click and one click (down from two levels).+- **SC-003**: No context-menu icon is coloured at rest, and no shortcut in any menu is written with a "+" separator on macOS.+- **SC-004**: The clipboard group (Copy, Cut, Paste, Duplicate) appears in the same order with the same shortcuts in every menu that offers it.+- **SC-005**: All existing smoke tests, including the design-token, label and icon guards, pass; no command that was reachable from a menu before becomes unreachable.++## Assumptions++- Height presets: the app has three presets (Compact, Standard, Large) and continuous drag; the mockup's "S · M · L · XL" maps to these three — no fourth size is added.+- "Add track" kinds follow the app (Instrument, Audio, Return); the mockup's "MIDI" label is read as the instrument track.+- "Added an instrument" means the user chose one: the browser (drop, double-click, palette), "Add track ▸ Instrument / Recent", an instrument preset, an instrument swap, and the MCP add / set-instrument tools. Tracks Nota creates as a side effect — Convert to MIDI, MIDI-file import, the AI assistant's helper tracks, the demo project — do not enter the recent list.+- Recent devices are tracked for instruments only; audio and MIDI effects have no recent list and add-device menus keep their current content (restyled only).+- The Windows / Linux shortcut spelling stays `Ctrl+…`; only macOS spelling changes.+- The native macOS menu bar and the Windows / Linux menu bar are out of scope; only context menus and drop-down menus drawn by the app are covered.+- Drop-down pickers that are not menus (combo boxes, the preset picker) are out of scope unless they are built as menus.+- The work happens on a feature branch off `develop`; the current branch (`fix/pr212-review`) is unrelated.++## 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 (two lines, see CONTRIBUTING.md)+- [x] No new dependency — or: license checked, AGPL-compatible, `LICENSES/third-party.md` row planned+- [x] Audio-thread impact considered: no alloc / lock / I/O on the audio thread (AR-6), command queue for data in (AR-4), immutable snapshots for structural edits (AR-5) — UI only, no engine change+- [x] Managed/native crossings go through the pure C ABI in `nota_engine.h` only (AR-7); no JUCE outside `pluginhost/`+- [x] Smoke-test impact assessed: engine behaviour change → extend `tests/Nota.SmokeTest` (no engine change; design guards may gain a menu check)+- [x] User-visible change → `CHANGELOG.md` `[Unreleased]` entry planned (and FEATURES.md / user docs via the nota-features / nota-docs skills when working with an agent that has them)+- [x] UI change → follows `DESIGN.md` (Studio design language)diff --git a/specs/034-context-menus/tasks.md b/specs/034-context-menus/tasks.mdnew file mode 100644index 00000000..fb3f3edc--- /dev/null+++ b/specs/034-context-menus/tasks.md@@ -0,0 +1,173 @@+---++description: "Task list for Studio context menus"+---++# Tasks: Studio context menus++**Input**: Design documents from `specs/034-context-menus/`++**Prerequisites**: [plan.md](plan.md), [spec.md](spec.md), [research.md](research.md), [data-model.md](data-model.md), [contracts/menu-kit.md](contracts/menu-kit.md), [quickstart.md](quickstart.md)++**Tests**: The plan adds a design guard (`RunMenus`) and a unit test for the recent-instruments list; both are included. No other tests.++**Organization**: Tasks are grouped by user story. Paths are relative to the repo root; `App/` = `src/managed/Nota.App/`.++## Format: `[ID] [P?] [Story] Description`++- **[P]**: Can run in parallel (different files, no dependencies)+- **[Story]**: Which user story this task belongs to (US1 – US5)++---++## Phase 1: Setup++- [X] T001 Create feature branch `034-context-menus` off `develop` (the spec folder `specs/034-context-menus/` moves with it)+- [X] T002 Re-grep every menu site (`new MenuFlyout|new ContextMenu|<ContextMenu|<MenuFlyout|FillMapMenu|ContextRequested|IsRightButtonPressed`) in `src/managed/Nota.App` and reconcile with the inventory table in `specs/034-context-menus/plan.md`; add any missing site as a row++---++## Phase 2: Foundational (blocking)++**Purpose**: the shared `MenuItem` theme and `MenuKit` primitives every story uses.++- [X] T003 [P] Add `Shortcut.Spell(KeyGesture)` (macOS `⌘G`, `⇧⌘G`, `⌫` — modifiers in the order ⌃⌥⇧⌘, no separators; elsewhere `Ctrl+Shift+G`, `Del`) reusing the existing `SpellText` rules in `src/managed/Nota.Application/Input/Shortcut.cs` — done as `MenuKit.Spell(KeyGesture)` in `src/managed/Nota.App/MenuKit.cs`, since Nota.Application has no Avalonia types; it builds a `Shortcut` and calls `ToPlatformString`+- [X] T004 [P] Add `GlyphKind`s needed by menus but missing (check: Snowflake/Freeze, ChainLink, Palette, Input, Copy, Cut, Paste, Duplicate, Trash, Folder, Ungroup, Plus, Edit, Note exist; add only what is missing, one-line comment each) in `App/Controls/Glyph.cs`+- [X] T005 Write the Nota `ControlTheme` for `MenuItem` per [contracts/menu-kit.md](contracts/menu-kit.md) § MenuItem theme — columns icon 16 · label * · value-or-shortcut auto · caret 12; 24 tall; radius `Radius.Clip`; shortcut via a converter calling `Shortcut.Spell` in Geist Mono 11 `TextMuted`; value cell bound to attached `MenuKit.Value`; caret `Glyph(ChevronRight, 8)`; highlight = `Accent` fill + `TextOnAccent` on every part with 120 ms transition; disabled = `TextDisabled`, no fill; classes `.danger` (label + icon `Danger`, disabled wins) and `.inline` (no highlight, no icon/caret columns, content spans) — replacing the current `MenuItem` styles in `App/Theme/NotaTheme.axaml`+- [X] T006 Set menu frame `MinWidth` 200 on `MenuFlyoutPresenter` and `ContextMenu`, keep seam ring / radius 3 / padding 4 / no blur, Separator 1 px `Rule` margin 4,4 in `App/Theme/NotaTheme.axaml`+- [X] T007 Extend `MenuKit` with attached property `Value` (implemented as `Trailing`: a value string, a switch or a colour chip), `ValueItem(header, icon, value)`, `Danger(header, icon, click, gesture?)`, `ClipboardGroup(copy, cut, paste, duplicate, canPaste)` (order Copy ⌘C · Cut ⌘X · Paste ⌘V · Duplicate ⌘D) in `App/MenuKit.cs` (labels stay sentence case at the call site — `RunLabels` checks them — rather than being re-cased by `NotaText.Label`, which would touch track and preset names)+- [X] T008 Add `DesignTokenCheck.RunMenus` per research R6 (no "Color"/"Track height" submenus; `MenuItem.Icon` only via `MenuKit.Icon`; no hand-built "⌘+"/"Ctrl+" gesture strings in menus; destructive headers `Delete|Remove|Clear|Discard|Flatten` only via `MenuKit.Danger` or class `danger`), a shrink-only `MenuAllowList.txt` pre-filled with today's violations, and wire it into the smoke-test runner in `tests/Nota.SmokeTest/DesignTokenCheck.Menus.cs`, `tests/Nota.SmokeTest/MenuAllowList.txt`, `tests/Nota.SmokeTest/DesignTokenCheck.cs`++**Checkpoint**: every existing menu already renders with the new frame, columns, `⌘G` spelling and glyph caret.++---++## Phase 3: User Story 1 — Every context menu looks and reads the same (P1) 🎯 MVP++**Goal**: all ~70 menus use neutral icons, `MenuKit` items, danger ink for destructive commands, no hand-tinted parts.++**Independent Test**: open each menu in the plan's inventory in all four themes; each passes the contract table; `RunMenus` passes with an empty allow list.++- [X] T009 [US1] Freeze menus: replace `SnowflakeIcon()`, `ChainLinkIcon()` and `GlyphIcon(…, accent:true)` in menu items with `MenuKit.Icon`, make "Discard edits" and "Flatten …" `MenuKit.Danger` in `App/MainWindow.Freeze.cs` and `App/MainWindow.LiveFreeze.cs`+- [X] T010 [P] [US1] Arrangement menus (inventory 1–10): icons via `MenuKit.Icon`, destructive via `MenuKit.Danger`, clipboard via `MenuKit.ClipboardGroup` in `App/ArrangementView.cs`, `App/ArrangementView.Tracks.cs`, `App/ArrangementView.LaneControl.cs`, `App/ArrangementView.Automation.cs`, `App/ArrangementView.Sections.cs`, `App/ArrangementView.Controls.cs`+- [X] T011 [P] [US1] Session menus (inventory 11–16) the same way in `App/SessionView.Grid.cs`, `App/SessionView.Toolbar.cs`, `App/SessionView.Inspector.cs`+- [X] T012 [P] [US1] Modular menus (inventory 17–19) in `App/ModularView.cs`+- [X] T013 [P] [US1] Device chain + racks + macros (inventory 20–23) in `App/DeviceChainView.Clipboard.cs`, `App/DeviceChainView.Shell.cs`, `App/DeviceChainView.Fold.cs`, `App/DeviceCards/Rack/RackCardView.cs`, `App/DeviceCards/Rack/RackCardView.Drum.cs`, `App/DeviceCards/Rack/MacroPanel.cs`, and `FillMapMenu` in `App/DeviceCards/Instruments/RhythmInstrumentCard.cs`+- [X] T014 [P] [US1] In-card menus (inventory 24–28) in `App/DeviceCards/Instruments/*.cs`, `App/DeviceCards/Bodies/*.cs`, `App/DeviceCards/Midi/ScaleMidiBody.cs`, `App/Controls/Eq8Views.cs`, `App/Controls/DynamicEqCurve.cs`, `App/DeviceCardKit.cs`, `App/ClipEditorKit.cs`+- [X] T015 [P] [US1] Browser, History, preview, snap, updates, metronome (inventory 29–35) in `App/BrowserView.cs`, `App/HistoryView.cs`, `App/PreviewPlayer.cs`, `App/SnapChip.cs`, `App/MainWindow.Updates.cs`, `App/MainWindow.axaml.cs`, `App/MainWindow.axaml`+- [X] T016 [US1] Empty `tests/Nota.SmokeTest/MenuAllowList.txt` (or leave only justified, commented exceptions) and run `scripts/build.sh` green++**Checkpoint**: US1 complete — consistent menus app-wide without inline rows.++---++## Phase 4: User Story 2 — Colour and height in one click (P1)++**Goal**: header row + colour grid + height segments on track, multi-track and return/master menus.++**Independent Test**: right-click a track → swatch recolours it (one undo step) → reopen → "Large" resizes it; Option-click resizes all.++- [X] T017 [US2] Create `MenuKit.Header(name, colour?, badge)` (inline, non-interactive, 28 tall, name 600 truncating with ellipsis, badge Geist Mono muted), `MenuKit.ColourGrid(current, pick)` (9 columns × 3 rows base/light/dark, 14 px swatches, gap 4, + "Auto" key; current ringed 1 px `TextPrimary` with 1 px gap; arrows move, Enter picks; closes the owning flyout) and `MenuKit.Segments(label, options, chosen, pick(value, allModifier))` (segmented keys butted on seams, chosen in accent, Option/Alt detected as `allModifier`) in new `App/MenuKit.Rows.cs` (SPDX header)+- [X] T018 [US2] Rebuild `ShowTrackMenu`: Header (track colour, name, "Audio · 3" / "Instrument · 3" / "Group · 3"), ColourGrid (replaces `BuildColorSubmenu`), Segments "Height" Compact/Standard/Large (none chosen on a custom height; click → `SetTrackHeights(one, h)`, Option → `SetAllTrackHeights(h)`) in `App/ArrangementView.cs` and `App/ArrangementView.Sizing.cs` (remove `BuildTrackHeightSubmenu` and the "All tracks: …" items)+- [X] T019 [US2] Rebuild `ShowTracksMenu` with Header "N tracks" (no colour chip), ColourGrid and Segments applying to all ids as one undo group in `App/ArrangementView.Tracks.cs`+- [X] T020 [US2] Rebuild `ShowFooterMenu` (return / master) with Header + ColourGrid; no height row for master in `App/ArrangementView.cs`; delete `BuildColorSubmenu`, `TrackColorNames`, `ShadeNames` if unused+- [X] T021 [US2] Session track header menu (`ShowHeaderMenu`) gets the same Header + ColourGrid in `App/SessionView.Grid.cs`+- [X] T022 [US2] Run `nota-shortcuts` skill: add "Option-click a height key — every track" to the Shortcuts pane++**Checkpoint**: US1 + US2 — the requested mockup is live.++---++## Phase 5: User Story 3 — Current state without opening submenus (P2)++**Goal**: value column on Record input / MIDI from; Live freeze switch.++**Independent Test**: set a record input to another track; its name shows on the right of "Record input"; Live freeze switch reflects and toggles the link.++- [X] T023 [US3] Create `MenuKit.SwitchItem(header, icon, isOn, toggle)` drawing `DeviceCardKit.Switch` (18 × 10, accent when on) in the value column in `App/MenuKit.Rows.cs`+- [X] T024 [US3] Record input and MIDI from become `MenuKit.ValueItem` showing the current source ("In 1–2" style hardware label, "Master", track / return name; "None" for MIDI from) in `App/ArrangementView.cs`+- [X] T025 [US3] `BuildTrackFreezeMenu`: "Live freeze" as `SwitchItem` on both sides of a link (off → `LiveFreezeAsync(trackId)`, on → `UnfreezeLink(src)`); while linked keep Edit source / Done — re-freeze / Discard edits and `Flatten (remove source)` (Danger ink) below it; drop the separate "Unfreeze (wake source)" item; leave the switch out for tracks that cannot be live-frozen or are frozen in place in `App/MainWindow.Freeze.cs`+- [X] T026 [US3] Same switch in the freeze buttons' own menus (`EnsureFreezeMenu`, `EnsureLiveFreezeMenu`) in `App/MainWindow.Freeze.cs`, `App/MainWindow.LiveFreeze.cs`++---++## Phase 6: User Story 4 — Same order everywhere (P2)++**Goal**: header rows on all named-object menus; group order and short labels (FR-007, FR-013).++**Independent Test**: clip, device, Session slot and track menus show the clipboard group and destructive group in the same places with the same labels.++- [X] T027 [P] [US4] Clip and multi-clip menu: Header (clip colour, name, "MIDI clip · 4 bars" / "Audio clip" / "3 clips"), labels Copy/Cut/Paste/Duplicate/Delete, group order in `App/ArrangementView.LaneControl.cs`+- [X] T028 [P] [US4] Section marker and automation lane menus: Header (section name; parameter name with device in badge) and order in `App/ArrangementView.Sections.cs`, `App/ArrangementView.LaneControl.cs`+- [X] T029 [P] [US4] Session slot (with clip) and scene menus: Header + order in `App/SessionView.Grid.cs`+- [X] T030 [P] [US4] Device card header / folded strip menu: Header (device name, badge kind "Audio effect · 2" etc.), order (A/B · move · clipboard · Delete) in `App/DeviceChainView.Clipboard.cs`, `App/DeviceChainView.Shell.cs`+- [X] T031 [P] [US4] Rack chain, drum pad, macro, EQ band menus: Header + order in `App/DeviceCards/Rack/RackCardView.cs`, `App/DeviceCards/Rack/RackCardView.Drum.cs`, `App/DeviceCards/Rack/MacroPanel.cs`, `App/Controls/Eq8Views.cs`, `App/Controls/DynamicEqCurve.cs`+- [X] T032 [P] [US4] Modulate menu: Header (parameter name) in `App/ModularView.cs`+- [X] T033 [P] [US4] Browser item and History version menus: Header (item name + type; version label + date) and order in `App/BrowserView.cs`, `App/HistoryView.cs`+- [X] T034 [US4] Track menu final order per FR-013: Header → colour → height → Rename… / Record input / MIDI from → freeze group → Add track / Group tracks / Ungroup → clipboard → Delete; short labels ("Copy", not "Copy track") in `App/ArrangementView.cs`, `App/ArrangementView.Tracks.cs`++---++## Phase 7: User Story 5 — Recent instruments in Add track (P3)++**Goal**: persisted "Recent" group under Add track.++**Independent Test**: add two instruments, restart, see both under Recent (most recent first); click one → new track after the clicked one.++- [X] T035 [P] [US5] Add `RecentInstrument { Kind ("builtin" | "plugin"), Id, Name, FactoryPreset? }` and `Settings.RecentInstruments : List<RecentInstrument>` (most recent first; missing / malformed → empty) in `src/managed/Nota.Application/Settings.cs`+- [X] T036 [P] [US5] Add pure helper `RecentInstruments.Record(list, entry)` — "Identity = (Kind, Id, FactoryPreset). Recording an entry already present moves it to the top; no duplicates. Capacity 5; recording a sixth drops the oldest." — and `Visible(list, isInstalled)` hiding (not deleting) plug-ins missing from the scan, in new `src/managed/Nota.Application/RecentInstruments.cs` (SPDX header)+- [X] T037 [US5] Unit test the rules above (move-to-top, de-dupe, cap 5, hide missing plug-in, empty on malformed) in new `tests/Nota.SmokeTest/RecentInstrumentsTests.cs` and wire it into the runner+- [X] T038 [US5] Record on every instrument add/replace in `src/managed/Nota.Presentation/DeviceInsertService.cs` (`CreateInstrumentTrack`, `Insert`, `TryReplaceInstrument`, `RouteToTrack`) and save via the settings service+- [X] T039 [P] [US5] Record "Nota Volt" on `AddTrack(NewTrackKind.Instrument)` in `App/MainWindow.axaml.cs`+- [X] T040 [P] [US5] Record on MCP instrument adds in `src/managed/Nota.Mcp/Tools/InstrumentTools.cs`, `src/managed/Nota.Mcp/Tools/PluginTools.cs`+- [X] T041 [US5] "Add track" submenu: "Instrument", "Audio", "Return", then a "Recent" caption and up to 5 entries (left out when empty); clicking creates the instrument track after the anchor via `DeviceInsertService.CreateInstrumentTrack` as one undo step; shared by Arrangement (`AddTrackItems`) and Session (`ShowAddTrackMenu`) in `App/ArrangementView.cs`, `App/SessionView.Grid.cs`++---++## Phase 8: Polish & cross-cutting++- [X] T042 Update `DESIGN.md` § Menus (header row, colour grid, segments, value column, switch item, danger item, group order) and § Accepted exceptions if needed; add a specimen menu to `scripts/design-html.py` and regenerate `DESIGN.html`+- [X] T043 [P] `CHANGELOG.md` `[Unreleased]` entry (Changed: context menus; Added: Recent instruments in Add track, Live freeze switch)+- [X] T044 [P] Run `nota-features` skill → `FEATURES.md`+- [X] T045 [P] Run `nota-docs` skill → user docs (EN + RU) and re-shot menu screenshots+- [X] T046 Headless menu-content shots in all four themes per [quickstart.md](quickstart.md) § 2; fix anything off-contract+- [X] T047 `scripts/build.sh` green (smoke test incl. `RunMenus`, `RunIcons`, `RunLabels`, `RunThemes`, `RecentInstrumentsTests`)+- [X] T048 Re-check the spec's Nota Compliance Checklist; run `/speckit-converge`++---++## Dependencies & Execution Order++- Setup (T001–T002) → Foundational (T003–T008) → stories.+- US1 (T009–T016) first: it removes the per-site styling the later stories would otherwise fight.+- US2 depends on Foundational + T017; independent of US3–US5.+- US3 depends on Foundational (T023 lives in `MenuKit.Rows.cs` created by T017 — do T017 first).+- US4 depends on T017 (Header) and on US1's per-file passes.+- US5: T035–T037 can start right after Foundational; T041 after T018 (same file).+- Polish last.++## Parallel Opportunities++- T003 ∥ T004 (different files).+- US1: T010 – T015 touch disjoint files — run in parallel after T009.+- US4: T027 – T033 are disjoint files.+- US5: T035 ∥ T036; T039 ∥ T040.+- Polish: T043 ∥ T044 ∥ T045.++## Implementation Strategy++1. **MVP = Foundational + US1**: every menu already consistent (frame, columns, `⌘G`, neutral icons, danger ink).+2. Add **US2** — the mockup's centrepiece; demo.+3. **US3** and **US4** — state in place and consistent order.+4. **US5** — Recent instruments.+5. Polish, docs, converge. One PR, one commit per phase/view (plan § Complexity Tracking).++---++## Phase 9: Convergence++- [X] T049 Record instrument presets in the recent list: `DeviceInsertService.ApplyPresetCore` swaps the instrument via `SetTrackBuiltinInstrument` (and builds new preset tracks) without raising `InstrumentAdded`; raise it there with the factory preset id so `RecentInstrument.FactoryPreset` is filled, in `src/managed/Nota.Presentation/DeviceInsertService.cs` and `src/managed/Nota.App/MainWindow.Recent.cs` per FR-012a (partial)+- [X] T050 Decide and document whether tracks created as a side effect (Convert to MIDI, MIDI file import, MCP `AiTools` Volt tracks, the demo project) count as "added instruments"; either record them through `RecentInstruments.RecordAndSave` or state the exclusion in spec Assumptions, in `src/managed/Nota.App/MainWindow.Convert.cs`, `src/managed/Nota.App/MainWindow.MidiImport.cs`, `src/managed/Nota.Mcp/Tools/AiTools.cs` per FR-012a (partial)+- [X] T051 Verify keyboard use of the inline rows (arrows move the cursor ring in the colour grid and height keys, Up/Down cross grid rows, Enter applies and closes, Escape closes) with a headless synthetic-key check in the menu harness and fix what fails, in `src/managed/Nota.App/MenuKit.Rows.cs` per FR-017 (partial)+- [X] T052 Give the track, multi-track and footer menus a 248 px minimum width so the colour grid and height keys never wrap on short track names, in `src/managed/Nota.App/ArrangementView.cs` / `ArrangementView.Tracks.cs` (MenuFlyout presenter `MinWidth`) per FR-001 (partial)+- [ ] T053 Review the Vocoder sidechain-source menu change: its per-track colour squares were replaced by a tick on the current source; confirm with the maintainer or restore the track colours as `MenuKit.Swatch` in the value column, in `src/managed/Nota.App/DeviceCards/Bodies/VocoderDeviceBody.cs` per FR-011 (unrequested)diff --git a/src/managed/Nota.App/ArrangementView.Automation.cs b/src/managed/Nota.App/ArrangementView.Automation.csindex 4aabd3f3..cb18bff8 100644--- a/src/managed/Nota.App/ArrangementView.Automation.cs+++ b/src/managed/Nota.App/ArrangementView.Automation.cs@@ -358,7 +358,7 @@ public sealed partial class ArrangementView{var flyout = new MenuFlyout();- // Params that already carry automation (lane with points): pinned as a brass-dotted+ // Params that already carry automation (lane with points): pinned (automation glyph)// quick-access section at the top, and their keys flag the same params in the tree.var automated = new HashSet<string>();if (_engine is { } eA)@@ -391,7 +391,7 @@ public sealed partial class ArrangementView}foreach (var (label, apply) in top){- var it = new MenuItem { Header = label, Icon = AutoDot() };+ var it = new MenuItem { Header = label, Icon = MenuKit.Icon(GlyphKind.Automation) };it.Click += (_, _) => apply();flyout.Items.Add(it);}@@ -611,17 +611,11 @@ public sealed partial class ArrangementView// A small dot dropped into a MenuItem.Icon slot to flag an already-automated param. Not the// accent: the hovered item fills with it, and the dot must stay visible there.- private static Control AutoDot() => new Avalonia.Controls.Shapes.Ellipse- {- Width = 7, Height = 7, Fill = NotaPalette.TextPrimary,- VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center,- };-- // A leaf target item, dot-flagged + accent-tinted when its param already carries automation.+ // A leaf target item, flagged with the automation glyph when its param already carries automation.private MenuItem Leaf(string header, string key, Action apply, HashSet<string> automated){var it = new MenuItem { Header = header };- if (automated.Contains(key)) { it.Icon = AutoDot(); }+ if (automated.Contains(key)) { it.Icon = MenuKit.Icon(GlyphKind.Automation); }it.Click += (_, _) => apply();return it;}diff --git a/src/managed/Nota.App/ArrangementView.Controls.cs b/src/managed/Nota.App/ArrangementView.Controls.csindex 818d1c03..7762fbc5 100644--- a/src/managed/Nota.App/ArrangementView.Controls.cs+++ b/src/managed/Nota.App/ArrangementView.Controls.cs@@ -130,8 +130,7 @@ public sealed partial class ArrangementViewtoggle.Click += (_, _) => _o.SetLoopOn(!_o._loopActive);var sel = new MenuItem { Header = "Loop selection", Icon = MenuKit.Icon(GlyphKind.Select), IsEnabled = _o.SelectionLoopRange() is not null };sel.Click += (_, _) => { if (_o.SelectionLoopRange() is { } r) _o.SetLoopRegion(r.Start, r.End); };- var clear = new MenuItem { Header = "Clear loop region", Icon = MenuKit.Icon(GlyphKind.Trash), IsEnabled = has };- clear.Click += (_, _) => _o.ClearLoopRegion();+ var clear = MenuKit.Danger("Clear loop region", GlyphKind.Trash, () => _o.ClearLoopRegion(), enabled: has);flyout.Items.Add(toggle);flyout.Items.Add(sel);flyout.Items.Add(new Separator());diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.csindex 41214d78..b4a4d87c 100644--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs@@ -1079,19 +1079,11 @@ public sealed partial class ArrangementView{bool hasSel = _o.HasAutoSelection && ReferenceEquals(_o._autoSelTrack, t);var flyout = new MenuFlyout();- var copy = new MenuItem { Header = "Copy automation", IsEnabled = hasSel, Icon = MenuKit.Icon(GlyphKind.Copy), InputGesture = MenuKit.CopyKey };- copy.Click += (_, _) => _o.CopyAutoSelection();- var cut = new MenuItem { Header = "Cut automation", IsEnabled = hasSel, Icon = MenuKit.Icon(GlyphKind.Cut), InputGesture = MenuKit.CutKey };- cut.Click += (_, _) => _o.CutAutoSelection();- var del = new MenuItem { Header = "Delete automation", IsEnabled = hasSel, Icon = MenuKit.Icon(GlyphKind.Trash), InputGesture = MenuKit.DeleteKey };- del.Click += (_, _) => _o.DeleteAutoSelection();- var paste = new MenuItem { Header = "Paste automation", IsEnabled = _o.HasAutoClip, Icon = MenuKit.Icon(GlyphKind.Paste), InputGesture = MenuKit.PasteKey };- paste.Click += (_, _) => _o.PasteAutoAt(t, _o.Snap(beat));- flyout.Items.Add(copy);- flyout.Items.Add(cut);- flyout.Items.Add(del);- flyout.Items.Add(new Separator());- flyout.Items.Add(paste);+ var copy = MenuKit.Item("Copy automation", GlyphKind.Copy, () => _o.CopyAutoSelection(), MenuKit.CopyKey, hasSel);+ var cut = MenuKit.Item("Cut automation", GlyphKind.Cut, () => _o.CutAutoSelection(), MenuKit.CutKey, hasSel);+ var paste = MenuKit.Item("Paste automation", GlyphKind.Paste, () => _o.PasteAutoAt(t, _o.Snap(beat)), MenuKit.PasteKey, _o.HasAutoClip);+ var del = MenuKit.Danger("Delete automation", GlyphKind.Trash, () => _o.DeleteAutoSelection(), MenuKit.DeleteKey, hasSel);+ MenuKit.AddGroups(flyout.Items, new Control[] { copy, cut, paste }, new Control[] { del });flyout.ShowAt(this, showAtPointer: true);}@@ -1145,6 +1137,11 @@ public sealed partial class ArrangementView}private void ShowClipMenu(int trackId, ClipVM clip, double beat)+ => BuildClipMenu(trackId, clip, beat).ShowAt(this, showAtPointer: true);++ // The clip menu (spec 034): header (the clip, or the count of a multi-selection) →+ // rename → edits → audio conversions → Session → clipboard → delete.+ internal MenuFlyout BuildClipMenu(int trackId, ClipVM clip, double beat){double at = _o.Snap(beat);int idx = clip.ClipIndex;@@ -1152,142 +1149,97 @@ public sealed partial class ArrangementView// part of a multi-selection; otherwise they collapse to just this clip.void EnsureSelected() { if (!_o.IsSelected(trackId, idx)) _o.Select(trackId, idx); }bool inGroup = _o.IsSelected(trackId, idx) && _o.Selection.Count > 1;-var flyout = new MenuFlyout();- var split = new MenuItem { Header = "Split here", Icon = MenuKit.Icon(GlyphKind.Split), InputGesture = MenuKit.SplitKey };- split.Click += (_, _) => { _o._engine?.SplitClip(trackId, idx, at); _o.Refresh(); };- var dup = new MenuItem { Header = inGroup ? "Duplicate selection" : "Duplicate", Icon = MenuKit.Icon(GlyphKind.Duplicate), InputGesture = MenuKit.DuplicateKey };- dup.Click += (_, _) => { EnsureSelected(); _o.DuplicateSelectedClip(); };- var del = new MenuItem { Header = inGroup ? "Delete selection" : "Delete", Icon = MenuKit.Icon(GlyphKind.Trash), InputGesture = MenuKit.DeleteKey };- del.Click += (_, _) =>- {- if (inGroup) _o.DeleteSelectedClips();- else { _o._engine?.DeleteClip(trackId, idx); _o.Select(-1, -1); _o.Refresh(); }- };- // Clip deactivate (key 0): header reflects the clicked clip's current state.- var deact = new MenuItem++ var track = _o._tracks.FirstOrDefault(v => v.Id == trackId);+ var header = inGroup+ ? MenuKit.Header($"{_o.Selection.Count} clips", null, "")+ : MenuKit.Header(clip.Name.Length > 0 ? clip.Name : "Clip",+ track is null ? null : TrackBrush(track.ColorIndex), clip.IsMidi ? "MIDI clip" : "Audio clip");++ var rename = MenuKit.Item("Rename…", GlyphKind.Edit,+ () => PromptRename(clip.Name, s => { _o._engine?.SetClipName(trackId, idx, s); _o.Refresh(); }));++ var edits = new List<Control>{- Header = clip.Active ? (inGroup ? "Deactivate selection" : "Deactivate clip")- : (inGroup ? "Activate selection" : "Activate clip"),- Icon = MenuKit.Icon(GlyphKind.Bypass),- InputGesture = MenuKit.ActivateKey,+ MenuKit.Item("Split here", GlyphKind.Split, () => { _o._engine?.SplitClip(trackId, idx, at); _o.Refresh(); }, MenuKit.SplitKey),};- deact.Click += (_, _) => { EnsureSelected(); _o.ToggleSelectedClipsActive(); };- // Reverse (audio only): non-destructive, so the header reflects the clicked clip.- MenuItem? reverse = null;+ // Reverse (audio only): non-destructive, so the label reflects the clicked clip.if (!clip.IsMidi && _o._engine is { } rev && rev.TryGetAudioClipInfo(trackId, idx, out var rai))- {- bool on = rai.Reversed != 0;- reverse = new MenuItem- {- Header = on ? (inGroup ? "Un-reverse selection" : "Un-reverse")- : (inGroup ? "Reverse selection" : "Reverse"),- Icon = MenuKit.Icon(GlyphKind.Reverse),- };- reverse.Click += (_, _) => { EnsureSelected(); _o.ToggleSelectedClipsReverse(); };- }+ edits.Add(MenuKit.Item(rai.Reversed != 0 ? "Un-reverse" : "Reverse", GlyphKind.Reverse,+ () => { EnsureSelected(); _o.ToggleSelectedClipsReverse(); }));// Consolidate: a right-click inside the time selection acts on that range; otherwise// on the multi-selection's span, or just this clip (bakes its edits into one clip).bool inRange = _o.TimeSelectionCovers(trackId, beat);- var consolidate = new MenuItem- {- Header = inRange || inGroup ? "Consolidate selection" : "Consolidate",- Icon = MenuKit.Icon(GlyphKind.Consolidate),- InputGesture = MenuKit.ConsolidateKey,- };- consolidate.Click += (_, _) =>- {- if (!inRange) EnsureSelected();- _o.ConsolidateSelection();- };- var copy = new MenuItem { Header = inGroup ? "Copy selection" : "Copy", Icon = MenuKit.Icon(GlyphKind.Copy), InputGesture = MenuKit.CopyKey };- copy.Click += (_, _) => { EnsureSelected(); _o.CopySelectedClip(); };- var cut = new MenuItem { Header = inGroup ? "Cut selection" : "Cut", Icon = MenuKit.Icon(GlyphKind.Cut), InputGesture = MenuKit.CutKey };- cut.Click += (_, _) => { EnsureSelected(); _o.CutSelectedClip(); };- var paste = new MenuItem { Header = "Paste", IsEnabled = _o.HasClipClipboard, Icon = MenuKit.Icon(GlyphKind.Paste), InputGesture = MenuKit.PasteKey };- paste.Click += (_, _) => _o.PasteClipboardAt(trackId, at);- var rename = new MenuItem { Header = "Rename…", Icon = MenuKit.Icon(GlyphKind.Edit) };- rename.Click += (_, _) => PromptRename(clip.Name, s => { _o._engine?.SetClipName(trackId, idx, s); _o.Refresh(); });- flyout.Items.Add(rename);- flyout.Items.Add(copy);- flyout.Items.Add(cut);- flyout.Items.Add(paste);- if (PasteBouncedItem(trackId, at) is { } bounced) flyout.Items.Add(bounced);- flyout.Items.Add(new Separator());- flyout.Items.Add(split);- flyout.Items.Add(dup);- if (reverse is not null) flyout.Items.Add(reverse);- flyout.Items.Add(consolidate);- flyout.Items.Add(deact);- flyout.Items.Add(del);-+ edits.Add(MenuKit.Item(inRange ? "Consolidate selection" : "Consolidate", GlyphKind.Consolidate,+ () => { if (!inRange) EnsureSelected(); _o.ConsolidateSelection(); }, MenuKit.ConsolidateKey));+ // Clip deactivate (key 0): the label reflects the clicked clip's current state.+ edits.Add(MenuKit.Item(clip.Active ? "Deactivate" : "Activate", GlyphKind.Bypass,+ () => { EnsureSelected(); _o.ToggleSelectedClipsActive(); }, MenuKit.ActivateKey));// Loop the current selection (or just this clip if nothing is selected).- var loop = new MenuItem { Header = "Loop selection", Icon = MenuKit.Icon(GlyphKind.Cycle), InputGesture = MenuKit.LoopKey };- loop.Click += (_, _) =>+ edits.Add(MenuKit.Item("Loop selection", GlyphKind.Cycle, () =>{if (!_o.LoopSelection())_o.SetLoopRegion(clip.StartBeat, clip.StartBeat + clip.LengthBeats);- };- flyout.Items.Add(new Separator());- flyout.Items.Add(loop);-+ }, MenuKit.LoopKey));// Several MIDI clips selected: open them together in the Clip editor (specs/029).if (clip.IsMidi && inGroup && _o.SelectedMidiClips().Count >= 2)- {- var together = new MenuItem { Header = "Edit selected clips together", Icon = MenuKit.Icon(GlyphKind.Edit) };- together.Click += (_, _) => _o.EditSelectedClipsRequested?.Invoke();- flyout.Items.Add(together);- }+ edits.Add(MenuKit.Item("Edit selected clips together", GlyphKind.Edit, () => _o.EditSelectedClipsRequested?.Invoke()));- // Audio clip → stems (AI model) and → MIDI: Convert / Slice to New MIDI Track.+ // Audio clip → stems (AI model) and → MIDI: Convert / Slice to a new MIDI track.+ var audio = new List<Control>();if (!clip.IsMidi){- var stems = new MenuItem { Header = "Separate stems…", Icon = MenuKit.Icon(GlyphKind.Stems) };- stems.Click += (_, _) => _o.SeparateStemsRequested?.Invoke(trackId, idx);-- var convert = new MenuItem { Header = "Convert", Icon = MenuKit.Icon(GlyphKind.Arrow) };- MenuItem ConvItem(string header, ClipConvertMode mode, bool enabled)- {- var mi = new MenuItem { Header = header, IsEnabled = enabled };- if (enabled) mi.Click += (_, _) => _o.ConvertClipRequested?.Invoke(trackId, idx, mode);- return mi;- }- convert.Items.Add(ConvItem("Convert melody to new MIDI track", ClipConvertMode.Melody, true));- convert.Items.Add(ConvItem("Convert Harmony to New MIDI Track", ClipConvertMode.Harmony, true));- convert.Items.Add(ConvItem("Convert Drums to New MIDI Track", ClipConvertMode.Drums, true));- convert.Items.Add(ConvItem("Slice to new MIDI track", ClipConvertMode.Slice, true));+ audio.Add(MenuKit.Item("Separate stems…", GlyphKind.Stems, () => _o.SeparateStemsRequested?.Invoke(trackId, idx)));+ var convert = MenuKit.Item("Convert", GlyphKind.Arrow);+ MenuItem ConvItem(string header, ClipConvertMode mode)+ => MenuKit.Item(header, null, () => _o.ConvertClipRequested?.Invoke(trackId, idx, mode));+ convert.Items.Add(ConvItem("Melody to new MIDI track", ClipConvertMode.Melody));+ convert.Items.Add(ConvItem("Harmony to new MIDI track", ClipConvertMode.Harmony));+ convert.Items.Add(ConvItem("Drums to new MIDI track", ClipConvertMode.Drums));+ convert.Items.Add(ConvItem("Slice to new MIDI track", ClipConvertMode.Slice));if (_o.CanTranscribe?.Invoke() == false){- var better = new MenuItem { Header = "Get the AI model for melody & harmony…" };- better.Click += (_, _) => _o.TranscriptionModelRequested?.Invoke();convert.Items.Add(new Separator());- convert.Items.Add(better);+ convert.Items.Add(MenuKit.Item("Get the AI model for melody and harmony…", null, () => _o.TranscriptionModelRequested?.Invoke()));}- flyout.Items.Add(new Separator());- flyout.Items.Add(stems);- flyout.Items.Add(convert);+ audio.Add(convert);}// M5-6: copy the clip selection into session slots — the first scene row where it// fits (⌘⇧C), or from a chosen scene down.+ var session = new List<Control>();if (_o._engine is { } eng){- var toSession = new MenuItem { Header = inGroup ? "Copy selection to Session" : "Copy to Session", Icon = MenuKit.Icon(GlyphKind.Grid), InputGesture = MenuKit.CopyToOtherViewKey };- toSession.Click += (_, _) => { EnsureSelected(); _o.CopySelectionToSession(); };- var toScene = new MenuItem { Header = "Copy to scene", Icon = MenuKit.Icon(GlyphKind.Grid) };+ session.Add(MenuKit.Item("Copy to Session", GlyphKind.Grid, () => { EnsureSelected(); _o.CopySelectionToSession(); }, MenuKit.CopyToOtherViewKey));+ var toScene = MenuKit.Item("Copy to scene", GlyphKind.Grid);for (int s = 0; s < eng.SceneCount; s++){int sc = s;string name = eng.GetSceneName(sc);- var it = new MenuItem { Header = name.Length > 0 ? $"{sc + 1} · {name}" : $"Scene {sc + 1}" };- it.Click += (_, _) => { EnsureSelected(); _o.CopySelectionToSession(sc); };- toScene.Items.Add(it);+ toScene.Items.Add(MenuKit.Item(name.Length > 0 ? $"{sc + 1} · {name}" : $"Scene {sc + 1}", null,+ () => { EnsureSelected(); _o.CopySelectionToSession(sc); }));}- flyout.Items.Add(new Separator());- flyout.Items.Add(toSession);- flyout.Items.Add(toScene);+ session.Add(toScene);}- flyout.ShowAt(this, showAtPointer: true);++ var clipboard = MenuKit.ClipboardGroup(+ () => { EnsureSelected(); _o.CopySelectedClip(); },+ () => { EnsureSelected(); _o.CutSelectedClip(); },+ () => _o.PasteClipboardAt(trackId, at),+ () => { EnsureSelected(); _o.DuplicateSelectedClip(); },+ _o.HasClipClipboard).Cast<Control>().ToList();+ if (PasteBouncedItem(trackId, at) is { } bounced) clipboard.Insert(3, bounced);++ var del = MenuKit.Danger("Delete", GlyphKind.Trash, () =>+ {+ if (inGroup) _o.DeleteSelectedClips();+ else { _o._engine?.DeleteClip(trackId, idx); _o.Select(-1, -1); _o.Refresh(); }+ }, MenuKit.DeleteKey);++ MenuKit.AddGroups(flyout.Items, new Control[] { header }, new Control[] { rename }, edits, audio, session,+ clipboard, new Control[] { del });+ return flyout;}public override void Render(DrawingContext ctx)diff --git a/src/managed/Nota.App/ArrangementView.Sections.cs b/src/managed/Nota.App/ArrangementView.Sections.csindex 9b9b3a98..f2d736db 100644--- a/src/managed/Nota.App/ArrangementView.Sections.cs+++ b/src/managed/Nota.App/ArrangementView.Sections.cs@@ -333,39 +333,34 @@ public sealed partial class ArrangementViewvar flyout = new MenuFlyout();if (s is not null){- var rename = new MenuItem { Header = "Rename…", Icon = MenuKit.Icon(GlyphKind.Edit) };- rename.Click += (_, _) => _o.RenameSection(this, s);- var loop = new MenuItem { Header = "Loop section", Icon = MenuKit.Icon(GlyphKind.Cycle) };- loop.Click += (_, _) => _o.SetLoopRegion(s.StartBeat, s.StartBeat + s.LengthBeats); // raises LoopChanged itself- var select = new MenuItem { Header = "Select section", Icon = MenuKit.Icon(GlyphKind.Select) };- select.Click += (_, _) => _o.SelectSectionRange(s);- var dup = new MenuItem { Header = "Duplicate", Icon = MenuKit.Icon(GlyphKind.Duplicate) };- dup.Click += (_, _) =>+ int bars = (int)Math.Round(s.LengthBeats / Math.Max(1, _o._beatsPerBar));+ var dup = MenuKit.Item("Duplicate", GlyphKind.Duplicate, () =>{if (_o.Live(s) is null) return;var copy = _o.AddSection(s.StartBeat + s.LengthBeats, s.LengthBeats);copy.Name = s.Name;_o.SectionsEdited(); // one step: the copy arrives already named- };- var del = new MenuItem { Header = "Delete", Icon = MenuKit.Icon(GlyphKind.Trash) };- del.Click += (_, _) => _o.RemoveSection(s);- flyout.Items.Add(rename);- flyout.Items.Add(loop);- flyout.Items.Add(select);- flyout.Items.Add(new Separator());- flyout.Items.Add(dup);- flyout.Items.Add(del);+ });+ 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.Item("Loop section", GlyphKind.Cycle, () => _o.SetLoopRegion(s.StartBeat, s.StartBeat + s.LengthBeats)), // raises LoopChanged itself+ MenuKit.Item("Select section", GlyphKind.Select, () => _o.SelectSectionRange(s)),+ },+ new Control[] { dup },+ new Control[] { MenuKit.Danger("Delete", GlyphKind.Trash, () => _o.RemoveSection(s)) });}else{- var add = new MenuItem { Header = "Add section here", Icon = MenuKit.Icon(GlyphKind.Plus) };- add.Click += (_, _) => { _o.AddSection(_o.SnapBar(beat), _o._beatsPerBar * 8); _o.SectionsEdited(); };- flyout.Items.Add(add);+ flyout.Items.Add(MenuKit.Item("Add section here", GlyphKind.Plus,+ () => { _o.AddSection(_o.SnapBar(beat), _o._beatsPerBar * 8); _o.SectionsEdited(); }));if (_o._sections.Count > 0){- var clear = new MenuItem { Header = "Delete all sections", Icon = MenuKit.Icon(GlyphKind.Trash) };- clear.Click += (_, _) => { _o._sections.Clear(); _o.SectionsEdited(); };- flyout.Items.Add(clear);+ flyout.Items.Add(new Separator());+ flyout.Items.Add(MenuKit.Danger("Delete all sections", GlyphKind.Trash,+ () => { _o._sections.Clear(); _o.SectionsEdited(); }));}}flyout.ShowAt(this, showAtPointer: true);diff --git a/src/managed/Nota.App/ArrangementView.Sizing.cs b/src/managed/Nota.App/ArrangementView.Sizing.csindex 20c6898c..5ef5932d 100644--- a/src/managed/Nota.App/ArrangementView.Sizing.cs+++ b/src/managed/Nota.App/ArrangementView.Sizing.cs@@ -388,32 +388,6 @@ public sealed partial class ArrangementViewreturn seam;}- // ---- presets (track context menu) ------------------------------------------- private MenuItem BuildTrackHeightSubmenu(IReadOnlyList<int> ids)- {- var menu = new MenuItem { Header = "Track height" };- (string name, double h)[] presets = { ("Compact", CompactRowHeight), ("Standard", StandardRowHeight), ("Large", LargeRowHeight) };- foreach (var (name, h) in presets)- {- var mi = new MenuItem- {- Header = name, ToggleType = MenuItemToggleType.Radio,- IsChecked = ids.Count > 0 && ids.All(id => Math.Abs(StoredRowHeight(id) - h) < 0.5),- };- mi.Click += (_, _) => SetTrackHeights(ids, h);- menu.Items.Add(mi);- }- menu.Items.Add(new Separator());- foreach (var (name, h) in presets)- {- var mi = new MenuItem { Header = $"All tracks: {name.ToLowerInvariant()}" };- mi.Click += (_, _) => SetAllTrackHeights(h);- menu.Items.Add(mi);- }- return menu;- }-// ---- duplicate / copy / paste carry the height ----------------------------private bool CopyTracksToClipboard(IReadOnlyList<int> ids)diff --git a/src/managed/Nota.App/ArrangementView.Tracks.cs b/src/managed/Nota.App/ArrangementView.Tracks.csindex 63de6472..c60b4f80 100644--- a/src/managed/Nota.App/ArrangementView.Tracks.cs+++ b/src/managed/Nota.App/ArrangementView.Tracks.cs@@ -191,37 +191,69 @@ public sealed partial class ArrangementView}// ---- multi-track context menu ------------------------------------------- private void ShowTracksMenu(Control anchor, List<int> ids)+ private void ShowTracksMenu(Control anchor, List<int> ids) => BuildTracksMenu(ids)?.ShowAt(anchor, showAtPointer: true);++ internal MenuFlyout? BuildTracksMenu(List<int> ids){- if (_engine is null) return;+ if (_engine is null) return null;var flyout = new MenuFlyout();- string n = $"{ids.Count} tracks";-- var group = MenuKit.Item($"Group {n}", GlyphKind.Folder, () => GroupTracks(-1), MenuKit.GroupKey);- var color = BuildColorSubmenu(ids);- var freeze = FreezeTracksMenuItems?.Invoke(ids) ?? Array.Empty<Control>();- var copy = MenuKit.Item($"Copy {n}", GlyphKind.Copy, () => CopyTracksToClipboard(ids), MenuKit.CopyKey);- var cut = MenuKit.Item($"Cut {n}", GlyphKind.Cut, () => CutTracks(ids), MenuKit.CutKey);- var paste = MenuKit.Item("Paste track", GlyphKind.Paste, () => PasteTracksAfter(ids[^1]), MenuKit.PasteKey,- enabled: _engine.HasTrackClipboard());- var dup = MenuKit.Item($"Duplicate {n}", GlyphKind.Duplicate, () => DuplicateTracks(ids), MenuKit.DuplicateKey);- var del = MenuKit.Item($"Delete {n}", GlyphKind.Trash, () => DeleteTracks(ids), MenuKit.DeleteKey);-- flyout.Items.Add(group);- flyout.Items.Add(color);- flyout.Items.Add(BuildTrackHeightSubmenu(ids));- if (freeze.Count > 0)+ flyout.FlyoutPresenterClasses.Add("rows");+ MenuKit.AddGroups(flyout.Items,+ new Control[] { MenuKit.Header($"{ids.Count} tracks", null, "") },+ new Control[] { TrackColourRow(ids), TrackHeightRow(ids) },+ FreezeTracksMenuItems?.Invoke(ids),+ new Control[] { MenuKit.Item("Group tracks", GlyphKind.Folder, () => GroupTracks(-1), MenuKit.GroupKey) },+ MenuKit.ClipboardGroup(() => CopyTracksToClipboard(ids), () => CutTracks(ids),+ () => PasteTracksAfter(ids[^1]), () => DuplicateTracks(ids), _engine.HasTrackClipboard()),+ new Control[] { MenuKit.Danger("Delete", GlyphKind.Trash, () => DeleteTracks(ids), MenuKit.DeleteKey) });+ return flyout;+ }++ // ---- shared track-menu rows (spec 034) ----------------------------------++ // "Audio · 3": the track's kind and its position in the list, for the menu header.+ private string TrackBadge(int trackId)+ {+ int pos = _tracks.FindIndex(v => v.Id == trackId);+ var vm = pos >= 0 ? _tracks[pos] : null;+ string kind = vm is null ? "Track" : vm.IsGroup ? "Group" : vm.IsReturn ? "Return" : vm.IsInstrument ? "Instrument" : "Audio";+ return pos >= 0 ? $"{kind} · {pos + 1}" : kind;+ }++ // The colour grid for one or more tracks: the stored colour is ringed (Auto when none is+ // stored; nothing when a selection disagrees). A pick is one undo step for all of them.+ private MenuItem TrackColourRow(IReadOnlyList<int> ids)+ {+ var stored = ids.Select(id => _engine!.GetTrackColorIndex(id)).Distinct().ToList();+ int current = stored.Count == 1 ? stored[0] : int.MinValue;+ return MenuKit.ColourGrid(current, ci =>{- flyout.Items.Add(new Separator());- foreach (var item in freeze) flyout.Items.Add(item);- }- flyout.Items.Add(new Separator());- flyout.Items.Add(copy);- flyout.Items.Add(cut);- flyout.Items.Add(paste);- flyout.Items.Add(dup);- flyout.Items.Add(new Separator());- flyout.Items.Add(del);- flyout.ShowAt(anchor, showAtPointer: true);+ if (_engine is null) return;+ _engine.BeginUndoGroup();+ try { foreach (var id in ids) _engine.SetTrackColorIndex(id, ci); }+ finally { _engine.EndUndoGroup(); }+ Refresh(); SessionChanged?.Invoke();+ });}++ // Compact / Standard / Large for one or more tracks (the chosen key when they all sit on+ // that preset); Option / Alt applies the height to every track.+ private MenuItem TrackHeightRow(IReadOnlyList<int> ids)+ {+ (string, double)[] presets = { ("Compact", CompactRowHeight), ("Standard", StandardRowHeight), ("Large", LargeRowHeight) };+ double? chosen = presets.Select(p => p.Item2)+ .Where(h => ids.Count > 0 && ids.All(id => Math.Abs(StoredRowHeight(id) - h) < 0.5))+ .Select(h => (double?)h).FirstOrDefault();+ return MenuKit.Segments("Height", presets, chosen, (h, all) =>+ {+ if (all) SetAllTrackHeights(h); else SetTrackHeights(ids, h);+ });+ }++ // "Recent" instruments under Add track (spec 034 US5): the host (MainWindow) builds the+ // items from the recent-instruments list; each adds a track after the anchor.+ public Func<int, IReadOnlyList<MenuItem>>? RecentInstrumentItems;++ private void AddRecentInstruments(MenuItem addTrack, int anchorTrackId)+ => MenuKit.AddRecent(addTrack, RecentInstrumentItems?.Invoke(anchorTrackId));}diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.csindex 5c638190..444d5faa 100644--- a/src/managed/Nota.App/ArrangementView.cs+++ b/src/managed/Nota.App/ArrangementView.cs@@ -2303,19 +2303,18 @@ public sealed partial class ArrangementView : UserControl// Track context menu (Duplicate / Delete). Both go through the engine's// snapshot ops, so undo/redo covers them; the whole view refreshes after.- private static readonly string[] TrackColorNames = { "Drums", "Perc", "Bass", "Keys", "Texture", "FX", "Brass", "Vox", "Return" };- private static readonly string[] ShadeNames = { "", " (light)", " (dark)" };// "Add …" entries shared by the arrangement's track-level menus. Return is left enabled// when the buses are full, like the toolbar's + Return — MainWindow says so in the status// line rather than the menu going quietly dead.- private IEnumerable<MenuItem> AddTrackItems(int anchorTrackId = -1)+ // Inside the "Add track" submenu the kinds read short ("Instrument", "Audio", "Return").+ private IEnumerable<MenuItem> AddTrackItems(int anchorTrackId = -1, bool inSubmenu = false){- MenuItem Item(string header, NewTrackKind kind)- => MenuKit.Item(header, GlyphKind.Plus, () => AddTrackRequested?.Invoke(kind, anchorTrackId));- yield return Item("Add instrument track", NewTrackKind.Instrument);- yield return Item("Add audio track", NewTrackKind.Audio);- yield return Item("Add return track", NewTrackKind.Return);+ MenuItem Item(string full, string brief, NewTrackKind kind)+ => MenuKit.Item(inSubmenu ? brief : full, GlyphKind.Plus, () => AddTrackRequested?.Invoke(kind, anchorTrackId));+ yield return Item("Add instrument track", "Instrument", NewTrackKind.Instrument);+ yield return Item("Add audio track", "Audio", NewTrackKind.Audio);+ yield return Item("Add return track", "Return", NewTrackKind.Return);}// Right-click on the empty space below the tracks: add a track (the main thing to do@@ -2338,44 +2337,60 @@ public sealed partial class ArrangementView : UserControl// Right-click inside a multi-selection acts on the whole set.var selected = SelectedTrackIds();if (selected.Count > 1 && selected.Contains(trackId)) { ShowTracksMenu(anchor, selected); return; }+ BuildTrackMenu(anchor, trackId)?.ShowAt(anchor, showAtPointer: true);+ }++ // The track header menu (spec 034), in the shared group order: header → colour and+ // height rows → naming and inputs → freeze → create / group → clipboard → delete.+ internal MenuFlyout? BuildTrackMenu(Control anchor, int trackId)+ {+ if (_engine is null) return null;var flyout = new MenuFlyout();+ flyout.FlyoutPresenterClasses.Add("rows");+ var one = new[] { trackId };+ var vm = _tracks.FirstOrDefault(v => v.Id == trackId);- var rename = new MenuItem { Header = "Rename…", Icon = MenuKit.Icon(GlyphKind.Edit) };- rename.Click += (_, _) => PromptRenameTrack(anchor, trackId);- var color = BuildColorSubmenu(new[] { trackId });+ var rename = MenuKit.Item("Rename…", GlyphKind.Edit, () => PromptRenameTrack(anchor, trackId));// Record input ▸ (audio tracks only): hardware, master, or another track's output- // (internal resampling). The active source is ticked.- bool isAudio = _tracks.Any(v => v.Id == trackId && !v.IsInstrument && !v.IsReturn && !v.IsGroup);+ // (internal resampling). The active source is ticked and shown on the item.+ bool isAudio = vm is { IsInstrument: false, IsReturn: false, IsGroup: false };MenuItem? recInput = null;if (isAudio){int cur = _engine.GetTrackRecordInput(trackId);- recInput = new MenuItem { Header = "Record input", Icon = MenuKit.Icon(GlyphKind.Input) };- MenuItem Src(string label, int source)+ string curName = "Ext";+ var choices = new List<MenuItem>();+ void Src(string label, string shortName, int source){var mi = new MenuItem { Header = label, ToggleType = MenuItemToggleType.Radio, IsChecked = cur == source };mi.Click += (_, _) => _engine.SetTrackRecordInput(trackId, source);- return mi;+ choices.Add(mi);+ if (cur == source) curName = shortName;}- recInput.Items.Add(Src("Audio input (hardware)", 0));- recInput.Items.Add(Src("Master", -1));- recInput.Items.Add(new Separator());+ Src("Audio input (hardware)", "Ext", 0);+ Src("Master", "Master", -1);foreach (var v in _tracks)- if (v.Id != trackId)- recInput.Items.Add(Src(v.Name.Length > 0 ? v.Name : $"Track {v.Id}", v.Id));+ if (v.Id != trackId) { string n = v.Name.Length > 0 ? v.Name : $"Track {v.Id}"; Src(n, n, v.Id); }foreach (var v in _returns)- recInput.Items.Add(Src(v.Name.Length > 0 ? v.Name : $"Return {v.Id}", v.Id));+ { string n = v.Name.Length > 0 ? v.Name : $"Return {v.Id}"; Src(n, n, v.Id); }+ recInput = MenuKit.ValueItem("Record input", GlyphKind.Input, curName);+ recInput.Items.Add(choices[0]);+ recInput.Items.Add(choices[1]);+ if (choices.Count > 2) recInput.Items.Add(new Separator());+ foreach (var c in choices.Skip(2)) recInput.Items.Add(c);}// MIDI from ▸ (instrument tracks only): play another instrument track's MIDI through- // this track's instrument. The current source is ticked.- bool isInstr = _tracks.Any(v => v.Id == trackId && v.IsInstrument);+ // this track's instrument. The current source is ticked and shown on the item.MenuItem? midiFrom = null;- if (isInstr)+ if (vm is { IsInstrument: true }){int curSrc = _engine.GetTrackMidiSource(trackId);- midiFrom = new MenuItem { Header = "MIDI from", Icon = MenuKit.Icon(GlyphKind.Note) };+ string curName = "None";+ var others = _tracks.Where(v => v.Id != trackId && v.IsInstrument).ToList();+ foreach (var v in others) if (v.Id == curSrc) curName = v.Name.Length > 0 ? v.Name : $"Track {v.Id}";+ midiFrom = MenuKit.ValueItem("MIDI from", GlyphKind.Note, curName);MenuItem Src(string label, int src){var mi = new MenuItem { Header = label, ToggleType = MenuItemToggleType.Radio, IsChecked = curSrc == src };@@ -2383,67 +2398,37 @@ public sealed partial class ArrangementView : UserControlreturn mi;}midiFrom.Items.Add(Src("None", -1));- var others = _tracks.Where(v => v.Id != trackId && v.IsInstrument).ToList();if (others.Count > 0) midiFrom.Items.Add(new Separator());foreach (var v in others)midiFrom.Items.Add(Src(v.Name.Length > 0 ? v.Name : $"Track {v.Id}", v.Id));}- // Clipboard + lifecycle go through the same set commands as the keys (a group carries- // its children); paste lands right after this track.- var one = new[] { trackId };- var copy = new MenuItem { Header = "Copy track", Icon = MenuKit.Icon(GlyphKind.Copy), InputGesture = MenuKit.CopyKey };- copy.Click += (_, _) => CopyTracksToClipboard(one);- var cut = new MenuItem { Header = "Cut track", Icon = MenuKit.Icon(GlyphKind.Cut), InputGesture = MenuKit.CutKey };- cut.Click += (_, _) => CutTracks(one);- var paste = new MenuItem { Header = "Paste track", IsEnabled = _engine.HasTrackClipboard(), Icon = MenuKit.Icon(GlyphKind.Paste), InputGesture = MenuKit.PasteKey };- paste.Click += (_, _) => PasteTracksAfter(trackId);-- var dup = new MenuItem { Header = "Duplicate track", Icon = MenuKit.Icon(GlyphKind.Duplicate), InputGesture = MenuKit.DuplicateKey };- dup.Click += (_, _) => DuplicateTracks(one);- var del = new MenuItem { Header = "Delete track", Icon = MenuKit.Icon(GlyphKind.Trash), InputGesture = MenuKit.DeleteKey };- del.Click += (_, _) => DeleteTracks(one);-// Group / Ungroup (submix). "Group" folds the multi-selection (or this track) into a// new group; "Ungroup" dissolves the group this track is/belongs to.- var group = new MenuItem { Header = "Group tracks", Icon = MenuKit.Icon(GlyphKind.Folder), InputGesture = MenuKit.GroupKey };- group.Click += (_, _) => GroupTracks(trackId);+ var create = new List<Control>();+ var addTrack = MenuKit.Item("Add track", GlyphKind.Plus);+ foreach (var mi in AddTrackItems(trackId, inSubmenu: true)) addTrack.Items.Add(mi);+ AddRecentInstruments(addTrack, trackId);+ create.Add(addTrack);+ create.Add(MenuKit.Item("Group tracks", GlyphKind.Folder, () => GroupTracks(trackId), MenuKit.GroupKey));int ungroupId = GroupToUngroupFor(trackId);- MenuItem? ungroup = null;if (ungroupId > 0)- {- ungroup = new MenuItem { Header = "Ungroup", Icon = MenuKit.Icon(GlyphKind.Ungroup), InputGesture = MenuKit.UngroupKey };- ungroup.Click += (_, _) => UngroupGroup(ungroupId);- }-- // Freeze ▸ state-dependent entries (Freeze / Live Freeze, or Unfreeze / Edit / Flatten).- var freeze = FreezeMenuItems?.Invoke(trackId) ?? Array.Empty<Control>();+ create.Add(MenuKit.Item("Ungroup", GlyphKind.Ungroup, () => UngroupGroup(ungroupId), MenuKit.UngroupKey));- flyout.Items.Add(rename);- flyout.Items.Add(color);- flyout.Items.Add(BuildTrackHeightSubmenu(one));- if (recInput is not null) flyout.Items.Add(recInput);- if (midiFrom is not null) flyout.Items.Add(midiFrom);- if (freeze.Count > 0)- {- flyout.Items.Add(new Separator());- foreach (var item in freeze) flyout.Items.Add(item);- }- flyout.Items.Add(new Separator());- flyout.Items.Add(group);- if (ungroup is not null) flyout.Items.Add(ungroup);- var addTrack = new MenuItem { Header = "Add track", Icon = MenuKit.Icon(GlyphKind.Plus) }; // submenu: this menu is long already- foreach (var mi in AddTrackItems(trackId)) addTrack.Items.Add(mi);+ // Clipboard + lifecycle go through the same set commands as the keys (a group carries+ // its children); paste lands right after this track.+ var clipboard = MenuKit.ClipboardGroup(() => CopyTracksToClipboard(one), () => CutTracks(one),+ () => PasteTracksAfter(trackId), () => DuplicateTracks(one), _engine.HasTrackClipboard());- flyout.Items.Add(new Separator());- flyout.Items.Add(addTrack);- flyout.Items.Add(copy);- flyout.Items.Add(cut);- flyout.Items.Add(paste);- flyout.Items.Add(dup);- flyout.Items.Add(new Separator());- flyout.Items.Add(del);- flyout.ShowAt(anchor, showAtPointer: true);+ MenuKit.AddGroups(flyout.Items,+ new Control[] { MenuKit.Header(vm?.Name ?? "", TrackBrush(EffectiveColorIndex(_engine, trackId)), TrackBadge(trackId)) },+ new Control[] { TrackColourRow(one), TrackHeightRow(one) },+ new Control?[] { rename, recInput, midiFrom }.OfType<Control>(),+ FreezeMenuItems?.Invoke(trackId),+ create,+ clipboard,+ new Control[] { MenuKit.Danger("Delete", GlyphKind.Trash, () => DeleteTracks(one), MenuKit.DeleteKey) });+ return flyout;}// Compact record-input selector for an audio track header: Ext (hardware), Master,@@ -2577,41 +2562,6 @@ public sealed partial class ArrangementView : UserControl// Colour ▸ one submenu per base hue, each with normal / light / dark shades shown as// swatches, plus Auto. Picking sets the stored palette index of every given track.- private MenuItem BuildColorSubmenu(IReadOnlyList<int> trackIds)- {- void SetColor(int ci)- {- if (_engine is null) return;- _engine.BeginUndoGroup();- try { foreach (var id in trackIds) _engine.SetTrackColorIndex(id, ci); }- finally { _engine.EndUndoGroup(); }- Refresh(); SessionChanged?.Invoke();- }- var color = new MenuItem { Header = "Color", Icon = MenuKit.Icon(GlyphKind.Palette) };- for (int b = 0; b < PaletteBases; b++)- {- var baseItem = new MenuItem { Header = TrackColorNames[b], Icon = Swatch(b * PaletteShades) };- for (int s = 0; s < PaletteShades; s++)- {- int ci = b * PaletteShades + s;- var shade = new MenuItem { Header = TrackColorNames[b] + ShadeNames[s], Icon = Swatch(ci) };- shade.Click += (_, _) => SetColor(ci);- baseItem.Items.Add(shade);- }- color.Items.Add(baseItem);- }- var autoColor = new MenuItem { Header = "Auto" };- autoColor.Click += (_, _) => SetColor(-1);- color.Items.Add(new Separator());- color.Items.Add(autoColor);- return color;- }-- // A small rounded colour swatch for the given palette index (menu icon).- private static Control Swatch(int colorIndex)- => new Border { Width = 13, Height = 13, CornerRadius = NotaRadius.Badge,- Background = TrackBrush(colorIndex) };-// Inline rename popup for a track header (Enter commits, Esc cancels).private void PromptRenameTrack(Control anchor, int trackId){@@ -2838,15 +2788,15 @@ public sealed partial class ArrangementView : UserControl{if (_engine is null) return;var flyout = new MenuFlyout();- var rename = new MenuItem { Header = "Rename…", Icon = MenuKit.Icon(GlyphKind.Edit) };- rename.Click += (_, _) => PromptRenameTrack(anchor, trackId);- flyout.Items.Add(rename);- flyout.Items.Add(BuildColorSubmenu(new[] { trackId }));- if (_returns.Any(r => r.Id == trackId))- {- flyout.Items.Add(new Separator());- flyout.Items.Add(MenuKit.Item("Delete track", GlyphKind.Trash, () => DeleteTracks(new[] { trackId }), MenuKit.DeleteKey));- }+ flyout.FlyoutPresenterClasses.Add("rows");+ bool isReturn = _returns.Any(r => r.Id == trackId);+ string name = _engine.GetTrackName(trackId);+ MenuKit.AddGroups(flyout.Items,+ new Control[] { MenuKit.Header(name.Length > 0 ? name : isReturn ? "Return" : "Master",+ TrackBrush(EffectiveColorIndex(_engine, trackId)), isReturn ? "Return" : "Master") },+ new Control[] { TrackColourRow(new[] { trackId }) },+ new Control[] { MenuKit.Item("Rename…", GlyphKind.Edit, () => PromptRenameTrack(anchor, trackId)) },+ isReturn ? new Control[] { MenuKit.Danger("Delete", GlyphKind.Trash, () => DeleteTracks(new[] { trackId }), MenuKit.DeleteKey) } : null);flyout.ShowAt(anchor, showAtPointer: true);}diff --git a/src/managed/Nota.App/BrowserView.cs b/src/managed/Nota.App/BrowserView.csindex 21b4d533..6a193f98 100644--- a/src/managed/Nota.App/BrowserView.cs+++ b/src/managed/Nota.App/BrowserView.cs@@ -1212,8 +1212,7 @@ public sealed class BrowserView : UserControl{var chip = item;var mi = new MenuItem { Header = chip.Label, ToggleType = MenuItemToggleType.CheckBox, IsChecked = chip.Active };- if (chip.ColorHex is not null)- mi.Icon = new Ellipse { Width = 10, Height = 10, Fill = BrushFromHex(chip.ColorHex) };+ if (chip.ColorHex is not null) MenuKit.SetTrailing(mi, MenuKit.Swatch(BrushFromHex(chip.ColorHex)));mi.Click += (_, _) => chip.OnClick();flyout.Items.Add(mi);}@@ -1477,7 +1476,30 @@ public sealed class BrowserView : UserControle.Handled = true;}+ // The row's menu with the item named at the top (spec 034).private MenuFlyout? BuildContextMenu(BrowserItem item)+ {+ var flyout = BuildContextMenuItems(item);+ if (flyout is null || flyout.Items.Count == 0) return flyout;+ flyout.Items.Insert(0, MenuKit.Header(item.Name, null, ItemKindLabel(item)));+ flyout.Items.Insert(1, new Separator());+ return flyout;+ }++ private static string ItemKindLabel(BrowserItem item) => item.Kind switch+ {+ BrowserItemKind.BuiltinInstrument or BrowserItemKind.PluginInstrument => "Instrument",+ BrowserItemKind.BuiltinEffect or BrowserItemKind.PluginEffect => "Audio effect",+ BrowserItemKind.BuiltinMidiEffect => "MIDI effect",+ BrowserItemKind.Sample => "Sample",+ BrowserItemKind.MidiFile => "MIDI file",+ BrowserItemKind.Project => "Project",+ BrowserItemKind.Preset => "Preset",+ BrowserItemKind.Folder => "Folder",+ _ => "",+ };++ private MenuFlyout? BuildContextMenuItems(BrowserItem item){var flyout = new MenuFlyout();@@ -1494,11 +1516,8 @@ public sealed class BrowserView : UserControl{var tag = t;bool assigned = _vm.IsTagAssigned(item, tag.Id);- var mi = new MenuItem- {- Header = tag.Title, ToggleType = MenuItemToggleType.CheckBox, IsChecked = assigned,- Icon = new Ellipse { Width = 10, Height = 10, Fill = BrushFromHex(tag.Color) },- };+ var mi = new MenuItem { Header = tag.Title, ToggleType = MenuItemToggleType.CheckBox, IsChecked = assigned };+ MenuKit.SetTrailing(mi, MenuKit.Swatch(BrushFromHex(tag.Color)));mi.Click += (_, _) => _vm.AssignTag(item, tag.Id, !assigned);tagsMenu.Items.Add(mi);}@@ -1553,8 +1572,7 @@ public sealed class BrowserView : UserControlopen.Click += (_, _) => ItemActivated?.Invoke(item, KeyModifiers.None);var reveal = new MenuItem { Header = "Reveal in Finder" };reveal.Click += (_, _) => RevealRequested?.Invoke(item);- var del = new MenuItem { Header = "Delete…" };- del.Click += (_, _) => DeleteProjectRequested?.Invoke(item);+ var del = MenuKit.Danger("Delete…", GlyphKind.Trash, () => DeleteProjectRequested?.Invoke(item));flyout.Items.Add(open);flyout.Items.Add(reveal);flyout.Items.Add(new Separator());diff --git a/src/managed/Nota.App/ClipEditorKit.cs b/src/managed/Nota.App/ClipEditorKit.csindex 52f6d844..eb42e56b 100644--- a/src/managed/Nota.App/ClipEditorKit.cs+++ b/src/managed/Nota.App/ClipEditorKit.cs@@ -240,7 +240,7 @@ internal static class ClipEditorKit{int idx = i;var mi = new MenuItem { Header = items[i] };- if (i == current) mi.Icon = new Glyph(GlyphKind.Dot, 6) { Foreground = NotaPalette.TextPrimary };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = i == current;mi.Click += (_, _) => pick(idx);f.Items.Add(mi);}diff --git a/src/managed/Nota.App/Controls/DynamicEqCurve.cs b/src/managed/Nota.App/Controls/DynamicEqCurve.csindex 89610db2..76e52fdf 100644--- a/src/managed/Nota.App/Controls/DynamicEqCurve.cs+++ b/src/managed/Nota.App/Controls/DynamicEqCurve.cs@@ -300,6 +300,8 @@ public sealed class DynamicEqCurve : Control{var fly = new MenuFlyout();int curT = BandType(b);+ fly.Items.Add(MenuKit.Header($"Band {b + 1}", null, DynEq.TypeNames[curT]));+ fly.Items.Add(new Separator());for (int t = 0; t < DynEq.TypeNames.Length; t++){int tt = t;diff --git a/src/managed/Nota.App/Controls/Eq8Views.cs b/src/managed/Nota.App/Controls/Eq8Views.csindex ebcb5548..3082ce68 100644--- a/src/managed/Nota.App/Controls/Eq8Views.cs+++ b/src/managed/Nota.App/Controls/Eq8Views.cs@@ -307,6 +307,8 @@ public sealed class Eq8Curve : Control{var fly = new MenuFlyout();int curT = BandType(b);+ fly.Items.Add(MenuKit.Header($"Band {b + 1}", null, Eq8.TypeNames[curT]));+ fly.Items.Add(new Separator());for (int t = 0; t < Eq8.TypeNames.Length; t++){int tt = t;diff --git a/src/managed/Nota.App/DeviceCards/Bodies/AutoGainDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/AutoGainDeviceBody.csindex bc4a7481..6ea9e2a5 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/AutoGainDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/AutoGainDeviceBody.cs@@ -162,7 +162,7 @@ internal sealed class AutoGainDeviceBody : IDeviceBody{if (it is not { } x) { fly.Items.Add(new Separator()); continue; }var mi = new MenuItem { Header = x.Label };- if (x.Current) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = x.Current;var pk = x.Pick;mi.Click += (_, _) => { pk(); RefreshAll(); };fly.Items.Add(mi);diff --git a/src/managed/Nota.App/DeviceCards/Bodies/AutoShiftDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/AutoShiftDeviceBody.csindex feb51c28..77eaef1c 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/AutoShiftDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/AutoShiftDeviceBody.cs@@ -319,7 +319,7 @@ internal sealed class AutoShiftDeviceBody : IDeviceBodystatic MenuItem Item(string label, bool cur, Action pick){var mi = new MenuItem { Header = label };- if (cur) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = cur;mi.Click += (_, _) => pick();return mi;}diff --git a/src/managed/Nota.App/DeviceCards/Bodies/BeatRepeatDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/BeatRepeatDeviceBody.csindex dd9153d2..050a7cf3 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/BeatRepeatDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/BeatRepeatDeviceBody.cs@@ -282,7 +282,7 @@ internal sealed class BeatRepeatDeviceBody : IDeviceBody{int iv = i;var mi = new MenuItem { Header = names[i] };- if (i == cur) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = i == cur;mi.Click += (_, _) => { pick(iv); RefreshAll(); };fly.Items.Add(mi);}diff --git a/src/managed/Nota.App/DeviceCards/Bodies/CeilingDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/CeilingDeviceBody.csindex 88a14533..1ace6b32 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/CeilingDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/CeilingDeviceBody.cs@@ -239,7 +239,7 @@ internal sealed class CeilingDeviceBody : IDeviceBodyforeach (var (label, cur, pick) in items()){var mi = new MenuItem { Header = label };- if (cur) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = cur;var pk = pick;mi.Click += (_, _) => { pk(); RefreshAll(); };fly.Items.Add(mi);diff --git a/src/managed/Nota.App/DeviceCards/Bodies/ChamberDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/ChamberDeviceBody.csindex 41e8681f..52cc2060 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/ChamberDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/ChamberDeviceBody.cs@@ -324,19 +324,19 @@ internal sealed class ChamberDeviceBody : IDeviceBodyif (irList[i].Cat != lastCat){if (lastCat.Length > 0) fly.Items.Add(new Separator());- fly.Items.Add(new MenuItem { Header = NotaText.Label(irList[i].Cat), IsEnabled = false, FontSize = 9 });+ fly.Items.Add(MenuKit.Caption(irList[i].Cat));lastCat = irList[i].Cat;}int iv = i;var mi = new MenuItem { Header = NotaNum.F($"{irList[i].Name} {irList[i].Len}\u2009s") };- if (i == cur) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Amber };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = i == cur;mi.Click += (_, _) => SetP(IrSelect, iv / (float)(IrCount - 1));fly.Items.Add(mi);}fly.Items.Add(new Separator());string userName = engine.DeviceText(track, di, 2);var um = new MenuItem { Header = userName.Length > 0 ? NotaNum.F($"User · {userName}") : "User IR (none loaded)", IsEnabled = userName.Length > 0 };- if (cur == IrCount - 1) um.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Amber };+ um.ToggleType = MenuItemToggleType.Radio; um.IsChecked = cur == IrCount - 1;um.Click += (_, _) => SetP(IrSelect, 1f);fly.Items.Add(um);var load = new MenuItem { Header = "Load impulse response…" };diff --git a/src/managed/Nota.App/DeviceCards/Bodies/PrismDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/PrismDeviceBody.csindex 9596025c..9657984d 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/PrismDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/PrismDeviceBody.cs@@ -533,7 +533,7 @@ internal sealed class PrismDeviceBody : IDeviceBodyvoid Item(string name, int id){var mi = new MenuItem { Header = name };- if (id == cur) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Amber };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = id == cur;mi.Click += (_, _) => { engine.SetDeviceSidechainSource(track, di, id); ctx.NotifyChanged(); foreach (var a in readouts) a(); };fly.Items.Add(mi);}diff --git a/src/managed/Nota.App/DeviceCards/Bodies/ShutterDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/ShutterDeviceBody.csindex 1d8852f9..85d6d850 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/ShutterDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/ShutterDeviceBody.cs@@ -288,7 +288,7 @@ internal sealed class ShutterDeviceBody : IDeviceBody{bool cur = id < 0 ? !ExtOn() : ExtOn() && Src() == id;var mi = new MenuItem { Header = label };- if (cur) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = cur;mi.Click += (_, _) =>{engine.SetDeviceSidechainSource(track, di, id);diff --git a/src/managed/Nota.App/DeviceCards/Bodies/ValveDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/ValveDeviceBody.csindex 8f732412..a81b362c 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/ValveDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/ValveDeviceBody.cs@@ -241,7 +241,7 @@ internal sealed class ValveDeviceBody : IDeviceBody{int iv = i;var mi = new MenuItem { Header = names[i] };- if (i == cur) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = i == cur;mi.Click += (_, _) => { SetP(p, iv); RefreshAll(); };fly.Items.Add(mi);}diff --git a/src/managed/Nota.App/DeviceCards/Bodies/VintageDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/VintageDeviceBody.csindex 238c7589..f66c40a6 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/VintageDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/VintageDeviceBody.cs@@ -229,7 +229,7 @@ internal sealed class VintageDeviceBody : IDeviceBody{int iv = i;var mi = new MenuItem { Header = Modes[i] };- if (i == cur) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = i == cur;mi.Click += (_, _) => { SetP(Mode, iv / 5f); RefreshAll(); };fly.Items.Add(mi);}diff --git a/src/managed/Nota.App/DeviceCards/Bodies/VocoderDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/VocoderDeviceBody.csindex 3fcbcaf4..17278cc8 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/VocoderDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/VocoderDeviceBody.cs@@ -213,10 +213,10 @@ internal sealed class VocoderDeviceBody : IDeviceBody{if (!e.GetCurrentPoint(picker).Properties.IsLeftButtonPressed) return;var fly = new MenuFlyout();- void Add(int id, string name, IBrush swatch)+ void Add(int id, string name){- var mi = new MenuItem { Header = name, Icon = new Rectangle { Width = 7, Height = 7, Fill = swatch, RadiusX = 1, RadiusY = 1 } };- if (id == (HasTrack() ? Source() : -1)) mi.FontWeight = FontWeight.SemiBold;+ // The current source is ticked, like every choice menu (spec 034).+ var mi = new MenuItem { Header = name, ToggleType = MenuItemToggleType.Radio, IsChecked = id == (HasTrack() ? Source() : -1) };mi.Click += (_, _) =>{engine.SetDeviceSidechainSource(track, di, id);@@ -225,9 +225,9 @@ internal sealed class VocoderDeviceBody : IDeviceBody};fly.Items.Add(mi);}- Add(-1, "None", NotaPalette.Rule);+ Add(-1, "None");fly.Items.Add(new Separator());- foreach (var (id, name, color) in Candidates()) Add(id, name, ArrangementView.TrackBrush(color));+ foreach (var (id, name, _) in Candidates()) Add(id, name);fly.ShowAt(picker);e.Handled = true;};diff --git a/src/managed/Nota.App/DeviceCards/Instruments/ConsortInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/ConsortInstrumentCard.csindex 82ae397c..6838a77e 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/ConsortInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/ConsortInstrumentCard.cs@@ -314,14 +314,8 @@ internal sealed class ConsortInstrumentCard : IInstrumentCardvoid JackMenu(ConsortJacks.Jack j, Control anchor){var f = new MenuFlyout();- f.Items.Add(new MenuItem { Header = $"{j.Name} · {(j.Out ? "output" : "input")}{(ConsortJacks.Normalled.Contains(j.Index) && !j.Out ? " (normalled)" : "")}", IsEnabled = false });- var mine = CableList().Where(c => j.Out ? c.Src == j.Index : c.Dst == j.Index).ToList();- foreach (var c in mine)- {- var mi = new MenuItem { Header = $"Remove {CableName(c)} {c.Depth * 100:+0;−0;0}" };- int slot = c.Slot; mi.Click += (_, _) => RemoveSlot(slot);- f.Items.Add(mi);- }+ f.Items.Add(MenuKit.Header(j.Name, null, $"{(j.Out ? "Output" : "Input")}{(ConsortJacks.Normalled.Contains(j.Index) && !j.Out ? " · normalled" : "")}"));+ f.Items.Add(new Separator());var sub = new MenuItem { Header = j.Out ? "Patch to" : "Patch from" };var list = j.Out ? ConsortJacks.Dests : ConsortJacks.Sources;for (int i = 1; i < list.Length; i++)@@ -332,6 +326,14 @@ internal sealed class ConsortInstrumentCard : IInstrumentCardsub.Items.Add(mi);}f.Items.Add(sub);+ // Removing a cable is destructive: last, in danger ink.+ var mine = CableList().Where(c => j.Out ? c.Src == j.Index : c.Dst == j.Index).ToList();+ if (mine.Count > 0) f.Items.Add(new Separator());+ foreach (var c in mine)+ {+ int slot = c.Slot;+ f.Items.Add(MenuKit.Danger($"Remove {CableName(c)} {c.Depth * 100:+0;−0;0}", GlyphKind.Trash, () => RemoveSlot(slot)));+ }f.ShowAt(anchor, showAtPointer: true);}diff --git a/src/managed/Nota.App/DeviceCards/Instruments/PendulumInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/PendulumInstrumentCard.csindex 865be8e4..0042f172 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/PendulumInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/PendulumInstrumentCard.cs@@ -455,7 +455,7 @@ internal sealed class PendulumInstrumentCard : IInstrumentCard{int mv = m;var mi = new MenuItem { Header = PendulumModel.ModeNames[m] };- if (m == cur) mi.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = m == cur;mi.Click += (_, _) => { Write("scalemode", mv / (float)(PendulumModel.ModeNames.Length - 1)); Refresh(); };fly.Items.Add(mi);}@@ -465,7 +465,7 @@ internal sealed class PendulumInstrumentCard : IInstrumentCard{int rv = r;var ri = new MenuItem { Header = PendulumModel.RootNames[r] };- if (r == curRoot) ri.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = Brass };+ ri.ToggleType = MenuItemToggleType.Radio; ri.IsChecked = r == curRoot;ri.Click += (_, _) => { Write("root", rv / 11f); Refresh(); };rootMenu.Items.Add(ri);}diff --git a/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.csindex 04fdfc10..32594ac4 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.cs@@ -297,9 +297,8 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardsrc.Click += (_, _) => { Act(RM.A_SetSource, v, isSample[v] ? 0f : 1f); ctx.NotifyChanged(); ctx.RequestRebuild(); };fly.Items.Add(src);fly.Items.Add(new Separator());- var clear = new MenuItem { Header = $"Clear its steps in bank {RM.BankNames[bank]}" };- clear.Click += (_, _) => { Act(RM.A_ClearVoice, v); ctx.NotifyChanged(); ReloadPattern(); };- fly.Items.Add(clear);+ fly.Items.Add(MenuKit.Danger($"Clear its steps in bank {RM.BankNames[bank]}", GlyphKind.Trash,+ () => { Act(RM.A_ClearVoice, v); ctx.NotifyChanged(); ReloadPattern(); }));fly.ShowAt(anchor);}var kitHead = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), Margin = new Thickness(7, 0) };@@ -556,7 +555,7 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardMenuItem Item(string h, Action a, bool check = false){var mi = new MenuItem { Header = h };- if (check) mi.Icon = new Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = check;mi.Click += (_, _) => a();fly.Items.Add(mi);return mi;@@ -569,7 +568,7 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardforeach (var pv in new[] { 1f, 0.75f, 0.5f, 0.25f }){var mi = new MenuItem { Header = RM.Pct(pv) };- if (on && Math.Abs(cur - pv) < 0.02f) mi.Icon = new Ellipse { Width = 6, Height = 6, Fill = Brass };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = on && Math.Abs(cur - pv) < 0.02f;mi.Click += (_, _) => { strip.On[s] = true; strip.Vel[s] = pv; strip.Commit!(s); strip.Changed(); };velMenu.Items.Add(mi);}@@ -585,7 +584,7 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardItem("Shift right", () => { var a = Snap(); SetSteps(k => a[(k + RM.Steps - 1) % RM.Steps]); });Item("Reverse", () => { var a = Snap(); SetSteps(k => a[RM.Steps - 1 - k]); });fly.Items.Add(new Separator());- Item($"Clear {RM.VoiceNames[sel]}", () => SetSteps(k => (false, strip.Vel[k], false)));+ fly.Items.Add(MenuKit.Danger($"Clear {RM.VoiceNames[sel]}", GlyphKind.Trash, () => SetSteps(k => (false, strip.Vel[k], false))));fly.ShowAt(strip);};@@ -630,9 +629,9 @@ internal sealed class RhythmInstrumentCard : IInstrumentCardcopy.Items.Add(mi);}fly.Items.Add(copy);- var clear = new MenuItem { Header = $"Clear bank {RM.BankNames[b]}" };- clear.Click += (_, _) => { Act(RM.A_ClearBank, b); ctx.NotifyChanged(); ReloadPattern(); };- fly.Items.Add(clear);+ fly.Items.Add(new Separator());+ fly.Items.Add(MenuKit.Danger($"Clear bank {RM.BankNames[b]}", GlyphKind.Trash,+ () => { Act(RM.A_ClearBank, b); ctx.NotifyChanged(); ReloadPattern(); }));fly.ShowAt(anchor);}var bankBox = new Borderdiff --git a/src/managed/Nota.App/DeviceCards/Midi/ScaleMidiBody.cs b/src/managed/Nota.App/DeviceCards/Midi/ScaleMidiBody.csindex 5f15fe38..3e39106e 100644--- a/src/managed/Nota.App/DeviceCards/Midi/ScaleMidiBody.cs+++ b/src/managed/Nota.App/DeviceCards/Midi/ScaleMidiBody.cs@@ -386,7 +386,7 @@ internal sealed class ScaleMidiBody : IMidiDeviceBody{int iv = sc;var item = new MenuItem { Header = ScaleNames[sc] };- if (Sc() == sc) item.Icon = new Avalonia.Controls.Shapes.Ellipse { Width = 6, Height = 6, Fill = NotaPalette.Accent };+ item.ToggleType = MenuItemToggleType.Radio; item.IsChecked = Sc() == sc;item.Click += (_, _) => PickType(iv);fly.Items.Add(item);}diff --git a/src/managed/Nota.App/DeviceCards/Rack/MacroPanel.cs b/src/managed/Nota.App/DeviceCards/Rack/MacroPanel.csindex e44bbb44..8fe554a7 100644--- a/src/managed/Nota.App/DeviceCards/Rack/MacroPanel.cs+++ b/src/managed/Nota.App/DeviceCards/Rack/MacroPanel.cs@@ -232,6 +232,8 @@ internal static class MacroPanelpublic static void ShowMenu(DeviceCardContext ctx, IMacroSurface s, Control anchor, int m, bool receivers = false){var f = new MenuFlyout();+ f.Items.Add(MenuKit.Header(s.MacroName(m), null, $"Macro · {m + 1}"));+ f.Items.Add(new Separator());if (receivers){// Where the card has no receivers panel (Rhythm), they open in a flyout.@@ -244,16 +246,13 @@ internal static class MacroPanelvar mapItem = new MenuItem { Header = "Map to" };foreach (var it in map.Items.ToList()) { map.Items.Remove(it); mapItem.Items.Add(it); }f.Items.Add(mapItem);- var rename = new MenuItem { Header = "Rename…" };- rename.Click += (_, _) => Avalonia.Threading.Dispatcher.UIThread.Post(() => PromptRename(ctx, s, anchor, m));- f.Items.Add(rename);+ f.Items.Add(MenuKit.Item("Rename…", GlyphKind.Edit, () => Avalonia.Threading.Dispatcher.UIThread.Post(() => PromptRename(ctx, s, anchor, m))));int n = Mappings(s, m).Count;if (n > 0){f.Items.Add(new Separator());- var clear = new MenuItem { Header = $"Clear {n} mapping{(n == 1 ? "" : "s")}" };- clear.Click += (_, _) => { Clear(s, m); ctx.NotifyChanged(); ctx.RequestRebuild(); };- f.Items.Add(clear);+ f.Items.Add(MenuKit.Danger($"Clear {n} mapping{(n == 1 ? "" : "s")}", GlyphKind.Trash,+ () => { Clear(s, m); ctx.NotifyChanged(); ctx.RequestRebuild(); }));}f.ShowAt(anchor, showAtPointer: true);}@@ -438,9 +437,8 @@ internal static class MacroPanelif (!e.GetCurrentPoint(g).Properties.IsRightButtonPressed) return;e.Handled = true;var f = new MenuFlyout();- var rm = new MenuItem { Header = "Remove this receiver" };- rm.Click += (_, _) => { s.RemoveMapping(index); ctx.NotifyChanged(); ctx.RequestRebuild(); };- f.Items.Add(rm);+ f.Items.Add(MenuKit.Danger("Remove this receiver", GlyphKind.Trash,+ () => { s.RemoveMapping(index); ctx.NotifyChanged(); ctx.RequestRebuild(); }));f.ShowAt(g, showAtPointer: true);};return g;@@ -481,8 +479,8 @@ internal static class MacroPanel/// <summary>A menu item that maps <paramref name="macro"/> to one target.</summary>public static MenuItem Target(IMacroSurface s, string header, int macro, int slot, int device, int param, float lo, float hi, Action changed, bool mapped = false){- var mi = new MenuItem { Header = header };- if (mapped) mi.Icon = new Ellipse { Width = 6, Height = 6, Fill = NotaPalette.Teal };+ // A mapped target is ticked like any chosen item (the menu theme's accent check).+ var mi = new MenuItem { Header = header, ToggleType = MenuItemToggleType.CheckBox, IsChecked = mapped };mi.Click += (_, _) => { Map(s, macro, slot, device, param, lo, hi); changed(); };return mi;}diff --git a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.Drum.cs b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.Drum.csindex 1fa2ec68..ae8c1b3a 100644--- a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.Drum.cs+++ b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.Drum.cs@@ -305,7 +305,9 @@ internal sealed partial class RackCardView{Sel = chain;var f = new MenuFlyout();- var rename = new MenuItem { Header = "Rename…" };+ f.Items.Add(MenuKit.Header(PadName(a, chain), null, "Pad"));+ f.Items.Add(new Separator());+ var rename = MenuKit.Item("Rename…", GlyphKind.Edit);rename.Click += (_, _) => Avalonia.Threading.Dispatcher.UIThread.Post(() => PromptRenamePad(a, anchor, chain));f.Items.Add(rename);@@ -324,9 +326,7 @@ internal sealed partial class RackCardViewopen.Click += (_, _) => _drumView = 2;f.Items.Add(open);f.Items.Add(new Separator());- var remove = new MenuItem { Header = "Remove pad" };- remove.Click += (_, _) => { a.RemoveChain(chain); _ctx.NotifyChanged(); };- f.Items.Add(remove);+ f.Items.Add(MenuKit.Danger("Remove pad", GlyphKind.Trash, () => { a.RemoveChain(chain); _ctx.NotifyChanged(); }));bool renaming = false;rename.Click += (_, _) => renaming = true;diff --git a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.csindex 0dc8a567..a29fff90 100644--- a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs+++ b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs@@ -1372,6 +1372,8 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)private void ShowMacroMenu(IRackAccess a, Control anchor, int m){var f = new MenuFlyout();+ f.Items.Add(MenuKit.Header(a.MacroName(m), null, $"Macro · {m + 1}"));+ f.Items.Add(new Separator());var map = new MenuItem { Header = "Map to parameter" };int chains = a.ChainCount();for (int c = 0; c < chains; c++)@@ -1413,9 +1415,9 @@ internal sealed partial class RackCardView(DeviceCardContext ctx)for (int i = 0; i < n; i++) if (a.TryGetMapping(i, out var mm) && mm.Macro == m) mapped++;if (mapped > 0){- var clr = new MenuItem { Header = $"Clear {mapped} mapping(s)" };- clr.Click += (_, _) => { ClearMacroMappings(a, m); _ctx.RequestRebuild(); };- f.Items.Add(clr);+ f.Items.Add(new Separator());+ f.Items.Add(MenuKit.Danger(mapped == 1 ? "Clear 1 mapping" : $"Clear {mapped} mappings", GlyphKind.Trash,+ () => { ClearMacroMappings(a, m); _ctx.RequestRebuild(); }));}f.ShowAt(anchor, showAtPointer: true);}diff --git a/src/managed/Nota.App/DeviceChainView.Clipboard.cs b/src/managed/Nota.App/DeviceChainView.Clipboard.csindex 069bcd0c..b859c042 100644--- a/src/managed/Nota.App/DeviceChainView.Clipboard.cs+++ b/src/managed/Nota.App/DeviceChainView.Clipboard.cs@@ -151,21 +151,37 @@ public sealed partial class DeviceChainView}// ---- context menu (header right-click) --------------------------------- // Adds Copy / Cut / Paste / Delete above the existing "Save preset" item.+ // The device named at the top (spec 034), then what the card's header hands in (preset,+ // compare, move, docs, fold), Save preset, the clipboard group, and Delete last.private void ShowDeviceContextMenu(Control anchor, ChainKind kind, int di, Action<MenuFlyout>? header = null){SelectDevice(kind, di);var flyout = new MenuFlyout();- header?.Invoke(flyout);- void Add(string header, GlyphKind icon, bool enabled, Action act, KeyGesture? gesture = null)- => flyout.Items.Add(MenuKit.Item(header, icon, act, gesture, enabled));- bool selectable = SelectableKind(kind);- Add("Copy", GlyphKind.Copy, selectable, CopySelectedDevice, MenuKit.CopyKey);- Add("Cut", GlyphKind.Cut, selectable, CutSelectedDevice, MenuKit.CutKey);- Add("Paste", GlyphKind.Paste, _clip != null, PasteDevice, MenuKit.PasteKey);- Add("Delete", GlyphKind.Trash, selectable, DeleteSelectedDevice, MenuKit.DeleteKey);+ string name = kind switch+ {+ ChainKind.Instrument => _engine.DeviceName(_trackId, -1),+ ChainKind.Midi => _engine.MidiEffectName(_trackId, di),+ _ => _engine.DeviceName(_trackId, di),+ };+ string badge = kind switch+ {+ ChainKind.Instrument => "Instrument",+ ChainKind.Midi => $"MIDI effect · {di + 1}",+ _ => $"Audio effect · {di + 1}",+ };+ flyout.Items.Add(MenuKit.Header(name.Length > 0 ? name : "Device", null, badge));flyout.Items.Add(new Separator());- Add("Save preset", GlyphKind.Save, true, () => PresetSaveRequested?.Invoke(di));+ header?.Invoke(flyout); // ends with its own separator+ bool selectable = SelectableKind(kind);+ MenuKit.AddGroups(flyout.Items,+ new Control[] { MenuKit.Item("Save preset", GlyphKind.Save, () => PresetSaveRequested?.Invoke(di)) },+ new Control[]+ {+ MenuKit.Item("Copy", GlyphKind.Copy, CopySelectedDevice, MenuKit.CopyKey, selectable),+ MenuKit.Item("Cut", GlyphKind.Cut, CutSelectedDevice, MenuKit.CutKey, selectable),+ MenuKit.Item("Paste", GlyphKind.Paste, PasteDevice, MenuKit.PasteKey, _clip != null),+ },+ new Control[] { MenuKit.Danger("Delete", GlyphKind.Trash, DeleteSelectedDevice, MenuKit.DeleteKey, selectable) });flyout.ShowAt(anchor, showAtPointer: true);}diff --git a/src/managed/Nota.App/DeviceChainView.Fold.cs b/src/managed/Nota.App/DeviceChainView.Fold.csindex 6bd79a76..0ba14899 100644--- a/src/managed/Nota.App/DeviceChainView.Fold.cs+++ b/src/managed/Nota.App/DeviceChainView.Fold.cs@@ -92,9 +92,7 @@ public sealed partial class DeviceChainViewvoid Menu(MenuFlyout flyout){- var unfold = new MenuItem { Header = "Unfold" };- unfold.Click += (_, _) => SetFolded(k, di, false);- flyout.Items.Add(unfold);+ flyout.Items.Add(MenuKit.Item("Unfold", null, () => SetFolded(k, di, false)));flyout.Items.Add(new Separator());}strip.PointerPressed += (_, e) =>diff --git a/src/managed/Nota.App/HistoryView.cs b/src/managed/Nota.App/HistoryView.csindex 7223dbfc..a14d0e35 100644--- a/src/managed/Nota.App/HistoryView.cs+++ b/src/managed/Nota.App/HistoryView.cs@@ -286,6 +286,8 @@ internal sealed class HistoryView : UserControlreturn mi;}+ menu.Items.Add(MenuKit.Header(v.Label ?? LongTime(v.CreatedAt), null, row.IsHead ? "Current version" : "Version"));+ menu.Items.Add(new Separator());Item("Switch to this version", () => _ = Switch(v), !row.IsHead && v.CanOpen, GlyphKind.Arrow);Item("Open as copy…", () => _ = _host.OpenVersionAsCopyAsync(v.Id), v.CanOpen, GlyphKind.Duplicate);menu.Items.Add(new Separator());@@ -296,6 +298,7 @@ internal sealed class HistoryView : UserControlItem(v.Starred ? "Remove star" : "Star", () => Apply(() => _history.SetStarred(_dir!, v.Id, !v.Starred)));menu.Items.Add(new Separator());var del = Item("Delete version…", () => _ = Delete(v), !row.IsHead, GlyphKind.Trash);+ del.Classes.Add("danger");if (row.IsHead) ToolTip.SetTip(del, "Switch to another version to delete this one");return menu;}@@ -310,6 +313,7 @@ internal sealed class HistoryView : UserControlIcon = MenuKit.Icon(GlyphKind.Trash),IsEnabled = unnamed.Count > 0,};+ clean.Classes.Add("danger");clean.Click += (_, _) => _ = DeleteUnnamed(unnamed);menu.Items.Add(clean);return menu;diff --git a/src/managed/Nota.App/MainWindow.Dnd.cs b/src/managed/Nota.App/MainWindow.Dnd.csindex 670ca3c8..4497fe90 100644--- a/src/managed/Nota.App/MainWindow.Dnd.cs+++ b/src/managed/Nota.App/MainWindow.Dnd.cs@@ -127,7 +127,15 @@ public partial class MainWindow}private DeviceInsertService? _insertion;- private DeviceInsertService Insertion => _insertion ??= new DeviceInsertService(Engine, _factory, _presets, _kits);+ private DeviceInsertService Insertion => _insertion ??= NewInsertion();++ private DeviceInsertService NewInsertion()+ {+ var s = new DeviceInsertService(Engine, _factory, _presets, _kits);+ s.InstrumentAdded += OnInstrumentAdded; // "Add track ▸ Recent" (MainWindow.Recent.cs)+ s.InstrumentPresetApplied += RecordTrackInstrument;+ return s;+ }/// <summary>What the views do after the insert service changed a track: card state, the/// last-instrument fallback, refreshes, revealing the chain, the status line.</summary>diff --git a/src/managed/Nota.App/MainWindow.Freeze.cs b/src/managed/Nota.App/MainWindow.Freeze.csindex bbb20a00..b5b3e028 100644--- a/src/managed/Nota.App/MainWindow.Freeze.cs+++ b/src/managed/Nota.App/MainWindow.Freeze.cs@@ -76,8 +76,8 @@ public partial class MainWindow{if (_freezeMenuBuilt) return;_freezeMenuBuilt = true;- _flattenItem = new MenuItem { Header = "Flatten to audio track" };- _flattenItem.Click += async (_, _) => { if (_freezeTrackId > 0) await FlattenTrackAsync(_freezeTrackId); };+ _flattenItem = MenuKit.Danger("Flatten to audio track", GlyphKind.Flatten,+ () => { if (_freezeTrackId > 0) _ = FlattenTrackAsync(_freezeTrackId); });var menu = new ContextMenu();menu.Items.Add(_flattenItem);// Flatten needs a frozen buffer to bounce, so gate it on the current state.@@ -143,45 +143,47 @@ public partial class MainWindow// --- arrangement track context menu -----------------------------------// Freeze entries for a track header's right-click menu, mirroring the header button- // cluster: Freeze / Live Freeze on a live track; Unfreeze / Flatten when frozen in place;- // Edit (or Done / Discard mid-session) + Unfreeze / Flatten on either side of a live-freeze- // link. Each command first selects its track so the device panel and header buttons follow.+ // cluster (spec 034). "Live freeze" is a switch, on for either side of a live-freeze link:+ // switching it on live-freezes the track, switching it off unfreezes the link (wakes the+ // source). While linked, Edit (or Done / Discard mid-session) and Flatten follow; a track+ // frozen in place offers Unfreeze / Flatten instead. Each command first selects its track+ // so the device panel and header buttons follow.private IReadOnlyList<Control> BuildTrackFreezeMenu(int trackId){var items = new List<Control>();if ((LinkForSource(trackId) ?? LinkForFrozen(trackId)) is { } link){int src = link.SourceId;+ items.Add(MenuKit.SwitchItem("Live freeze", GlyphKind.ChainLink, true, () => UnfreezeLink(src)));if (link.State == LinkState.Editing){- items.Add(FreezeMenuItem("Done — re-freeze", GlyphIcon(GlyphKind.Check, accent: true),- async () => { Timeline.Select(trackId, -1); await CommitEditSessionAsync(src); }));- items.Add(FreezeMenuItem("Discard edits", GlyphIcon(GlyphKind.Cross, accent: false),+ items.Add(MenuKit.Item("Done — re-freeze", GlyphKind.Check,+ () => { Timeline.Select(trackId, -1); _ = CommitEditSessionAsync(src); }));+ items.Add(MenuKit.Danger("Discard edits", GlyphKind.Cross,() => { Timeline.Select(trackId, -1); DiscardEditSession(src); }));}else// Editing changes the source's notes/devices, so land on the source track.- items.Add(FreezeMenuItem("Edit source", GlyphIcon(GlyphKind.Edit, accent: true),+ items.Add(MenuKit.Item("Edit source", GlyphKind.Edit,() => { Timeline.Select(src, -1); BeginEditSession(src); }));- items.Add(FreezeMenuItem("Unfreeze (wake source)", MenuKit.Icon(GlyphKind.Freeze), () => UnfreezeLink(src)));- items.Add(FreezeMenuItem("Flatten (remove source)", MenuKit.Icon(GlyphKind.Flatten), () => FlattenLinkAsync(src)));+ items.Add(MenuKit.Danger("Flatten (remove source)", GlyphKind.Flatten, () => FlattenLinkAsync(src)));return items;}if (!IsFreezable(trackId)) return items;if (Engine.IsTrackFrozen(trackId)){- items.Add(FreezeMenuItem("Unfreeze track", SnowflakeIcon(),+ items.Add(MenuKit.Item("Unfreeze track", GlyphKind.Freeze,() => { Timeline.Select(trackId, -1); UnfreezeTrack(trackId); }));- items.Add(FreezeMenuItem("Flatten to audio track", MenuKit.Icon(GlyphKind.Flatten),- async () => { Timeline.Select(trackId, -1); await FlattenTrackAsync(trackId); }));+ items.Add(MenuKit.Danger("Flatten to audio track", GlyphKind.Flatten,+ () => { Timeline.Select(trackId, -1); _ = FlattenTrackAsync(trackId); }));}else{- items.Add(FreezeMenuItem("Freeze track", SnowflakeIcon(),- async () => { Timeline.Select(trackId, -1); await FreezeTrackAsync(trackId); }));- items.Add(FreezeMenuItem("Live freeze", ChainLinkIcon(),- async () => { Timeline.Select(trackId, -1); await LiveFreezeAsync(trackId); }));+ items.Add(MenuKit.Item("Freeze track", GlyphKind.Freeze,+ () => { Timeline.Select(trackId, -1); _ = FreezeTrackAsync(trackId); }));+ items.Add(MenuKit.SwitchItem("Live freeze", GlyphKind.ChainLink, false,+ () => { Timeline.Select(trackId, -1); _ = LiveFreezeAsync(trackId); }));}return items;}@@ -196,10 +198,10 @@ public partial class MainWindowvar live = plain.Where(id => !Engine.IsTrackFrozen(id)).ToList();var frozen = plain.Where(id => Engine.IsTrackFrozen(id)).ToList();if (live.Count > 0)- items.Add(FreezeMenuItem(live.Count == 1 ? "Freeze track" : $"Freeze {live.Count} tracks", SnowflakeIcon(),- () => FreezeTracksAsync(live)));+ items.Add(MenuKit.Item(live.Count == 1 ? "Freeze track" : $"Freeze {live.Count} tracks", GlyphKind.Freeze,+ () => _ = FreezeTracksAsync(live)));if (frozen.Count > 0)- items.Add(FreezeMenuItem(frozen.Count == 1 ? "Unfreeze track" : $"Unfreeze {frozen.Count} tracks", SnowflakeIcon(),+ items.Add(MenuKit.Item(frozen.Count == 1 ? "Unfreeze track" : $"Unfreeze {frozen.Count} tracks", GlyphKind.Freeze,() => UnfreezeTracks(frozen)));return items;}@@ -247,33 +249,10 @@ public partial class MainWindowAfterFreezeChange();}- private static MenuItem FreezeMenuItem(string header, Control? icon, Action run)- {- var mi = new MenuItem { Header = header, Icon = icon };- mi.Click += (_, _) => run();- return mi;- }-- private static MenuItem FreezeMenuItem(string header, Control? icon, Func<Task> run)- {- var mi = new MenuItem { Header = header, Icon = icon };- mi.Click += async (_, _) => await run();- return mi;- }-- // Menu-icon glyphs matching the arrangement header badges (❄ / chain-link in ice blue)- // and the Edit / Done / Discard header buttons.+ // The frozen state's ice tint on the header Freeze button (not used in menus: menu icons+ // stay neutral — spec 034).private static readonly IBrush IceBrush = NotaPalette.Frozen;- private static Control SnowflakeIcon()- => new Glyph(GlyphKind.Freeze, 11) { Foreground = IceBrush };-- private static Control ChainLinkIcon()- => new Glyph(GlyphKind.ChainLink, 14) { Foreground = IceBrush };-- private Control GlyphIcon(GlyphKind glyph, bool accent)- => new Glyph(glyph, 11) { Foreground = accent ? NotaPalette.TextPrimary : NotaPalette.TextTertiary };-// --- Flatten -----------------------------------------------------------private async Task FlattenTrackAsync(int trackId)diff --git a/src/managed/Nota.App/MainWindow.LiveFreeze.cs b/src/managed/Nota.App/MainWindow.LiveFreeze.csindex 5ba65c68..2ec55bc4 100644--- a/src/managed/Nota.App/MainWindow.LiveFreeze.cs+++ b/src/managed/Nota.App/MainWindow.LiveFreeze.cs@@ -269,19 +269,21 @@ public partial class MainWindowcatch (Exception ex) { _vm.StatusText = $"{title} failed: {ex.Message}"; return null; }}- // --- context menu (Unfreeze / Flatten), shared by source + frozen tracks ---+ // --- context menu (Live freeze switch / Flatten), shared by source + frozen tracks ---private bool _liveFreezeMenuBuilt;private void EnsureLiveFreezeMenu(){if (_liveFreezeMenuBuilt) return;_liveFreezeMenuBuilt = true;- var unfreeze = new MenuItem { Header = "Unfreeze (wake source)" };- unfreeze.Click += (_, _) => { int s = LinkSourceFor(_freezeTrackId); if (s > 0) UnfreezeLink(s); };- var flatten = new MenuItem { Header = "Flatten (remove source)" };- flatten.Click += (_, _) => { int s = LinkSourceFor(_freezeTrackId); if (s > 0) FlattenLinkAsync(s); };+ // The same switch the track menu shows: on while linked; switching it off unfreezes.+ var unfreeze = MenuKit.SwitchItem("Live freeze", GlyphKind.ChainLink, true,+ () => { int s = LinkSourceFor(_freezeTrackId); if (s > 0) UnfreezeLink(s); });+ var flatten = MenuKit.Danger("Flatten (remove source)", GlyphKind.Flatten,+ () => { int s = LinkSourceFor(_freezeTrackId); if (s > 0) FlattenLinkAsync(s); });var menu = new ContextMenu();menu.Items.Add(unfreeze);+ menu.Items.Add(new Separator());menu.Items.Add(flatten);EditBtn.ContextMenu = menu;DoneBtn.ContextMenu = menu;diff --git a/src/managed/Nota.App/MainWindow.Recent.cs b/src/managed/Nota.App/MainWindow.Recent.csnew file mode 100644index 00000000..fada098a--- /dev/null+++ b/src/managed/Nota.App/MainWindow.Recent.cs@@ -0,0 +1,90 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// "Add track ▸ Recent" (spec 034): the window records every instrument the insert service+// puts on a track (and the plain "Instrument" track's Volt) into the settings, and hands the+// arrangement and Session menus the items that add one again after the clicked track. The+// MCP tools record through the same settings (Nota.Mcp InstrumentTools / PluginTools).++using System.Collections.Generic;+using System.Linq;+using Avalonia.Controls;+using Microsoft.Extensions.DependencyInjection;+using Nota.Application;+using Nota.Presentation;++namespace Nota.App;++public partial class MainWindow+{+ private IPluginCatalog? RecentCatalog => App.Services.GetService<IPluginCatalog>();++ private void HookRecentInstruments()+ {+ Timeline.RecentInstrumentItems = RecentInstrumentMenuItems;+ if (_session is not null) _session.RecentInstrumentItems = RecentInstrumentMenuItems;+ }++ private void OnInstrumentAdded(BrowserItem item)+ {+ if (_vm is null) return;+ RecentInstrument? entry = item.Kind switch+ {+ BrowserItemKind.BuiltinInstrument when item.BuiltinKind >= 0 => RecentInstrument.Builtin(item.BuiltinKind, item.Name),+ BrowserItemKind.PluginInstrument when RecentCatalog?.Id(item.CatalogIndex) is { Length: > 0 } id => RecentInstrument.Plugin(id, item.Name),+ _ => null,+ };+ if (entry is not null) RecentInstruments.RecordAndSave(_vm.Settings, entry);+ }++ // The instrument a track plays now — after "Add track ▸ Instrument" (Volt) or an+ // instrument preset. Built-in only: a preset never brings a plug-in.+ private void RecordTrackInstrument(int trackId)+ {+ if (_vm is null || trackId <= 0) return;+ int kind = Engine.TrackInstrumentKind(trackId);+ if (kind < 0) return;+ RecentInstruments.RecordAndSave(_vm.Settings, RecentInstrument.Builtin(kind, Engine.DeviceName(trackId, -1)));+ }++ // The menu items for the recent list: each adds a track with that instrument right after+ // the anchor (inside it for a group), as one undo step — like "Add track ▸ Instrument".+ private IReadOnlyList<MenuItem> RecentInstrumentMenuItems(int anchorTrackId)+ {+ if (_vm is null) return [];+ var catalog = RecentCatalog;+ var shown = RecentInstruments.Visible(_vm.Settings.Current.RecentInstruments,+ e => !e.IsPlugin || (catalog?.IndexOfId(e.Id) ?? -1) >= 0);+ return shown.Select(e => MenuKit.Item(e.Name, e.IsPlugin ? GlyphKind.Plug : GlyphKind.Device,+ () => AddRecentInstrument(e, anchorTrackId))).ToList();+ }++ private void AddRecentInstrument(RecentInstrument e, int anchorTrackId)+ {+ if (_vm is null) return;+ BrowserItem item;+ if (e.IsPlugin)+ {+ int index = RecentCatalog?.IndexOfId(e.Id) ?? -1;+ if (index < 0) { _vm.StatusText = $"{e.Name} is no longer installed."; return; }+ item = new BrowserItem { Name = e.Name, Kind = BrowserItemKind.PluginInstrument, CatalogIndex = index };+ }+ else item = new BrowserItem { Name = e.Name, Kind = BrowserItemKind.BuiltinInstrument, BuiltinKind = e.BuiltinKindId };++ int trackId;+ Engine.BeginUndoGroup();+ try+ {+ trackId = Insertion.CreateInstrumentTrack(item, 0.0); // records it as most recent+ if (trackId > 0) Timeline.PlaceNewTrack(trackId, anchorTrackId);+ }+ finally { Engine.EndUndoGroup(); }+ if (trackId <= 0) { _vm.StatusText = $"Couldn't load {e.Name}."; return; }+ Timeline.Refresh();+ Timeline.RevealTrack(trackId);+ if (anchorTrackId > 0) Timeline.Select(trackId, -1);+ _session?.Refresh();+ if (_modular?.IsVisible == true) _modular.Refresh();+ _vm.StatusText = $"Added {e.Name} (track {trackId})";+ }+}diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.csindex 6b9e85bc..b07ca903 100644--- a/src/managed/Nota.App/MainWindow.axaml.cs+++ b/src/managed/Nota.App/MainWindow.axaml.cs@@ -435,6 +435,7 @@ public partial class MainWindow : Windowif (kind == NewTrackKind.Return) OnAddReturnClicked(this, new RoutedEventArgs());else AddTrack(kind, anchor);};+ HookRecentInstruments(); // "Add track ▸ Recent" in both views' menus// Selecting a slot selects its track everywhere: devices below, arrangement header._session.SlotSelected += (trackId, _) => Timeline.Select(trackId, -1);Timeline.SessionChanged += () => _session?.Refresh(); // M5-6@@ -622,6 +623,7 @@ public partial class MainWindow : WindowTimeline.PlaceNewTrack(trackId, anchorTrackId);}finally { Engine.EndUndoGroup(); }+ if (kind == NewTrackKind.Instrument) RecordTrackInstrument(trackId);Timeline.Refresh();Timeline.RevealTrack(trackId); // scrolled into view, not left below the pinned returnsif (anchorTrackId > 0) Timeline.Select(trackId, -1); // show where it landeddiff --git a/src/managed/Nota.App/MenuKit.Rows.cs b/src/managed/Nota.App/MenuKit.Rows.csnew file mode 100644index 00000000..c4d123b0--- /dev/null+++ b/src/managed/Nota.App/MenuKit.Rows.cs@@ -0,0 +1,236 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The inline rows a context menu can carry (spec 034): the object header, the colour grid,+// a segmented row and the switch item. A menu shows a row as a MenuItem with the `inline`+// class (no highlight, spans the width — NotaTheme.axaml), so keyboard navigation and+// light-dismiss keep working. A row applies through the item's own Click — the pick the+// pointer is over, or the keyboard cursor — so the menu closes the usual way.++using System;+using System.Collections.Generic;+using Avalonia;+using Avalonia.Controls;+using Avalonia.Input;+using Avalonia.Interactivity;+using Avalonia.Layout;+using Avalonia.Media;++namespace Nota.App;++internal static partial class MenuKit+{+ /// <summary>The object a menu acts on, named at its top: colour chip (when it has one),+ /// name in the heading weight, and a muted mono badge with its type and position or count+ /// ("Audio · 3", "3 tracks"). Not interactive.</summary>+ public static MenuItem Header(string name, IBrush? colour, string badge)+ {+ var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto"), MinHeight = 28 };+ if (colour is not null)+ grid.Children.Add(new Border+ {+ Width = 8, Height = 8, CornerRadius = NotaRadius.Badge, Background = colour,+ Margin = new Thickness(0, 0, 8, 0), VerticalAlignment = VerticalAlignment.Center,+ });+ var title = new TextBlock+ {+ Text = name, FontWeight = FontWeight.SemiBold, FontSize = NotaType.Name,+ Foreground = NotaPalette.TextHeading, TextTrimming = TextTrimming.CharacterEllipsis,+ VerticalAlignment = VerticalAlignment.Center,+ };+ Grid.SetColumn(title, 1);+ grid.Children.Add(title);+ if (badge.Length > 0)+ {+ var tag = new TextBlock+ {+ Text = badge, FontFamily = NotaFonts.MonoFamily, FontSize = NotaType.Value,+ Foreground = NotaPalette.TextTertiary, Margin = new Thickness(12, 0, 0, 0),+ VerticalAlignment = VerticalAlignment.Center,+ };+ Grid.SetColumn(tag, 2);+ grid.Children.Add(tag);+ }+ var mi = new MenuItem { Header = grid, IsHitTestVisible = false, Focusable = false, IsEnabled = false };+ mi.Classes.Add("inline");+ return mi;+ }++ /// <summary>The track palette in one click: 9 bases × (base, light, dark) plus Auto, the+ /// current colour ringed. Click or Enter picks (index, or −1 for Auto) and closes the menu;+ /// arrow keys move the cursor ring.</summary>+ public static MenuItem ColourGrid(int current, Action<int> pick)+ {+ int bases = ArrangementView.PaletteBases, shades = ArrangementView.PaletteShades;+ var row = new PickRow();+ var grid = new Grid { HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(0, 4) };+ for (int c = 0; c < bases; c++) grid.ColumnDefinitions.Add(new ColumnDefinition(18, GridUnitType.Pixel));+ grid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto));+ for (int r = 0; r < shades; r++) grid.RowDefinitions.Add(new RowDefinition(18, GridUnitType.Pixel));++ // Cursor order: row by row (base, light, dark), Auto last.+ for (int s = 0; s < shades; s++)+ for (int b = 0; b < bases; b++)+ {+ int ci = b * shades + s;+ var swatch = new Border { Width = 12, Height = 12, CornerRadius = NotaRadius.Badge, Background = ArrangementView.TrackBrush(ci) };+ var ring = new Border+ {+ Width = 16, Height = 16, CornerRadius = NotaRadius.Control, BorderThickness = new Thickness(1),+ Child = swatch, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top,+ };+ Grid.SetColumn(ring, b); Grid.SetRow(ring, s);+ grid.Children.Add(ring);+ row.Add(ring, ci, ci == current, (cell, chosen, cursor) =>+ cell.BorderBrush = chosen ? NotaPalette.TextPrimary : cursor ? NotaPalette.TextMuted : Brushes.Transparent,+ up: s > 0 ? row.Count - bases : -1, down: s < shades - 1 ? row.Count + bases : -1);+ }++ var auto = new Border+ {+ Height = 52, MinWidth = 40, Margin = new Thickness(6, 0, 0, 0), CornerRadius = NotaRadius.Control,+ BorderThickness = new Thickness(1), Padding = new Thickness(6, 0), VerticalAlignment = VerticalAlignment.Top,+ Child = new TextBlock { Text = "Auto", FontSize = NotaType.Caption, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center },+ };+ Grid.SetColumn(auto, bases); Grid.SetRowSpan(auto, shades);+ grid.Children.Add(auto);+ row.Add(auto, -1, current == -1, (cell, chosen, cursor) =>+ {+ cell.BorderBrush = chosen ? NotaPalette.TextPrimary : NotaPalette.Rule;+ cell.Background = cursor ? NotaPalette.SurfaceHover : Brushes.Transparent;+ });++ return row.Attach(grid, (v, _) => pick(v));+ }++ /// <summary>A captioned row of segmented keys ("Height S M L"): the chosen key in the+ /// accent. Click or Enter picks; Option / Alt held passes <c>all = true</c>.</summary>+ public static MenuItem Segments<T>(string label, IReadOnlyList<(string Label, T Value)> options, T? chosen,+ Action<T, bool> pick) where T : struct+ {+ var row = new PickRow();+ var keys = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 1 };+ var group = new Border+ {+ Child = keys, Background = NotaPalette.Seam, BorderBrush = NotaPalette.Seam, BorderThickness = new Thickness(1),+ CornerRadius = NotaRadius.Control, ClipToBounds = true, HorizontalAlignment = HorizontalAlignment.Right,+ };+ for (int i = 0; i < options.Count; i++)+ {+ var (name, value) = options[i];+ var text = new TextBlock { Text = name, FontSize = NotaType.Caption, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };+ var key = new Border { MinWidth = 52, Height = 18, Padding = new Thickness(6, 0), Child = text };+ keys.Children.Add(key);+ bool isChosen = chosen is { } c && EqualityComparer<T>.Default.Equals(c, value);+ row.Add(key, i, isChosen, (cell, ch, cursor) =>+ {+ var k = cell;+ k.Background = ch ? NotaPalette.Accent : cursor ? NotaPalette.SurfaceHover : NotaPalette.SurfaceRaised;+ ((TextBlock)k.Child!).Foreground = ch ? NotaPalette.TextOnAccent : NotaPalette.TextSecondary;+ });+ }+ var line = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto"), MinHeight = 28 };+ line.Children.Add(new TextBlock { Text = NotaText.Label(label), FontSize = NotaType.Caption, Foreground = NotaPalette.TextMuted, VerticalAlignment = VerticalAlignment.Center });+ Grid.SetColumn(group, 1);+ group.VerticalAlignment = VerticalAlignment.Center;+ line.Children.Add(group);+ return row.Attach(line, (i, all) => pick(options[i].Value, all));+ }++ /// <summary>A small colour chip for a menu's value column — a user colour that is data (a+ /// tag's colour), shown beside the label rather than as its icon so a tick can sit left.</summary>+ public static Control Swatch(IBrush colour)+ => new Border { Width = 8, Height = 8, CornerRadius = NotaRadius.Badge, Background = colour, VerticalAlignment = VerticalAlignment.Center };++ /// <summary>Appends a "Recent" caption and its items to a submenu (nothing when empty).</summary>+ public static void AddRecent(MenuItem submenu, IReadOnlyList<MenuItem>? recent)+ {+ if (recent is null || recent.Count == 0) return;+ submenu.Items.Add(new Separator());+ submenu.Items.Add(Caption("Recent"));+ foreach (var mi in recent) submenu.Items.Add(mi);+ }++ /// <summary>A small muted caption heading a group inside a menu ("Recent"). Not interactive.</summary>+ public static MenuItem Caption(string text)+ {+ var mi = new MenuItem+ {+ Header = new TextBlock { Text = NotaText.Label(text), FontSize = NotaType.Caption, Foreground = NotaPalette.TextMuted, VerticalAlignment = VerticalAlignment.Center },+ IsHitTestVisible = false, Focusable = false, IsEnabled = false, MinHeight = 20,+ };+ mi.Classes.Add("inline");+ return mi;+ }++ /// <summary>An item with an 18 × 10 switch in its value column (accent while on); a click+ /// anywhere on the item toggles it.</summary>+ public static MenuItem SwitchItem(string header, GlyphKind? icon, bool isOn, Action toggle)+ {+ var mi = Item(header, icon, toggle);+ SetTrailing(mi, new SwitchTrack { IsOn = isOn });+ return mi;+ }++ // One inline row of pickable cells: tracks the pointer and a keyboard cursor, paints the+ // cells through the caller's painter, and applies on the hosting item's Click.+ private sealed class PickRow+ {+ private readonly List<(Border Cell, int Value, Action<Border, bool, bool> Paint, int Up, int Down)> _cells = new();+ private int _chosen = -1, _cursor = -1;+ private KeyModifiers _mods;++ public int Count => _cells.Count;++ public void Add(Border cell, int value, bool chosen, Action<Border, bool, bool> paint, int up = -1, int down = -1)+ {+ int i = _cells.Count;+ _cells.Add((cell, value, paint, up, down));+ if (chosen) _chosen = i;+ cell.Background ??= Brushes.Transparent;+ cell.PointerEntered += (_, _) => Move(i);+ paint(cell, chosen, false);+ }++ private void Move(int i)+ {+ int old = _cursor;+ _cursor = i;+ if (old >= 0 && old < _cells.Count) Repaint(old);+ if (i >= 0) Repaint(i);+ }++ private void Repaint(int i) => _cells[i].Paint(_cells[i].Cell, i == _chosen, i == _cursor);++ public MenuItem Attach(Control content, Action<int, bool> apply)+ {+ var mi = new MenuItem { Header = content };+ mi.Classes.Add("inline");+ content.PointerExited += (_, _) => Move(-1);+ // Remember the modifiers of the gesture that will become Click.+ mi.AddHandler(InputElement.PointerReleasedEvent, (_, e) => _mods = e.KeyModifiers, RoutingStrategies.Tunnel);+ mi.AddHandler(InputElement.KeyDownEvent, (_, e) =>+ {+ _mods = e.KeyModifiers;+ if (_cells.Count == 0) return;+ int at = _cursor >= 0 ? _cursor : Math.Max(0, _chosen);+ int next = e.Key switch+ {+ Key.Left => Math.Max(0, at - 1),+ Key.Right => Math.Min(_cells.Count - 1, at + 1),+ Key.Up when _cells[at].Up >= 0 => _cells[at].Up,+ Key.Down when _cells[at].Down >= 0 => _cells[at].Down,+ _ => -1,+ };+ if (next >= 0) { Move(next); e.Handled = true; }+ }, RoutingStrategies.Tunnel);+ mi.GotFocus += (_, _) => { if (_cursor < 0) Move(Math.Max(0, _chosen)); };+ mi.Click += (_, _) =>+ {+ if (_cursor < 0 || _cursor >= _cells.Count) return;+ apply(_cells[_cursor].Value, (_mods & KeyModifiers.Alt) != 0);+ };+ return mi;+ }+ }+}diff --git a/src/managed/Nota.App/MenuKit.cs b/src/managed/Nota.App/MenuKit.csindex e13f6f54..f2a83820 100644--- a/src/managed/Nota.App/MenuKit.cs+++ b/src/managed/Nota.App/MenuKit.cs@@ -1,20 +1,27 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//-// Context-menu items with a drawn icon on the left and the matching shortcut on the right.+// Context-menu items with a drawn icon on the left and the matching shortcut on the right,+// plus the shared parts every menu is built from (spec 034): the value / switch column,+// danger items, the clipboard group and grouped separators. The inline rows (header,+// colour grid, segments, switch) live in MenuKit.Rows.cs.// The gesture is display-only (MenuItem.InputGesture doesn't bind anything): the real key// handlers live in MainWindow.Input.cs / the native Edit menu / DeviceChainView, so only// list a gesture here when one of those actually performs the same command.using System;using System.Collections.Generic;+using System.Globalization;+using System.Linq;+using Avalonia;using Avalonia.Controls;+using Avalonia.Data.Converters;using Avalonia.Input;using Nota.Application.Input;namespace Nota.App;-internal static class MenuKit+internal static partial class MenuKit{private static KeyModifiers Primary => OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control;@@ -60,4 +67,111 @@ internal static class MenuKitif (click is not null) mi.Click += (_, _) => click();return mi;}++ // ---- The right-hand column (spec 034) -----------------------------------------------+ // The Nota MenuItem theme (NotaTheme.axaml) draws one column between the label and the+ // submenu caret: the item's Trailing content (a current value such as "In 1–2", or a+ // switch) followed by its shortcut. Trailing is attached so call sites keep plain items.++ public static readonly AttachedProperty<object?> TrailingProperty =+ AvaloniaProperty.RegisterAttached<MenuItem, object?>("Trailing", typeof(MenuKit));++ public static object? GetTrailing(MenuItem mi) => mi.GetValue(TrailingProperty);+ public static void SetTrailing(MenuItem mi, object? value) => mi.SetValue(TrailingProperty, value);++ /// <summary>A submenu item that shows its current choice in muted ink before the caret+ /// ("Record input In 1–2 ›"); the caller adds the choices to <c>Items</c>.</summary>+ public static MenuItem ValueItem(string header, GlyphKind? icon, string value)+ {+ var mi = Item(header, icon);+ SetTrailing(mi, value);+ return mi;+ }++ /// <summary>A destructive command (delete, remove, clear, discard): danger ink at rest,+ /// the usual accent fill while highlighted. It belongs in the menu's last group.</summary>+ public static MenuItem Danger(string header, GlyphKind? icon, Action click,+ KeyGesture? gesture = null, bool enabled = true)+ {+ var mi = Item(header, icon, click, gesture, enabled);+ mi.Classes.Add("danger");+ return mi;+ }++ /// <summary>The clipboard group every object menu shares, always in this order with these+ /// keys: Copy ⌘C · Cut ⌘X · Paste ⌘V · Duplicate ⌘D. A null action leaves its item out;+ /// Paste is disabled while there is nothing to paste.</summary>+ public static IEnumerable<MenuItem> ClipboardGroup(Action? copy, Action? cut, Action? paste,+ Action? duplicate, bool canPaste = true)+ {+ if (copy is not null) yield return Item("Copy", GlyphKind.Copy, copy, CopyKey);+ if (cut is not null) yield return Item("Cut", GlyphKind.Cut, cut, CutKey);+ if (paste is not null) yield return Item("Paste", GlyphKind.Paste, paste, PasteKey, canPaste);+ if (duplicate is not null) yield return Item("Duplicate", GlyphKind.Duplicate, duplicate, DuplicateKey);+ }++ /// <summary>Adds groups to a menu with a rule between non-empty ones, so callers can pass+ /// groups that may come out empty without leaving doubled or trailing separators.</summary>+ public static void AddGroups(ItemCollection items, params IEnumerable<Control>?[] groups)+ {+ foreach (var g in groups)+ {+ if (g is null) continue;+ var list = g.ToList();+ if (list.Count == 0) continue;+ if (items.Count > 0 && items[^1] is not Separator) items.Add(new Separator());+ foreach (var c in list) items.Add(c);+ }+ }++ // ---- Shortcut spelling --------------------------------------------------------------++ /// <summary>A menu shortcut as this platform writes it: "⌘G", "⌘⇧G", "⌫" on macOS (no+ /// separators), "Ctrl+G", "Ctrl+Shift+G", "Del" elsewhere.</summary>+ public static string Spell(KeyGesture? gesture) => Spell(gesture, OperatingSystem.IsMacOS());++ internal static string Spell(KeyGesture? gesture, bool mac)+ {+ if (gesture is null) return "";+ var mods = ShortcutModifiers.None;+ var km = gesture.KeyModifiers;+ if (km.HasFlag(KeyModifiers.Meta)) mods |= ShortcutModifiers.Primary;+ if (km.HasFlag(KeyModifiers.Control)) mods |= mac ? ShortcutModifiers.Ctrl : ShortcutModifiers.Primary;+ if (km.HasFlag(KeyModifiers.Alt)) mods |= ShortcutModifiers.Alt;+ if (km.HasFlag(KeyModifiers.Shift)) mods |= ShortcutModifiers.Shift;+ return new Shortcut(mods, KeyName(gesture.Key, mac)).ToPlatformString(mac);+ }++ private static string KeyName(Key key, bool mac) => key switch+ {+ >= Key.A and <= Key.Z => key.ToString(),+ >= Key.D0 and <= Key.D9 => ((char)('0' + (key - Key.D0))).ToString(),+ >= Key.NumPad0 and <= Key.NumPad9 => ((char)('0' + (key - Key.NumPad0))).ToString(),+ >= Key.F1 and <= Key.F24 => key.ToString(),+ Key.Back => KeyGlyphs.Backspace.ToString(),+ Key.Delete => mac ? "⌦" : "Del", // ⌦ forward delete+ Key.Enter => KeyGlyphs.Return.ToString(),+ Key.Escape => "Esc",+ Key.Space => "Space",+ Key.Tab => "Tab",+ Key.Left => "←", Key.Right => "→", Key.Up => "↑", Key.Down => "↓",+ Key.OemPlus or Key.Add => "+",+ Key.OemMinus or Key.Subtract => "−",+ Key.OemComma => ",", Key.OemPeriod => ".",+ Key.OemOpenBrackets => "[", Key.OemCloseBrackets => "]",+ _ => key.ToString(),+ };+}++/// <summary>Turns a MenuItem's InputGesture into the platform spelling for the Nota menu+/// theme (Avalonia's own converter writes "⌘+G").</summary>+internal sealed class MenuGestureConverter : IValueConverter+{+ public static readonly MenuGestureConverter Instance = new();++ public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)+ => MenuKit.Spell(value as KeyGesture);++ public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)+ => throw new NotSupportedException();}diff --git a/src/managed/Nota.App/ModularView.cs b/src/managed/Nota.App/ModularView.csindex 12fb9195..95d0bd49 100644--- a/src/managed/Nota.App/ModularView.cs+++ b/src/managed/Nota.App/ModularView.cs@@ -1201,8 +1201,12 @@ public sealed class ModularView : UserControl{int t = _trackId; var e = _engine;var flyout = new MenuFlyout();+ flyout.Items.Add(MenuKit.Header(paramName, null, "Parameter"));+ flyout.Items.Add(new Separator());- // Already modulated? Offer edit + remove (the link may be owned by another track).+ // Already modulated? Offer edit + remove (the link may be owned by another track);+ // Remove goes last, in the destructive group.+ MenuItem? remove = null;var (owner, li) = FindModulation(targetKind, device, param);if (owner >= 0){@@ -1212,10 +1216,9 @@ public sealed class ModularView : UserControl: "LFO " + e.CvLinkSource(owner, li);var edit = new MenuItem { Header = $"Edit modulation · {srcLabel}{(cross ? " (" + TrackName(owner) + ")" : "")}…" };edit.Click += (_, _) => ShowLinkEditor(anchor, owner, li);- var rm = new MenuItem { Header = "Remove modulation" };- rm.Click += (_, _) => { e.CvLinkRemove(owner, li); Rebuild(); Changed?.Invoke(); };flyout.Items.Add(edit);- flyout.Items.Add(rm);+ remove = MenuKit.Danger("Remove modulation", null,+ () => { e.CvLinkRemove(owner, li); Rebuild(); Changed?.Invoke(); });}else{@@ -1280,6 +1283,12 @@ public sealed class ModularView : UserControlflyout.Items.Add(ex);}+ if (remove is not null)+ {+ flyout.Items.Add(new Separator());+ flyout.Items.Add(remove);+ }+flyout.ShowAt(anchor, showAtPointer: true);}diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.csindex 8d646351..a26173cd 100644--- a/src/managed/Nota.App/PreferencesWindow.cs+++ b/src/managed/Nota.App/PreferencesWindow.cs@@ -1251,10 +1251,11 @@ public sealed partial class PreferencesWindow : NotaWindow("Right-click the metronome", "Count-in before Play / Record: off · 1 · 2 · 4 bars"),("Drag an audio clip's ADSR handle", "Shape attack · decay + sustain · release (top corners and the dot on hover) · double-click resets the stage"),("⇧-click track header", "Add the track to the selection · again to remove it"),- ("Right-click track headers", "A multi-selection gets its own menu: group, colour, track height, freeze, copy, duplicate, delete"),+ ("Right-click track headers", "A multi-selection gets its own menu: colour, height, freeze, group, copy, duplicate, delete"),("Drag a track's bottom edge", "Resize the track (header or lane) · snaps to compact / standard / large · a multi-selection resizes together"),("Drag a track's bottom edge + ⌥", "Resize every track at once"),("Double-click a track's bottom edge", "Back to the standard height"),+ ("⌥-click a height key in the track menu", "Set every track to Compact · Standard · Large"),("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"),diff --git a/src/managed/Nota.App/PreviewPlayer.cs b/src/managed/Nota.App/PreviewPlayer.csindex 9a53cdba..d270e052 100644--- a/src/managed/Nota.App/PreviewPlayer.cs+++ b/src/managed/Nota.App/PreviewPlayer.cs@@ -522,7 +522,7 @@ public sealed class PreviewPlayer : UserControlif (t.Group != group){flyout.Items.Add(new Separator());- flyout.Items.Add(new MenuItem { Header = NotaText.Label(t.Group), IsEnabled = false, FontSize = 11 });+ flyout.Items.Add(MenuKit.Caption(t.Group));group = t.Group;}Add(t.Name, t.Id, t.Blurb);diff --git a/src/managed/Nota.App/SessionView.Grid.cs b/src/managed/Nota.App/SessionView.Grid.csindex 3212291f..027ce260 100644--- a/src/managed/Nota.App/SessionView.Grid.cs+++ b/src/managed/Nota.App/SessionView.Grid.cs@@ -862,31 +862,31 @@ public sealed partial class SessionViewvar f = new MenuFlyout();if (filled){- f.Items.Add(MenuKit.Item("Launch", GlyphKind.Play, () => _engine.LaunchSlot(c.TrackId, scene)));- f.Items.Add(MenuKit.Item("Edit", GlyphKind.Edit, () => SlotEditRequested?.Invoke(c.TrackId, scene)));- f.Items.Add(MenuKit.Item("Rename…", GlyphKind.Edit, () => RenameSelection(), new KeyGesture(Key.F2)));- f.Items.Add(new Separator());- f.Items.Add(MenuKit.Item("Copy", GlyphKind.Copy, () => CopySelection(), MenuKit.CopyKey));- f.Items.Add(MenuKit.Item("Cut", GlyphKind.Cut, () => CutSelection(), MenuKit.CutKey));- }- f.Items.Add(MenuKit.Item("Paste", GlyphKind.Paste, () => PasteSelection(), MenuKit.PasteKey, CanPaste));- if (filled)- {- f.Items.Add(MenuKit.Item("Duplicate", GlyphKind.Duplicate, () => DuplicateSelection(), MenuKit.DuplicateKey));- f.Items.Add(MenuKit.Item("Copy to Arrangement", GlyphKind.Arrow, () => CopySelectionToArrangement(), MenuKit.CopyToOtherViewKey));- f.Items.Add(new Separator());- f.Items.Add(MenuKit.Item("Delete", GlyphKind.Trash, () => DeleteSelection(), MenuKit.DeleteKey));+ string name = _engine.GetSessionClipName(c.TrackId, scene);+ MenuKit.AddGroups(f.Items,+ new Control[] { MenuKit.Header(name.Length > 0 ? name : "Clip", c.Brush, $"{c.Name} · scene {scene + 1}") },+ new Control[]+ {+ MenuKit.Item("Launch", GlyphKind.Play, () => _engine.LaunchSlot(c.TrackId, scene)),+ MenuKit.Item("Edit", GlyphKind.Edit, () => SlotEditRequested?.Invoke(c.TrackId, scene)),+ MenuKit.Item("Rename…", GlyphKind.Edit, () => RenameSelection(), new KeyGesture(Key.F2)),+ },+ new Control[] { MenuKit.Item("Copy to Arrangement", GlyphKind.Arrow, () => CopySelectionToArrangement(), MenuKit.CopyToOtherViewKey) },+ new Control[] { AddTrackSubmenu(c.TrackId) },+ MenuKit.ClipboardGroup(() => CopySelection(), () => CutSelection(), () => PasteSelection(), () => DuplicateSelection(), CanPaste),+ new Control[] { MenuKit.Danger("Delete", GlyphKind.Trash, () => DeleteSelection(), MenuKit.DeleteKey) });}else{- f.Items.Add(new Separator());- if (c.IsInstrument) f.Items.Add(MenuKit.Item("Insert MIDI clip", GlyphKind.Plus, () => InsertMidiClip(c.TrackId, scene)));- f.Items.Add(MenuKit.Item("Record here", GlyphKind.Record, () => { _engine.RecordSessionSlot(c.TrackId, scene); Refresh(); }));+ var create = new List<Control>();+ if (c.IsInstrument) create.Add(MenuKit.Item("Insert MIDI clip", GlyphKind.Plus, () => InsertMidiClip(c.TrackId, scene)));+ create.Add(MenuKit.Item("Record here", GlyphKind.Record, () => { _engine.RecordSessionSlot(c.TrackId, scene); Refresh(); }));bool stop = _engine.GetSessionSlotStopButton(c.TrackId, scene);- f.Items.Add(MenuKit.Item(stop ? "Remove stop button" : "Add stop button", GlyphKind.Stop, () => { _engine.SetSessionSlotStopButton(c.TrackId, scene, !stop); RefreshSlot(c.TrackId, scene); }));+ create.Add(MenuKit.Item(stop ? "Remove stop button" : "Add stop button", GlyphKind.Stop, () => { _engine.SetSessionSlotStopButton(c.TrackId, scene, !stop); RefreshSlot(c.TrackId, scene); }));+ MenuKit.AddGroups(f.Items, create,+ new Control[] { MenuKit.Item("Paste", GlyphKind.Paste, () => PasteSelection(), MenuKit.PasteKey, CanPaste) },+ new Control[] { AddTrackSubmenu(c.TrackId) });}- f.Items.Add(new Separator());- foreach (var mi in AddTrackItems(c.TrackId)) f.Items.Add(mi);f.ShowAt(anchor, showAtPointer: true);}@@ -898,29 +898,69 @@ public sealed partial class SessionViewyield return MenuKit.Item("Add return track", GlyphKind.Plus, () => AddTrackRequested?.Invoke(NewTrackKind.Return, anchorTrackId));}+ // "Add track ▸ Instrument / Audio / Return · Recent" — the same submenu the arrangement+ // track menu has.+ public Func<int, IReadOnlyList<MenuItem>>? RecentInstrumentItems;++ private MenuItem AddTrackSubmenu(int anchorTrackId)+ {+ var add = MenuKit.Item("Add track", GlyphKind.Plus);+ add.Items.Add(MenuKit.Item("Instrument", GlyphKind.Plus, () => AddTrackRequested?.Invoke(NewTrackKind.Instrument, anchorTrackId)));+ add.Items.Add(MenuKit.Item("Audio", GlyphKind.Plus, () => AddTrackRequested?.Invoke(NewTrackKind.Audio, anchorTrackId)));+ add.Items.Add(MenuKit.Item("Return", GlyphKind.Plus, () => AddTrackRequested?.Invoke(NewTrackKind.Return, anchorTrackId)));+ MenuKit.AddRecent(add, RecentInstrumentItems?.Invoke(anchorTrackId));+ return add;+ }+private void ShowAddTrackMenu(Control anchor, int anchorTrackId){var f = new MenuFlyout();foreach (var mi in AddTrackItems(anchorTrackId)) f.Items.Add(mi);+ if (RecentInstrumentItems?.Invoke(anchorTrackId) is { Count: > 0 } recent)+ {+ f.Items.Add(new Separator());+ f.Items.Add(MenuKit.Caption("Recent"));+ foreach (var mi in recent) f.Items.Add(mi);+ }f.ShowAt(anchor, showAtPointer: true);}- // Column header menu: rename / delete the track, or add one next to it.+ // Column header menu (spec 034): the track named at the top, its colour, rename, add a+ // track next to it, delete.private void ShowHeaderMenu(Control anchor, Column c){var f = new MenuFlyout();- if (c.Kind != ColKind.Master)+ if (c.Kind == ColKind.Master){- f.Items.Add(MenuKit.Item("Rename…", GlyphKind.Edit, () => PromptRenameTrack(anchor, c.TrackId)));- f.Items.Add(MenuKit.Item(c.Kind == ColKind.Group ? "Delete group and its tracks" : "Delete track", GlyphKind.Trash, () =>- {- _engine.RemoveTracks(new[] { c.TrackId }); // a group takes its tracks along, one undo step- Refresh();- ArrangementChanged?.Invoke();- }));- f.Items.Add(new Separator());+ MenuKit.AddGroups(f.Items,+ new Control[] { MenuKit.Header("Master", NotaPalette.Master, "Master") },+ new Control[] { AddTrackSubmenu(-1) });+ f.ShowAt(anchor, showAtPointer: true);+ return;}- foreach (var mi in AddTrackItems(c.Kind == ColKind.Master ? -1 : c.TrackId)) f.Items.Add(mi);+ int pos = NavCols.FindIndex(x => x.TrackId == c.TrackId);+ f.FlyoutPresenterClasses.Add("rows");+ int stored = _engine.GetTrackColorIndex(c.TrackId);+ var colour = MenuKit.ColourGrid(stored, ci =>+ {+ _engine.SetTrackColorIndex(c.TrackId, ci);+ Refresh();+ ArrangementChanged?.Invoke();+ });+ MenuKit.AddGroups(f.Items,+ new Control[] { MenuKit.Header(c.Name, c.Brush, pos >= 0 ? $"{c.KindLabel} · {pos + 1}" : c.KindLabel) },+ new Control[] { colour },+ new Control[] { MenuKit.Item("Rename…", GlyphKind.Edit, () => PromptRenameTrack(anchor, c.TrackId)) },+ new Control[] { AddTrackSubmenu(c.TrackId) },+ new Control[]+ {+ MenuKit.Danger(c.Kind == ColKind.Group ? "Delete group and its tracks" : "Delete", GlyphKind.Trash, () =>+ {+ _engine.RemoveTracks(new[] { c.TrackId }); // a group takes its tracks along, one undo step+ Refresh();+ ArrangementChanged?.Invoke();+ }),+ });f.ShowAt(anchor, showAtPointer: true);}@@ -935,17 +975,23 @@ public sealed partial class SessionViewprivate void ShowSceneMenu(Control anchor, int scene){var f = new MenuFlyout();- f.Items.Add(MenuKit.Item("Launch scene", GlyphKind.Play, () => LaunchSceneRow(scene)));- f.Items.Add(MenuKit.Item("Stop scene", GlyphKind.Stop, () => _engine.StopScene(scene)));- f.Items.Add(MenuKit.Item("Rename…", GlyphKind.Edit, () => RenameSelection(), new KeyGesture(Key.F2)));- f.Items.Add(new Separator());- f.Items.Add(MenuKit.Item("Insert scene below", GlyphKind.Plus, () => InsertSceneAtSelection(), MenuKit.Cmd(Key.I)));- f.Items.Add(MenuKit.Item("Duplicate scene", GlyphKind.Duplicate, () => DuplicateSelection(), MenuKit.DuplicateKey));- f.Items.Add(MenuKit.Item("Capture playing clips below", GlyphKind.Copy, CaptureScene));- f.Items.Add(MenuKit.Item("Paste", GlyphKind.Paste, () => PasteSelection(), MenuKit.PasteKey, ClipTransfer.FromArrangement(_engine)));- f.Items.Add(MenuKit.Item("Copy scene to Arrangement", GlyphKind.Arrow, () => CopySelectionToArrangement(), MenuKit.CopyToOtherViewKey, SelectedSlots().Length > 0));- f.Items.Add(new Separator());- f.Items.Add(MenuKit.Item("Delete scene", GlyphKind.Trash, () => DeleteSelection(), MenuKit.DeleteKey, _sceneCount > 1));+ string name = _engine.GetSceneName(scene);+ MenuKit.AddGroups(f.Items,+ new Control[] { MenuKit.Header(name.Length > 0 ? name : $"Scene {scene + 1}", null, $"Scene · {scene + 1}") },+ new Control[]+ {+ MenuKit.Item("Launch scene", GlyphKind.Play, () => LaunchSceneRow(scene)),+ MenuKit.Item("Stop scene", GlyphKind.Stop, () => _engine.StopScene(scene)),+ MenuKit.Item("Rename…", GlyphKind.Edit, () => RenameSelection(), new KeyGesture(Key.F2)),+ },+ new Control[]+ {+ MenuKit.Item("Insert scene below", GlyphKind.Plus, () => InsertSceneAtSelection(), MenuKit.Cmd(Key.I)),+ MenuKit.Item("Capture playing clips below", GlyphKind.Copy, CaptureScene),+ MenuKit.Item("Copy scene to Arrangement", GlyphKind.Arrow, () => CopySelectionToArrangement(), MenuKit.CopyToOtherViewKey, SelectedSlots().Length > 0),+ },+ MenuKit.ClipboardGroup(null, null, () => PasteSelection(), () => DuplicateSelection(), ClipTransfer.FromArrangement(_engine)),+ new Control[] { MenuKit.Danger("Delete scene", GlyphKind.Trash, () => DeleteSelection(), MenuKit.DeleteKey, _sceneCount > 1) });f.ShowAt(anchor, showAtPointer: true);}}diff --git a/src/managed/Nota.App/SnapChip.cs b/src/managed/Nota.App/SnapChip.csindex 4c3747df..c5cedb96 100644--- a/src/managed/Nota.App/SnapChip.cs+++ b/src/managed/Nota.App/SnapChip.cs@@ -118,7 +118,7 @@ internal sealed class SnapChipvoid Item(string header, bool on, Func<GridSetting, GridSetting> apply, KeyGesture? gesture = null){var mi = new MenuItem { Header = header, InputGesture = gesture };- if (on) mi.Icon = new Glyph(GlyphKind.Dot, 6) { Foreground = NotaPalette.TextPrimary };+ mi.ToggleType = MenuItemToggleType.Radio; mi.IsChecked = on;mi.Click += (_, _) => Grids.Set(_kind, apply(Grids.Get(_kind)));f.Items.Add(mi);}diff --git a/src/managed/Nota.App/Theme/NotaTheme.axaml b/src/managed/Nota.App/Theme/NotaTheme.axamlindex cd878636..75a9cda4 100644--- a/src/managed/Nota.App/Theme/NotaTheme.axaml+++ b/src/managed/Nota.App/Theme/NotaTheme.axaml@@ -64,6 +64,185 @@and sets the Shadow.* elevations and Fluent's SystemAccentColor ramp from thetheme on every switch. Views reach them with {DynamicResource Brush.*} /{DynamicResource Shadow.*}; a StaticResource cannot follow a theme change. -->++ <!-- ===== Menu item (spec 034) ============================================+ Every item inside a context menu, flyout or submenu. One row of fixed columns so+ every item of a menu lines up: icon (or the check of a chosen choice) · label ·+ trailing (a current value or a switch, MenuKit.Trailing) · shortcut · caret.+ Shortcuts are spelled the platform's way ("⌘G", "Ctrl+G") by MenuKit.Spell —+ Avalonia's own converter writes "⌘+G". Icons are muted ink at rest; everything+ takes the derived ink on the accent fill while highlighted. Menubar triggers keep+ Fluent's top-level theme. -->+ <ControlTheme x:Key="{x:Type MenuItem}" TargetType="MenuItem">+ <Setter Property="Background" Value="Transparent"/>+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextPrimary}"/>+ <Setter Property="FontFamily" Value="{StaticResource Font.UI}"/>+ <Setter Property="FontSize" Value="12"/>+ <Setter Property="MinHeight" Value="24"/>+ <Setter Property="Padding" Value="8,0"/>+ <Setter Property="CornerRadius" Value="{StaticResource Radius.Clip}"/>+ <Setter Property="Template">+ <ControlTemplate>+ <Panel>+ <Border Name="PART_LayoutRoot"+ Padding="{TemplateBinding Padding}"+ MinHeight="{TemplateBinding MinHeight}"+ Background="{TemplateBinding Background}"+ CornerRadius="{TemplateBinding CornerRadius}">+ <Border.Transitions>+ <Transitions>+ <BrushTransition Property="Background" Duration="0:0:0.12" Easing="CubicEaseOut"/>+ </Transitions>+ </Border.Transitions>+ <Grid>+ <Grid.ColumnDefinitions>+ <ColumnDefinition Width="Auto" SharedSizeGroup="NotaMenuIcon"/>+ <ColumnDefinition Width="*"/>+ <ColumnDefinition Width="Auto" SharedSizeGroup="NotaMenuTrailing"/>+ <ColumnDefinition Width="Auto" SharedSizeGroup="NotaMenuGesture"/>+ <ColumnDefinition Width="Auto" SharedSizeGroup="NotaMenuCaret"/>+ </Grid.ColumnDefinitions>+ <Panel Name="PART_IconColumn" Grid.Column="0" Width="14" Margin="0,0,8,0" IsVisible="False">+ <ContentPresenter Name="PART_IconPresenter"+ Content="{TemplateBinding Icon}"+ Foreground="{DynamicResource Brush.TextMuted}"+ HorizontalAlignment="Center" VerticalAlignment="Center"/>+ <app:Glyph Name="PART_Check" Kind="Check" Width="11" Height="11"+ Foreground="{DynamicResource Brush.Accent}"+ HorizontalAlignment="Center" VerticalAlignment="Center" IsVisible="False"/>+ </Panel>+ <ContentPresenter Name="PART_HeaderPresenter" Grid.Column="1"+ Content="{TemplateBinding Header}"+ ContentTemplate="{TemplateBinding HeaderTemplate}"+ RecognizesAccessKey="True"+ VerticalAlignment="Center" HorizontalAlignment="Stretch"/>+ <ContentPresenter Name="PART_TrailingPresenter" Grid.Column="2"+ Content="{Binding (app:MenuKit.Trailing), RelativeSource={RelativeSource TemplatedParent}}"+ Foreground="{DynamicResource Brush.TextMuted}"+ Margin="16,0,0,0"+ VerticalAlignment="Center" HorizontalAlignment="Right"/>+ <TextBlock Name="PART_InputGestureText" Grid.Column="3"+ Text="{Binding InputGesture, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static app:MenuGestureConverter.Instance}}"+ FontFamily="{StaticResource Font.Mono}" FontSize="11"+ Foreground="{DynamicResource Brush.TextMuted}"+ Margin="16,0,0,0"+ VerticalAlignment="Center" HorizontalAlignment="Right"/>+ <app:Glyph Name="PART_Caret" Grid.Column="4" Kind="ChevronRight" Width="8" Height="8"+ Foreground="{DynamicResource Brush.TextMuted}"+ Margin="10,0,0,0" VerticalAlignment="Center"/>+ </Grid>+ </Border>+ <Popup Name="PART_Popup"+ WindowManagerAddShadowHint="False"+ Placement="RightEdgeAlignedTop"+ HorizontalOffset="2" VerticalOffset="-5"+ IsLightDismissEnabled="False"+ IsOpen="{TemplateBinding IsSubMenuOpen, Mode=TwoWay}">+ <Border Background="{DynamicResource Brush.SurfaceRaised}"+ BorderBrush="{DynamicResource Brush.Seam}" BorderThickness="1"+ CornerRadius="{StaticResource Radius.Control}"+ Padding="4" MinWidth="200" MaxHeight="560">+ <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">+ <ItemsPresenter Name="PART_ItemsPresenter"+ ItemsPanel="{TemplateBinding ItemsPanel}"+ Grid.IsSharedSizeScope="True"/>+ </ScrollViewer>+ </Border>+ </Popup>+ </Panel>+ </ControlTemplate>+ </Setter>++ <Style Selector="^:icon /template/ Panel#PART_IconColumn">+ <Setter Property="IsVisible" Value="True"/>+ </Style>+ <Style Selector="^:checked /template/ Panel#PART_IconColumn">+ <Setter Property="IsVisible" Value="True"/>+ </Style>+ <Style Selector="^:checked /template/ app|Glyph#PART_Check">+ <Setter Property="IsVisible" Value="True"/>+ </Style>+ <Style Selector="^:checked /template/ ContentPresenter#PART_IconPresenter">+ <Setter Property="IsVisible" Value="False"/>+ </Style>+ <Style Selector="^:empty /template/ app|Glyph#PART_Caret">+ <Setter Property="IsVisible" Value="False"/>+ </Style>++ <!-- Destructive: danger ink on label and icon at rest. -->+ <Style Selector="^.danger">+ <Setter Property="Foreground" Value="{DynamicResource Brush.Danger}"/>+ <Style Selector="^ /template/ ContentPresenter#PART_IconPresenter">+ <Setter Property="Foreground" Value="{DynamicResource Brush.Danger}"/>+ </Style>+ </Style>++ <!-- Highlight (pointer or keyboard; Avalonia marks it :selected): the accent fill,+ every part in the derived ink. -->+ <Style Selector="^:selected">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextOnAccent}"/>+ <Style Selector="^ /template/ Border#PART_LayoutRoot">+ <Setter Property="Background" Value="{DynamicResource Brush.Accent}"/>+ </Style>+ <Style Selector="^ /template/ ContentPresenter#PART_IconPresenter">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextOnAccent}"/>+ </Style>+ <Style Selector="^ /template/ app|Glyph#PART_Check">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextOnAccent}"/>+ </Style>+ <Style Selector="^ /template/ ContentPresenter#PART_TrailingPresenter">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextOnAccent}"/>+ </Style>+ <Style Selector="^ /template/ TextBlock#PART_InputGestureText">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextOnAccent}"/>+ </Style>+ <Style Selector="^ /template/ app|Glyph#PART_Caret">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextOnAccent}"/>+ </Style>+ </Style>++ <!-- Disabled: the disabled ink step on every part, never a fill (wins over danger). -->+ <Style Selector="^:disabled">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextDisabled}"/>+ <Style Selector="^ /template/ Border#PART_LayoutRoot">+ <Setter Property="Background" Value="Transparent"/>+ </Style>+ <Style Selector="^ /template/ ContentPresenter#PART_IconPresenter">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextDisabled}"/>+ </Style>+ <Style Selector="^ /template/ ContentPresenter#PART_TrailingPresenter">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextDisabled}"/>+ </Style>+ <Style Selector="^ /template/ TextBlock#PART_InputGestureText">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextDisabled}"/>+ </Style>+ <Style Selector="^ /template/ app|Glyph#PART_Caret">+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextDisabled}"/>+ </Style>+ </Style>++ <!-- An inline row (header, colour grid, segments, caption) takes a template of its+ own: one presenter, no column grid. On the item grid it spanned the menu's+ shared-size columns, so its width hung on the other items (a long current value+ such as "Nota Pentad") and, a few pixels short in the native popup, it was+ centred and clipped on both sides. Now it simply asks for its width. -->+ <Style Selector="^.inline">+ <Setter Property="Padding" Value="8,0"/>+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextPrimary}"/>+ <Setter Property="Template">+ <ControlTemplate>+ <Border Name="PART_LayoutRoot"+ Padding="{TemplateBinding Padding}"+ MinHeight="{TemplateBinding MinHeight}"+ Background="Transparent">+ <ContentPresenter Name="PART_HeaderPresenter"+ Content="{TemplateBinding Header}"+ VerticalAlignment="Center" HorizontalAlignment="Stretch"/>+ </Border>+ </ControlTemplate>+ </Setter>+ </Style>+ </ControlTheme></ResourceDictionary></Styles.Resources>@@ -984,6 +1163,12 @@<Setter Property="BorderThickness" Value="1"/><Setter Property="CornerRadius" Value="{StaticResource Radius.Control}"/><Setter Property="Padding" Value="4"/>+ <Setter Property="MinWidth" Value="200"/>+ </Style>+ <!-- A menu carrying inline rows (colour grid, height keys): wide enough that they never+ wrap, whatever the track's name (spec 034). -->+ <Style Selector="MenuFlyoutPresenter.rows">+ <Setter Property="MinWidth" Value="248"/></Style><!-- A plain flyout (a popover with its own content). --><Style Selector="FlyoutPresenter">@@ -1006,50 +1191,18 @@<Setter Property="BorderThickness" Value="1"/><Setter Property="CornerRadius" Value="{StaticResource Radius.Control}"/><Setter Property="Padding" Value="4"/>+ <Setter Property="MinWidth" Value="200"/></Style>- <Style Selector="MenuItem">- <Setter Property="Foreground" Value="{DynamicResource Brush.TextPrimary}"/>- <Setter Property="FontFamily" Value="{StaticResource Font.UI}"/>- <Setter Property="FontSize" Value="12"/>- <Setter Property="MinHeight" Value="24"/>- <Setter Property="Padding" Value="8,0"/>- </Style>- <!-- Root Border of the MenuItem template: transparent by default, a full accent fill on- highlight (Avalonia marks the hovered flyout item :selected). -->- <Style Selector="MenuItem /template/ Border#PART_LayoutRoot">- <Setter Property="Background" Value="Transparent"/>- <Setter Property="CornerRadius" Value="{StaticResource Radius.Clip}"/>- <Setter Property="Margin" Value="0"/>- </Style>- <Style Selector="MenuItem:selected /template/ Border#PART_LayoutRoot,- MenuItem:pointerover /template/ Border#PART_LayoutRoot">- <Setter Property="Background" Value="{DynamicResource Brush.Accent}"/>- </Style>- <Style Selector="MenuItem:selected, MenuItem:pointerover">- <Setter Property="Foreground" Value="{DynamicResource Brush.TextOnAccent}"/>- </Style>- <Style Selector="MenuItem:disabled">- <Setter Property="Foreground" Value="{DynamicResource Brush.TextDisabled}"/>- </Style>- <Style Selector="MenuItem:disabled /template/ Border#PART_LayoutRoot">- <Setter Property="Background" Value="Transparent"/>- </Style>- <!-- Shortcut on the right of an item (MenuItem.InputGesture): muted ink — the next ink- step, not opacity — and the derived ink while the item is highlighted. -->- <Style Selector="MenuItem /template/ TextBlock#PART_InputGestureText">- <Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}"/>- <Setter Property="Margin" Value="20,0,0,0"/>- </Style>- <Style Selector="MenuItem:selected /template/ TextBlock#PART_InputGestureText,- MenuItem:pointerover /template/ TextBlock#PART_InputGestureText">- <Setter Property="Foreground" Value="{DynamicResource Brush.TextOnAccent}"/>- </Style>+ <!-- Menu items take the Nota MenuItem theme (ControlTheme above); the danger and inline+ classes, hover and disabled states live there with it. --><!-- The menubar's own triggers (File, Edit…): secondary ink that lifts to the raised toneon hover or while open — only the items inside a menu fill with the accent. --><Style Selector="Menu > MenuItem"><Setter Property="Foreground" Value="{DynamicResource Brush.TextSecondary}"/>+ <Setter Property="FontFamily" Value="{StaticResource Font.UI}"/>+ <Setter Property="FontSize" Value="12"/><Setter Property="Padding" Value="8,0"/><Setter Property="MinHeight" Value="22"/></Style>diff --git a/src/managed/Nota.Application/RecentInstruments.cs b/src/managed/Nota.Application/RecentInstruments.csnew file mode 100644index 00000000..2bd6c6eb--- /dev/null+++ b/src/managed/Nota.Application/RecentInstruments.cs@@ -0,0 +1,76 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The instruments the user added most recently (spec 034), offered under "Add track ▸+// Recent". Kept in the app settings, per user, not in the project. Every route that puts an+// instrument on a track records into it — the browser, the menus, the MCP tools — so the+// rules live here, once, and the smoke test checks them.++using System;+using System.Collections.Generic;+using System.Globalization;+using System.Linq;++namespace Nota.Application;++/// <summary>One recently added instrument. <see cref="Kind"/> is "builtin" (Id = the built-in+/// instrument kind) or "plugin" (Id = the plug-in catalog's stable identifier); identity is+/// (Kind, Id, FactoryPreset).</summary>+public sealed record RecentInstrument(string Kind, string Id, string Name, string? FactoryPreset = null)+{+ public const string BuiltinKind = "builtin", PluginKind = "plugin";++ public bool IsPlugin => Kind == PluginKind;++ /// <summary>The built-in instrument kind, or -1 for a plug-in or a malformed entry.</summary>+ public int BuiltinKindId => Kind == BuiltinKind && int.TryParse(Id, NumberStyles.Integer, CultureInfo.InvariantCulture, out int k) ? k : -1;++ public static RecentInstrument Builtin(int kind, string name)+ => new(BuiltinKind, kind.ToString(CultureInfo.InvariantCulture), name);++ public static RecentInstrument Plugin(string id, string name) => new(PluginKind, id, name);++ public bool SameAs(RecentInstrument other)+ => Kind == other.Kind && Id == other.Id && FactoryPreset == other.FactoryPreset;+}++public static class RecentInstruments+{+ public const int Capacity = 5;++ /// <summary>Puts <paramref name="entry"/> at the top: an entry already present moves up+ /// (no duplicates), and the oldest falls off past <see cref="Capacity"/>.</summary>+ public static void Record(List<RecentInstrument> list, RecentInstrument entry)+ {+ if (string.IsNullOrEmpty(entry.Kind) || string.IsNullOrEmpty(entry.Id)) return;+ list.RemoveAll(e => e is null || e.SameAs(entry));+ list.Insert(0, entry);+ if (list.Count > Capacity) list.RemoveRange(Capacity, list.Count - Capacity);+ }++ /// <summary>The entries to offer, most recent first: well-formed, de-duplicated, at most+ /// <see cref="Capacity"/>, and only those <paramref name="available"/> accepts — a plug-in+ /// that is no longer installed is hidden, not forgotten, so it comes back if reinstalled.</summary>+ public static IReadOnlyList<RecentInstrument> Visible(IEnumerable<RecentInstrument?>? list, Func<RecentInstrument, bool> available)+ {+ var shown = new List<RecentInstrument>();+ if (list is null) return shown;+ foreach (var e in list)+ {+ if (e is null || string.IsNullOrEmpty(e.Kind) || string.IsNullOrEmpty(e.Id) || string.IsNullOrEmpty(e.Name)) continue;+ if (e.Kind is not (RecentInstrument.BuiltinKind or RecentInstrument.PluginKind)) continue;+ if (shown.Any(s => s.SameAs(e)) || !available(e)) continue;+ shown.Add(e);+ if (shown.Count == Capacity) break;+ }+ return shown;+ }++ /// <summary>Records into the app settings and saves them.</summary>+ public static void RecordAndSave(ISettingsService settings, RecentInstrument entry)+ {+ settings.Current.RecentInstruments ??= new();+ Record(settings.Current.RecentInstruments, entry);+ settings.Save();+ }+}diff --git a/src/managed/Nota.Application/Settings.cs b/src/managed/Nota.Application/Settings.csindex 16b94659..7e7fef02 100644--- a/src/managed/Nota.Application/Settings.cs+++ b/src/managed/Nota.Application/Settings.cs@@ -44,6 +44,9 @@ public sealed class Settings/// <summary>Recently opened/saved project bundle paths, most-recent first. Shown on the/// welcome screen; capped and pruned of missing folders when displayed.</summary>public List<string> RecentProjects { get; set; } = new();+ /// <summary>Instruments added most recently, most-recent first (spec 034): "Add track ▸+ /// Recent". Rules in <see cref="Nota.Application.RecentInstruments"/>.</summary>+ public List<RecentInstrument> RecentInstruments { get; set; } = new();/// <summary>Show the welcome screen (recent projects launcher) on startup. On by default;/// toggled from the welcome screen's "Show on startup" checkbox.</summary>public bool ShowWelcomeOnStartup { get; set; } = true;diff --git a/src/managed/Nota.Mcp/Tools/InstrumentTools.cs b/src/managed/Nota.Mcp/Tools/InstrumentTools.csindex 40ff45e5..c5a3941c 100644--- a/src/managed/Nota.Mcp/Tools/InstrumentTools.cs+++ b/src/managed/Nota.Mcp/Tools/InstrumentTools.cs@@ -10,7 +10,8 @@ using Nota.Application;namespace Nota.Mcp.Tools;[McpServerToolType]-public sealed class InstrumentTools(IAudioEngine engine, IEngineDispatch dispatch, IArrangementRefresh refresh)+public sealed class InstrumentTools(IAudioEngine engine, IEngineDispatch dispatch, IArrangementRefresh refresh,+ ISettingsService? settings = null): EngineTools(engine, dispatch, refresh){// Built-in instrument kinds (matches the engine's kind() ids + browser mapping). Nota Synth (0)@@ -31,28 +32,35 @@ public sealed class InstrumentTools(IAudioEngine engine, IEngineDispatch dispatcpublic InstrumentKind[] ListInstrumentKinds() => Array.ConvertAll(Kinds, k => new InstrumentKind(k.Kind, k.Name));[McpServerTool(Name = "add_instrument_track"), Description("Add an instrument track with the given built-in kind (see list_instrument_kinds). Returns the track id.")]- public Task<int> AddInstrumentTrack([Description("Instrument kind id from list_instrument_kinds")] int kind) => Mutate(() => kind switch+ public Task<int> AddInstrumentTrack([Description("Instrument kind id from list_instrument_kinds")] int kind) => Mutate(() =>{- 0 => E.AddInstrumentTrack(), // legacy Nota Synth-- 1 => E.AddSamplerInstrumentTrack(),- 2 => E.AddPhysicalSynthTrack(),- 3 => E.AddInstrumentRackTrack(),- 4 => E.AddDrumRackTrack(),- 5 => E.AddWavetableSynthTrack(),- 6 => E.AddVoltSynthTrack(),- 7 => E.AddBassSynthTrack(),- 8 => E.AddPendulumSynthTrack(),- 9 => E.AddOperatorSynthTrack(),- 10 => E.AddGrainSynthTrack(),- 11 => E.AddFluxSynthTrack(),- 12 => E.AddRhythmTrack(),- 13 => E.AddMonolithTrack(),- 14 => E.AddPentadTrack(),- 15 => E.AddConsortTrack(),- 16 => E.AddKeysTrack(),- 17 => E.AddMosaicTrack(),- _ => E.AddVoltSynthTrack(), // the default instrument+ int t = kind switch+ {+ 0 => E.AddInstrumentTrack(), // legacy Nota Synth+ 1 => E.AddSamplerInstrumentTrack(),+ 2 => E.AddPhysicalSynthTrack(),+ 3 => E.AddInstrumentRackTrack(),+ 4 => E.AddDrumRackTrack(),+ 5 => E.AddWavetableSynthTrack(),+ 6 => E.AddVoltSynthTrack(),+ 7 => E.AddBassSynthTrack(),+ 8 => E.AddPendulumSynthTrack(),+ 9 => E.AddOperatorSynthTrack(),+ 10 => E.AddGrainSynthTrack(),+ 11 => E.AddFluxSynthTrack(),+ 12 => E.AddRhythmTrack(),+ 13 => E.AddMonolithTrack(),+ 14 => E.AddPentadTrack(),+ 15 => E.AddConsortTrack(),+ 16 => E.AddKeysTrack(),+ 17 => E.AddMosaicTrack(),+ _ => E.AddVoltSynthTrack(), // the default instrument+ };+ // Recorded for "Add track ▸ Recent" (spec 034), like an add from the browser: the+ // instrument the track really got, under the name the engine gives it.+ if (t > 0 && settings is not null)+ RecentInstruments.RecordAndSave(settings, RecentInstrument.Builtin(E.TrackInstrumentKind(t), E.DeviceName(t, -1)));+ return t;});[McpServerTool(Name = "get_instrument_params"), Description("List the track instrument's parameters (index, stable id, name, normalized value 0..1).")]diff --git a/src/managed/Nota.Mcp/Tools/PluginTools.cs b/src/managed/Nota.Mcp/Tools/PluginTools.csindex 95314833..bfbc4f12 100644--- a/src/managed/Nota.Mcp/Tools/PluginTools.cs+++ b/src/managed/Nota.Mcp/Tools/PluginTools.cs@@ -13,11 +13,19 @@ using Nota.Application;namespace Nota.Mcp.Tools;[McpServerToolType]-public sealed class PluginTools(IAudioEngine engine, IEngineDispatch dispatch, IArrangementRefresh refresh, IPluginCatalog catalog)+public sealed class PluginTools(IAudioEngine engine, IEngineDispatch dispatch, IArrangementRefresh refresh, IPluginCatalog catalog,+ ISettingsService? settings = null): EngineTools(engine, dispatch, refresh){private readonly IPluginCatalog _cat = catalog;+ // Recorded for "Add track ▸ Recent" (spec 034), like an add from the browser.+ private void RecordRecent(int catalogIndex, int trackId)+ {+ if (settings is null || _cat.Id(catalogIndex) is not { Length: > 0 } id) return;+ RecentInstruments.RecordAndSave(settings, RecentInstrument.Plugin(id, E.DeviceName(trackId, -1)));+ }+public sealed record PluginEntry(int Index, string Id, string Description);public sealed record Param(int Index, string Id, string Name, float Value);@@ -37,10 +45,19 @@ public sealed class PluginTools(IAudioEngine engine, IEngineDispatch dispatch, Ipublic Task<int> FindPlugin(string identifier) => Read(() => _cat.IndexOfId(identifier));[McpServerTool(Name = "add_plugin_instrument"), Description("Add a new track whose instrument is the hosted plugin at the given catalog index. Returns the track id (0 on failure).")]- public Task<int> AddPluginInstrument(int catalogIndex) => Mutate(() => E.AddPluginInstrumentTrack(catalogIndex));+ public Task<int> AddPluginInstrument(int catalogIndex) => Mutate(() =>+ {+ int t = E.AddPluginInstrumentTrack(catalogIndex);+ if (t > 0) RecordRecent(catalogIndex, t);+ return t;+ });[McpServerTool(Name = "set_track_instrument_plugin"), Description("Replace a track's instrument with the hosted plugin at the given catalog index.")]- public Task SetTrackInstrumentPlugin(int trackId, int catalogIndex) => Mutate(() => E.SetTrackInstrumentPlugin(trackId, catalogIndex));+ public Task SetTrackInstrumentPlugin(int trackId, int catalogIndex) => Mutate(() =>+ {+ E.SetTrackInstrumentPlugin(trackId, catalogIndex);+ RecordRecent(catalogIndex, trackId);+ });[McpServerTool(Name = "add_plugin_effect"), Description("Add a hosted plugin as an insert effect on a track. Returns the new device index (-1 on failure).")]public Task<int> AddPluginEffect(int trackId, int catalogIndex) => Mutate(() => E.AddTrackEffectPlugin(trackId, catalogIndex));diff --git a/src/managed/Nota.Presentation/DeviceInsertService.cs b/src/managed/Nota.Presentation/DeviceInsertService.csindex 5e28381b..8fa0c204 100644--- a/src/managed/Nota.Presentation/DeviceInsertService.cs+++ b/src/managed/Nota.Presentation/DeviceInsertService.cs@@ -71,6 +71,14 @@ public sealed class DeviceInsertServiceprivate const string FactoryPrefix = "factory:", KitPrefix = "kit:", RhythmKitPrefix = "rhythmkit:";+ /// <summary>Raised when an instrument lands on a track — a new track or a replaced+ /// instrument — so the host can record it under "Add track ▸ Recent" (spec 034).</summary>+ public event Action<BrowserItem>? InstrumentAdded;++ /// <summary>Raised when an instrument preset lands on a track (in place, or on a new+ /// track), with that track's id: the host records the instrument the track now plays.</summary>+ public event Action<int>? InstrumentPresetApplied;+// ---- what a track is --------------------------------------------------------------------public bool TryTrackInfo(int trackId, out NotaTrackInfo info)@@ -140,7 +148,7 @@ public sealed class DeviceInsertService};if (item.BuiltinKind == RhythmModel.Kind && _kits is not null) _kits.LoadInto(_engine, t, _kits.DefaultRhythmKit, out _); // a Rhythm starts on a factory kit}- if (t > 0) _engine.AddMidiClip(t, beat, 4.0);+ if (t > 0) { _engine.AddMidiClip(t, beat, 4.0); InstrumentAdded?.Invoke(item); }return t;}@@ -155,6 +163,7 @@ public sealed class DeviceInsertService}else if (item.Kind == BrowserItemKind.PluginInstrument) _engine.SetTrackInstrumentPlugin(trackId, item.CatalogIndex);else return false;+ InstrumentAdded?.Invoke(item);return true;}@@ -382,6 +391,7 @@ public sealed class DeviceInsertServiceswapped = true;}string w = _factory.ApplyInPlace(_engine, factoryId, t, -1);+ if (w.Length == 0) InstrumentPresetApplied?.Invoke(t);return new InsertResult{Ok = w.Length == 0, TrackId = t, InstrumentReplaced = swapped, ShowDevices = true,@@ -392,12 +402,15 @@ public sealed class DeviceInsertService// …and a preset file (a user preset, a Mosaic pack preset) the same way.if (fp is null && !target.NewTrack && target.InPlace && CanReplaceInstrument(t)&& _presets?.ApplyInstrumentInPlace(_engine, item.Path, t, out bool fileSwapped) is { } fw)+ {+ if (fw.Length == 0) InstrumentPresetApplied?.Invoke(t);return new InsertResult{Ok = fw.Length == 0, TrackId = t, InstrumentReplaced = fileSwapped, ShowDevices = true,Status = fw.Length > 0 ? fw : $"Applied preset {item.Name}",PresetLanded = (t, PresetChain.Instrument, -1, item.Name, ""),};+ }// Apply doesn't say where the preset landed, so diff the chain around it: a new track// (instrument preset) or one more device / MIDI effect on the target (appended last).@@ -409,6 +422,7 @@ public sealed class DeviceInsertServiceif (warn.Length > 0) return InsertResult.Fail(warn);int newTrack = TrackIds().FirstOrDefault(id => !before.Contains(id));+ if (newTrack > 0) InstrumentPresetApplied?.Invoke(newTrack);if (newTrack > 0)return new InsertResult{diff --git a/tests/Nota.SmokeTest/DesignTokenCheck.Menus.cs b/tests/Nota.SmokeTest/DesignTokenCheck.Menus.csnew file mode 100644index 00000000..5b357220--- /dev/null+++ b/tests/Nota.SmokeTest/DesignTokenCheck.Menus.cs@@ -0,0 +1,71 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Context-menu guard (spec 034). Every menu is drawn by the Nota MenuItem theme and built+// from MenuKit, so a menu stays consistent only if call sites don't route around it: a+// tinted icon control, a destructive command without danger ink, or the old Color / Track+// height submenus coming back. Source scan, counted per file against MenuAllowList.txt+// (a ratchet: counts may only go down).++using System;+using System.Collections.Generic;+using System.IO;+using System.Linq;+using System.Text.RegularExpressions;++namespace Nota.SmokeTest;++internal static partial class DesignTokenCheck+{+ // A menu icon that is not MenuKit.Icon(…): a MenuItem's Icon set to anything else (in its+ // initializer or as `x.Icon =` on a menu item variable), or a freeze-menu helper handed+ // some other control. Window icons and list-row icons are not menus.+ private static readonly Regex MenuIconOther = new(+ @"(?:\bnew\s+MenuItem\s*\{[^}]*\bIcon\s*=\s*(?!MenuKit\.Icon\b|null\b)[A-Za-z_])"+ + @"|(?:\b(?:mi|it|item|um|ri|ti|sub|baseItem|shade)\.Icon\s*=\s*(?!MenuKit\.Icon\b|null\b)[A-Za-z_])"+ + @"|(?:\bFreezeMenuItem\(\s*[^,]+,\s*(?!MenuKit\.Icon\b)[A-Za-z_])");++ // A destructive command written as a plain item instead of MenuKit.Danger.+ private static readonly Regex MenuDestructivePlain = new(+ @"(?:\bHeader\s*=\s*|\bMenuKit\.Item\(\s*|\bFreezeMenuItem\(\s*)\$?""(?:Delete|Remove|Clear|Discard|Flatten)\b");++ // The submenus the inline rows replaced.+ private static readonly Regex MenuOldSubmenu = new(@"\bHeader\s*=\s*""(?:Color|Colour|Track height)""");++ public static IEnumerable<(bool Ok, string Label)> RunMenus()+ {+ var root = RepoRoot();+ if (root is null) { yield return (false, "repo root located"); yield break; }+ var app = Path.Combine(root, "src/managed/Nota.App");++ var counts = new SortedDictionary<string, int>(StringComparer.Ordinal);+ var samples = new List<string>();+ foreach (var f in SourceFiles(app, ".cs").Where(f => !Norm(f).EndsWith("/MenuKit.cs") && !Norm(f).EndsWith("/MenuKit.Rows.cs")))+ {+ int n = 0, lineNo = 0;+ foreach (var line in File.ReadLines(f))+ {+ lineNo++;+ var code = CodeOf(line);+ int hit = MenuIconOther.Matches(code).Count + MenuDestructivePlain.Matches(code).Count+ + MenuOldSubmenu.Matches(code).Count;+ if (hit > 0 && samples.Count < 8) samples.Add($"{RelManaged(root, f)}:{lineNo}");+ n += hit;+ }+ if (n > 0) counts[RelManaged(root, f)] = n;+ }++ var allowed = new Dictionary<string, int>(StringComparer.Ordinal);+ foreach (var (path, key) in ReadRatchet(Path.Combine(root, RatchetDir, "MenuAllowList.txt")))+ allowed[path] = int.TryParse(key, out var c) ? c : 0;+ var over = counts.Where(kv => kv.Value > allowed.GetValueOrDefault(kv.Key))+ .Select(kv => $"{kv.Key} ({kv.Value}, allowed {allowed.GetValueOrDefault(kv.Key)})").ToArray();+ yield return (over.Length == 0,+ over.Length == 0 ? "menus: icons via MenuKit.Icon, destructive items via MenuKit.Danger, no Color / Track height submenus"+ : $"menu items outside MenuKit conventions: {string.Join(", ", over.Take(8))} — e.g. {string.Join(", ", samples)}");+ var slack = allowed.Where(kv => kv.Value > counts.GetValueOrDefault(kv.Key))+ .Select(kv => $"{kv.Key} {kv.Value} → {counts.GetValueOrDefault(kv.Key)}").ToArray();+ yield return (slack.Length == 0,+ slack.Length == 0 ? "menu allow-list counts are tight" : $"menu allow-list above today's count (lower it): {string.Join(", ", slack.Take(8))}");+ }+}diff --git a/tests/Nota.SmokeTest/MenuAllowList.txt b/tests/Nota.SmokeTest/MenuAllowList.txtnew file mode 100644index 00000000..c450a3e2--- /dev/null+++ b/tests/Nota.SmokeTest/MenuAllowList.txt@@ -0,0 +1,10 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+#+# Menu ratchet for DesignTokenCheck.RunMenus (spec 034).+#+# Menu items built outside the MenuKit conventions — an icon that is not MenuKit.Icon, a+# destructive command (Delete / Remove / Clear / Discard / Flatten) without MenuKit.Danger,+# or a Color / Track height submenu — counted per file. A count may only go down. Empty:+# every menu follows the conventions; add a line only for a justified exception, with why.+#diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 8ceb9f67..67892758 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -87,6 +87,8 @@ Console.WriteLine($"engine v{NotaEngine.Version}");foreach (var (ok, label) in Nota.SmokeTest.DesignTokenCheck.RunLabels()) Check(ok, label);Console.WriteLine("-- design: icons --");foreach (var (ok, label) in Nota.SmokeTest.DesignTokenCheck.RunIcons()) Check(ok, label);+ Console.WriteLine("-- design: menus --");+ foreach (var (ok, label) in Nota.SmokeTest.DesignTokenCheck.RunMenus()) Check(ok, label);Console.WriteLine("-- design: browser --");foreach (var (ok, label) in Nota.SmokeTest.DesignTokenCheck.RunBrowser()) Check(ok, label);Console.WriteLine("-- design: remote --");@@ -15015,6 +15017,10 @@ foreach (var (ok, label) in ShortcutBuilderTests.Run()) Check(ok, label);Console.WriteLine("-- command palette --");foreach (var (ok, label) in PaletteTests.Run()) Check(ok, label);+// --- context menus: "Add track ▸ Recent" list rules (spec 034) ---+Console.WriteLine("-- recent instruments --");+foreach (var (ok, label) in RecentInstrumentsTests.Run()) Check(ok, label);+// --- get plug-ins: registry index, install/uninstall from local archives ---Console.WriteLine("-- get plug-ins: registry store --");foreach (var (ok, label) in PluginStoreTests.Run()) Check(ok, label);diff --git a/tests/Nota.SmokeTest/RecentInstrumentsTests.cs b/tests/Nota.SmokeTest/RecentInstrumentsTests.csnew file mode 100644index 00000000..3d513c4c--- /dev/null+++ b/tests/Nota.SmokeTest/RecentInstrumentsTests.cs@@ -0,0 +1,54 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// "Add track ▸ Recent" (spec 034): the recent-instruments rules — most recent first, no+// duplicates, five at most, uninstalled plug-ins hidden but kept, malformed entries skipped —+// and that the list survives a settings round trip through JSON.++using System.Collections.Generic;+using System.Linq;+using System.Text.Json;+using Nota.Application;++namespace Nota.SmokeTest;++internal static class RecentInstrumentsTests+{+ public static IEnumerable<(bool Ok, string Label)> Run()+ {+ var volt = RecentInstrument.Builtin(6, "Nota Volt");+ var keys = RecentInstrument.Builtin(16, "Nota Keys");+ var serum = RecentInstrument.Plugin("vst3:serum", "Serum");++ var list = new List<RecentInstrument>();+ RecentInstruments.Record(list, volt);+ RecentInstruments.Record(list, keys);+ RecentInstruments.Record(list, serum);+ yield return (list.Select(e => e.Name).SequenceEqual(new[] { "Serum", "Nota Keys", "Nota Volt" }),+ "recent instruments: most recent first");++ RecentInstruments.Record(list, RecentInstrument.Builtin(6, "Nota Volt"));+ yield return (list.Count == 3 && list[0].SameAs(volt),+ "recent instruments: re-adding moves the entry to the top, no duplicate");++ for (int k = 7; k < 12; k++) RecentInstruments.Record(list, RecentInstrument.Builtin(k, $"Kind {k}"));+ yield return (list.Count == RecentInstruments.Capacity && list[0].BuiltinKindId == 11 && list.All(e => !e.SameAs(volt)),+ $"recent instruments: capped at {RecentInstruments.Capacity}, the oldest drops off");++ var stored = new List<RecentInstrument?> { serum, null, new("plugin", "", "Broken"), new("odd", "x", "Odd"), keys, serum };+ var shown = RecentInstruments.Visible(stored, e => !e.IsPlugin);+ yield return (shown.Count == 1 && shown[0].SameAs(keys) && stored.Contains(serum),+ "recent instruments: an uninstalled plug-in is hidden (kept in the list), malformed entries skipped");++ var settings = new Settings();+ RecentInstruments.Record(settings.RecentInstruments, serum);+ RecentInstruments.Record(settings.RecentInstruments, keys);+ var back = JsonSerializer.Deserialize<Settings>(JsonSerializer.Serialize(settings));+ yield return (back?.RecentInstruments.Count == 2 && back.RecentInstruments[0].SameAs(keys) && back.RecentInstruments[1].IsPlugin,+ "recent instruments: survive a settings JSON round trip");++ var old = JsonSerializer.Deserialize<Settings>("{\"RecentProjects\":[]}");+ yield return (old is not null && old.RecentInstruments.Count == 0,+ "recent instruments: an older settings file without the list reads as empty");+ }+}