Skip to content

armgit / nota

Public Imported from GitHub
0

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

(feat) Browser: your own sample folders, a file-system browse view, Locate and a richer Projects tab (#268, #346, #579, #580, #581, #582) (#583)

Egor Khindikaynene191a57bfc6f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e0600e9c..76210c7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,32 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Your own sample folders in the browser** (#268, #346, specs/092). Settings → Library
+ lists every folder the Files tab shows: **Add folder…**, drop folders from Finder /
+ Explorer, rename the label, set the default, show it, remove it (the files stay on disk).
+ The Files tab adds folders the same ways. With more than one folder each is a top-level
+ node with its own menu; every folder is indexed (tempo, key, loop or one-shot, similar
+ sounds) and searched. One folder is the default: downloaded sample packs go there. A
+ folder on an unplugged drive stays listed as unavailable and comes back with the drive.
+ A folder already in the list, or inside or around one, is refused with a note.
+- **Browse the whole computer from the Files tab** (#580, specs/092). A **Tree | Browse**
+ switch: Browse shows one folder at a time, starting at the default sample folder, with
+ **Back / Forward / Up** (⌘[ ⌘] ⌘↑; Ctrl or Alt elsewhere) up to the list of drives, **Home**
+ (back to the default sample folder), a path bar whose segments jump there, **Copy path**,
+ and a path you type or paste (⌘L), a file path selecting that file. Every row has an icon
+ for what it is (folder, drive, audio, MIDI, other file); files show their extension and size
+ in their own columns, and files Nota can't add are listed in a faded ink and can't be
+ dragged or opened. Audio files preview and drag as in the tree; a folder can be added to
+ the browser from its menu. Every file and folder row in the Files tab has **Copy path**.
+- **Locate a clip's file** (#581, specs/092). An audio clip's menu in the arrangement and in
+ Session has **Locate ▸ In browser / In Finder** (In Explorer, In file manager). In browser
+ opens the Files tab at the file (the tree if it lies in a sample folder, else the browse
+ view); with a clip selected, its file is marked in the Files list whenever its folder is
+ open. Projects now remember the file each audio clip came from, so Locate still works after
+ reopening; a recording or a project from before shows the project's own copy instead.
+- **The Projects tab shows your newest work first** (#582, specs/092): projects sorted by the
+ last save (or by name, remembered), each with its date, tempo, key, length and number of
+ tracks, read in the background and cached. The open project is marked.
- **Classic look** (#572, specs/091). **Settings → Appearance → Look** switches between the
new look and **Classic**. Classic brings back 0.59's colours, its tighter corners and
values in Geist Mono (tempo, position, dB, Hz, counters). It works with any colour theme
@@ -552,6 +578,8 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
MCP: `list_audio_inputs`, `set_track_input`, `get_track_input`.
### Fixed
+- **The Files icon in the browser rail is the same size as its neighbours** (#579): the
+ folder is drawn on the same grid as the other rail icons.
- **Monitoring a track through an audio track no longer crackles** (#563): an audio track whose
input is another track (an instrument, say) played it with clicks while monitoring, though a
recording of the same input was clean. It happened whenever the audio device asked for blocks
diff --git a/FEATURES.md b/FEATURES.md
index 241cc0e6..b9e8e71c 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -678,6 +678,12 @@ docks as a panel under any of the three, or floats in its own window — see
shortcut) writes that fade onto a join where the selected clips already touch, without
shortening a longer one, in one undo step. MIDI clips are left alone. The shape is saved
with the project.
+- **Locate** (right-click an audio clip, in the arrangement or a Session slot): **In
+ browser** opens the Files tab at the file the clip was made from (the tree when it is in a
+ sample folder, else the browse view); **In Finder** (In Explorer / In file manager) reveals
+ it, or the project's own copy when the source is unknown (a recording) or gone. While an
+ audio clip is selected, its file is marked in the Files list whenever its folder is open.
+ Projects keep each clip's source path, so this works after reopening.
- **Separate Stems** (right-click an audio clip): the **htdemucs** AI model (Demucs v4)
splits the clip into Drums, Bass, Other and Vocals — a group of four audio tracks under the
clip's track. Each stem clip copies the original's shape exactly (region, warp markers, trim,
@@ -1337,7 +1343,23 @@ audio effects after it keep running and keep their settings; saved with the proj
preview volume fader; ↑ ↓ step through files and Space plays the selected one. It stays
hidden until you use a list and tightens in a narrow browser. Space in the arrangement
always drives the project transport.
-- **Smart samples**: the Samples folder is analysed in the background — tempo, key, loop or
+- **Sample folders**: the Files tab shows every folder in the list (Settings → Library, or
+ **+ Add folder…** and folders dropped on the tab). One folder looks as it always did;
+ with several, each is a top-level node — **Rename** (the label only), **Set as default**,
+ Reveal, **Remove from browser** (files stay on disk). The default folder is where sample
+ packs install. A folder on an unplugged drive stays listed, dimmed, until it is back; a
+ folder already in the list, or inside or around one, is refused with a note.
+- **Browse view** (Files → **Tree | Browse**): one folder at a time anywhere on the
+ computer, starting at the default sample folder — **Back / Forward / Up** (⌘[ ⌘] ⌘↑) up
+ to the drives, **Home**, a path bar whose segments jump, **Copy path**, and ⌘L to type or
+ paste a path (a file path selects the file). Rows carry a kind icon (folder, drive, audio,
+ MIDI, other file); files show extension and size in their own columns, and files Nota
+ can't add are listed faded and inert. Audio and MIDI files preview, drag and open as in
+ the tree; a folder's menu adds it to the sample folders. Search filters the folder shown.
+- **Projects tab**: newest save first (or by name — a **Date | Name** switch, remembered),
+ each project with its save date, tempo, key, length and track count (read in the
+ background and cached); the open project carries a dot.
+- **Smart samples**: every sample folder is analysed in the background — tempo, key, loop or
one-shot, and a timbre fingerprint — once per file (results kept across launches, a newly
installed pack first; the status line shows the progress). Names win over the analysis
("Loop_124_Am", "Pad C#m 90bpm", a "One Shots" folder), and a loop's exact tempo comes from
@@ -1386,7 +1408,7 @@ audio effects after it keep running and keep their settings; saved with the proj
filter chips in the header); favourited devices sort to the top of their section. The
chips keep to one line — whatever does not fit collapses into a **+N** that opens the rest.
- **Context menus**: Projects — Open / Reveal in Finder / Delete (to the Trash, with
- confirmation); Files — Show similar sounds / Reveal in Finder; Presets — Reveal in Finder
+ confirmation); Files — Show similar sounds / Reveal in Finder / Copy path; Presets — Reveal in Finder
and Delete… (to the Trash) on a saved preset, Reveal in Finder on a folder row (opens the
presets folder).
On Windows and Linux the reveal item reads Show in Explorer / Show in file manager.
@@ -1580,7 +1602,9 @@ audio effects after it keep running and keep their settings; saved with the proj
- **Plug-ins**: scan paths, Rescan, **Open plug-in window on insert**.
- **Updates**: automatic update checks on/off, the last check and **Check now**.
- **Downloads**: Plug-ins, Sample Packs and AI Models (see [Plugin hosting](#plugin-hosting)).
-- **Library**: library folders. Without an explicit choice, the Projects and Samples folders
+- **Library**: **Sample folders** — the list the browser's Files tab shows (Add folder…,
+ drop folders, Set as default, Rename, Show, Remove) — and the Projects folder. Without an
+ explicit choice, the Projects and Samples folders
sit in the system's Documents and Music locations (Known Folders on Windows and macOS,
`user-dirs.dirs` on Linux), relocated or translated ones included.
- **Appearance**: **Look** — **New** or **Classic** (0.59's colours, corners and monospaced
diff --git a/specs/092-browser-files-projects/checklists/requirements.md b/specs/092-browser-files-projects/checklists/requirements.md
new file mode 100644
index 00000000..aa90282c
--- /dev/null
+++ b/specs/092-browser-files-projects/checklists/requirements.md
@@ -0,0 +1,40 @@
+# Specification Quality Checklist: Browser — your own sample folders, a file-system browse mode, Locate, and a richer Projects tab
+
+**Purpose**: Validate specification completeness and quality before proceeding to planning
+**Created**: 2026-11-12
+**Feature**: [spec.md](../spec.md)
+
+## Content Quality
+
+- [x] No implementation details (languages, frameworks, APIs)
+- [x] Focused on user value and business needs
+- [x] Written for non-technical stakeholders
+- [x] All mandatory sections completed
+
+## Requirement Completeness
+
+- [x] No [NEEDS CLARIFICATION] markers remain
+- [x] Requirements are testable and unambiguous
+- [x] Success criteria are measurable
+- [x] Success criteria are technology-agnostic (no implementation details)
+- [x] All acceptance scenarios are defined
+- [x] Edge cases are identified
+- [x] Scope is clearly bounded
+- [x] Dependencies and assumptions identified
+
+## Feature Readiness
+
+- [x] All functional requirements have clear acceptance criteria
+- [x] User scenarios cover primary flows
+- [x] Feature meets measurable outcomes defined in Success Criteria
+- [x] No implementation details leak into specification
+
+## Notes
+
+- The "Where things are today" block in Nota Context names current behaviour for
+ orientation only (the project's spec template asks for it); requirements stay
+ behaviour-level.
+- Clarified 2026-11-12 (see spec § Clarifications): browse mode is a Tree / Browse toggle;
+ nested folders are refused; Projects rows show date, tempo, length, tracks and key;
+ projects save each audio clip's original source path for Locate. Still defaults: no
+ automatic Desktop/Downloads/Music places; Locate covers audio clips only.
diff --git a/specs/092-browser-files-projects/contracts/persisted-formats.md b/specs/092-browser-files-projects/contracts/persisted-formats.md
new file mode 100644
index 00000000..ecb8309f
--- /dev/null
+++ b/specs/092-browser-files-projects/contracts/persisted-formats.md
@@ -0,0 +1,64 @@
+# Contract: persisted formats (spec 092)
+
+Two files change shape. Both changes are additive: an older Nota reads them and ignores
+(and, for `project.json`, preserves) the new fields.
+
+## settings JSON (`Nota.Application/Settings.cs`)
+
+```jsonc
+{
+ "SamplesFolder": "/Users/me/Music/Nota Samples", // kept: mirror of the default entry's Path
+ "SampleFolders": [ // new
+ { "Path": "", "Name": null, "IsDefault": true }, // "" = default location
+ { "Path": "/Volumes/Lib/Splice", "Name": "Splice", "IsDefault": false }
+ ],
+ "FilesBrowseMode": false, // new: Files tab shows Tree (false) / Browse (true)
+ "FilesBrowseFolder": "/Users/me/Downloads", // new: last browsed folder
+ "ProjectsSort": "Date" // new: "Date" | "Name"
+}
+```
+
+- Load: `SampleFolders` missing/empty → `[{ Path: SamplesFolder, IsDefault: true }]`.
+- Load: zero or several defaults → the first entry becomes the only default.
+- Load: an entry equal to / nested in / containing an earlier one is dropped (logged).
+- Save: `SamplesFolder = default.Path`.
+
+`ISettingsService`:
+
+| Member | Meaning |
+|---|---|
+| `string ResolvedSamplesFolder()` | **Unchanged meaning**: the default folder, created if missing. |
+| `IReadOnlyList<ResolvedSampleFolder> ResolvedSampleFolders()` | New: every entry → `(Index, Path, Label, IsDefault, Available)`; never creates folders other than the default. |
+| `SampleFolderResult AddSampleFolder(string path)` | New: `Added` · `AlreadyPresent(index)` · `Overlaps(index)` · `NotADirectory`. Saves on success. |
+| `bool RemoveSampleFolder(int index)` | New: false for the last remaining entry; removing the default promotes the next. |
+| `void RenameSampleFolder(int index, string? name)` / `void SetDefaultSampleFolder(int index)` | New; save. |
+| `event Action? SampleFoldersChanged` | New: raised after any change; Browser and Preferences rebuild from it. |
+
+## project.json (`Nota.Infrastructure/Persistence/ProjectModel.cs`)
+
+```jsonc
+// AudioClipDto (arrangement clip, session slot "Audio") and AudioTakeDto
+{
+ "Sample": "samples/3f2a….wav",
+ "Name": "Kick 01",
+ "Source": "/Users/me/Music/Nota Samples/Drums/Kick 01.wav" // new, optional
+}
+```
+
+- Written only when the engine knows a source for the clip's sample id.
+- No `FormatVersion` change; no migration step.
+
+## IAudioEngine additions (managed only — no C ABI change)
+
+| Member | Meaning |
+|---|---|
+| `string SampleSource(long sampleId)` | Full path the sample was loaded from, or `""`. |
+| `void SetSampleSource(long sampleId, string path)` | Restore on project load. |
+
+Recorded by `AddAudioClip`, `AddAudioClipEx`, `AddSessionAudioClip`, `AddSessionAudioFile`
+(and the existing Sampler/Rack/Rhythm loads, for free) unless the path is inside a
+`*.nota/samples/` folder.
+
+## Cache: `NOTA_DATA_DIR/cache/project-summaries.json`
+
+Disposable; a missing or corrupt file is rebuilt. Shape in [data-model.md](../data-model.md).
diff --git a/specs/092-browser-files-projects/contracts/ui.md b/specs/092-browser-files-projects/contracts/ui.md
new file mode 100644
index 00000000..33edfb64
--- /dev/null
+++ b/specs/092-browser-files-projects/contracts/ui.md
@@ -0,0 +1,86 @@
+# Contract: UI surfaces (spec 092)
+
+All strings via `Loc.T` with EN + RU entries; all colours/radii/fonts from tokens
+(nota-design); every surface checked in the four themes and the classic look.
+
+## Browser rail
+
+- Files tab icon: `GlyphKind.Folder` as a 24-grid path (x 3.5–20.5, y 5–19), same stroke as
+ neighbours. No other rail change.
+
+## Files tab — header
+
+```
+[ Search… 123 ]
+[ Tree | Browse ] [ + ] ← segmented toggle · Add folder… (Tree mode)
+```
+
+Browse mode adds, under the toggle:
+
+```
+[ ‹ ] [ › ] [ ↑ ] [ ⌂ ] Macintosh HD › Users › me › Music › Nota Samples [⧉]
+```
+
+- `‹` Back, `›` Forward, `↑` Up (disabled at Computer level); tooltips with shortcuts:
+ Back ⌘[, Forward ⌘], Up ⌘↑ (Ctrl elsewhere, where Alt+Left / Right / Up also work; Files
+ tab focused).
+- `⌂` Home: the default sample folder (disabled while there).
+- Rows: kind icon (folder / drive / audio / MIDI / other); files: extension and size columns
+ (size fixed width, right-aligned); a file Nota can't add in the disabled ink, inert.
+- Segments are buttons; long paths elide from the left (first segment kept).
+- Click empty bar area or ⌘L / Ctrl+L → editable text field (full path, selected); Enter
+ go, Esc cancel; error → field shakes/edge turns red token + status "Can't open <path>".
+- `⧉` Copy path (current folder) → status "Path copied".
+
+## Files tab — rows
+
+| Row | Tree | Browse | Context menu (additions) |
+|---|---|---|---|
+| Sample-folder root (only with 2+ folders; one folder keeps today's flat tree) | top-level, label = Name ?? folder; dimmed when missing | — | Rename · Remove from browser · Show in Finder/Explorer/file manager · Set as default |
+| Folder | as today | navigates on click/double-click/Enter | Copy path · Show in … · Add this folder to the browser (browse only) |
+| Audio / MIDI file | as today | same behaviour as tree (preview, drag, double-click) | Copy path · Show in … |
+| Located (selected clip's source) | orange left edge line (2 px) on top of normal styling | same | — |
+
+- Dropping a folder (from the OS) on the Files tab → AddSampleFolder; files dropped behave
+ as today.
+- Notes for refused adds: "Already in the browser" / "Inside <Label> — already in the
+ browser" / "Contains <Label> — remove it first".
+- Browse mode empty/unreadable states: "This folder has no audio or MIDI files" /
+ "Nota can't read this folder".
+- Computer level rows: volume icon + name; double-click enters.
+
+## Settings → Library — Sample folders
+
+```
+Sample folders
+ Nota Samples ~/Music/Nota Samples default
+ Splice /Volumes/Lib/Splice unavailable
+[ Add folder… ] [ Set as default ] [ Rename… ] [ Show ] [ Remove ]
+```
+
+- A well of selectable rows (like Plug-ins → scan folders) over a row of buttons acting on
+ the selected folder; folders can be dropped on the well. Remove of the default asks:
+ "<Next> becomes the default folder…". Remove is disabled for the only entry.
+- Sits above the Content folders section, which keeps the Projects folder picker.
+
+## Clip context menus (arrangement lane control + Session grid slot)
+
+Audio clips only, single-clip menu (not in multi-selection header):
+
+```
+Locate ▸ In browser
+ In Finder (macOS) · In Explorer (Windows) · In file manager (Linux)
+```
+
+- In browser disabled when no known source or source missing.
+- In Finder enabled when source exists **or** the project is saved (reveals the bundle copy).
+
+## Projects tab rows
+
+```
+My Song ● (open)
+11/12/2026 14:20 · 124 BPM · Am · 3:42 · 12 tracks
+```
+
+- Second line muted (TextTertiary); details absent until read; unreadable → date only.
+- Header right of search: sort toggle `Date | Name`.
diff --git a/specs/092-browser-files-projects/data-model.md b/specs/092-browser-files-projects/data-model.md
new file mode 100644
index 00000000..92667d03
--- /dev/null
+++ b/specs/092-browser-files-projects/data-model.md
@@ -0,0 +1,76 @@
+# Data Model: spec 092
+
+## SampleFolder (settings)
+
+Stored in `Settings.SampleFolders` (settings JSON, `Nota.Application/Settings.cs`).
+
+| Field | Type | Rules |
+|---|---|---|
+| `Path` | string | Absolute, normalised (no trailing separator). `""` only for the migrated "default location" entry, resolved to `~/Music/Nota Samples`. Unique (OS path comparer). |
+| `Name` | string? | Display label; null/empty → folder name. Never renames on disk. |
+| `IsDefault` | bool | Exactly one `true` in the list. Pack installs and Mosaic `samples:` refs use it. |
+
+Derived at runtime (not stored): `Resolved` (absolute path), `Available` (directory exists
+and is readable at the last refresh), `Label` (Name ?? folder name).
+
+**Invariants**
+
+- List has ≥ 1 entry; exactly one default (repaired on load: first entry).
+- No entry is equal to, inside, or containing another (checked on add; on load an
+ offending later entry is dropped with a log line).
+- `Settings.SamplesFolder` is rewritten on every save to the default entry's `Path`
+ (downgrade compatibility).
+
+**Transitions**: Add (validate → append → save → rebuild tree + re-watch index) · Remove
+(non-default, or default when another exists → confirm → next becomes default) · Rename
+(label only) · Set default · Availability refresh (tab shown, Settings opened, start).
+
+## Browse state (settings + session)
+
+| Field | Where | Rules |
+|---|---|---|
+| `FilesBrowseMode` | Settings (bool) | Tree = false (default). |
+| `FilesBrowseFolder` | Settings (string) | Last browsed folder; missing → default sample folder. `""` = Computer level is never persisted (falls back to default folder). |
+| Current location | memory | A folder path, or the **Computer** pseudo-location (volume list). |
+| Back / Forward stacks | memory | Navigating to a new location pushes current onto Back and clears Forward; Back/Forward move between stacks; capped at 100. |
+
+## Clip source (project)
+
+`AudioClipDto.Source : string?` and `AudioTakeDto.Source : string?` in `project.json`
+(arrangement clips, comp takes, session audio slots' `Audio`).
+
+| Rule | |
+|---|---|
+| Written | when `engine.SampleSource(sampleId)` is non-empty. |
+| Not written | recordings, consolidate/bounce/stems/reverse renders, files loaded from a bundle's `samples/`. |
+| Read | after the clip's sample is loaded from the bundle: `engine.SetSampleSource(id, Source)`. |
+| Format | optional, additive, no version bump; absent = unknown. |
+
+Runtime: `NotaEngine._sampleSources[sampleId] = fullPath` (beside `_sampleNames`).
+
+## Project entry (Projects tab)
+
+`BrowserItem` (Kind = Project) gains:
+
+| Field | Type | Source |
+|---|---|---|
+| `Modified` | DateTime? | `project.json` last-write time, else bundle dir time; null sorts last. |
+| `Summary` | ProjectSummary? | Background read / cache; null until read or when unreadable. |
+| `IsOpen` | bool | `Path` equals the open project's path. |
+
+`ProjectSummary`: `Bpm : double`, `Key : string?`, `TrackCount : int`,
+`LengthBeats : double` (shown as m:ss at `Bpm`).
+
+Cache file `NOTA_DATA_DIR/cache/project-summaries.json`:
+`{ "<bundle path>": { "stamp": "<manifest ticks>:<size>", "bpm": …, "key": …, "tracks": …, "lengthBeats": … } }`.
+Entries for vanished bundles are pruned on write.
+
+Settings: `ProjectsSort : "Date" | "Name"` (default `Date`).
+
+## BrowserItem additions (Files)
+
+| Field | Meaning |
+|---|---|
+| `PlaceIndex : int` | ≥ 0 on a top-level sample-folder node (index into `SampleFolders`), else −1. |
+| `Unavailable : bool` | The place's folder is missing/unreadable; row dimmed, children empty. |
+| `Located : bool` | The row is the selected clip's source file (highlight). |
diff --git a/specs/092-browser-files-projects/plan.md b/specs/092-browser-files-projects/plan.md
new file mode 100644
index 00000000..25ff666c
--- /dev/null
+++ b/specs/092-browser-files-projects/plan.md
@@ -0,0 +1,152 @@
+# Implementation Plan: Browser — your own sample folders, a file-system browse mode, Locate, and a richer Projects tab
+
+**Branch**: `feat/browser-files-projects` | **Date**: 2026-11-12 | **Spec**: [spec.md](spec.md)
+
+**Input**: Feature specification from `specs/092-browser-files-projects/spec.md`
+(issues #268, #346, #579, #580, #581, #582 — one pull request, milestone 0.60.1).
+
+## Summary
+
+The single Samples folder becomes a list of sample folders kept in settings (the old field
+stays as a mirror of the default, so pack installs, Nota Mosaic refs and older versions keep
+working); the sample index scans all of them; the Files tab shows each as a root with
+Rename / Remove / Reveal, accepts dropped folders, and gains a Tree / Browse toggle whose
+Browse view walks the whole file system with Back / Forward / Up, a clickable and editable
+path bar and Copy path. Audio clips remember the file they came from (a managed-side map
+plus an optional `Source` field in `project.json`), which drives a highlight of the selected
+clip's file in the browser and a Locate → In browser / In Finder submenu. The Projects tab
+sorts newest first and shows date, tempo, key, length and track count read in the
+background from each project's manifest and cached. The rail's folder icon is redrawn on
+the common 24-unit grid. Details: [research.md](research.md).
+
+## Nota: Read Before Planning
+
+- **UI work** → [`DESIGN.md`](../../DESIGN.md) and the `nota-design` skill (tokens, row
+ states, the orange line/tint/solid strengths, sentence-case labels).
+- **Anything** → [`CONTRIBUTING.md`](../../CONTRIBUTING.md).
+- New keyboard shortcuts (browse Back/Forward/Up, path field) → `nota-shortcuts` skill.
+- User-visible → CHANGELOG `[Unreleased]`, `nota-features`, `nota-docs` (EN + RU).
+
+## Technical Context
+
+**Language/Version**: C# / .NET 10 (managed app only). No C++ change.
+
+**Primary Dependencies**: Avalonia (existing). No new dependency.
+
+**Storage**: settings JSON (`NOTA_DATA_DIR`), `project.json` in `.nota` bundles (one
+optional field), a disposable cache `NOTA_DATA_DIR/cache/project-summaries.json`.
+
+**Audio-Thread Impact**: None. All work is UI-thread or background-thread managed code;
+the new sample-source map lives beside the existing sample-name map in the managed engine
+wrapper and is never touched by the audio thread.
+
+**Testing**: `tests/Nota.SmokeTest` (the only harness; run by `scripts/build.sh`) plus the
+headless-app screenshot harness for UI.
+
+**Target Platform**: macOS (Apple Silicon/Intel), Windows x64/ARM, Linux x86_64/ARM —
+volume listing and the "Show in …" label differ per OS.
+
+**Project Type**: desktop app.
+
+**Performance Goals**: no UI stall when adding or browsing large/slow folders (enumeration
+off the UI thread; first level ≤ 1 s, SC-005); Projects tab names + dates ≤ 1 s, details
+≤ 10 s for 200 projects first time, instant from cache (SC-008).
+
+**Constraints**: downgrade-safe settings and project files; Mosaic `samples:` refs keep
+resolving against the default folder; the per-folder file cap (`MaxSamples`) and the index
+cap apply per root (#358 lesson: never walk a huge tree synchronously).
+
+**Scale/Scope**: 5 user stories, 31 FRs; touches Settings, SettingsService,
+SampleLibraryIndex, BrowserViewModel, BrowserView, PreferencesWindow (Library), Glyph,
+NotaEngine (managed), ProjectService/ProjectModel, ArrangementView lane menu, SessionView
+grid menu, MainWindow wiring, Welcome date helper, localisation files.
+
+## Constitution Check
+
+*GATE: Must pass before Phase 0 research. Re-checked after Phase 1 design: still passes.*
+
+| Principle | Status |
+|---|---|
+| 0. Approved issue first | ✅ #268, #346, #579–#582 carry `approved`, milestone 0.60.1. |
+| I. Real-time audio safety | ✅ No audio-thread code touched. |
+| II. Boundary discipline | ✅ No C ABI change; `SampleSource` is managed-only (like `SampleName`). |
+| III. Licensing hygiene | ✅ No dependency; new files get the two-line SPDX header. |
+| IV. Verification gate | ✅ Smoke test extended (settings migration, multi-root index, clip source round-trip, project summary, browse state). |
+| V. One logical change per PR | ⚠️ Six issues in one PR — explicitly requested by the maintainer; they share one surface (browser Files/Projects) and one stored folder list. Tracked below. |
+| VI. Documentation in sync | ✅ Planned: CHANGELOG, FEATURES.md, nota-docs (EN+RU), nota-shortcuts. |
+| VII. Spec-first | ✅ This spec/plan/tasks. |
+| VIII. Rules not weakened | ✅ |
+
+## Project Structure
+
+### Documentation (this feature)
+
+```text
+specs/092-browser-files-projects/
+├── spec.md
+├── plan.md # this file
+├── research.md # R1–R9 decisions
+├── data-model.md
+├── quickstart.md
+├── contracts/
+│ ├── persisted-formats.md # settings JSON, project.json Source, IAudioEngine additions
+│ └── ui.md # rail, Files tab, Settings → Library, clip menus, Projects rows
+├── checklists/requirements.md
+└── tasks.md # /speckit-tasks
+```
+
+### Source Code (repository root)
+
+```text
+src/managed/
+├── Nota.Application/
+│ ├── Settings.cs # SampleFolders, FilesBrowse*, ProjectsSort; ISettingsService additions
+│ ├── Ports/ISampleIndex.cs # Watch(IReadOnlyList<string> roots)
+│ ├── Engine/IAudioEngine.cs # SampleSource / SetSampleSource
+│ └── Browser/ (new) # SampleFolderRules (overlap/dup checks), FileBrowseState, PathInput, ProjectSummary
+├── Nota.Infrastructure/
+│ ├── Settings/SettingsService.cs # migration, mirror, add/remove/rename/default, availability
+│ ├── SampleStore/SampleLibraryIndex.cs # multi-root scan, per-root hints and sweep
+│ ├── SampleStore/SampleStore.cs # installs into the default folder (unchanged call)
+│ ├── Interop/NotaEngine.Tracks.cs / .Session.cs # record sources on audio-clip loads
+│ ├── Persistence/ProjectModel.cs # AudioClipDto.Source, AudioTakeDto.Source
+│ ├── Persistence/ProjectService.cs # write/restore Source
+│ └── Persistence/ProjectSummaryReader.cs (new) + cache
+├── Nota.Presentation/ViewModels/BrowserViewModel.cs # multi-root tree (background), browse list, project rows/sort, located path
+└── Nota.App/
+ ├── Controls/Glyph.cs # Folder → 24-grid path
+ ├── BrowserView.cs (+ new BrowserView.Browse.cs, BrowserView.Places.cs) # toggle, nav bar, path field, root menus, folder drop, located marker
+ ├── PreferencesWindow.cs / PreferencesWindow.Samples.cs # Sample folders list
+ ├── ArrangementView.LaneControl.cs # Locate submenu
+ ├── SessionView.Grid.cs # Locate submenu
+ ├── MainWindow.Browser.cs / .Detail.cs / .Welcome.cs # selection → located path, Locate handlers, shared date helper, open-project marker
+ (strings) Nota.Application/Localization/en.json; RU in ../nota-translations/languages/ru.json (validated after the app PR reaches develop)
+
+tests/Nota.SmokeTest/
+├── SampleFoldersTests.cs (new) # migration, mirror, overlap/dup, remove/default rules, multi-root tree, index hint root
+├── ClipSourceTests.cs (new) # Source round-trip, split shares, bundle-path exclusion, record has none
+├── ProjectSummaryTests.cs (new) # tempo/key/tracks/length, warped/unwarped audio, unreadable, cache stamp
+└── FileBrowseTests.cs (new) # back/forward/up, computer level, path parsing (~, file path, invalid)
+```
+
+**Structure Decision**: Managed-only change following the existing layering — pure rules
+and state in `Nota.Application` (testable from the smoke test without UI), file-system and
+persistence in `Nota.Infrastructure`, list building in `Nota.Presentation`, Avalonia views in
+`Nota.App`. `BrowserView.cs` is already ~1700 lines, so Browse-mode and Places UI go into
+partial-class files.
+
+## Delivery order (one PR, independently testable steps)
+
+1. Rail icon (#579) — isolated.
+2. Settings model + migration + rules (#346 core) → index multi-root → Files tab roots +
+ menus + folder drop (#268) → Settings → Library list (#346 UI).
+3. Projects tab (#582) — independent of 2.
+4. Clip source capture + persistence → highlight + Locate (#581).
+5. Browse mode (#580) — then Locate's "outside every folder" path switches to it.
+6. Docs: CHANGELOG, FEATURES.md, nota-docs EN+RU, shortcuts pane; screenshots.
+
+## Complexity Tracking
+
+| Violation | Why Needed | Simpler Alternative Rejected Because |
+|-----------|------------|-------------------------------------|
+| Six issues in one PR (principle V) | Maintainer asked for a single PR; #268/#346 share one stored list, #580/#581 depend on it, all touch the same browser files | Six PRs would conflict on `BrowserView.cs` / `BrowserViewModel.cs` and ship the folder list half-done (#268 without #346 or vice versa) |
diff --git a/specs/092-browser-files-projects/quickstart.md b/specs/092-browser-files-projects/quickstart.md
new file mode 100644
index 00000000..c1b4760c
--- /dev/null
+++ b/specs/092-browser-files-projects/quickstart.md
@@ -0,0 +1,49 @@
+# Quickstart: validating spec 092
+
+## Prerequisites
+
+- Release engine build in `build/` (see BUILD.md; never a Debug engine there).
+- A scratch data dir so real settings aren't touched: `export NOTA_DATA_DIR=/tmp/nota092`.
+- Two sample folders, one nested folder and one "external" folder, e.g.
+ `/tmp/s092/A/Drums/kick.wav`, `/tmp/s092/B/loop.wav`, `/tmp/s092/A/Drums` (nested),
+ `/tmp/s092/Other/far.wav` (never added).
+
+## Gate
+
+```bash
+scripts/build.sh
+```
+
+Builds native + managed and runs the smoke test; the new smoke checks (research R9) must
+pass.
+
+## Manual / harness checks
+
+1. **Migration** — start with an old settings file holding only `SamplesFolder=/tmp/s092/A`.
+ Settings → Library lists A as default; the Files tab looks as before; the saved settings
+ still contain `SamplesFolder` = A.
+2. **Add folders** — add B via Settings, drag `/tmp/s092/Other` onto the Files tab; both
+ show as roots; search "loop" finds B's file; tags appear after the scan. Add
+ `/tmp/s092/A/Drums` → refused ("Inside A"). Rename B → label changes, disk unchanged.
+3. **Unavailable** — rename `/tmp/s092/B` on disk, reopen the tab → B dimmed "Unavailable";
+ restore → back.
+4. **Default** — set B as default, install a pack from Downloads → lands in `B/Downloaded`.
+5. **Rail icon** — headless screenshot of the rail in Studio Dark/Light, Ember Graphite/Paper,
+ classic look; the folder sits in the same padding as Doc/Bookmark.
+6. **Browse mode** — toggle Browse: opens at default folder; Up to `/`, then Computer;
+ Back/Forward; click a segment; paste `/tmp/s092/Other/far.wav` + Enter → folder opened,
+ file selected; Copy path; drag `far.wav` into the arrangement; restart → Browse mode and
+ last folder restored.
+7. **Locate** — drag `A/Drums/kick.wav` into the arrangement; collapse `Drums` and select
+ the clip → no highlight; expand → row highlighted; right-click → Locate → In browser
+ (tree reveals + selects, no audition); Locate → In Finder reveals it. Save, close,
+ reopen → Locate still works. Record a clip → In browser disabled, In Finder reveals
+ `samples/<hash>.wav`. Repeat in Session.
+8. **Projects** — save three projects a minute apart with different tempos/keys; the tab
+ lists newest first with `MM/dd/yyyy HH:mm · BPM · key · m:ss · N tracks`; the open one
+ is marked; switch to Name and restart → kept; corrupt one `project.json` → that row
+ shows name + date only.
+9. **RU** — switch language to Russian; every new label is translated.
+
+UI evidence for the PR: before/after shots of the rail, Files tab (tree with two roots,
+browse mode), Settings → Library, a Locate highlight, Projects tab.
diff --git a/specs/092-browser-files-projects/research.md b/specs/092-browser-files-projects/research.md
new file mode 100644
index 00000000..2710a205
--- /dev/null
+++ b/specs/092-browser-files-projects/research.md
@@ -0,0 +1,152 @@
+# Research: Browser — sample folders, browse mode, Locate, Projects tab (spec 092)
+
+Every decision below was taken from reading the current code on `develop` (c613167d).
+
+## R1. Where the list of sample folders lives, and what "the Samples folder" means afterwards
+
+- **Decision**: Add `Settings.SampleFolders` (a list of `{ Path, Name?, IsDefault }`) and keep
+ `Settings.SamplesFolder` as a **mirror of the default entry's path** (written on every save).
+ `ISettingsService.ResolvedSamplesFolder()` keeps its meaning — *the default folder* — and a
+ new `ResolvedSampleFolders()` returns every entry with availability.
+- **Rationale**: Six call sites use `ResolvedSamplesFolder()` for a single folder and all of
+ them mean "the default": pack installs (`SampleStore`), Nota Mosaic's `samples:` path root
+ and refs (`MosaicLibrary.ToRef/Resolve`, `NotaEngine.SetPathRoot`), the import dialog's
+ start folder, Preferences. Keeping it means Mosaic presets saved as `samples:/…` keep
+ resolving, and an older Nota reading the same settings file still finds its folder
+ (downgrade-safe).
+- **Migration**: On load, if `SampleFolders` is null/empty → one entry
+ `{ Path = SamplesFolder (or "" = default location), IsDefault = true }`. Exactly one
+ default is enforced on load (first entry wins if none/several).
+- **Alternatives**: Replace `SamplesFolder` outright (breaks downgrade and needs every call
+ site touched); keep the default outside the list (two concepts for one thing in the UI).
+
+## R2. Indexing several folders
+
+- **Decision**: `ISampleIndex.Watch(string root)` becomes `Watch(IReadOnlyList<string> roots)`;
+ one scan thread walks the roots in list order (priority folders first, as today), and
+ name hints (`SampleNameHints.Parse(path, root)`) use the root that contains the path.
+ The stale-entry sweep (`IsUnder(p, root)`) runs per root; files under an *unavailable*
+ root are kept (not swept), so an unplugged drive doesn't lose its analyses.
+- **Rationale**: `SampleLibraryIndex` already scans in the background with a cap and a
+ progress counter; the only single-root assumptions are `_root`, the hint parse and the
+ sweep. Nested roots are refused (FR-008), so no file belongs to two roots.
+- **Alternatives**: One index instance per folder (duplicates the similar-search space and
+ the progress line).
+
+## R3. Files tab tree with several roots
+
+- **Decision**: `BrowserViewModel.RebuildSamples()` builds one top-level `Folder` node per
+ entry (default first, then list order) and places files under it with
+ `GetOrCreateFolder(root, …)` per root. The default root's `Downloaded` pack folder keeps
+ its icon and first place *inside* that root. A root node carries a new
+ `BrowserItem.RootIndex` (or a `IsPlace` flag) so the view can give it the Rename / Remove /
+ Reveal menu, and an `Unavailable` flag that dims it. The per-folder `MaxSamples` cap
+ applies per root.
+- **Enumeration off the UI thread**: today `RebuildSamples` enumerates synchronously. With
+ several (possibly slow, external) roots it moves to a background task that builds the tree
+ and swaps it in on the UI thread; first level of each root appears first (SC-005).
+- **Rationale**: Reuses the existing flattened-tree machinery (`_sampleTree`,
+ `RebuildSampleVisible`, filter chips, "similar").
+
+## R4. Browse mode
+
+- **Decision**: A second presenter in the Files tab, toggled by a two-state control next to
+ the search field: **Tree** (today) / **Browse**. Browse is a flat `BrowserItem` list of one
+ folder (folders first, then audio/MIDI files; hidden entries skipped) bound to the same
+ list control, so preview, double-click, drag-and-drop and the sample player work
+ unchanged. A `FileBrowseState` in `Nota.Presentation` holds the current folder and
+ back/forward stacks; enumeration runs off the UI thread.
+- **Above the root**: "Computer" level = drives/volumes:
+ - Windows: `DriveInfo.GetDrives()` that are ready.
+ - macOS: `/` (labelled with the system volume name) + each directory in `/Volumes` except
+ the one that is a symlink to `/`.
+ - Linux: `/`, `$HOME`, and mount points under `/media/$USER`, `/run/media/$USER`, `/mnt`.
+- **Path bar**: segments as buttons; clicking the bar's empty area (or ⌘L / Ctrl+L while the
+ Files tab has focus) turns it into a text field; Enter navigates, Esc cancels; a file path
+ opens its folder with the file selected; `~` expands to home.
+- **Persistence**: `Settings.FilesBrowseMode` (bool) and `Settings.FilesBrowseFolder`
+ (string).
+- **Alternatives**: a "Computer" root inside the tree (rejected in clarification); the OS
+ file dialog (not a browser — no preview/drag).
+
+## R5. Remembering a clip's original file (Locate after reopen)
+
+- **Finding**: The engine keeps only audio; the managed `NotaEngine` remembers a sample's
+ *file name* per sample id (`_sampleNames`, `RememberSampleName`) for Sampler/Rack/Rhythm
+ loads only — **audio clip loads (`AddAudioClip`, `AddAudioClipEx`, `AddSessionAudioClip`,
+ `AddSessionAudioFile`) remember nothing**. On save, `RegisterSample` content-hashes the
+ buffer into `samples/<hash>.wav`; `AudioClipDto` has `Sample` (bundle path) and `Name`
+ only.
+- **Decision**:
+ - `NotaEngine` gains `_sampleSources: Dictionary<long sampleId, string fullPath>` with
+ `SampleSource(id)` / `SetSampleSource(id, path)` on `IAudioEngine`, recorded by every
+ audio-clip and session-audio load **when the path is not inside a `.nota` bundle's
+ `samples/` folder** (those are project copies, not sources).
+ - `AudioClipDto.Source` (`string?`, absolute path) is written by `ProjectService` from
+ `engine.SampleSource(ac.SampleId)` for arrangement clips, comp takes and session audio
+ slots; on load, after the clip is restored, `SetSampleSource(newSampleId, dto.Source)`.
+ - Split / duplicate / copy share the sample id, so the source follows for free;
+ consolidate, record, bounce, stems and reverse-render make new buffers with no source
+ (correct per spec).
+- **Format**: optional, additive; no `CurrentFormatVersion` bump and no migration step
+ (absent = unknown). Older Nota versions keep it via `[JsonExtensionData] Extra` on
+ round-trip.
+- **Sessions-named saves** (`doc.SessionNames`, autosave/recovery) write the same field.
+- **Alternatives**: search by file name (clarification rejected); session-only memory.
+
+## R6. Highlight of the selected clip's file
+
+- **Decision**: `MainWindow` already hears `Timeline.ClipSelectionChanged`; Session's slot
+ selection gets the equivalent hook. On change it resolves the selected audio clip's
+ source (`engine.SampleSource(sampleId)`) and calls `Browser.SetLocatedPath(path | null)`.
+ The browser marks the matching row if it is in the visible (flattened) list — tree or
+ browse — with a left accent bar + soft tint distinct from selection (nota-design: "orange
+ soft tint for picked" is the selection; the located marker uses the orange *line*
+ treatment). No expand/scroll/tab switch (FR-019).
+- **Locate → In browser**: `BrowserView.RevealFile(path)`: if under a root → switch to Tree,
+ expand ancestors, scroll into view, select (no audition); else → Browse at its folder
+ with it selected. Expands a collapsed browser first.
+- **Locate → In Finder**: `MainWindow.RevealInFileManager(path)` (exists); for a clip with
+ no known/existing source, reveal the bundle copy: the saved project's
+ `samples/<hash>.wav` when the project is saved, otherwise the item is disabled.
+
+## R7. Projects tab summary
+
+- **Decision**: `ProjectSummaryReader` (Infrastructure) reads `project.json` with
+ `System.Text.Json` `JsonDocument` (no full `ProjectDocument` bind, no engine): tempo =
+ `Transport.Bpm`; key = `Transport.Key`; tracks = `Tracks.Length` (excluding returns/master
+ — they live in `Mixer`/`Master`); length = max clip end in beats over MIDI clips
+ (`StartBeat + LengthBeats`), audio clips (warped: `StartBeat + (WarpPlayEnd > 0 ?
+ WarpPlayEnd - WarpPlayStart : WarpBeats)`; unwarped: `LengthFrames` or the WAV header's
+ frame count of `Sample`, ÷ the WAV's sample rate × bpm/60), and session slots don't
+ count; shown as `m:ss` at the project tempo.
+- **Cache**: `NOTA_DATA_DIR/cache/project-summaries.json`, keyed by bundle path + the
+ manifest's last-write time + size; read on a background task; rows update in place.
+- **Date**: the **manifest's** (`project.json`) last-write time, falling back to the bundle
+ directory's. Welcome uses the directory's time, but that changes only when entries are
+ added/removed, while every save rewrites `project.json`. Welcome switches to the same
+ helper so both show the same date.
+ Format reuses Welcome's `"MM/dd/yyyy HH:mm"` through one shared helper.
+- **Sort**: `Settings.ProjectsSort` = `Date` (default) | `Name`.
+- **Open marker**: `BrowserViewModel.OpenProjectPath` set by MainWindow on open/save/new.
+
+## R8. Rail icon size
+
+- **Finding**: `GlyphKind.Folder` is drawn procedurally at ±0.42 of the box; the other rail
+ icons are 24-unit SVG paths in `Glyph`'s path table with ~3–6 units of padding (e.g. Doc
+ spans x 6–18.4, y 3.5–20.5).
+- **Decision**: Move `Folder` to the path table as a 24-grid outline spanning x 3.5–20.5,
+ y 5–19 (tab at top-left), same stroke as its neighbours. Check the other users of the
+ glyph (group-tracks menu items, Rhythm card at 8 px, Reveal items).
+
+## R9. Tests
+
+- Smoke test project (`tests/Nota.SmokeTest`) is the only test harness; it already has
+ `SampleStoreTests`, `SmartSampleTests`, `BrowserCategoryTests`, `BrowserTestSupport`.
+- New smoke checks: settings migration (single folder → list; mirror kept), nested/duplicate
+ refusal, multi-root tree build, index hint root, `AudioClipDto.Source` save/load
+ round-trip (incl. split + bundle-path exclusion), project summary reader (tempo, key,
+ tracks, length incl. warped/unwarped audio, unreadable manifest), browse-state
+ back/forward/up semantics, path parsing.
+- UI checked with the headless-app screenshot harness (rail icon, Files tab both modes,
+ Settings → Library list, Projects rows, Locate highlight), all themes + classic look.
diff --git a/specs/092-browser-files-projects/spec.md b/specs/092-browser-files-projects/spec.md
new file mode 100644
index 00000000..59bbed57
--- /dev/null
+++ b/specs/092-browser-files-projects/spec.md
@@ -0,0 +1,461 @@
+# Feature Specification: Browser — your own sample folders, a file-system browse mode, Locate, and a richer Projects tab
+
+**Feature Branch**: `feat/browser-files-projects`
+
+**Created**: 2026-11-12
+
+**Status**: Draft
+
+**Input**: One feature covering six approved issues in nota-daw/nota, milestone 0.60.1,
+shipped in one pull request:
+[#268](https://github.com/nota-daw/nota/issues/268) (Files tab: add your own folders),
+[#346](https://github.com/nota-daw/nota/issues/346) (Settings → Library: a list of sample folders),
+[#579](https://github.com/nota-daw/nota/issues/579) (the Files rail icon is drawn larger than the others),
+[#580](https://github.com/nota-daw/nota/issues/580) (Files tab: a full file-system browse mode),
+[#581](https://github.com/nota-daw/nota/issues/581) (locate a selected clip's file in the browser / in Finder),
+[#582](https://github.com/nota-daw/nota/issues/582) (Projects tab: newest first, with dates).
+
+## Nota Context *(fill in — drives plan and tasks)*
+
+**Feature area** *(pick the main one)*:
+
+- [ ] Engine (C++, `src/native/nota.engine`) — real-time audio rules apply, see `ARCHITECTURE.md` AR table
+- [x] Managed app (C#, `src/managed/*`) — domain, application, infrastructure, presentation
+- [x] UI (Avalonia, `src/managed/Nota.Presentation`) — follow `DESIGN.md` (Studio)
+- [ ] Plugin hosting (`pluginhost/`) — the only place JUCE is allowed
+- [ ] Build / packaging / CI (`scripts/`, `.github/`) — see `BUILD.md`
+- [ ] Docs only
+
+**Nota docs to keep in mind** *(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).
+
+**Where things are today** (for orientation, not a design):
+
+- One Samples folder setting (Settings → Library; empty = `~/Music/Nota Samples`). The
+ Files tab shows its tree; sample packs from Downloads install into its `Downloaded`
+ subfolder, which is listed first with its own icon. The sample index (tempo, key,
+ similar sounds) watches that one folder.
+- The Projects tab lists the `.nota` bundles of the projects folder, sorted by name, each
+ row reading just "project".
+- The Welcome window's recent-projects list shows each project's last-modified date and
+ time.
+- The rail's Files icon is a hand-drawn folder that fills more of its box than the other
+ rail icons, which are drawn on a common 24-unit grid with padding.
+
+## Clarifications
+
+### Session 2026-11-12
+
+- Q: How does the file-system browse mode (#580) sit in the Files tab? → A: A Tree / Browse toggle inside the Files tab; the tree of added folders stays as it is, browse is a separate flat view of one folder with the path bar and Back / Forward / Up.
+- Q: What happens when a folder being added is inside, or contains, a folder already in the list? → A: Refuse it, with a note naming the overlapping folder.
+- Q: What does a Projects tab row show besides the name (#582)? → A: Last-modified date and time, tempo, length, number of tracks, and the project key when one is set; read from each project in the background and cached.
+- Q: Saved projects keep only the bundle copy of a clip's audio, not where it came from — how does Locate (#581) find the file? → A: Projects save each audio clip's original source path (optional, additive field). Locate uses it; without one (older projects, recordings, a deleted source) **In browser** is disabled and **In Finder** reveals the bundle copy.
+
+### Session 2026-11-12 (review of the browse view)
+
+- Q: How do I get back to where browsing started? → A: A **Home** button next to Back / Forward / Up opens the default sample folder.
+- Q: How are folders and files told apart in the browse view? → A: Each row has an icon — folder, drive, audio file, MIDI file, other file.
+- Q: What does a file row show, and which files are listed? → A: Every file of the folder is listed (hidden ones excepted); each shows its extension and size in their own columns; files Nota can't add (anything but audio and MIDI it can load) are drawn half-transparent and can't be dragged, opened or previewed.
+- Q: Can audio be auditioned in the browse view? → A: Yes — selecting an audio file there drives the sample player exactly as in the tree.
+
+## User Scenarios & Testing *(mandatory)*
+
+### User Story 1 - Keep samples in several folders and see them all in the browser (Priority: P1) — #346, #268
+
+My samples live in several places — my own recordings, a commercial library on an
+external drive, packs from another DAW. I add each folder once, either in Settings →
+Library or straight from the Files tab (button or by dragging a folder in from
+Finder/Explorer), and every one of them appears in the Files tab as its own top-level
+folder, searchable and with tempo/key tags like the Samples folder has today.
+
+**Why this priority**: It's the most requested gap (a reviewer looked for a file browser
+and dragged a sample in from Finder instead), and the browse mode and Locate stories build
+on the list of folders.
+
+**Independent Test**: Add two folders (one via Settings, one by dragging onto the Files
+tab), confirm both show as top-level nodes with their files, are searched, get tags, and
+survive a restart; remove one and confirm the files on disk are untouched.
+
+**Acceptance Scenarios**:
+
+1. **Given** an existing install with a custom Samples folder, **When** the new version
+ starts, **Then** Settings → Library shows a list with that folder as its first entry,
+ marked as the default, and the Files tab looks as before.
+2. **Given** Settings → Library, **When** I click **Add folder…** and pick a folder,
+ **Then** it is appended to the list and appears as a new top-level node in the Files
+ tab, labelled with the folder's name.
+3. **Given** the Files tab, **When** I click its **Add folder…** control or drag a folder
+ from Finder/Explorer onto the tab, **Then** the folder is added to the same list and is
+ visible in Settings → Library as well.
+4. **Given** a top-level folder node, **When** I right-click it, **Then** I get **Rename**
+ (changes only the label Nota shows), **Remove from browser** (forgets the folder; files
+ on disk are never touched), and **Show in Finder / Explorer / file manager**.
+5. **Given** several folders, **When** I type in the Files search box or use the sample
+ filter chips (loops, one-shots, BPM, key, "similar"), **Then** results come from all
+ folders.
+6. **Given** a folder on an external drive that is unplugged, **When** I open the browser
+ or Settings, **Then** the folder stays in the list, shown as unavailable (dimmed, with a
+ note), and its contents come back when the drive is reconnected — at the latest on the
+ next refresh or restart.
+7. **Given** a non-default folder, **When** I mark it **Default** in Settings → Library,
+ **Then** sample packs downloaded afterwards install into it (into its `Downloaded`
+ subfolder), and the default folder is the one listed first in the Files tab.
+
+---
+
+### User Story 2 - The Files rail icon is the same size as its neighbours (Priority: P1) — #579
+
+The rail of browser tabs reads as one row of equal icons; the Files icon no longer looks
+bigger than Instruments, FX, MIDI, Presets, Projects, Map, History and Track.
+
+**Why this priority**: A small visual defect, fixed in minutes, visible to everyone.
+
+**Independent Test**: Screenshot the rail in each colour theme and the classic look;
+the folder's drawn extent matches the other icons' (same padding, same stroke weight).
+
+**Acceptance Scenarios**:
+
+1. **Given** the browser rail, **When** I compare the Files icon with the Projects icon,
+ **Then** their drawn heights and widths differ by no more than the shapes themselves
+ require (a folder is wider than tall), and both sit inside the same padding.
+2. **Given** the other places that draw the folder icon (group-tracks menu items, the
+ Rhythm card, "Show in Finder" menu items), **When** I open them, **Then** the icon still
+ reads clearly at their sizes.
+
+---
+
+### User Story 3 - Browse anywhere on the computer from the Files tab (Priority: P2) — #580
+
+Sometimes the sample I need is outside every folder I've added — a bounce folder, Downloads,
+another drive. I switch the Files tab into a **browse** view that works like a small file
+manager: it opens at the default Samples folder, I can go up past it to the drive roots,
+step back and forward, see where I am in a path bar, click a path segment to jump there,
+copy the path, or paste a path and go straight to it.
+
+**Why this priority**: Saves a trip to Finder/Explorer, but the folder list (P1) already
+covers the common case.
+
+**Independent Test**: Enter browse mode, go up to the volume root, into another drive,
+back and forward, paste a path, copy a path; preview a file and drag it into the
+arrangement.
+
+**Acceptance Scenarios**:
+
+1. **Given** the Files tab, **When** I switch to browse mode, **Then** it shows the
+ contents of the default Samples folder (or of the folder last selected in the tree, if
+ one is), with a path bar on top and **Back**, **Forward**, **Up** and **Home** buttons.
+2. **Given** browse mode at any folder, **When** I press **Up** repeatedly, **Then** I
+ reach the drive/volume root and, above that, a list of drives/volumes (Windows drive
+ letters; macOS `/Volumes` entries and the system disk; Linux `/` and mounted media).
+3. **Given** I have navigated through several folders, **When** I press **Back** and
+ **Forward**, **Then** I move through the visited folders like in a web browser; opening
+ a new folder after going back clears the forward history.
+4. **Given** the path bar, **When** I click a segment, **Then** browse mode jumps to that
+ folder.
+5. **Given** the path bar, **When** I choose **Copy path**, **Then** the current folder's
+ full path is on the clipboard; a selected file's context menu also has **Copy path**.
+6. **Given** the path bar, **When** I click into it, paste or type a path and press Enter,
+ **Then** browse mode opens that folder (or the folder containing it, with the file
+ selected, if it is a file); an invalid or unreadable path leaves me where I was and
+ says so.
+7. **Given** browse mode, **When** I preview, double-click or drag an audio or MIDI file,
+ **Then** it behaves exactly as in the tree view (audition, drop into the arrangement /
+ Session / device).
+8. **Given** browse mode at a folder that isn't in the list yet, **When** I choose **Add
+ this folder to the browser**, **Then** it is added to the list from Story 1.
+9. **Given** browse mode, **When** I switch back to the tree view, **Then** the tree is as
+ I left it, and switching to browse mode again returns to the last browsed folder.
+10. **Given** browse mode anywhere, **When** I press **Home**, **Then** it opens the default
+ sample folder (a step Back returns where I was).
+11. **Given** a folder holding subfolders, audio, MIDI and other files, **When** browse mode
+ shows it, **Then** every row has an icon for its kind (folder, drive, audio, MIDI, other
+ file), each file shows its extension and size in separate columns, and files Nota can't
+ add are half-transparent and can't be dragged, opened or previewed.
+12. **Given** browse mode, **When** I select an audio file (click or arrow keys), **Then** the
+ sample player auditions it as in the tree view (Auto, Space, Loop, waveform).
+
+---
+
+### User Story 4 - Find a selected clip's file (Priority: P2) — #581
+
+I select an audio clip in the arrangement or in Session and want to see where its file
+lives — to find a similar sample next to it or reuse it. If its folder is open in the Files
+tab, the file's row is highlighted; from the clip's context menu I can **Locate → In
+browser** to open the Files tab right at the file, or **Locate → In Finder** (Explorer,
+file manager) to reveal it on disk.
+
+**Why this priority**: Valuable navigation, but depends on the folder list for "in
+browser" to find most files.
+
+**Independent Test**: Drag a sample from a nested folder into the arrangement, collapse
+the tree, select the clip → no highlight; expand the folder → the row is highlighted;
+Locate → In browser expands, scrolls to and selects it; Locate → In Finder reveals it.
+
+**Acceptance Scenarios**:
+
+1. **Given** an audio clip whose file is inside one of the browser's folders, and the
+ Files tab shows the folder containing it expanded, **When** I select the clip in the
+ arrangement or Session, **Then** the file's row is highlighted (a marker distinct from
+ the normal selection), and the highlight moves or clears as the clip selection changes.
+2. **Given** the same clip but the containing folder collapsed (or another tab showing),
+ **When** I select the clip, **Then** nothing in the browser changes — no automatic
+ expanding, scrolling or tab switch.
+3. **Given** browse mode showing the folder that contains the clip's file, **When** I
+ select the clip, **Then** its row is highlighted there too.
+4. **Given** an audio clip, **When** I right-click it and choose **Locate → In browser**,
+ **Then** the browser opens the Files tab, expands the folders down to the file, scrolls
+ it into view and selects it (without auditioning it).
+5. **Given** an audio clip whose file is outside every browser folder, **When** I choose
+ **Locate → In browser**, **Then** browse mode opens at the file's folder with the file
+ selected.
+6. **Given** a project saved and reopened, **When** I right-click an audio clip that was
+ dragged in from a sample folder before saving, **Then** Locate still leads to that
+ original file (the project remembers where each clip's audio came from).
+7. **Given** a clip with no known source (recorded in Nota, from a project saved by an
+ older version, or created by consolidate / export), **When** I open its context menu,
+ **Then** **In browser** is disabled and **In Finder** reveals the clip's audio inside
+ the project bundle.
+8. **Given** an audio clip, **When** I choose **Locate → In Finder** (macOS) / **In
+ Explorer** (Windows) / **In file manager** (Linux), **Then** the OS file manager opens
+ with the file selected (or its folder opened, where the OS can't select).
+9. **Given** a clip whose source file no longer exists on disk, **When** I open its context
+ menu, **Then** **In browser** is disabled and **In Finder** reveals the bundle copy.
+10. **Given** a MIDI clip (no source file), **When** I open its context menu, **Then** there
+ is no Locate submenu.
+
+---
+
+### User Story 5 - See my newest projects first, with dates (Priority: P2) — #582
+
+The Projects tab lists the most recently changed project first and shows when each was
+last changed, the way the Welcome window's recent list does, so I can pick up yesterday's
+work without remembering its name.
+
+**Why this priority**: Self-contained, used every session.
+
+**Independent Test**: Save three projects at different times and tempos; the Projects tab
+lists them newest first, each with its date and time, tempo, length, track count and key
+(when set); switch the sort to name and back.
+
+**Acceptance Scenarios**:
+
+1. **Given** the projects folder with several projects, **When** I open the Projects tab,
+ **Then** they are listed by last-modified time, newest first.
+2. **Given** a project row, **When** I look at it, **Then** it shows the project name and,
+ on a muted second line, its last-modified date and time in the same format as the
+ Welcome window's recent list, its tempo, its length, its number of tracks, and its
+ key when the project has one set.
+3. **Given** the Projects tab, **When** I switch the sort to **Name**, **Then** projects are
+ ordered A–Z; the choice is remembered across restarts.
+4. **Given** I save the open project, **When** I look at the Projects tab, **Then** that
+ project moves to the top with its new date (on the next refresh at the latest — the tab
+ refreshes when shown).
+5. **Given** the search box, **When** I type, **Then** filtering works as today and keeps
+ the chosen order.
+6. **Given** the project that is currently open, **When** I look at the list, **Then** its
+ row is marked as open.
+7. **Given** a projects folder with many projects, **When** I open the Projects tab,
+ **Then** names and dates appear at once and tempo / length / tracks / key fill in as
+ they are read in the background; a project that hasn't changed since is not re-read.
+8. **Given** a project that can't be read (damaged or from a newer version), **When** its
+ row is shown, **Then** it shows the name and date only.
+
+### Edge Cases
+
+- Adding a folder that is already in the list → nothing is added; the existing node is
+ selected and a short note says it's already there.
+- Adding a folder that sits inside, or contains, a folder already in the list → refused
+ with a note naming the overlapping folder (so no file is listed or indexed twice). The
+ same check applies to **Add this folder to the browser** in browse mode.
+- Removing the default folder → refused while it's the only folder; otherwise the next
+ folder becomes the default, after a confirmation that names it.
+- The list may not be emptied: the last folder can be changed but not removed.
+- Two folders with the same name → both shown; the label is the folder name, and the
+ tooltip shows the full path; Rename lets the user tell them apart.
+- A folder becomes unavailable while browsing it → its node shows unavailable; preview of
+ its files fails quietly with the normal "file not found" status.
+- Very large folders (500 GB+, see #358) → adding one must not freeze the app; listing and
+ indexing stay in the background with the existing per-folder file cap and progress line.
+- Browse mode in folders the OS denies access to (macOS privacy-protected folders,
+ Windows system folders) → an "unreadable folder" note in place of the list; the app
+ never prompts in a loop.
+- Browse mode lists every folder and file except hidden ones; files Nota can't add are shown
+ half-transparent and are inert.
+- Browse mode does not add folders to the sample index; tags appear only for files that
+ are also inside an added folder (or after the user adds the folder).
+- Locate on a clip whose file is inside a `Downloaded` pack folder → works like any other
+ file in the default folder.
+- Locate when the browser is collapsed → **In browser** expands it first.
+- Projects folder contains a bundle with an unreadable date → it sorts last, with no date.
+- Settings from older versions with an empty Samples folder (meaning the default
+ location) → migrate to a list whose one entry is the default location.
+
+## Requirements *(mandatory)*
+
+### Functional Requirements
+
+**Sample folders (#346, #268)**
+
+- **FR-001**: The app MUST store a list of sample folders (one or more) in place of the
+ single Samples folder setting, each with a path, an optional display name, and exactly
+ one marked as default.
+- **FR-002**: On first start after upgrade, the existing Samples folder (or the default
+ location when unset) MUST become the first, default entry; nothing else changes for a
+ user who never touches the new controls.
+- **FR-003**: Settings → Library MUST show the list with **Add folder…**, **Remove**,
+ **Set as default** and **Show in Finder/Explorer** per entry, accept folders dropped from
+ the OS file manager, and show unavailable folders as such.
+- **FR-004**: The Files tab MUST show each folder as a top-level node (default first, then
+ in list order), and offer **Add folder…** and folder drag-and-drop that write to the same
+ list.
+- **FR-005**: A top-level folder node's context menu MUST offer **Rename**, **Remove from
+ browser**, and **Show in Finder/Explorer/file manager**; Remove and Rename never touch
+ files on disk.
+- **FR-006**: Every folder MUST be indexed like the Samples folder is today (tempo, key,
+ loop/one-shot, similar sounds), in the background, and take part in search, filter
+ chips and "similar".
+- **FR-007**: Downloaded sample packs MUST install into the default folder's `Downloaded`
+ subfolder; packs already installed in the old default stay where they are and remain
+ visible.
+- **FR-008**: Duplicate and overlapping (nested) folders MUST be refused with a note, as
+ described in Edge Cases.
+- **FR-009**: Everything else that reads "the Samples folder" today (pack installs, kit
+ folders, similar-sample search, MCP sample tools) MUST keep working, using the default
+ folder where a single folder is needed and all folders where a search is meant.
+
+**Rail icon (#579)**
+
+- **FR-010**: The folder icon MUST be drawn with the same padding and stroke weight as the
+ other rail icons, so that at the rail's size it reads as the same size as its
+ neighbours, in every theme and in the classic look.
+
+**Browse mode (#580)**
+
+- **FR-011**: The Files tab MUST offer a toggle between the folder tree and a browse view.
+- **FR-012**: The browse view MUST show one folder's subfolders and files, folders first,
+ each group sorted by name; hidden entries are not shown. Files Nota can't add (anything
+ but the audio and MIDI it loads) MUST be drawn half-transparent and MUST NOT be dragged,
+ opened or previewed.
+- **FR-012a**: Each browse row MUST carry an icon for its kind (folder, drive, audio file,
+ MIDI file, other file); each file row MUST show its extension and its size in separate
+ columns.
+- **FR-013**: The browse view MUST provide **Back**, **Forward**, **Up**, **Home** (the
+ default sample folder), a path bar with
+ clickable segments, **Copy path**, and an editable path field that accepts a typed or
+ pasted folder or file path.
+- **FR-014**: **Up** MUST continue past the samples folder to the volume root and then to a
+ list of drives/volumes appropriate to the OS.
+- **FR-015**: Files in the browse view MUST support the same preview, double-click and
+ drag-and-drop as files in the tree, plus **Copy path** and **Show in
+ Finder/Explorer/file manager** in their context menu.
+- **FR-016**: A folder shown in the browse view MUST offer **Add this folder to the
+ browser**, which goes through the same checks as FR-008.
+- **FR-017**: Search in the browse view MUST filter the current folder's entries only.
+- **FR-018**: The tree/browse choice and the last browsed folder MUST be remembered across
+ restarts; a remembered folder that no longer exists falls back to the default folder.
+
+**Locate (#581)**
+
+- **FR-019**: While an audio clip is selected in the arrangement or Session, the Files tab
+ MUST highlight that clip's file row if the row is currently visible in the list (its
+ folder is expanded in the tree, or its folder is the one shown in browse mode). It MUST
+ NOT expand, scroll or switch tabs on its own.
+- **FR-019a**: Saving a project MUST record, for each audio clip whose audio came from a
+ file on disk, that file's original path; loading MUST restore it. The field is optional
+ and additive: projects without it load as before, and older Nota versions ignore it.
+- **FR-020**: The context menu of an audio clip (arrangement and Session) MUST offer
+ **Locate → In browser** and **Locate → In Finder** (Explorer on Windows, File manager on
+ Linux).
+- **FR-021**: **In browser** MUST bring the Files tab up, reveal the file (expand its
+ folders, scroll, select) in the tree when it is inside an added folder, or open browse
+ mode at its folder with it selected otherwise; it MUST NOT start a preview.
+- **FR-022**: **In Finder/Explorer/file manager** MUST reveal the clip's original file in
+ the OS file manager, or the clip's audio inside the project bundle when the original
+ path is unknown or the file is gone.
+- **FR-023**: **In browser** MUST be disabled when the clip has no known original path or
+ the file at it is missing; MIDI clips show no Locate submenu.
+
+**Projects tab (#582)**
+
+- **FR-024**: The Projects tab MUST sort projects by last-modified time, newest first, by
+ default, with a choice of **Date** / **Name** that is remembered.
+- **FR-025**: Each project row MUST show the last-modified date and time in the format the
+ Welcome window's recent list uses, plus tempo, length, number of tracks, and key when
+ set.
+- **FR-025a**: Tempo, length, track count and key MUST be read in the background without
+ blocking the list, cached per project, and re-read only when the project has changed
+ since; an unreadable project shows name and date only.
+- **FR-026**: The currently open project's row MUST be marked.
+- **FR-027**: The list MUST refresh when the tab is shown and after the open project is
+ saved.
+
+**Common**
+
+- **FR-028**: All new labels MUST be localised in English (in-app) and Russian (nota-translations).
+- **FR-029**: All new UI MUST follow the Studio design language (DESIGN.md) and work in all
+ four colour themes and in the classic look.
+
+### Key Entities
+
+- **Sample folder**: a folder on disk the user added to the browser — path, optional
+ display name, default flag, availability (present / unavailable).
+- **Browse location**: the folder the browse view is showing, plus back/forward history
+ (session-only) and the last location (persisted).
+- **Project entry**: a project bundle in the projects folder — name, path, last-modified
+ time, whether it is the open project, and a cached summary (tempo, length, track count,
+ key when set).
+- **Clip source**: the original file an audio clip's audio was taken from — a path that
+ may be unknown or point to a file that no longer exists.
+
+## Success Criteria *(mandatory)*
+
+### Measurable Outcomes
+
+- **SC-001**: A user can add a second sample folder and find a file in it by search in
+ under 30 seconds, without leaving Nota.
+- **SC-002**: Upgrading users see the same Files tab contents as before the upgrade, with
+ no manual step (100% of existing Samples folder settings migrate).
+- **SC-003**: From a selected audio clip, the user reaches its file in the browser or in
+ Finder/Explorer in 2 clicks (right-click, choose Locate item).
+- **SC-004**: From the default Samples folder, the user can reach any readable folder on
+ any mounted drive using only Up, Back/Forward, path segments or a pasted path.
+- **SC-005**: Adding a folder with tens of thousands of files never freezes the UI; the
+ first level of the folder appears within 1 second and the rest fills in in the
+ background.
+- **SC-006**: The most recently saved project is the first row of the Projects tab in
+ 100% of cases (date sort), with its date visible without hovering.
+- **SC-008**: With 200 projects in the folder, the Projects tab shows all names and dates
+ within 1 second and the remaining details within 10 seconds on first open, instantly on
+ later opens.
+- **SC-007**: In a side-by-side screenshot of the rail, the Files icon's drawn extent is
+ within 1 pixel of the other rail icons' padding.
+
+## Assumptions
+
+- Default suggestions (Desktop, Downloads, Music) from #268 are **not** added
+ automatically; the user adds what they want. Browse mode covers one-off access.
+- Rename changes only the label Nota shows, never the folder on disk.
+- Locate applies to audio clips; MIDI clips imported from `.mid` files don't keep a link
+ to the file and are out of scope.
+- Clips already in projects saved before this change have no recorded source; they get
+ one only when re-added from a file.
+- A thumbnail or waveform preview of a project is out of scope.
+- Folder availability is re-checked when the browser refreshes (tab shown, Settings
+ opened, app start) — no live file-system watching of drive mounts is required.
+- The Linux label for the OS file manager is "Show in file manager", matching the
+ existing Reveal wording on each platform.
+- No engine change: this is managed app and UI work only; the smoke test is unaffected
+ except where it reads settings.
+
+## 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/managed only, no audio-thread code touched
+- [x] Managed/native crossings go through the pure C ABI in `nota_engine.h` only (AR-7); no JUCE outside `pluginhost/` — no ABI change
+- [x] Smoke-test impact assessed: engine behaviour change → extend `tests/Nota.SmokeTest` — no engine change; project format gains an optional clip-source field: check save/load round-trip and settings migration don't break it
+- [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/092-browser-files-projects/tasks.md b/specs/092-browser-files-projects/tasks.md
new file mode 100644
index 00000000..6a18de86
--- /dev/null
+++ b/specs/092-browser-files-projects/tasks.md
@@ -0,0 +1,236 @@
+---
+
+description: "Tasks for spec 092 — browser sample folders, browse mode, Locate, Projects tab, rail icon"
+---
+
+# Tasks: Browser — your own sample folders, a file-system browse mode, Locate, and a richer Projects tab
+
+**Input**: Design documents from `specs/092-browser-files-projects/`
+
+**Prerequisites**: [plan.md](plan.md), [spec.md](spec.md), [research.md](research.md),
+[data-model.md](data-model.md), [contracts/](contracts/), [quickstart.md](quickstart.md)
+
+**Tests**: Included — constitution IV requires the smoke test to cover new behaviour; plan R9
+lists the checks. All tests live in `tests/Nota.SmokeTest/` as `Run()` iterators of
+`(bool Ok, string Label)` (pattern: `SampleStoreTests.cs`), wired into `Program.cs` both in
+the full run and behind a standalone flag.
+
+**Organization**: Tasks are grouped by user story (spec.md US1–US5).
+
+## Format: `[ID] [P?] [Story] Description`
+
+- **[P]**: Can run in parallel (different files, no dependencies on incomplete tasks)
+- **[Story]**: US1 sample folders (#346/#268) · US2 rail icon (#579) · US3 browse mode (#580) ·
+ US4 Locate (#581) · US5 Projects tab (#582)
+
+## Path Conventions
+
+- Managed: `src/managed/<Project>/…` · Strings: `src/managed/Nota.Application/Localization/en.json`
+ (RU later in `../nota-translations/languages/ru.json`) · Tests: `tests/Nota.SmokeTest/`
+- Every new source file starts with the two-line SPDX header
+ (`// SPDX-License-Identifier: AGPL-3.0-only` / `// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.`)
+ followed by a short *why this file exists* comment.
+
+---
+
+## Phase 1: Setup (Shared Infrastructure)
+
+**Purpose**: Test scaffolding the stories add to.
+
+- [X] T001 Create empty test classes `SampleFoldersTests`, `FileBrowseTests`, `ClipSourceTests`, `ProjectSummaryTests` (each `internal static class … { public static IEnumerable<(bool Ok, string Label)> Run() { yield break; } }`, SPDX header) in `tests/Nota.SmokeTest/SampleFoldersTests.cs`, `FileBrowseTests.cs`, `ClipSourceTests.cs`, `ProjectSummaryTests.cs`
+- [X] T002 Wire the four classes into `tests/Nota.SmokeTest/Program.cs`: a standalone flag `--browser-files` (runs all four, prints `BROWSER FILES PASSED/FAILED`, next to the existing `--browser` block ~line 198) and a `-- browser files (spec 092) --` section in the full run right after the `BrowserCategoryTests` section (~line 15634)
+
+---
+
+## Phase 2: Foundational (Blocking Prerequisites)
+
+**Purpose**: The settings shape every story reads.
+
+- [X] T003 Add settings fields in `src/managed/Nota.Application/Settings.cs`: `public List<SampleFolderEntry>? SampleFolders { get; set; }` with `SampleFolderEntry { string Path = ""; string? Name; bool IsDefault }` (Path: "Absolute, normalised (no trailing separator). `""` only for the migrated default-location entry"; Name: "Display label; null/empty → folder name. Never renames on disk"; IsDefault: "Exactly one `true` in the list"); `public bool FilesBrowseMode { get; set; }` (default false = Tree); `public string FilesBrowseFolder { get; set; } = ""`; `public string ProjectsSort { get; set; } = "Date"` ("Date" | "Name"). Keep `SamplesFolder` and update its doc comment: "mirror of the default SampleFolders entry, kept for older versions and Mosaic refs"
+- [X] T004 Add `ResolvedSampleFolder` record `(int Index, string Path, string Label, bool IsDefault, bool Available)`, `SampleFolderResult` (`Added`, `AlreadyPresent`, `Overlaps`, `NotADirectory`, with the conflicting index) and the `ISettingsService` members from contracts/persisted-formats.md (`ResolvedSampleFolders()`, `AddSampleFolder`, `RemoveSampleFolder`, `RenameSampleFolder`, `SetDefaultSampleFolder`, `event Action? SampleFoldersChanged`) in `src/managed/Nota.Application/Settings.cs`
+- [X] T005 Create pure rules `SampleFolderRules` in new `src/managed/Nota.Application/Browser/SampleFolderRules.cs`: `Normalize(path)`, `IsSameOrInside(a, b)` (OS path comparer: case-insensitive on Windows/macOS, sensitive on Linux; separator-aware so `/A/Drum` is not inside `/A/Drums`), `Check(existing, candidate) → SampleFolderResult`, `Repair(list, legacySamplesFolder)` (migration: null/empty → `[{Path = legacy, IsDefault = true}]`; zero/several defaults → first is default; drop entries equal to/nested in/containing an earlier one, returning dropped for logging)
+- [X] T006 Implement in `src/managed/Nota.Infrastructure/Settings/SettingsService.cs`: run `SampleFolderRules.Repair` on load; on save write `SamplesFolder = default.Path`; `ResolvedSamplesFolder()` returns the default entry resolved (`""` → `~/Music/Nota Samples`, created if missing — unchanged behaviour); `ResolvedSampleFolders()` (never creates non-default folders; `Available = Directory.Exists`); Add (normalise → rules → append → save → raise), Remove (false for the last entry; removing the default promotes the next), Rename (null/blank clears), SetDefault; all mutators save and raise `SampleFoldersChanged`
+- [X] T007 Update the test double in `tests/Nota.SmokeTest/SampleStoreTests.cs` (~line 178, the class implementing `ResolvedSamplesFolder()`) and any other `ISettingsService` implementations (`grep -rn ": ISettingsService" src tests`) so the solution builds
+
+**Checkpoint**: builds; old settings files load into a one-entry list; nothing visible changed.
+
+---
+
+## Phase 3: User Story 1 — Several sample folders in the browser (P1) 🎯 MVP
+
+**Goal**: Add/remove/rename/default folders in Settings → Library and from the Files tab; each is a root in the Files tab, indexed, searched, filtered.
+
+**Independent Test**: quickstart.md steps 1–4.
+
+### Tests for User Story 1
+
+- [X] T008 [P] [US1] In `tests/Nota.SmokeTest/SampleFoldersTests.cs` check `SampleFolderRules`: legacy `SamplesFolder="/x/A"` → one default entry; empty legacy → `Path=""` default; two defaults repaired to first; duplicate (incl. trailing slash / case on macOS-Windows) → `AlreadyPresent`; `/A/Drums` vs `/A` → `Overlaps` both directions; `/A/Drum` vs `/A/Drums` → not overlapping; nested entry in a loaded list is dropped
+- [X] T009 [P] [US1] In `tests/Nota.SmokeTest/SampleFoldersTests.cs` check `SettingsService` against a temp `NOTA_DATA_DIR`: add/rename/set-default/remove round-trip through save+reload; `SamplesFolder` mirrors the default after each save; remove of the only entry returns false; removing the default promotes the next; `ResolvedSampleFolders()` marks a deleted folder `Available=false` and keeps it
+- [X] T010 [P] [US1] In `tests/Nota.SmokeTest/SampleFoldersTests.cs` check `BrowserViewModel.RebuildSamples` with two temp roots (use `BrowserTestSupport`): two top-level folder nodes, default first, labels = Name ?? folder name, files under the right root, the default root's `Downloaded` subfolder first within it, an unavailable root present with `Unavailable=true` and no children, search finds a file in the second root
+- [X] T011 [P] [US1] In `tests/Nota.SmokeTest/SmartSampleTests.cs` (index section) check `SampleLibraryIndex.Watch(new[]{rootA, rootB})` analyses files from both roots, name hints use the containing root, and files under a root that disappears are not swept
+
+### Implementation for User Story 1
+
+- [X] T012 [US1] Change `ISampleIndex.Watch(string root)` to `Watch(IReadOnlyList<string> roots)` in `src/managed/Nota.Application/Ports/ISampleIndex.cs` and implement in `src/managed/Nota.Infrastructure/SampleStore/SampleLibraryIndex.cs`: `_roots` list replaces `_root` (clear `Info` when the set changes), `Scan` enumerates roots in order honouring `_priority`, `Classify` passes the containing root to `SampleNameHints.Parse`, the stale sweep runs per *available* root only, `Prioritize` re-watches `_roots`; update every caller (`grep -rn "\.Watch(" src/managed`)
+- [X] T013 [US1] Rework `RebuildSamples()` in `src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs`: iterate `_settings.ResolvedSampleFolders()`; one top-level `BrowserItem` (Kind Folder, Depth 0, `PlaceIndex` = entry index, `Unavailable`, Name = Label, Path = root) per entry; `GetOrCreateFolder` keyed under each root; `MaxSamples` cap per root; `AppendKitFolders()` unchanged; `_index?.Watch(available roots)`; enumeration moves to a background `Task` that builds the tree then swaps it in on the UI thread (cancel a running build when a new one starts; show first-level folders before files fill in). Also fix the second `ResolvedSamplesFolder()` use (~line 704) to search all roots where it means "the library"
+- [X] T014 [US1] Add `PlaceIndex` (int, default −1), `Unavailable` (bool) and `Located` (bool, used by US4) to `BrowserItem` (`grep -rn "class BrowserItem" src/managed`)
+- [X] T015 [US1] Subscribe `BrowserViewModel` to `ISettingsService.SampleFoldersChanged` → `RebuildSamples()` and refresh availability when the Files tab is shown, in `src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs` and `src/managed/Nota.App/BrowserView.cs` (tab activation ~line 715)
+- [X] T016 [US1] New partial `src/managed/Nota.App/BrowserView.Places.cs`: root-row context menu (Rename → inline prompt reusing the existing rename prompt helper; Remove from browser → confirm when it is the default, naming the next default; Show in Finder/Explorer/file manager via `MenuKit.RevealLabel` + `RevealRequested`; Set as default); dimmed style + "Unavailable" sub-label for `Unavailable` rows (tokens only, nota-design)
+- [X] T017 [US1] Files-tab header **Add folder…** button (`GlyphKind.Plus`, tooltip) opening the OS folder picker (`StorageProvider.OpenFolderPickerAsync`, start at default folder) and folder drop: in `src/managed/Nota.App/BrowserView.cs` drop handler (`ExternalFiles`, ~line 103–140) route directories to `AddSampleFolder`, files stay as today; show refusal notes from contracts/ui.md through the browser status line
+- [X] T018 [US1] Replace the single Samples-folder picker (`src/managed/Nota.App/PreferencesWindow.cs` ~line 971) with a **Sample folders** list in `src/managed/Nota.App/PreferencesWindow.Samples.cs`: rows (label, path, Default badge, Unavailable note, Show, ⋯ menu Rename / Set as default / Remove), **Add folder…**, drop target; rebuild on `SampleFoldersChanged`; Remove disabled for the only entry
+- [X] T019 [US1] Make the default folder drive pack installs and Mosaic roots on change: `src/managed/Nota.Infrastructure/SampleStore/SampleStore.cs` keeps `settings.ResolvedSamplesFolder` (verify it re-reads per install, not cached), `src/managed/Nota.Infrastructure/Mosaic/MosaicLibrary.cs` re-calls `NotaEngine.SetPathRoot(MosaicPaths.SamplesRoot, …)` on `SampleFoldersChanged`
+- [X] T020 [US1] Add EN strings to `src/managed/Nota.Application/Localization/en.json`: `browser.add_folder`, `browser.remove_from_browser`, `browser.set_as_default`, `browser.unavailable`, `browser.folder_already_added`, `browser.folder_inside` ("Inside {0} — already in the browser"), `browser.folder_contains` ("Contains {0} — remove it first"), `browser.remove_default_confirm` ("{0} becomes the default folder for downloaded packs."), `preferences.sample_folders`, `preferences.default`, plus any new labels used in T016–T018
+
+**Checkpoint**: US1 works alone (quickstart 1–4); `--browser-files` and `--smart-samples` pass.
+
+---
+
+## Phase 4: User Story 2 — Files rail icon size (P1)
+
+**Goal**: The folder glyph matches the other rail icons.
+
+**Independent Test**: quickstart step 5.
+
+- [X] T021 [P] [US2] In `src/managed/Nota.App/Controls/Glyph.cs` remove the procedural `case GlyphKind.Folder` (~line 341) and add a 24-grid entry to the path table (~line 468, next to `[GlyphKind.Doc]`): outline spanning x 3.5–20.5, y 5–19 with the tab at top-left, e.g. `"M3.5 6.5 a1.5 1.5 0 0 1 1.5 -1.5 h4.6 l2 2.2 h7.4 a1.5 1.5 0 0 1 1.5 1.5 v8.8 a1.5 1.5 0 0 1 -1.5 1.5 h-14 a1.5 1.5 0 0 1 -1.5 -1.5 z"`; tune by screenshot so its extent matches Doc/Bookmark
+- [X] T022 [US2] Screenshot the rail (headless harness, memory: nota-ui-verify) in Studio Dark/Light, Ember Graphite/Paper and the classic look; also check `GlyphKind.Folder` users: `ArrangementView.Tracks.cs:210`, `ArrangementView.cs:2857`, `DeviceChainView.Clipboard.cs:558`, `PreferencesWindow.Skins.cs:71`, `DeviceCards/Instruments/RhythmInstrumentCard.cs:322` (8 px)
+
+**Checkpoint**: icon shots before/after saved for the PR.
+
+---
+
+## Phase 5: User Story 3 — Browse mode (P2)
+
+**Goal**: Tree / Browse toggle; Browse walks the file system with Back/Forward/Up, path bar, Copy path, typed/pasted paths.
+
+**Independent Test**: quickstart step 6.
+
+### Tests for User Story 3
+
+- [X] T023 [P] [US3] In `tests/Nota.SmokeTest/FileBrowseTests.cs` check `FileBrowseState`: Go pushes Back and clears Forward; Back/Forward move between stacks; stacks capped at 100; Up from a folder → parent; Up from a volume root → Computer; Up at Computer disabled; `Volumes()` contains `/` (macOS/Linux) or a ready drive (Windows)
+- [X] T024 [P] [US3] In `tests/Nota.SmokeTest/FileBrowseTests.cs` check `PathInput.Parse`: `~` and `~/x` expand to home; a file path → (its folder, the file selected); a trailing separator is ignored; a missing path → error; quoted pasted paths (`"…"`, `'…'`) are unquoted; `file://` URLs are decoded
+- [X] T025 [P] [US3] In `tests/Nota.SmokeTest/FileBrowseTests.cs` check `BrowserViewModel` browse listing of a temp folder: folders first then audio/MIDI files, each sorted by name; hidden entries (`.x`, Windows hidden attribute) and non-audio files skipped; search filters the current folder only
+
+### Implementation for User Story 3
+
+- [X] T026 [P] [US3] New `src/managed/Nota.Application/Browser/FileBrowseState.cs`: `Location` (path or `Computer`), `Back`/`Forward` stacks (cap 100), `Go`, `GoBack`, `GoForward`, `Up`, `CanUp`, `Segments` (for the path bar: volume root first), and static `Volumes()` per OS (Windows `DriveInfo.GetDrives()` ready; macOS `/` labelled with the system volume name + `/Volumes/*` except the symlink to `/`; Linux `/`, `$HOME`, `/media/$USER/*`, `/run/media/$USER/*`, `/mnt/*`)
+- [X] T027 [P] [US3] New `src/managed/Nota.Application/Browser/PathInput.cs`: `Parse(string text) → (string Folder, string? SelectFile) | error` per T024
+- [X] T028 [US3] In `src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs` add browse mode: `BrowseMode` (persisted to `Settings.FilesBrowseMode`), `Browse` (`FileBrowseState`, starting at `Settings.FilesBrowseFolder` if it exists else the default folder, or the folder of the row selected in the tree when switching), `BrowseItems` collection built off the UI thread (Kind Folder / Sample / MidiFile, `Sample` tags from `_index.Get` when indexed), `Unreadable` / `Empty` states, search over the current folder; persist `FilesBrowseFolder` on navigation (never the Computer level)
+- [X] T029 [US3] New partial `src/managed/Nota.App/BrowserView.Browse.cs`: Tree | Browse segmented toggle under the search box (Files tab only); nav bar with Back/Forward/Up buttons (`GlyphKind` arrows), path segments as buttons eliding from the left, empty-area click or ⌘L/Ctrl+L → editable `TextBox` (Enter go via `PathInput`, Esc cancel, error → red edge token + status "Can't open {0}"), Copy path button (clipboard + status "Path copied"); Back ⌘[ / Alt+Left, Forward ⌘] / Alt+Right, Up ⌘↑ / Alt+Up when the Files tab has focus; bind the list to `BrowseItems` in Browse mode so preview, double-click, drag, sample player reuse the existing paths; folder rows navigate on click/double-click/Enter; empty/unreadable placeholders
+- [X] T030 [US3] Context menu additions in `src/managed/Nota.App/BrowserView.cs` (~line 1667 folder/file menu): **Copy path** on folders and files (tree and browse), **Show in …** on browse rows, **Add this folder to the browser** on browse folders (and on the current folder from the path bar) via `AddSampleFolder` with the same refusal notes
+- [X] T031 [US3] EN strings in `src/managed/Nota.Application/Localization/en.json`: `browser.tree`, `browser.browse`, `browser.back`, `browser.forward`, `browser.up`, `browser.computer`, `browser.copy_path`, `browser.path_copied`, `browser.cant_open` ("Can't open {0}"), `browser.add_this_folder`, `browser.folder_empty` ("This folder has no audio or MIDI files"), `browser.folder_unreadable` ("Nota can't read this folder")
+
+**Checkpoint**: US3 works alone (quickstart 6); `--browser-files` passes.
+
+---
+
+## Phase 6: User Story 4 — Locate a clip's file (P2)
+
+**Goal**: Clips remember their source file across save/reopen; the selected clip's file is highlighted when visible; Locate → In browser / In Finder.
+
+**Independent Test**: quickstart step 7.
+
+### Tests for User Story 4
+
+- [X] T032 [P] [US4] In `tests/Nota.SmokeTest/ClipSourceTests.cs` (real engine, like other project tests in Program.cs): add an audio clip from a temp WAV → `SampleSource(id)` = full path; split the clip → both halves report it; save to a temp bundle, reopen → `AudioClipDto.Source` present in `project.json` and `SampleSource` restored on the reloaded clip; a session audio slot round-trips the same way; loading from `<bundle>.nota/samples/x.wav` records no source; a project without `Source` loads with `SampleSource` = ""
+
+### Implementation for User Story 4
+
+- [X] T033 [US4] Add `string SampleSource(long sampleId)` and `void SetSampleSource(long sampleId, string path)` to `src/managed/Nota.Application/Engine/IAudioEngine.cs` (doc: "full path the sample was loaded from, or \"\"; managed-only, like SampleName") and implement in `src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs` with `_sampleSources` beside `_sampleNames` (~line 914); record in `RememberSampleName`'s callers and in `AddAudioClip` (~line 20), `AddAudioClipEx` (~line 996) and `src/managed/Nota.Infrastructure/Interop/NotaEngine.Session.cs` `AddSessionAudioClip`/`AddSessionAudioFile` (~line 131–135) by reading the new clip's sample id; skip paths containing a `.nota` directory segment followed by `samples`; implement in any other `IAudioEngine` (`grep -rn ": IAudioEngine" src tests`)
+- [X] T034 [US4] Add `public string? Source { get; set; }` to `AudioClipDto` and `AudioTakeDto` in `src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs` (comment: "original file the audio came from (spec 092); optional, absent = unknown"); in `src/managed/Nota.Infrastructure/Persistence/ProjectService.cs` set it from `engine.SampleSource(sampleId)` (null when "") for arrangement clips (~line 259), takes (~line 272) and session audio slots (~line 303); on load, after each clip/take/slot sample is restored, call `engine.SetSampleSource(newSampleId, dto.Source)` when non-empty; no `CurrentFormatVersion` change
+- [X] T035 [US4] In `src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs` add `SetLocatedPath(string? path)`: clears the previous `Located` row and sets it on the matching row in the visible Files list (tree `Samples` or `BrowseItems`); never expands, scrolls or switches tabs; re-applied after rebuilds
+- [X] T036 [US4] In `src/managed/Nota.App/BrowserView.cs` render `Located` rows with the orange line treatment (2 px left edge, `Brush.Accent`), distinct from selection; add `RevealFile(string path)`: expand the browser if collapsed, open the Files tab, if `path` is under an available root → Tree mode, expand ancestors, scroll into view, select without auditioning; else → Browse mode at its folder with it selected
+- [X] T037 [US4] Wire selection in `src/managed/Nota.App/MainWindow.Browser.cs`: on `Timeline.ClipSelectionChanged` (hooked in `MainWindow.axaml.cs:215`) and on Session slot selection changes (`src/managed/Nota.App/SessionView.Grid.cs` — add a `SlotSelectionChanged` event if none), resolve a single selected audio clip's sample id → `engine.SampleSource` → `Browser.SetLocatedPath`, else null
+- [X] T038 [US4] Add the **Locate ▸** submenu (single audio clip only, not in the multi-selection menu) in `src/managed/Nota.App/ArrangementView.LaneControl.cs` (clip menu ~line 1030–1090) and `src/managed/Nota.App/SessionView.Grid.cs` (slot menu ~line 898): **In browser** (enabled when source known and `File.Exists`) → `LocateInBrowserRequested(path)`; **In Finder** / **In Explorer** / **In file manager** by OS → reveal source if it exists, else the bundle copy `<open project>/samples/<hash>.wav` (resolve via `BundleContent` for the clip's sample id) when the project is saved, else disabled; handle both events in `src/managed/Nota.App/MainWindow.Browser.cs` with `Browser.RevealFile` / `RevealInFileManager`
+- [X] T039 [US4] EN strings in `src/managed/Nota.Application/Localization/en.json`: `clip.locate`, `clip.locate_in_browser`, `clip.locate_in_finder`, `clip.locate_in_explorer`, `clip.locate_in_file_manager`
+
+**Checkpoint**: US4 works (quickstart 7) incl. after save/reopen; `--browser-files` passes.
+
+---
+
+## Phase 7: User Story 5 — Projects newest first with details (P2)
+
+**Goal**: Date sort by default, date/tempo/key/length/tracks per row, open marker, remembered sort.
+
+**Independent Test**: quickstart step 8.
+
+### Tests for User Story 5
+
+- [X] T040 [P] [US5] In `tests/Nota.SmokeTest/ProjectSummaryTests.cs` write temp bundles with hand-made `project.json` and check `ProjectSummaryReader`: bpm and key from `Transport`; tracks = `Tracks` count; length = max end over MIDI clips (`StartBeat + LengthBeats`), warped audio (`WarpPlayEnd - WarpPlayStart`, else `WarpBeats`), unwarped audio (`LengthFrames` or the WAV header frames ÷ WAV rate × bpm/60); session slots ignored; corrupt JSON → null summary; the cache returns the stored summary when stamp (manifest ticks + size) matches and re-reads when it changes
+- [X] T041 [P] [US5] In `tests/Nota.SmokeTest/ProjectSummaryTests.cs` check `BrowserViewModel.RebuildProjects` ordering: Date (manifest write time, newest first; unreadable date last) and Name (A–Z); `IsOpen` follows `OpenProjectPath`
+
+### Implementation for User Story 5
+
+- [X] T042 [P] [US5] New `src/managed/Nota.Application/Browser/ProjectSummary.cs` (`record ProjectSummary(double Bpm, string? Key, int TrackCount, double LengthBeats)`, `FormatLength(bpm, beats) → "m:ss"`) and a shared `ProjectDates.Modified(string bundlePath) → DateTime?` (manifest `project.json` write time, else bundle dir time) + `ProjectDates.Format(DateTime)` = `"MM/dd/yyyy HH:mm"` with `NotaNum.Culture`
+- [X] T043 [US5] New `src/managed/Nota.Infrastructure/Persistence/ProjectSummaryReader.cs` + cache: read `project.json` via `JsonDocument` (no `ProjectDocument` bind, no engine) per T040; cache at `NOTA_DATA_DIR/cache/project-summaries.json` keyed by bundle path with stamp `"<manifest ticks>:<size>"`, prune vanished bundles on write, corrupt cache → rebuilt
+- [X] T044 [US5] Rework `RebuildProjects()` in `src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs` (~line 902): `Modified` from `ProjectDates`, sort by `Settings.ProjectsSort`, `Sub` = formatted date; then a background pass fills `Summary` (cache first) and updates rows in place; add `OpenProjectPath` (marks `IsOpen`) and `ProjectsSort` setter (persists, re-sorts); keep the view-side search filter working with the order
+- [X] T045 [US5] In `src/managed/Nota.App/BrowserView.cs` Projects rows: name + open marker (accent dot) on line 1; muted second line `date · 124 BPM · Am · 3:42 · 12 tracks` (parts absent until known; date only when unreadable); `Date | Name` sort toggle beside the search when the Projects tab is active; refresh the list when the tab is shown
+- [X] T046 [US5] In `src/managed/Nota.App/MainWindow.Welcome.cs` (~line 87) use `ProjectDates.Modified/Format`; in MainWindow open/save/new paths set `Browser` VM `OpenProjectPath` and call `RebuildProjects()` after save (`grep -n "SaveProject\|OpenProject" src/managed/Nota.App/MainWindow*.cs`)
+- [X] T047 [US5] EN strings in `src/managed/Nota.Application/Localization/en.json`: `browser.sort_date`, `browser.sort_name`, `browser.project_open`, `browser.project_tracks` (plural via `Loc.Plural`), `browser.bpm`
+
+**Checkpoint**: US5 works alone (quickstart 8).
+
+---
+
+## Phase 8: Polish & Cross-Cutting Concerns
+
+- [X] T048 [P] Shortcuts pane: run the `nota-shortcuts` skill for browse Back/Forward/Up and ⌘L/Ctrl+L (Files tab)
+- [X] T049 [P] `CHANGELOG.md` `[Unreleased]` entries (Added: sample folders, browse mode, Locate, Projects details; Fixed: Files icon size) referencing #268 #346 #579 #580 #581 #582
+- [X] T050 [P] `FEATURES.md` via the `nota-features` skill
+- [X] T051 User docs via the `nota-docs` skill (EN + RU pages for the browser Files/Projects tabs, Settings → Library, clip context menu; re-shoot screenshots)
+- [ ] T052 RU strings for every key added in T020, T031, T039, T047 in `../nota-translations/languages/ru.json` (validated once the app PR reaches develop)
+- [ ] T053 Run `/speckit-converge`, then `scripts/build.sh` (must pass incl. smoke test); walk quickstart.md 1–9 with the headless harness and collect before/after screenshots for the PR (rail, Files tree with two roots, Browse mode, Settings → Library, Locate highlight, Projects tab) in all four themes + classic look where the surface is themed
+- [X] T054 Re-check the Nota Compliance Checklist in spec.md (SPDX headers on new files, no dependency, no audio-thread code, no ABI change, CHANGELOG/FEATURES/docs done, DESIGN.md followed) and tick it
+
+---
+
+## Dependencies & Execution Order
+
+### Phase Dependencies
+
+- Setup (T001–T002) → Foundational (T003–T007) → stories.
+- **US1** (T008–T020) needs Foundational.
+- **US2** (T021–T022) needs nothing — can be done first or in parallel with anything.
+- **US3** (T023–T031) needs Foundational (settings fields) and T014 (`BrowserItem` fields) and T017's `AddSampleFolder` UI path for T030.
+- **US4** (T032–T039) needs T014 (`Located`); T036's "outside every folder → Browse" branch needs US3 (T028/T029) — without it, that branch falls back to In Finder.
+- **US5** (T040–T047) needs Foundational (`ProjectsSort`) only.
+- Polish after all stories.
+
+### Within stories
+
+Tests first (they fail until implemented) → Application-layer rules/state → Infrastructure → ViewModel → View → strings.
+
+### Parallel Opportunities
+
+- T008–T011 in parallel; T021 any time; T023–T025 and T026–T027 in parallel; T032 alongside T033; T040–T042 in parallel; T048–T050 in parallel.
+- US2 and US5 can proceed in parallel with US1 (different files except `BrowserView.cs` / `BrowserViewModel.cs` — serialise edits to those two files).
+
+## Parallel Example: User Story 3
+
+```text
+T023 FileBrowseState tests ─┐
+T024 PathInput tests ─┼─ together
+T026 FileBrowseState.cs ─┤
+T027 PathInput.cs ─┘
+then T028 (VM) → T029 (view) → T030 (menus) → T031 (strings)
+```
+
+## Implementation Strategy
+
+1. **MVP**: Setup + Foundational + US1 + US2 (both P1) → shippable on their own (#268, #346, #579).
+2. Add US5 (independent) → Projects tab.
+3. Add US3 → browse mode.
+4. Add US4 last so "In browser" can use browse mode for files outside every folder.
+5. Polish, converge, build, screenshots → one PR closing all six issues.
+
+## Phase 9: Convergence
+
+- [X] T055 Show each sample folder's first-level subfolders as soon as they are listed and fill files in when the walk ends, in `src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs` (`RebuildSamplesAsync`) per SC-005 (partial)
+- [X] T056 Open the selected folder with Enter in the Files browse view (and keep Enter on a file a no-op beyond today's behaviour) in `src/managed/Nota.App/BrowserView.Files.cs` per contracts/ui.md browse rows (partial)
+
+## Phase 10: Browse view review (2026-11-12, spec § Clarifications)
+
+- [X] T057 [US3] Add a Home button (new `GlyphKind.Home`, 24-grid path) after Up in the nav bar of `src/managed/Nota.App/BrowserView.Files.cs`, opening the default sample folder through `FileBrowseState.Go` (history kept); tooltip with no shortcut; EN string `browser.home_tip` per FR-013
+- [X] T058 [US3] List every non-hidden file in `BrowserViewModel.ListBrowse` (`src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs`): unsupported files as a new `BrowserItemKind.OtherFile`; set `BrowserItem.Size` (bytes) on file rows per FR-012
+- [X] T059 [US3] Browse rows in `src/managed/Nota.App/BrowserView.cs`: kind icon (Folder / new `GlyphKind.Drive` / new `GlyphKind.AudioFile` / `Midi` / `Doc`), extension and size as two right-hand columns (size column fixed width, `Loc` unit strings), `OtherFile` rows at reduced opacity and excluded from drag, double-click and preview per FR-012a
+- [X] T060 [US3] Verify the sample player auditions an audio file selected in the browse view (click and arrow keys) and fix whatever stops it, in `src/managed/Nota.App/BrowserView.cs` / `PreviewPlayer.cs` per US3 AC12
+- [X] T061 [US3] Extend `tests/Nota.SmokeTest/FileBrowseTests.cs`: listing includes other files as `OtherFile` with sizes, order folders → files by name; FileBrowseState Home; re-shoot browse view in the harness
diff --git a/src/managed/Nota.App/App.axaml.cs b/src/managed/Nota.App/App.axaml.cs
index 7db45e58..3673a940 100644
--- a/src/managed/Nota.App/App.axaml.cs
+++ b/src/managed/Nota.App/App.axaml.cs
@@ -88,6 +88,7 @@ public partial class App : Avalonia.Application
services.AddSingleton<RemoteService>();
// Presentation.
services.AddSingleton<TransportViewModel>();
+ services.AddSingleton<Nota.Application.Browser.IProjectSummaries, ProjectSummaryReader>(); // spec 092
services.AddSingleton<BrowserViewModel>();
services.AddSingleton<MainWindowViewModel>();
Services = services.BuildServiceProvider();
diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.cs
index 7e186741..0031c816 100644
--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs
+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs
@@ -1134,7 +1134,13 @@ public sealed partial class ArrangementView
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,
+ // Locate ▸ In browser / In Finder: the file the audio came from (spec 092, #581).
+ var locate = new List<Control>();
+ if (!inGroup && !clip.IsMidi && _o.Locate is { } hooks && _o._engine is { } leng
+ && leng.TryGetAudioClipInfo(trackId, idx, out var lai))
+ locate.Add(LocateMenu.Build(hooks, lai.SampleId));
+
+ MenuKit.AddGroups(flyout.Items, new Control[] { header }, new Control[] { rename }, locate, edits, audio, session,
clipboard, new Control[] { del });
return flyout;
}
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index 594ee688..47731d6a 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -145,6 +145,9 @@ public sealed partial class ArrangementView : UserControl
/// <summary>Scroll the track list so <paramref name="trackId"/>'s whole row is in view. Runs
/// after the next layout pass, so it also works straight after a Refresh that added the
/// row (the scroll extent isn't updated until then). A row already fully visible doesn't move.</summary>
+ /// <summary>Set by the main window: what an audio clip's Locate submenu does (spec 092).</summary>
+ internal LocateHooks? Locate { get; set; }
+
public void RevealTrack(int trackId)
{
Dispatcher.UIThread.Post(() =>
diff --git a/src/managed/Nota.App/BrowserView.Files.cs b/src/managed/Nota.App/BrowserView.Files.cs
new file mode 100644
index 00000000..d4cd3ff0
--- /dev/null
+++ b/src/managed/Nota.App/BrowserView.Files.cs
@@ -0,0 +1,437 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The browser's Files tab beyond the plain sample tree (spec 092): several sample folders
+// with their own menu (#268 / #346), folders dropped in from the OS, and the browse view
+// (#580) — a Tree / Browse switch, Back / Forward / Up, a path bar whose segments jump and
+// which turns into a text field for a typed or pasted path, and Copy path. Kept apart from
+// BrowserView.cs, which is the list machinery every tab shares.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Input.Platform;
+using Avalonia.Interactivity;
+using Avalonia.Layout;
+using Avalonia.Media;
+using Avalonia.Platform.Storage;
+using Avalonia.Threading;
+using Avalonia.VisualTree;
+using Nota.Application;
+using Nota.Application.Browser;
+using Nota.Application.Localization;
+using Nota.Presentation;
+
+namespace Nota.App;
+
+public sealed partial class BrowserView
+{
+ private Border _filesBar = null!; // Tree | Browse · Add folder…
+ private Border _navBar = null!; // ‹ › ↑ · path · copy
+ private Border _modeSeg = null!;
+ private Border _addFolderBtn = null!;
+ private Border _backBtn = null!, _fwdBtn = null!, _upBtn = null!, _homeBtn = null!, _copyPathBtn = null!;
+ private StackPanel _segments = null!;
+ private ScrollViewer _segmentsScroll = null!;
+ private TextBox _pathBox = null!;
+ private Border _pathWrap = null!;
+
+ /// <summary>A one-line note for the app's status line ("Path copied", why a folder wasn't added).</summary>
+ public event Action<string>? StatusMessage;
+
+ private bool BrowseOn => _vm?.BrowseMode == true;
+
+ // Built once from the constructor; shown only on the Files tab.
+ private Control BuildFilesBars()
+ {
+ _modeSeg = SessionView.Segmented(new[] { Loc.T("browser.tree"), Loc.T("browser.browse") }, 0, i => SetBrowseMode(i == 1));
+ _modeSeg.HorizontalAlignment = HorizontalAlignment.Left;
+ _addFolderBtn = IconButton(GlyphKind.Plus, Loc.T("browser.add_folder"), () => _ = AddFolderAsync());
+
+ var top = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto") };
+ top.Children.Add(_modeSeg);
+ Grid.SetColumn(_addFolderBtn, 1);
+ top.Children.Add(_addFolderBtn);
+ _filesBar = new Border { Margin = new Thickness(8, 0, 8, 6), Child = top, IsVisible = false };
+
+ _backBtn = IconButton(GlyphKind.ChevronLeft, MenuKit.Keys(Loc.T("browser.back_tip")), () => _vm?.Browse.GoBack());
+ _fwdBtn = IconButton(GlyphKind.ChevronRight, MenuKit.Keys(Loc.T("browser.forward_tip")), () => _vm?.Browse.GoForward());
+ _upBtn = IconButton(GlyphKind.ChevronUp, MenuKit.Keys(Loc.T("browser.up_tip")), () => _vm?.Browse.Up());
+ _homeBtn = IconButton(GlyphKind.Home, Loc.T("browser.home_tip"), () => _vm?.BrowseHome());
+ _copyPathBtn = IconButton(GlyphKind.Copy, Loc.T("browser.copy_path"), () => _ = CopyPathAsync(_vm?.Browse.Location));
+
+ // The path: segments as buttons, scrolled to the end so the folder you are in is what
+ // stays visible; a click on the bar's empty part (or ⌘L) swaps in a text field.
+ _segments = new StackPanel { Orientation = Orientation.Horizontal, VerticalAlignment = VerticalAlignment.Center };
+ _segmentsScroll = new ScrollViewer
+ {
+ Content = _segments,
+ HorizontalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Hidden,
+ VerticalScrollBarVisibility = Avalonia.Controls.Primitives.ScrollBarVisibility.Disabled,
+ };
+ _pathBox = new TextBox
+ {
+ IsVisible = false,
+ BorderThickness = new Thickness(0),
+ Background = Brushes.Transparent,
+ FontSize = NotaType.Caption,
+ Padding = new Thickness(0),
+ VerticalContentAlignment = VerticalAlignment.Center,
+ Classes = { "search" },
+ };
+ _pathBox.KeyDown += (_, e) =>
+ {
+ if (e.Key == Key.Enter) { CommitPath(); e.Handled = true; }
+ else if (e.Key == Key.Escape) { EndPathEdit(); e.Handled = true; }
+ };
+ _pathBox.LostFocus += (_, _) => EndPathEdit();
+ var pathGrid = new Grid();
+ pathGrid.Children.Add(_segmentsScroll);
+ pathGrid.Children.Add(_pathBox);
+ _pathWrap = new Border
+ {
+ Height = 24, CornerRadius = NotaRadius.Field, Padding = new Thickness(6, 0), Margin = new Thickness(4, 0),
+ BorderThickness = new Thickness(1), BorderBrush = Brushes.Transparent, Child = pathGrid,
+ Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Ibeam),
+ };
+ _pathWrap.BindResource(Border.BackgroundProperty, "Brush.Well");
+ _pathWrap.PointerPressed += (_, e) =>
+ {
+ // Segment buttons handle their own clicks; the empty part edits.
+ if (e.Source is Visual v && v.FindAncestorOfType<Button>(includeSelf: true) is not null) return;
+ BeginPathEdit();
+ e.Handled = true;
+ };
+
+ var nav = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,Auto,Auto,*,Auto") };
+ nav.Children.Add(_backBtn);
+ Grid.SetColumn(_fwdBtn, 1); nav.Children.Add(_fwdBtn);
+ Grid.SetColumn(_upBtn, 2); nav.Children.Add(_upBtn);
+ Grid.SetColumn(_homeBtn, 3); nav.Children.Add(_homeBtn);
+ Grid.SetColumn(_pathWrap, 4); nav.Children.Add(_pathWrap);
+ Grid.SetColumn(_copyPathBtn, 5); nav.Children.Add(_copyPathBtn);
+ _navBar = new Border { Margin = new Thickness(8, 0, 8, 6), Child = nav, IsVisible = false };
+
+ AddHandler(KeyDownEvent, OnFilesKey, RoutingStrategies.Tunnel);
+
+ // Folders dropped on the Files list join the sample folders.
+ var files = _pages[FilesTab];
+ DragDrop.SetAllowDrop(files, true);
+ files.AddHandler(DragDrop.DragOverEvent, (_, e) =>
+ {
+ if (IsBrowserDrag || DeviceDrag.IsActive) return;
+ if (ExternalPaths(e).Any(System.IO.Directory.Exists)) { e.DragEffects = DragDropEffects.Copy; e.Handled = true; }
+ });
+ files.AddHandler(DragDrop.DropEvent, (_, e) =>
+ {
+ if (IsBrowserDrag || _settings is null) return;
+ var dirs = ExternalPaths(e).Where(System.IO.Directory.Exists).ToList();
+ if (dirs.Count == 0) return;
+ Say(SampleFolderUi.AddAll(_settings, dirs));
+ e.Handled = true;
+ });
+
+ return new StackPanel { Children = { _filesBar, _navBar } };
+ }
+
+ // A 24px icon button in the browser's style: no fill at rest, the well on hover.
+ private static Border IconButton(GlyphKind kind, string tip, Action click)
+ {
+ var icon = RailIcon(kind, 14, "Brush.TextSecondary");
+ // Disabled reads in the disabled ink, not through transparency (DESIGN.md).
+ icon.HorizontalAlignment = HorizontalAlignment.Center;
+ icon.VerticalAlignment = VerticalAlignment.Center;
+ var btn = new Border
+ {
+ Width = 24, Height = 24, CornerRadius = NotaRadius.Field, Background = Brushes.Transparent,
+ Cursor = new Cursor(StandardCursorType.Hand), Child = icon,
+ };
+ btn.PointerEntered += (_, _) => { if (btn.IsEnabled) btn.BindResource(Border.BackgroundProperty, "Brush.Well"); };
+ btn.PointerExited += (_, _) => btn.Background = Brushes.Transparent;
+ btn.PointerPressed += (_, e) => { if (btn.IsEnabled && e.GetCurrentPoint(btn).Properties.IsLeftButtonPressed) { click(); e.Handled = true; } };
+ btn.PropertyChanged += (_, e) =>
+ {
+ if (e.Property == IsEnabledProperty) icon.BindResource(Glyph.ForegroundProperty, btn.IsEnabled ? "Brush.TextSecondary" : "Brush.TextDisabled");
+ };
+ ToolTip.SetTip(btn, tip);
+ return btn;
+ }
+
+ private void Say(string? note)
+ {
+ if (!string.IsNullOrEmpty(note)) StatusMessage?.Invoke(note);
+ }
+
+ // Wire the VM's browse events (from SetViewModel).
+ private void HookBrowse(BrowserViewModel vm)
+ {
+ vm.BrowseItems.CollectionChanged += (_, _) => { if (_active == FilesTab && BrowseOn) RefreshCounts(); };
+ vm.BrowseRefreshed += () =>
+ {
+ RenderPath();
+ if (vm.BrowseSelect is { } sel && vm.BrowseItems.FirstOrDefault(r => SampleFolderRules.PathComparer.Equals(r.Path, sel)) is { } row)
+ {
+ // Selected for the eye, not the ear: Locate doesn't audition (#581).
+ _suppressPreview = true;
+ _pages[FilesTab].SelectedItem = row;
+ _pages[FilesTab].ScrollIntoView(row);
+ _suppressPreview = false;
+ }
+ RefreshCounts();
+ };
+ if (_settings is not null) _settings.SampleFoldersChanged += () => Dispatcher.UIThread.Post(() => vm.RebuildSamples());
+ ApplyBrowseMode();
+ if (vm.BrowseMode) _ = vm.RefreshBrowseAsync();
+ }
+
+ private void SetBrowseMode(bool on)
+ {
+ if (_vm is null || _vm.BrowseMode == on) return;
+ // Switching to Browse from a folder row in the tree opens that folder.
+ if (on && _pages[FilesTab].SelectedItem is BrowserItem { Kind: BrowserItemKind.Folder } f && !f.Unavailable)
+ _vm.BrowseTo(f.Path);
+ _vm.BrowseMode = on;
+ ApplyBrowseMode();
+ }
+
+ // The Files list shows the tree or the browse list; the bars and counts follow.
+ private void ApplyBrowseMode()
+ {
+ if (_vm is null) return;
+ bool on = _vm.BrowseMode;
+ _pages[FilesTab].ItemsSource = on ? _vm.BrowseItems : _vm.Samples;
+ if (_modeSeg.Child is Avalonia.Controls.Primitives.UniformGrid g)
+ for (int i = 0; i < g.Children.Count; i++)
+ if (g.Children[i] is Avalonia.Controls.Primitives.ToggleButton tb) tb.IsChecked = (i == 1) == on;
+ UpdateFilesBars();
+ RenderPath();
+ if (_active == FilesTab) RefreshCounts();
+ }
+
+ private void UpdateFilesBars()
+ {
+ bool files = _active == FilesTab && _vm is not null;
+ _filesBar.IsVisible = files;
+ _addFolderBtn.IsVisible = files && !BrowseOn;
+ _navBar.IsVisible = files && BrowseOn;
+ // The sample filter chips belong to the indexed tree, not to an arbitrary folder.
+ _sampleChipsHost.IsVisible = files && !BrowseOn && _vm?.HasSampleIndex == true;
+ }
+
+ private void RenderPath()
+ {
+ if (_vm is null || !BrowseOn) return;
+ var b = _vm.Browse;
+ _backBtn.IsEnabled = b.CanGoBack;
+ _fwdBtn.IsEnabled = b.CanGoForward;
+ _upBtn.IsEnabled = b.CanGoUp;
+ _homeBtn.IsEnabled = !_vm.BrowseAtHome;
+ _copyPathBtn.IsEnabled = !b.IsComputer;
+ _segments.Children.Clear();
+ var computer = SegmentButton(Loc.T("browser.computer"), FileBrowseState.Computer, b.IsComputer);
+ _segments.Children.Add(computer);
+ var segs = b.Segments();
+ for (int i = 0; i < segs.Count; i++)
+ {
+ _segments.Children.Add(SegmentSeparator());
+ _segments.Children.Add(SegmentButton(segs[i].Label, segs[i].Path, i == segs.Count - 1));
+ }
+ ToolTip.SetTip(_pathWrap, b.IsComputer ? Loc.T("browser.computer") : b.Location);
+ Dispatcher.UIThread.Post(() => _segmentsScroll.Offset = new Vector(double.MaxValue, 0), DispatcherPriority.Loaded);
+ }
+
+ private Control SegmentButton(string label, string path, bool current)
+ {
+ var text = new TextBlock { Text = label, FontSize = NotaType.Caption, VerticalAlignment = VerticalAlignment.Center };
+ text.BindResource(TextBlock.ForegroundProperty, current ? "Brush.TextPrimary" : "Brush.TextSecondary");
+ var btn = new Button
+ {
+ Content = text, Padding = new Thickness(3, 0), Background = Brushes.Transparent, BorderThickness = new Thickness(0),
+ VerticalAlignment = VerticalAlignment.Center, Cursor = new Cursor(StandardCursorType.Hand), Classes = { "ghost" },
+ };
+ btn.Click += (_, _) => { if (!current) _vm?.BrowseTo(path); };
+ return btn;
+ }
+
+ private static Control SegmentSeparator()
+ {
+ var g = RailIcon(GlyphKind.CaretRight, 9, "Brush.TextTertiary");
+ g.VerticalAlignment = VerticalAlignment.Center;
+ return g;
+ }
+
+ private void BeginPathEdit()
+ {
+ if (_vm is null || !BrowseOn) return;
+ _segmentsScroll.IsVisible = false;
+ _pathBox.IsVisible = true;
+ _pathBox.Text = _vm.Browse.IsComputer ? "" : _vm.Browse.Location;
+ _pathWrap.BindResource(Border.BorderBrushProperty, "Brush.Accent");
+ Dispatcher.UIThread.Post(() => { _pathBox.Focus(); _pathBox.SelectAll(); }, DispatcherPriority.Input);
+ }
+
+ private void EndPathEdit()
+ {
+ if (!_pathBox.IsVisible) return;
+ _pathBox.IsVisible = false;
+ _segmentsScroll.IsVisible = true;
+ _pathWrap.BorderBrush = Brushes.Transparent;
+ }
+
+ private void CommitPath()
+ {
+ if (_vm is null) return;
+ string text = _pathBox.Text ?? "";
+ if (PathInput.Parse(text) is not { } target)
+ {
+ _pathWrap.BindResource(Border.BorderBrushProperty, "Brush.Danger");
+ Say(Loc.F("browser.cant_open", text.Trim()));
+ return;
+ }
+ EndPathEdit();
+ _vm.BrowseTo(target.Folder, target.SelectFile);
+ }
+
+ private async System.Threading.Tasks.Task CopyPathAsync(string? path)
+ {
+ if (string.IsNullOrEmpty(path)) return;
+ if (TopLevel.GetTopLevel(this)?.Clipboard is { } cb)
+ {
+ await cb.SetTextAsync(path);
+ Say(Loc.T("browser.path_copied"));
+ }
+ }
+
+ private async System.Threading.Tasks.Task AddFolderAsync()
+ {
+ if (_settings is null || TopLevel.GetTopLevel(this) is not { } top) return;
+ var picked = await top.PickFoldersAsync(new FolderPickerOpenOptions
+ {
+ Title = Loc.T("preferences.add_sample_folder"),
+ AllowMultiple = true,
+ });
+ var paths = picked.Select(f => f.TryGetLocalPath()).OfType<string>().ToList();
+ if (paths.Count > 0) Say(SampleFolderUi.AddAll(_settings, paths));
+ }
+
+ // ⌘[ ⌘] ⌘↑ (Ctrl elsewhere, where Alt+Left / Right / Up work too) walk the browse view;
+ // ⌘L / Ctrl+L edits the path.
+ private void OnFilesKey(object? sender, KeyEventArgs e)
+ {
+ if (_vm is null || _active != FilesTab || _collapsed || _search.IsFocused || _pathBox.IsFocused) return;
+ bool mac = OperatingSystem.IsMacOS();
+ var cmd = mac ? KeyModifiers.Meta : KeyModifiers.Control;
+ if (e.KeyModifiers == cmd && e.Key == Key.L)
+ {
+ if (!BrowseOn) { SetBrowseMode(true); }
+ BeginPathEdit();
+ e.Handled = true;
+ return;
+ }
+ if (!BrowseOn) return;
+ // Enter opens the selected folder (or drive) of the browse view.
+ if (e.Key is Key.Enter or Key.Return && e.KeyModifiers == KeyModifiers.None
+ && _pages[FilesTab].SelectedItem is BrowserItem { Kind: BrowserItemKind.Folder } folder)
+ {
+ _vm.BrowseTo(folder.Path);
+ e.Handled = true;
+ return;
+ }
+ bool alt = !mac && e.KeyModifiers == KeyModifiers.Alt;
+ bool back = e.KeyModifiers == cmd && e.Key == Key.OemOpenBrackets || alt && e.Key == Key.Left;
+ bool fwd = e.KeyModifiers == cmd && e.Key == Key.OemCloseBrackets || alt && e.Key == Key.Right;
+ bool up = e.KeyModifiers == cmd && e.Key == Key.Up || alt && e.Key == Key.Up;
+ if (back) _vm.Browse.GoBack();
+ else if (fwd) _vm.Browse.GoForward();
+ else if (up) _vm.Browse.Up();
+ else return;
+ e.Handled = true;
+ }
+
+ // --- context menu additions -------------------------------------------------------------
+
+ // A top-level sample folder: Rename · Set as default · Reveal · Remove from browser.
+ private void AddPlaceItems(MenuFlyout flyout, BrowserItem item)
+ {
+ if (_settings is null || item.PlaceIndex < 0) return;
+ var folders = _settings.ResolvedSampleFolders();
+ if (item.PlaceIndex >= folders.Count) return;
+ var f = folders[item.PlaceIndex];
+ var owner = TopLevel.GetTopLevel(this) as Window;
+ flyout.Items.Add(MenuKit.Item(Loc.T("common.rename"), GlyphKind.Edit, () => { if (owner is not null) _ = SampleFolderUi.RenameAsync(owner, _settings, f); }));
+ flyout.Items.Add(MenuKit.Item(Loc.T("browser.set_as_default"), null, () => _settings.SetDefaultSampleFolder(f.Index), enabled: !f.IsDefault && f.Available));
+ flyout.Items.Add(new Separator());
+ flyout.Items.Add(MenuKit.Danger(Loc.T("browser.remove_from_browser"), GlyphKind.Minus,
+ () => { if (owner is not null) _ = SampleFolderUi.RemoveAsync(owner, _settings, f); }, enabled: folders.Count > 1));
+ }
+
+ private MenuItem CopyPathItem(BrowserItem item)
+ => MenuKit.Item(Loc.T("browser.copy_path"), GlyphKind.Copy, () => _ = CopyPathAsync(item.Path));
+
+ // Browse view folder: open it, or keep it as a sample folder.
+ private void AddBrowseFolderItems(MenuFlyout flyout, BrowserItem item)
+ {
+ flyout.Items.Add(MenuKit.Item(Loc.T("common.open"), null, () => _vm?.BrowseTo(item.Path)));
+ if (_settings is not null && !item.IsVolume)
+ flyout.Items.Add(MenuKit.Item(Loc.T("browser.add_this_folder"), GlyphKind.Plus,
+ () => Say(SampleFolderUi.AddAll(_settings, new[] { item.Path }) ?? Loc.F("browser.folder_added", item.Name))));
+ }
+
+ // --- Locate (spec 092, #581) ------------------------------------------------------------
+
+ /// <summary>Shows <paramref name="path"/> in the Files tab: in the tree when it lies in a
+ /// sample folder (its folders opened, scrolled to, selected — not auditioned), otherwise in
+ /// the browse view at its folder.</summary>
+ public void RevealFile(string path)
+ {
+ if (_vm is null) return;
+ _revealWaiting = null; // a newer Locate replaces one still waiting for the tree
+ SetCollapsed(false, persist: true);
+ SelectTab(FilesTab);
+ var inFolder = _settings?.ResolvedSampleFolders().Any(f => f.Available && SampleFolderRules.IsSameOrInside(path, f.Path)) == true;
+ if (inFolder)
+ {
+ if (BrowseOn) { _vm.BrowseMode = false; ApplyBrowseMode(); }
+ _search.Text = "";
+ var row = _vm.RevealSample(path);
+ if (row is null)
+ {
+ // The tree is still being walked (startup, a big folder just added): try
+ // again once it is in.
+ if (_vm.SamplesBuilding)
+ {
+ _revealWaiting = path; // the latest request wins
+ if (!_revealHooked) { _revealHooked = true; _vm.SamplesRebuilt += RevealWaiting; }
+ }
+ return;
+ }
+ _suppressPreview = true;
+ _pages[FilesTab].SelectedItem = row;
+ _pages[FilesTab].ScrollIntoView(row);
+ _suppressPreview = false;
+ }
+ else
+ {
+ _search.Text = ""; // a query that misses the file would filter it out of view
+ if (!BrowseOn) { _vm.BrowseMode = true; ApplyBrowseMode(); }
+ _vm.BrowseTo(System.IO.Path.GetDirectoryName(path) ?? path, path);
+ }
+ }
+
+ private bool _suppressPreview;
+ private string? _revealWaiting;
+ private bool _revealHooked;
+
+ // The tree came in: reveal the last file asked for while it was being walked, if any.
+ private void RevealWaiting()
+ {
+ if (_vm is not null) _vm.SamplesRebuilt -= RevealWaiting;
+ _revealHooked = false;
+ var p = _revealWaiting;
+ _revealWaiting = null;
+ if (p is not null) RevealFile(p);
+ }
+}
diff --git a/src/managed/Nota.App/BrowserView.Projects.cs b/src/managed/Nota.App/BrowserView.Projects.cs
new file mode 100644
index 00000000..59343ea0
--- /dev/null
+++ b/src/managed/Nota.App/BrowserView.Projects.cs
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The browser's Projects tab rows and order (spec 092, #582): newest first by default, a
+// Date | Name switch, and a two-line row — the name (with a dot on the open project), then
+// the save date, tempo, key, length and track count in muted ink as they are read.
+
+using System.Collections.Generic;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.Shapes;
+using Avalonia.Layout;
+using Avalonia.Media;
+using Nota.Application;
+using Nota.Application.Localization;
+using Nota.Presentation;
+
+namespace Nota.App;
+
+public sealed partial class BrowserView
+{
+ private const int ProjectsTab = 5;
+ private Border _projectsBar = null!;
+ private Border _projectsSortSeg = null!;
+
+ private Control BuildProjectsBar()
+ {
+ _projectsSortSeg = SessionView.Segmented(new[] { Loc.T("browser.sort_date"), Loc.T("browser.sort_name") }, 0,
+ i => { if (_vm is not null) _vm.ProjectsSort = i == 1 ? ProjectsSortOrder.Name : ProjectsSortOrder.Date; });
+ _projectsSortSeg.HorizontalAlignment = HorizontalAlignment.Left;
+ ToolTip.SetTip(_projectsSortSeg, Loc.T("browser.sort_projects"));
+ _projectsBar = new Border { Margin = new Thickness(8, 0, 8, 6), Child = _projectsSortSeg, IsVisible = false };
+ return _projectsBar;
+ }
+
+ private void HookProjects(BrowserViewModel vm)
+ {
+ if (_projectsSortSeg.Child is Avalonia.Controls.Primitives.UniformGrid g)
+ for (int i = 0; i < g.Children.Count; i++)
+ if (g.Children[i] is Avalonia.Controls.Primitives.ToggleButton tb) tb.IsChecked = (i == 1) == (vm.ProjectsSort == ProjectsSortOrder.Name);
+ }
+
+ private void UpdateProjectsBar()
+ {
+ bool on = _active == ProjectsTab && _vm is not null;
+ _projectsBar.IsVisible = on;
+ if (on) _vm!.RebuildProjects(); // saved since last time: newest first again
+ }
+
+ // Line 1: name (+ the open project's dot). Line 2: "11/12/2026 14:20 · 124 BPM · Am · 3:42 · 12 tracks".
+ private Control ProjectRow(BrowserItem item)
+ {
+ var edge = new Border { Classes = { "RowEdge" } };
+ var name = new TextBlock { Text = item.Name, Classes = { "RowName" }, TextTrimming = TextTrimming.CharacterEllipsis, VerticalAlignment = VerticalAlignment.Center };
+ var dot = new Ellipse { Width = 6, Height = 6, Margin = new Thickness(6, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center, IsVisible = item.IsOpen };
+ dot.BindResource(Shape.FillProperty, "Brush.Accent");
+ ToolTip.SetTip(dot, Loc.T("browser.project_open"));
+ var line1 = new DockPanel { LastChildFill = true };
+ DockPanel.SetDock(dot, Dock.Right);
+ line1.Children.Add(dot);
+ line1.Children.Add(name);
+
+ var details = new TextBlock { Classes = { "RowTag" }, TextTrimming = TextTrimming.CharacterEllipsis, Text = ProjectDetails(item) };
+ var stack = new StackPanel { Spacing = 1, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(20, 0, 9, 0), Children = { line1, details } };
+ var grid = new Grid { Height = 40, ColumnDefinitions = new ColumnDefinitions("Auto,*"), Background = Brushes.Transparent };
+ grid.Children.Add(edge);
+ Grid.SetColumn(stack, 1);
+ grid.Children.Add(stack);
+
+ void Changed(object? _, System.ComponentModel.PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == nameof(BrowserItem.Summary)) details.Text = ProjectDetails(item);
+ else if (e.PropertyName == nameof(BrowserItem.IsOpen)) dot.IsVisible = item.IsOpen;
+ }
+ grid.AttachedToVisualTree += (_, _) => { item.PropertyChanged -= Changed; item.PropertyChanged += Changed; details.Text = ProjectDetails(item); dot.IsVisible = item.IsOpen; };
+ grid.DetachedFromVisualTree += (_, _) => item.PropertyChanged -= Changed;
+ ToolTip.SetTip(grid, item.Path);
+ return grid;
+ }
+
+ private static string ProjectDetails(BrowserItem item)
+ {
+ var parts = new List<string>();
+ if (item.Sub.Length > 0) parts.Add(item.Sub);
+ if (item.Summary is { } s)
+ {
+ parts.Add(Loc.F("browser.bpm", s.Bpm.ToString("0.##", NotaNum.Culture)));
+ if (!string.IsNullOrEmpty(s.Key)) parts.Add(s.Key!);
+ if (s.LengthBeats > 0) parts.Add(s.LengthText);
+ parts.Add(Loc.Plural("browser.project_tracks", s.TrackCount));
+ }
+ return string.Join(" · ", parts);
+ }
+}
diff --git a/src/managed/Nota.App/BrowserView.cs b/src/managed/Nota.App/BrowserView.cs
index 2493ecd5..e51ffff4 100644
--- a/src/managed/Nota.App/BrowserView.cs
+++ b/src/managed/Nota.App/BrowserView.cs
@@ -38,7 +38,7 @@ using Nota.Application.Localization;
namespace Nota.App;
-public sealed class BrowserView : UserControl
+public sealed partial class BrowserView : UserControl
{
// The browser drag payload. macOS's native drag session requires exactly one
// pasteboard item per drag image, and Avalonia makes one drag image per data
@@ -415,7 +415,7 @@ public sealed class BrowserView : UserControl
contentHost.Children.Add(_emptyWrap);
var right = new DockPanel();
- var topStack = new StackPanel { Children = { headerRow, _categoryChipsHost, _chipsHost, _sampleChipsHost } };
+ var topStack = new StackPanel { Children = { headerRow, BuildFilesBars(), BuildProjectsBar(), _categoryChipsHost, _chipsHost, _sampleChipsHost } };
DockPanel.SetDock(topStack, Dock.Top);
DockPanel.SetDock(_statusBar, Dock.Bottom);
DockPanel.SetDock(_previewFooter, Dock.Bottom);
@@ -565,6 +565,8 @@ public sealed class BrowserView : UserControl
if (!ReferenceEquals(_chipsAnchor, vm.SimilarAnchor) || _chipsFilter != vm.SampleFilter) RebuildSampleChips();
};
RebuildSampleChips();
+ HookBrowse(vm);
+ HookProjects(vm);
RefreshCounts();
}
@@ -573,7 +575,7 @@ public sealed class BrowserView : UserControl
0 => _vm?.Instruments,
1 => _vm?.Effects,
2 => _vm?.MidiEffects,
- 3 => _vm?.Samples,
+ 3 => _vm is null ? null : _vm.BrowseMode ? _vm.BrowseItems : _vm.Samples,
4 => _vm?.Presets,
_ => null,
};
@@ -642,6 +644,10 @@ public sealed class BrowserView : UserControl
bool sampleFilter = tab == FilesTab && _vm is not null && (!_vm.SampleFilter.IsEmpty || _vm.SimilarAnchor is not null);
if (sampleFilter && _vm!.IndexProgress.Total > 0)
return (Loc.T("browser.no_matches_yet"), Loc.T("browser.nota_is_still_analysing_your"));
+ if (tab == FilesTab && BrowseOn && !searching)
+ return _vm!.BrowseState == BrowseListState.Unreadable
+ ? (Loc.T("browser.folder_unreadable"), "")
+ : (Loc.T("browser.folder_empty"), "");
if (searching || filtering || sampleFilter) return (Loc.T("browser.no_matches"), Loc.T("browser.try_a_different_search_or"));
return tab switch
{
@@ -677,6 +683,8 @@ public sealed class BrowserView : UserControl
}
int n = VisibleCount(tab);
// Filtered, the folders on screen are only there to hold the matches: count those.
+ if (tab == FilesTab && BrowseOn)
+ return Loc.Plural("browser.samples", System.Linq.Enumerable.Count(_vm.BrowseItems, s => s.Kind is BrowserItemKind.Sample or BrowserItemKind.MidiFile));
if (tab == FilesTab && _vm.SimilarAnchor is not null || tab == FilesTab && !_vm.SampleFilter.IsEmpty)
n = System.Linq.Enumerable.Count(_vm.Samples, s => s.Kind != BrowserItemKind.Folder);
return tab switch
@@ -721,7 +729,9 @@ public sealed class BrowserView : UserControl
// Favorite/tag filter chips apply only to the device tabs.
_chipsHost.IsVisible = index is 0 or 1 or 2;
RebuildCategoryChips();
- _sampleChipsHost.IsVisible = index == FilesTab && _vm?.HasSampleIndex == true;
+ UpdateFilesBars();
+ UpdateProjectsBar();
+ if (index == FilesTab) _vm?.RefreshSampleAvailability(); // a drive plugged in or pulled out meanwhile
_statusBar.IsVisible = !isMap;
if (isMap) { _matchCount.Text = ""; _emptyWrap.IsVisible = false; return; }
// The shared search box may have changed on another tab (#342).
@@ -773,7 +783,7 @@ public sealed class BrowserView : UserControl
private IDataTemplate BuildItemTemplate() => new FuncDataTemplate<BrowserItem>((item, _) =>
{
if (item is null) return new Control();
- return item.IsGroup ? GroupRow(item) : IndexRow(item);
+ return item.IsGroup ? GroupRow(item) : item.Kind == BrowserItemKind.Project ? ProjectRow(item) : IndexRow(item);
}, supportsRecycling: false);
// A section header: caption, a hairline filling the gap, and the section's count.
@@ -859,24 +869,54 @@ public sealed class BrowserView : UserControl
{
icon = RailIcon(GlyphKind.Downloads, 13, "Brush.TextSecondary");
}
+ // The Files browse view (spec 092): every row says what it is — folder, drive, audio,
+ // MIDI or another file — since folders open with a click rather than a caret.
+ else if (IsBrowseRow(item))
+ {
+ var kind = item.IsVolume ? GlyphKind.Drive
+ : item.Kind switch
+ {
+ BrowserItemKind.Folder => GlyphKind.Folder,
+ BrowserItemKind.Sample => GlyphKind.AudioFile,
+ BrowserItemKind.MidiFile => GlyphKind.Midi,
+ _ => GlyphKind.Doc,
+ };
+ icon = RailIcon(kind, 14, item.Kind switch
+ {
+ BrowserItemKind.Folder => "Brush.TextSecondary",
+ BrowserItemKind.OtherFile => "Brush.TextDisabled",
+ _ => "Brush.TextTertiary",
+ });
+ }
// A built-in row shows its distinctive word only ("Aurora", not "Nota Aurora"): the
// family name would repeat down the whole list. Search still matches the full name.
var name = new TextBlock
{
- Text = item.Prefix.Length > 0 ? item.ShortName : item.Name,
+ // Files and folders keep their real names ("Nota Samples" is a folder, not a device).
+ // (The factory kits' node is Nota's own and keeps its short name.)
+ Text = item.Prefix.Length > 0 && (item.Sub == "factory" || item.Kind is not (BrowserItemKind.Folder or BrowserItemKind.Sample or BrowserItemKind.MidiFile))
+ ? item.ShortName : item.Name,
Classes = { "RowName" },
TextTrimming = TextTrimming.CharacterEllipsis,
};
- if (child) name.Classes.Add("child");
+ if (child || item.Size is not null) name.Classes.Add("child");
+ if (item.Unavailable) name.Classes.Add("unavailable");
+ // The selected clip's source file (spec 092, #581): an orange edge and name.
+ void MarkLocated() { edge.Classes.Set("located", item.Located); name.Classes.Set("located", item.Located); }
+ MarkLocated();
// The type, as a quiet tag on the right edge (toggleable in the ⋮ menu). A sample's
// tag is what the index heard — "124 · Am" — and fills in as the scan reaches it.
- bool sample = item.Kind == BrowserItemKind.Sample;
- string tag = sample ? SampleTag(item) : item.Kind == BrowserItemKind.MidiFile ? RowTag(item) : Capital(RowTag(item));
+ bool browseFile = item.Size is not null;
+ bool sample = item.Kind == BrowserItemKind.Sample && !browseFile;
+ string tag = browseFile ? Extension(item) : sample ? SampleTag(item) : item.Kind == BrowserItemKind.MidiFile ? RowTag(item) : Capital(RowTag(item));
TextBlock? tagText = null;
- if (sample || (tag.Length > 0 && (_settings?.Current.BrowserShowTypeTags ?? true)))
+ if (sample || browseFile || (tag.Length > 0 && (_settings?.Current.BrowserShowTypeTags ?? true)))
tagText = new TextBlock { Text = tag, Classes = { "RowTag" }, TextTrimming = TextTrimming.CharacterEllipsis };
+ TextBlock? sizeText = item.Size is { } bytes
+ ? new TextBlock { Text = FileSize(bytes), Classes = { "RowTag" }, TextAlignment = TextAlignment.Right }
+ : null;
var row = new IndexRowPanel
{
@@ -888,22 +928,41 @@ public sealed class BrowserView : UserControl
Name2 = name,
Markers = BuildRowMarkers(item), // brass ★ + tag colour dots
Tag2 = tagText,
+ Size2 = sizeText,
};
+ // A file Nota can't add stays in the list, in the disabled ink (spec 092).
+ if (item.Kind == BrowserItemKind.OtherFile)
+ {
+ name.Classes.Add("inert");
+ tagText?.Classes.Add("inert");
+ sizeText?.Classes.Add("inert");
+ }
// The row's full identity lives in the tooltip, where the tag has no room for it
// (a plug-in's format, a sample's folder, tempo and key).
string tip = item.Tip.Length > 0 ? item.Tip : item.Sub;
ToolTip.SetTip(row, tip.Length > 0 ? $"{item.Name} · {tip}" : item.Name);
+ // Every other file row still follows Locate's mark as the selected clip changes.
+ if (!sample && item.Kind is BrowserItemKind.Sample or BrowserItemKind.MidiFile)
+ {
+ void Relocate(object? _, System.ComponentModel.PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName == nameof(BrowserItem.Located)) MarkLocated();
+ }
+ row.AttachedToVisualTree += (_, _) => { item.PropertyChanged -= Relocate; item.PropertyChanged += Relocate; MarkLocated(); };
+ row.DetachedFromVisualTree += (_, _) => item.PropertyChanged -= Relocate;
+ }
if (sample)
{
- void Retag(object? _, System.ComponentModel.PropertyChangedEventArgs __)
+ void Retag(object? _, System.ComponentModel.PropertyChangedEventArgs e)
{
+ if (e.PropertyName == nameof(BrowserItem.Located)) { MarkLocated(); return; }
tagText!.Text = SampleTag(item);
row.InvalidateArrange();
}
// Subscribe only while shown: the item outlives its rows (they are rebuilt on every
// scroll), so a lasting handler would pin every row ever drawn.
- row.AttachedToVisualTree += (_, _) => { item.PropertyChanged -= Retag; item.PropertyChanged += Retag; tagText!.Text = SampleTag(item); };
+ row.AttachedToVisualTree += (_, _) => { item.PropertyChanged -= Retag; item.PropertyChanged += Retag; tagText!.Text = SampleTag(item); MarkLocated(); };
row.DetachedFromVisualTree += (_, _) => item.PropertyChanged -= Retag;
row.PointerEntered += (_, _) =>
{
@@ -917,6 +976,25 @@ public sealed class BrowserView : UserControl
return row;
}
+ // A browse row (spec 092): a listed folder / drive / file of the browse view.
+ private static bool IsBrowseRow(BrowserItem item)
+ => item.Size is not null || item.IsVolume
+ || item.Kind == BrowserItemKind.Folder && !item.HasChildren && item.PlaceIndex < 0 && item.Path.Length > 0
+ && System.IO.Path.IsPathRooted(item.Path) && item.Sub != "factory";
+
+ private static string Extension(BrowserItem item)
+ => System.IO.Path.GetExtension(item.Path).TrimStart('.').ToLowerInvariant();
+
+ // "820 KB", "12.4 MB" — the browse view's size column.
+ private static string FileSize(long bytes)
+ {
+ const double K = 1024;
+ if (bytes < K) return Loc.F("browser.size_b", bytes);
+ if (bytes < K * K) return Loc.F("browser.size_kb", Math.Round(bytes / K).ToString("0", NotaNum.Culture));
+ if (bytes < K * K * K) return Loc.F("browser.size_mb", (bytes / (K * K)).ToString(bytes < 10 * K * K ? "0.0" : "0", NotaNum.Culture));
+ return Loc.F("browser.size_gb", (bytes / (K * K * K)).ToString("0.0", NotaNum.Culture));
+ }
+
// "124 · Am", a hit's note, or (until analysed, or with nothing to say) the file type.
private string SampleTag(BrowserItem item)
{
@@ -941,6 +1019,9 @@ public sealed class BrowserView : UserControl
public TextBlock Name2 { get; init; } = null!;
public Control? Markers { get; init; }
public TextBlock? Tag2 { get; init; }
+ /// <summary>The browse view's size column: fixed width, so sizes line up.</summary>
+ public TextBlock? Size2 { get; init; }
+ private const double SizeW = 54;
protected override Size MeasureOverride(Size availableSize)
{
@@ -960,6 +1041,7 @@ public sealed class BrowserView : UserControl
Children.Add(Name2);
if (Markers is not null) Children.Add(Markers);
if (Tag2 is not null) Children.Add(Tag2);
+ if (Size2 is not null) Children.Add(Size2);
}
protected override Size ArrangeOverride(Size finalSize)
@@ -979,6 +1061,11 @@ public sealed class BrowserView : UserControl
}
double right = Math.Max(left, finalSize.Width - Gutter);
+ if (Size2 is not null)
+ {
+ Size2.Arrange(new Rect(right - SizeW, (h - Size2.DesiredSize.Height) / 2, SizeW, Size2.DesiredSize.Height));
+ right = Math.Max(left, right - SizeW - 8);
+ }
double markersW = Markers?.DesiredSize.Width ?? 0;
double avail = Math.Max(0, right - left - (markersW > 0 ? markersW + 6 : 0));
@@ -1159,7 +1246,7 @@ public sealed class BrowserView : UserControl
{
int i = rows.IndexOf(item);
for (int j = i + 1; i >= 0 && j < rows.Count; j++)
- if (rows[j] is BrowserItem { IsGroup: false } r && r.Kind != BrowserItemKind.Folder) { next = r; break; }
+ if (rows[j] is BrowserItem { IsGroup: false } r && r.Kind is not (BrowserItemKind.Folder or BrowserItemKind.OtherFile)) { next = r; break; }
}
_previewFooter.SetItem(item, next);
}
@@ -1176,14 +1263,18 @@ public sealed class BrowserView : UserControl
list.DoubleTapped += (_, e) =>
{
if (list.SelectedItem is not BrowserItem { IsGroup: false } item) return;
+ if (item.Kind == BrowserItemKind.OtherFile) return; // listed, but nothing Nota can open
// Folders (sample dirs, preset categories) are navigation: double-click opens them.
- if (item.Kind == BrowserItemKind.Folder) _vm?.ToggleExpand(item);
+ // In Browse a single click already opened it; a second open would go one deeper.
+ if (item.Kind == BrowserItemKind.Folder && list == _pages[FilesTab] && BrowseOn) return;
+ else if (item.Kind == BrowserItemKind.Folder) _vm?.ToggleExpand(item);
else { DismissPreview(); ItemActivated?.Invoke(item, e.KeyModifiers); }
};
list.SelectionChanged += (_, _) =>
{
// Section headers are chrome: never let one become the selection.
if (list.SelectedItem is BrowserItem { IsGroup: true }) { list.SelectedItem = null; return; }
+ if (_suppressPreview) return; // Locate selects a row without auditioning it
if (_active <= PresetsTab && list == _pages[_active])
{
SyncPreview(list);
@@ -1202,8 +1293,13 @@ public sealed class BrowserView : UserControl
list.AddHandler(InputElement.PointerPressedEvent, OnRowPressed, RoutingStrategies.Bubble, handledEventsToo: true);
list.AddHandler(InputElement.PointerMovedEvent, OnRowMoved, RoutingStrategies.Bubble, handledEventsToo: true);
list.AddHandler(InputElement.PointerReleasedEvent,
- (object? _, PointerReleasedEventArgs _) =>
+ (object? _, PointerReleasedEventArgs e) =>
{
+ // A Browse folder opens on a click (contracts/ui.md), released on the row it was pressed on.
+ if (_pressedFolder is { } folder && list == _pages[FilesTab] && BrowseOn
+ && (e.Source as StyledElement)?.DataContext == folder && !folder.Unavailable)
+ _vm?.BrowseTo(folder.Path);
+ _pressedFolder = null;
_pressedItem = null; _pressArgs = null;
if (_listPointerDown && _active <= PresetsTab && list == _pages[_active]) ShowPreview(true);
_listPointerDown = false;
@@ -1214,16 +1310,21 @@ public sealed class BrowserView : UserControl
list.ContextRequested += (_, e) => ShowContextMenu(list, e);
}
+ private BrowserItem? _pressedFolder; // a Browse folder row pressed; opens on release
+
private void OnRowPressed(object? sender, PointerPressedEventArgs e)
{
_pressedItem = null;
_pressArgs = null;
+ _pressedFolder = null;
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
if (InButton(e.Source as StyledElement)) return; // preview button etc.
var item = (e.Source as StyledElement)?.DataContext as BrowserItem;
+ if (item is { Kind: BrowserItemKind.Folder, IsGroup: false } && e.ClickCount == 1 && BrowseOn && IsBrowseRow(item))
+ _pressedFolder = item;
// Projects, folders and section headers aren't draggable (folders are navigation,
// not payload; headers are chrome).
- if (item is null || item.IsGroup || item.Kind is BrowserItemKind.Project or BrowserItemKind.Folder) return;
+ if (item is null || item.IsGroup || item.Kind is BrowserItemKind.Project or BrowserItemKind.Folder or BrowserItemKind.OtherFile) return;
_pressedItem = item;
_pressPoint = e.GetPosition(this);
_pressArgs = e; // DoDragDropAsync needs the PointerPressed args
@@ -1588,6 +1689,7 @@ public sealed class BrowserView : UserControl
BrowserItemKind.Project => Loc.T("browser.project"),
BrowserItemKind.Preset => Loc.T("browser.preset"),
BrowserItemKind.Folder => Loc.T("browser.folder"),
+ BrowserItemKind.OtherFile => Loc.T("browser.file"),
_ => "",
};
@@ -1634,6 +1736,7 @@ public sealed class BrowserView : UserControl
reveal.Click += (_, _) => RevealRequested?.Invoke(item);
flyout.Items.Add(similar);
flyout.Items.Add(reveal);
+ flyout.Items.Add(CopyPathItem(item));
return flyout;
}
// A saved preset file on disk (#234). Synthetic rows (factory presets, drum kits)
@@ -1658,21 +1761,29 @@ public sealed class BrowserView : UserControl
}
case BrowserItemKind.Sample:
case BrowserItemKind.MidiFile:
+ case BrowserItemKind.OtherFile:
{
var reveal = new MenuItem { Header = MenuKit.RevealLabel };
reveal.Click += (_, _) => RevealRequested?.Invoke(item);
flyout.Items.Add(reveal);
+ flyout.Items.Add(CopyPathItem(item));
return flyout;
}
case BrowserItemKind.Folder when _active == FilesTab: // real sample folders (preset folders are synthetic)
{
- var multi = new MenuItem { Header = Loc.T("browser.create_multisample") };
- multi.Click += (_, _) => CreateMultisampleRequested?.Invoke(item);
- ToolTip.SetTip(multi, Loc.T("browser.map_the_folders_samples_by"));
- var reveal = new MenuItem { Header = MenuKit.RevealLabel };
+ if (BrowseOn) AddBrowseFolderItems(flyout, item);
+ if (!item.Unavailable && !item.IsVolume)
+ {
+ var multi = new MenuItem { Header = Loc.T("browser.create_multisample") };
+ multi.Click += (_, _) => CreateMultisampleRequested?.Invoke(item);
+ ToolTip.SetTip(multi, Loc.T("browser.map_the_folders_samples_by"));
+ flyout.Items.Add(multi);
+ }
+ var reveal = new MenuItem { Header = MenuKit.RevealLabel, IsEnabled = !item.Unavailable };
reveal.Click += (_, _) => RevealRequested?.Invoke(item);
- flyout.Items.Add(multi);
flyout.Items.Add(reveal);
+ flyout.Items.Add(CopyPathItem(item));
+ if (!BrowseOn && item.PlaceIndex >= 0) { flyout.Items.Add(new Separator()); AddPlaceItems(flyout, item); }
return flyout;
}
case BrowserItemKind.Project:
diff --git a/src/managed/Nota.App/Controls/Glyph.cs b/src/managed/Nota.App/Controls/Glyph.cs
index bc56a6c5..64882a5d 100644
--- a/src/managed/Nota.App/Controls/Glyph.cs
+++ b/src/managed/Nota.App/Controls/Glyph.cs
@@ -40,6 +40,7 @@ internal enum GlyphKind
Lock, LockOpen, // a reference (read-only) clip in the multi-clip editor, and the unlocked toggle
DockIn, // PopOut's opposite: bring a floating window back into the main one
Expand, Shrink, // a panel filling the window, and back to its split
+ Home, Drive, AudioFile, // the Files browse view: home folder, a drive, an audio file (spec 092)
Menu, // the transport bar's Menu key: the whole app menu on Windows / Linux (#518)
}
@@ -339,22 +340,6 @@ internal sealed class Glyph : Control
Stroke(ctx, pen, new Point(cx - d + hd, y2 - hd), new Point(cx - d, y2), new Point(cx - d + hd, y2 + hd));
break;
}
- case GlyphKind.Folder:
- {
- var g = new StreamGeometry();
- using (var c = g.Open())
- {
- c.BeginFigure(new Point(cx - s * 0.42, cy + s * 0.34), false);
- c.LineTo(new Point(cx - s * 0.42, cy - s * 0.34));
- c.LineTo(new Point(cx - s * 0.1, cy - s * 0.34));
- c.LineTo(new Point(cx + s * 0.02, cy - s * 0.2));
- c.LineTo(new Point(cx + s * 0.42, cy - s * 0.2));
- c.LineTo(new Point(cx + s * 0.42, cy + s * 0.34));
- c.EndFigure(true);
- }
- ctx.DrawGeometry(null, pen, g);
- break;
- }
case GlyphKind.Ungroup:
{
// Two blocks pulled apart.
@@ -464,6 +449,13 @@ internal sealed class Glyph : Control
// A five-point star, solid (a favourite).
[GlyphKind.StarFilled] = (null, "M12 3 L14.5 9 L21 9.3 L16 13.5 L17.7 20 L12 16.2 L6.3 20 L8 13.5 L3 9.3 L9.5 9 Z"),
// A bookmark (a saved preset).
+ // A folder with its tab (Files, groups, "show in Finder"): drawn on the shared grid with
+ // the rail's padding, so it is no bigger than its neighbours (#579).
+ [GlyphKind.Folder] = ("M4 7 a1.5 1.5 0 0 1 1.5 -1.5 h4.2 l2 2 h6.8 a1.5 1.5 0 0 1 1.5 1.5 v8 a1.5 1.5 0 0 1 -1.5 1.5 h-13 a1.5 1.5 0 0 1 -1.5 -1.5 z", null),
+ // The Files browse view (spec 092): home, a drive, an audio file's waveform.
+ [GlyphKind.Home] = ("M4 11.2 L12 4.5 L20 11.2 M6.5 9.4 V19.5 H17.5 V9.4 M10 19.5 V14.5 H14 V19.5", null),
+ [GlyphKind.Drive] = ("M3.5 13.5 h17 v5 a1 1 0 0 1 -1 1 h-15 a1 1 0 0 1 -1 -1 z M3.5 13.5 l2.6 -7.4 a1 1 0 0 1 0.95 -0.7 h9.9 a1 1 0 0 1 0.95 0.7 l2.6 7.4 M16 16.5 h1.5", null),
+ [GlyphKind.AudioFile] = ("M4 12 h1 M7.5 9 v6 M10.5 5.5 v13 M13.5 8.5 v7 M16.5 6.5 v11 M19.5 10 v4", null),
[GlyphKind.Bookmark] = ("M6.5 4 h11 v16 l-5.5 -4.399 l-5.5 4.399 z", null),
// A document with a dog-ear and two lines (a project).
[GlyphKind.Doc] = ("M6 3.5 h7.601 l4.8 4.8 v12.199 h-12.4 zM13.601 3.5 v4.8 h4.8 M9.2 13.399 h6 M9.2 16.8 h6", null),
diff --git a/src/managed/Nota.App/LocateMenu.cs b/src/managed/Nota.App/LocateMenu.cs
new file mode 100644
index 00000000..1642eb15
--- /dev/null
+++ b/src/managed/Nota.App/LocateMenu.cs
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The "Locate ▸ In browser / In Finder" submenu of an audio clip (spec 092, #581), shared by
+// the arrangement's clip menu and Session's slot menu. The views know the clip's sample id;
+// MainWindow supplies what to do (it knows the open project and the browser).
+
+using System;
+using Avalonia.Controls;
+using Nota.Application;
+using Nota.Application.Localization;
+
+namespace Nota.App;
+
+/// <summary>What a view needs to offer Locate: the file behind a sample and the two actions.</summary>
+internal sealed class LocateHooks
+{
+ /// <summary>The clip's source file if known and on disk, else null.</summary>
+ public required Func<long, string?> Source { get; init; }
+ /// <summary>The project's copy of the sample's audio, if saved, else null.</summary>
+ public required Func<long, string?> BundleCopy { get; init; }
+ public required Action<string> InBrowser { get; init; }
+ public required Action<string> InFileManager { get; init; }
+}
+
+internal static class LocateMenu
+{
+ /// <summary>"In Finder" in the platform's own words.</summary>
+ public static string FileManagerLabel =>
+ OperatingSystem.IsMacOS() ? Loc.T("clip.locate_in_finder")
+ : OperatingSystem.IsWindows() ? Loc.T("clip.locate_in_explorer")
+ : Loc.T("clip.locate_in_file_manager");
+
+ public static MenuItem Build(LocateHooks hooks, long sampleId)
+ {
+ string? source = hooks.Source(sampleId);
+ string? reveal = source ?? hooks.BundleCopy(sampleId);
+ var menu = MenuKit.Item(Loc.T("clip.locate"), GlyphKind.Search);
+ menu.Items.Add(MenuKit.Item(Loc.T("clip.locate_in_browser"), null,
+ () => { if (source is not null) hooks.InBrowser(source); }, enabled: source is not null));
+ menu.Items.Add(MenuKit.Item(FileManagerLabel, GlyphKind.Folder,
+ () => { if (reveal is not null) hooks.InFileManager(reveal); }, enabled: reveal is not null));
+ return menu;
+ }
+}
diff --git a/src/managed/Nota.App/MainWindow.Browser.cs b/src/managed/Nota.App/MainWindow.Browser.cs
index dea8dddb..cd3308eb 100644
--- a/src/managed/Nota.App/MainWindow.Browser.cs
+++ b/src/managed/Nota.App/MainWindow.Browser.cs
@@ -127,6 +127,43 @@ public partial class MainWindow
}
}
+ // --- Locate (spec 092, #581) ------------------------------------------------------------
+
+ // The arrangement and Session clip menus' Locate submenu, and the Files-tab highlight of
+ // the selected clip's source file.
+ private void InitLocate()
+ {
+ var hooks = new LocateHooks
+ {
+ Source = id => ClipFiles.Source(Engine, id),
+ BundleCopy = id => ClipFiles.BundleCopy(Engine, id, _projectPath),
+ InBrowser = path => Browser.RevealFile(path),
+ InFileManager = path =>
+ {
+ try { RevealInFileManager(path); }
+ catch (Exception ex) { if (_vm is not null) _vm.StatusText = Loc.F("main.browser.reveal_failed", ex.Message); }
+ },
+ };
+ Timeline.Locate = hooks;
+ if (_session is not null)
+ {
+ _session.Locate = hooks;
+ _session.SlotSelected += (t, s) => MarkLocated(SessionSource(t, s));
+ }
+ Timeline.ClipSelectionChanged += () => MarkLocated(ArrangementSource());
+ }
+
+ private void MarkLocated(string? path) => _vm?.Browser.SetLocatedPath(path);
+
+ // The selected arrangement clip's source file, when it is one audio clip with a known source.
+ private string? ArrangementSource()
+ => SelectedClip(out int t, out int c, out bool midi) && !midi && Engine.TryGetAudioClipInfo(t, c, out var ai)
+ ? ClipFiles.Source(Engine, ai.SampleId) : null;
+
+ private string? SessionSource(int trackId, int scene)
+ => trackId > 0 && scene >= 0 && Engine.TryGetSessionAudioSlot(trackId, scene, out var sa)
+ ? ClipFiles.Source(Engine, sa.SampleId) : null;
+
// Reveal a sample / folder / project in the OS file manager (Finder / Explorer / files).
private void OnBrowserReveal(BrowserItem item)
{
diff --git a/src/managed/Nota.App/MainWindow.Files.cs b/src/managed/Nota.App/MainWindow.Files.cs
index ee432022..373c81c0 100644
--- a/src/managed/Nota.App/MainWindow.Files.cs
+++ b/src/managed/Nota.App/MainWindow.Files.cs
@@ -194,6 +194,7 @@ public partial class MainWindow
_vm.Transport.KeyCode = -1;
_panLawLegacy = false; // new projects use the Stereo pan law (set by the template)
_projectPath = null;
+ if (_vm is not null) _vm.Browser.OpenProjectPath = null;
_learn?.Clear(); // start with a clean MIDI-map for the new project
Timeline.ResetTrackView(); // …at the default track sizes
Nota.Infrastructure.ProjectTemplate.ApplyDefault(Engine); // instrument, audio, Reverb + Delay returns
diff --git a/src/managed/Nota.App/MainWindow.Welcome.cs b/src/managed/Nota.App/MainWindow.Welcome.cs
index 1ed69fca..15daa392 100644
--- a/src/managed/Nota.App/MainWindow.Welcome.cs
+++ b/src/managed/Nota.App/MainWindow.Welcome.cs
@@ -84,8 +84,8 @@ public partial class MainWindow
if (string.IsNullOrWhiteSpace(path) || !Directory.Exists(path)) continue;
var name = Path.GetFileNameWithoutExtension(path.TrimEnd('/', '\\'));
string modified;
- try { modified = Directory.GetLastWriteTime(path).ToString("MM/dd/yyyy HH:mm", NotaNum.Culture); }
- catch { modified = ""; }
+ // The same date the browser's Projects tab shows (spec 092): the last save.
+ modified = Nota.Application.Browser.ProjectDates.Modified(path) is { } m ? Nota.Application.Browser.ProjectDates.Format(m) : "";
items.Add(new RecentProjectItem(name, path, modified));
}
return items;
@@ -104,6 +104,11 @@ public partial class MainWindow
if (list.Count > MaxRecentProjects) list.RemoveRange(MaxRecentProjects, list.Count - MaxRecentProjects);
settings.Save();
RefreshRecentMenu(); // File → Open recent follows the same list
+ if (_vm is not null)
+ {
+ _vm.Browser.OpenProjectPath = dir; // the Projects tab marks it, newest first
+ _vm.Browser.RebuildProjects();
+ }
}
catch { /* recent list is best-effort — never disrupt the open/save */ }
}
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index 8fc2f905..fca4bd68 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -450,6 +450,7 @@ public partial class MainWindow : Window
Browser.ItemActivated += OnBrowserItemActivated;
Browser.Preview.Attach(vm.Engine, vm.Settings, App.Services.GetRequiredService<IPresetAudition>());
Browser.Preview.StatusChanged += msg => { if (_vm is not null) _vm.StatusText = msg; };
+ Browser.StatusMessage += msg => { if (_vm is not null) _vm.StatusText = msg; }; // Files: path copied, folder not added (spec 092)
Browser.RevealRequested += OnBrowserReveal;
Browser.CreateMultisampleRequested += item => OpenMosaicCreate(new[] { item.Path }, -1);
Browser.DeleteProjectRequested += OnBrowserDeleteProject;
@@ -498,6 +499,7 @@ public partial class MainWindow : Window
};
HookRecentInstruments(); // "Add track ▸ Recent" in both views' menus
_session.SlotSelected += OnSessionSlotSelected;
+ InitLocate(); // clip menus' Locate ▸ and the Files highlight (spec 092)
Timeline.SessionChanged += () => _session?.Refresh(); // M5-6
MainContent.Children.Add(_session);
diff --git a/src/managed/Nota.App/PreferencesWindow.SampleFolders.cs b/src/managed/Nota.App/PreferencesWindow.SampleFolders.cs
new file mode 100644
index 00000000..2c4453d3
--- /dev/null
+++ b/src/managed/Nota.App/PreferencesWindow.SampleFolders.cs
@@ -0,0 +1,141 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Settings → Library → Sample folders (spec 092, #346): the list the browser's Files tab
+// shows, in place of the single Samples-folder picker. Built like the plug-in scan folders
+// list (a well of selectable rows over a row of buttons); folders can also be dropped onto
+// the well from the OS file manager. The list re-renders whenever it changes, here or from
+// the browser.
+
+using System;
+using System.Linq;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Layout;
+using Avalonia.Media;
+using Avalonia.Platform.Storage;
+using Nota.Application;
+using Nota.Application.Localization;
+
+namespace Nota.App;
+
+public sealed partial class PreferencesWindow
+{
+ private int _selSampleFolder;
+
+ private Control SampleFoldersSection(ISettingsService settings)
+ {
+ var list = new StackPanel();
+ var well = new Border
+ {
+ Background = Sunken, BorderBrush = Divider, BorderThickness = new Thickness(1),
+ CornerRadius = NotaRadius.Group, Padding = new Thickness(4), MinHeight = 96, Child = list,
+ };
+ DragDrop.SetAllowDrop(well, true);
+ var note = new TextBlock { FontSize = 10, Foreground = TextTertiary, TextWrapping = TextWrapping.Wrap, IsVisible = false };
+
+ var addBtn = Btn(Loc.T("preferences.add_folder"));
+ var defaultBtn = Btn(Loc.T("browser.set_as_default"));
+ var renameBtn = Btn(Loc.T("common.rename"));
+ var showBtn = Btn(Loc.T("common.show"));
+ var removeBtn = Btn(Loc.T("preferences.remove"));
+
+ void Note(string? text) { note.Text = text ?? ""; note.IsVisible = !string.IsNullOrEmpty(text); }
+
+ void Render()
+ {
+ var folders = settings.ResolvedSampleFolders();
+ list.Children.Clear();
+ if (_selSampleFolder >= folders.Count) _selSampleFolder = folders.Count - 1;
+ if (_selSampleFolder < 0) _selSampleFolder = 0;
+ foreach (var f in folders)
+ {
+ bool sel = f.Index == _selSampleFolder;
+ var name = new TextBlock
+ {
+ Text = f.Label, FontSize = 11, FontWeight = FontWeight.SemiBold,
+ Foreground = f.Available ? TextPrimary : TextTertiary,
+ VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis,
+ };
+ var path = new TextBlock
+ {
+ Text = f.Path, FontSize = 10, FontFamily = NotaFonts.UiFamily, Foreground = sel ? TextSecondary : TextTertiary,
+ VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis,
+ };
+ string tagText = (f.IsDefault, f.Available) switch
+ {
+ (true, true) => Loc.T("preferences.default"),
+ (true, false) => Loc.T("preferences.default_unavailable"),
+ (false, false) => Loc.T("browser.unavailable"),
+ _ => "",
+ };
+ var tag = new TextBlock { Text = tagText, FontSize = 9, Foreground = TextTertiary, VerticalAlignment = VerticalAlignment.Center };
+ var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto"), ColumnSpacing = 10 };
+ grid.Children.Add(name);
+ Grid.SetColumn(path, 1); grid.Children.Add(path);
+ Grid.SetColumn(tag, 2); grid.Children.Add(tag);
+ int idx = f.Index;
+ var row = new Border
+ {
+ Height = 28, Padding = new Thickness(8, 0), CornerRadius = NotaRadius.Field,
+ Background = sel ? AccentSubtle : Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand), Child = grid,
+ };
+ ToolTip.SetTip(row, f.Path);
+ row.PointerPressed += (_, _) => { _selSampleFolder = idx; Render(); };
+ list.Children.Add(row);
+ }
+ var cur = folders.Count > 0 ? folders[_selSampleFolder] : null;
+ removeBtn.IsEnabled = cur is not null && folders.Count > 1;
+ defaultBtn.IsEnabled = cur is { IsDefault: false, Available: true };
+ renameBtn.IsEnabled = cur is not null;
+ showBtn.IsEnabled = cur is { Available: true };
+ }
+
+ ResolvedSampleFolder? Selected()
+ {
+ var folders = settings.ResolvedSampleFolders();
+ return _selSampleFolder >= 0 && _selSampleFolder < folders.Count ? folders[_selSampleFolder] : null;
+ }
+
+ addBtn.Click += async (_, _) =>
+ {
+ Activate();
+ var picked = await this.PickFoldersAsync(new FolderPickerOpenOptions { Title = Loc.T("preferences.add_sample_folder"), AllowMultiple = true });
+ var paths = picked.Select(f => f.TryGetLocalPath()).OfType<string>().ToList();
+ if (paths.Count == 0) return;
+ Note(SampleFolderUi.AddAll(settings, paths));
+ _selSampleFolder = settings.ResolvedSampleFolders().Count - 1;
+ Render();
+ };
+ defaultBtn.Click += (_, _) => { if (Selected() is { } f) settings.SetDefaultSampleFolder(f.Index); };
+ renameBtn.Click += async (_, _) => { if (Selected() is { } f) await SampleFolderUi.RenameAsync(this, settings, f); };
+ showBtn.Click += (_, _) => { if (Selected() is { } f) { try { MainWindow.RevealInFileManager(f.Path); } catch { /* no file manager */ } } };
+ removeBtn.Click += async (_, _) => { if (Selected() is { } f) await SampleFolderUi.RemoveAsync(this, settings, f); };
+
+ well.AddHandler(DragDrop.DragOverEvent, (_, e) =>
+ {
+ e.DragEffects = BrowserView.ExternalPaths(e).Any(System.IO.Directory.Exists) ? DragDropEffects.Copy : DragDropEffects.None;
+ e.Handled = true;
+ });
+ well.AddHandler(DragDrop.DropEvent, (_, e) =>
+ {
+ var dirs = BrowserView.ExternalPaths(e).Where(System.IO.Directory.Exists).ToList();
+ if (dirs.Count == 0) return;
+ Note(SampleFolderUi.AddAll(settings, dirs));
+ e.Handled = true;
+ });
+
+ // The list can change from the browser too (Add folder…, a dropped folder, Remove).
+ Action changed = () => Avalonia.Threading.Dispatcher.UIThread.Post(Render);
+ well.AttachedToVisualTree += (_, _) => { settings.SampleFoldersChanged -= changed; settings.SampleFoldersChanged += changed; Render(); };
+ well.DetachedFromVisualTree += (_, _) => settings.SampleFoldersChanged -= changed;
+ Render();
+
+ return Section(Loc.T("preferences.sample_folders"), 10,
+ well,
+ new WrapPanel { Orientation = Orientation.Horizontal, ItemSpacing = 8, LineSpacing = 8, Children = { addBtn, defaultBtn, renameBtn, showBtn, removeBtn } },
+ note,
+ Caption(Loc.T("preferences.sample_folders_caption")));
+ }
+}
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index 798184a0..6955e1f2 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -966,11 +966,8 @@ public sealed partial class PreferencesWindow : NotaWindow
{
if (_main is null) return Caption(Loc.T("preferences.content_folders_are_unavailable_in"));
var settings = _main.Settings;
- return Sections(Section(Loc.T("preferences.content_folders"), 10, Table(new List<Control>
+ return Sections(SampleFoldersSection(settings), Section(Loc.T("preferences.content_folders"), 10, Table(new List<Control>
{
- FolderRow(Loc.T("preferences.samples"),
- () => settings.Current.SamplesFolder, () => settings.ResolvedSamplesFolder(),
- path => { settings.Current.SamplesFolder = path; settings.Save(); _main.Browser.RebuildSamples(); }),
FolderRow(Loc.T("preferences.projects"),
() => settings.Current.ProjectsFolder, () => settings.ResolvedProjectsFolder(),
path => { settings.Current.ProjectsFolder = path; settings.Save(); _main.Browser.RebuildProjects(); }),
@@ -1628,6 +1625,13 @@ public sealed partial class PreferencesWindow : NotaWindow
(Loc.T("preferences.drag_a_device_onto_a"), Loc.T("preferences.move_it_there_out_of")),
(Loc.T("preferences.drag_a_device_onto_a_2"), Loc.T("preferences.copy_it_there")),
}),
+ (Loc.T("preferences.browser_files_after_a_click"), new[]
+ {
+ ("⌘[ ⌘]", Loc.T("preferences.back_forward_in_the_browse")),
+ ("⌘↑", Loc.T("preferences.up_to_the_parent_folder")),
+ ("⌘L", Loc.T("preferences.type_or_paste_a_path")),
+ ("Return", Loc.T("preferences.open_the_selected_folder_browse")),
+ }),
(Loc.T("preferences.racks"), new[]
{
("Esc", Loc.T("preferences.end_macro_mapping_map_on")),
diff --git a/src/managed/Nota.App/SampleFolderUi.cs b/src/managed/Nota.App/SampleFolderUi.cs
new file mode 100644
index 00000000..173e0b8a
--- /dev/null
+++ b/src/managed/Nota.App/SampleFolderUi.cs
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The words and dialogs the sample-folder list (spec 092, #346 / #268) shares between the
+// browser's Files tab and Settings → Library: why a folder wasn't added, the rename prompt,
+// and the confirmation before the default folder is removed — so both places say the same.
+
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Avalonia.Controls;
+using Nota.Application;
+using Nota.Application.Localization;
+
+namespace Nota.App;
+
+internal static class SampleFolderUi
+{
+ /// <summary>A short note for a folder that wasn't added; null when it was.</summary>
+ public static string? Refusal(SampleFolderResult r, IReadOnlyList<ResolvedSampleFolder> folders)
+ {
+ string Other() => r.Other >= 0 && r.Other < folders.Count ? folders[r.Other].Label : "";
+ return r.Outcome switch
+ {
+ SampleFolderOutcome.Added => null,
+ SampleFolderOutcome.AlreadyPresent => Loc.T("browser.folder_already_added"),
+ SampleFolderOutcome.Inside => Loc.F("browser.folder_inside", Other()),
+ SampleFolderOutcome.Contains => Loc.F("browser.folder_contains", Other()),
+ _ => Loc.T("browser.not_a_folder"),
+ };
+ }
+
+ /// <summary>Adds each folder, returning the note for the last one refused (or null).</summary>
+ public static string? AddAll(ISettingsService settings, IEnumerable<string> paths)
+ {
+ string? note = null;
+ foreach (var p in paths)
+ {
+ var r = settings.AddSampleFolder(p);
+ note = Refusal(r, settings.ResolvedSampleFolders()) ?? note;
+ }
+ return note;
+ }
+
+ /// <summary>Asks for the label a folder shows; empty restores the folder's own name.</summary>
+ public static async Task RenameAsync(Window owner, ISettingsService settings, ResolvedSampleFolder folder)
+ {
+ var name = await new TextPromptWindow(Loc.T("browser.rename_folder"), Loc.T("browser.folder_label"), folder.Label)
+ .ShowDialog<string?>(owner);
+ if (name is null) return;
+ settings.RenameSampleFolder(folder.Index, name);
+ }
+
+ /// <summary>Forgets a folder (asks first when it is the default). Files on disk stay.</summary>
+ public static async Task RemoveAsync(Window owner, ISettingsService settings, ResolvedSampleFolder folder)
+ {
+ var all = settings.ResolvedSampleFolders();
+ if (all.Count <= 1) return;
+ if (folder.IsDefault)
+ {
+ int next = folder.Index < all.Count - 1 ? folder.Index + 1 : folder.Index - 1;
+ bool ok = await new ConfirmWindow(Loc.T("browser.remove_default_title"),
+ Loc.F("browser.remove_default_confirm", all[next].Label),
+ Loc.T("browser.remove_from_browser"), Loc.T("common.cancel")).ShowDialog<bool>(owner);
+ if (!ok) return;
+ }
+ settings.RemoveSampleFolder(folder.Index);
+ }
+}
diff --git a/src/managed/Nota.App/SessionView.Grid.cs b/src/managed/Nota.App/SessionView.Grid.cs
index 8340a22a..0603b587 100644
--- a/src/managed/Nota.App/SessionView.Grid.cs
+++ b/src/managed/Nota.App/SessionView.Grid.cs
@@ -884,6 +884,12 @@ public sealed partial class SessionView
// ---- context menus -------------------------------------------------------------------
+ // Locate ▸ for an audio take (spec 092, #581); nothing for a MIDI clip.
+ private Control[] LocateItems(int trackId, int scene)
+ => Locate is { } hooks && _engine.TryGetSessionAudioSlot(trackId, scene, out var sa)
+ ? new Control[] { LocateMenu.Build(hooks, sa.SampleId) }
+ : Array.Empty<Control>();
+
private void ShowSlotMenu(Control anchor, Column c, int scene)
{
bool filled = SlotFilled(c.TrackId, scene);
@@ -899,6 +905,7 @@ public sealed partial class SessionView
MenuKit.Item(Loc.T("common.edit"), GlyphKind.Edit, () => SlotEditRequested?.Invoke(c.TrackId, scene)),
MenuKit.Item(Loc.T("common.rename"), GlyphKind.Edit, () => RenameSelection(), new KeyGesture(Key.F2)),
},
+ LocateItems(c.TrackId, scene),
new Control[] { MenuKit.Item(Loc.T("session.grid.copy_to_arrangement"), GlyphKind.Arrow, () => CopySelectionToArrangement(), MenuKit.CopyToOtherViewKey) },
new Control[] { AddTrackSubmenu(c.TrackId) },
MenuKit.ClipboardGroup(() => CopySelection(), () => CutSelection(), () => PasteSelection(), () => DuplicateSelection(), CanPaste),
diff --git a/src/managed/Nota.App/SessionView.cs b/src/managed/Nota.App/SessionView.cs
index a95ea23f..a0419955 100644
--- a/src/managed/Nota.App/SessionView.cs
+++ b/src/managed/Nota.App/SessionView.cs
@@ -87,6 +87,8 @@ public sealed partial class SessionView : UserControl
/// <summary>Raised when the selection lands on another slot, or on a Return / Master column
/// (trackId, scene).</summary>
public event Action<int, int>? SlotSelected;
+ /// <summary>Set by the main window: what an audio take's Locate submenu does (spec 092).</summary>
+ internal LocateHooks? Locate { get; set; }
/// <summary>Raised after slots are copied / moved into the arrangement (M5-6) or a track is renamed.</summary>
public event Action? ArrangementChanged;
/// <summary>A context menu asked for a new track (kind, the track to place it after, or -1 = at the end).</summary>
diff --git a/src/managed/Nota.App/Theme/NotaTheme.axaml b/src/managed/Nota.App/Theme/NotaTheme.axaml
index 31894b9d..ecac109d 100644
--- a/src/managed/Nota.App/Theme/NotaTheme.axaml
+++ b/src/managed/Nota.App/Theme/NotaTheme.axaml
@@ -1231,6 +1231,24 @@
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="Foreground" Value="{DynamicResource Brush.TextSecondary}"/>
</Style>
+ <!-- Files (spec 092): the selected clip's source file wears the accent edge and name
+ (the selection adds its tint); a sample folder that can't be found is dimmed. -->
+ <Style Selector="Border.RowEdge.located">
+ <Setter Property="Background" Value="{DynamicResource Brush.Accent}"/>
+ </Style>
+ <Style Selector="TextBlock.RowName.located">
+ <Setter Property="Foreground" Value="{DynamicResource Brush.Accent}"/>
+ </Style>
+ <Style Selector="TextBlock.RowName.unavailable">
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextTertiary}"/>
+ </Style>
+ <!-- A browse-view file Nota can't add: listed, inert, in the disabled ink. -->
+ <Style Selector="TextBlock.RowName.inert">
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextDisabled}"/>
+ </Style>
+ <Style Selector="TextBlock.RowTag.inert">
+ <Setter Property="Foreground" Value="{DynamicResource Brush.TextDisabled}"/>
+ </Style>
<!-- Row metadata on the right: the label scale, 11 / 400 in ink 3. -->
<Style Selector="TextBlock.RowTag">
<Setter Property="FontFamily" Value="{DynamicResource Font.Measure}"/>
diff --git a/src/managed/Nota.Application/Browser/FileBrowseState.cs b/src/managed/Nota.Application/Browser/FileBrowseState.cs
new file mode 100644
index 00000000..1cf0aa87
--- /dev/null
+++ b/src/managed/Nota.Application/Browser/FileBrowseState.cs
@@ -0,0 +1,174 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Where the Files tab's browse view is (spec 092, #580): one folder, or the "Computer"
+// level above every drive, plus web-browser style Back / Forward history. Kept out of the
+// view so the smoke test can pin the navigation rules and the per-OS volume list.
+
+using System.Collections.Generic;
+using System.IO;
+
+namespace Nota.Application.Browser;
+
+public sealed class FileBrowseState
+{
+ /// <summary>The pseudo-location above the volume roots: a list of drives / volumes.</summary>
+ public const string Computer = "";
+
+ private const int HistoryCap = 100;
+ private readonly List<string> _back = new();
+ private readonly List<string> _forward = new();
+
+ public FileBrowseState(string start) { Location = start ?? Computer; }
+
+ /// <summary>The folder shown, or <see cref="Computer"/>.</summary>
+ public string Location { get; private set; }
+
+ public bool IsComputer => Location.Length == 0;
+ public bool CanGoBack => _back.Count > 0;
+ public bool CanGoForward => _forward.Count > 0;
+ public bool CanGoUp => !IsComputer;
+
+ /// <summary>Raised after <see cref="Location"/> changed.</summary>
+ public event Action? Changed;
+
+ /// <summary>Opens <paramref name="location"/>: the current one goes on the Back list and
+ /// the Forward list is cleared. Opening the current location again does nothing.</summary>
+ public void Go(string location)
+ {
+ location ??= Computer;
+ if (location.Length > 0) location = SampleFolderRules.Normalize(location);
+ if (SampleFolderRules.PathComparer.Equals(location, Location)) return;
+ Push(_back, Location);
+ _forward.Clear();
+ Location = location;
+ Changed?.Invoke();
+ }
+
+ public void GoBack()
+ {
+ if (_back.Count == 0) return;
+ Push(_forward, Location);
+ Location = Pop(_back);
+ Changed?.Invoke();
+ }
+
+ public void GoForward()
+ {
+ if (_forward.Count == 0) return;
+ Push(_back, Location);
+ Location = Pop(_forward);
+ Changed?.Invoke();
+ }
+
+ /// <summary>The parent folder; from a volume root, the Computer level.</summary>
+ public void Up()
+ {
+ if (IsComputer) return;
+ Go(ParentOf(Location));
+ }
+
+ /// <summary>The folder above <paramref name="folder"/>, or <see cref="Computer"/> for a
+ /// volume root (or a macOS volume under /Volumes).</summary>
+ public static string ParentOf(string folder)
+ {
+ folder = SampleFolderRules.Normalize(folder);
+ if (folder.Length == 0) return Computer;
+ string root = Path.GetPathRoot(folder) ?? "";
+ if (SampleFolderRules.PathComparer.Equals(folder, root)) return Computer;
+ if (OperatingSystem.IsMacOS() && SampleFolderRules.PathComparer.Equals(Path.GetDirectoryName(folder), "/Volumes"))
+ return Computer;
+ return Path.GetDirectoryName(folder) ?? Computer;
+ }
+
+ /// <summary>The path bar's segments, outermost first: each with the folder it opens.</summary>
+ public IReadOnlyList<(string Label, string Path)> Segments()
+ {
+ var list = new List<(string, string)>();
+ if (IsComputer) return list;
+ for (string? p = Location; !string.IsNullOrEmpty(p); p = ParentOf(p))
+ {
+ string name = Path.GetFileName(p);
+ if (name.Length == 0) name = VolumeLabel(p);
+ list.Insert(0, (name, p));
+ if (ParentOf(p).Length == 0) break;
+ }
+ return list;
+ }
+
+ /// <summary>The drives / volumes the Computer level lists: (label, root path).</summary>
+ public static IReadOnlyList<(string Label, string Path)> Volumes()
+ {
+ var list = new List<(string, string)>();
+ try
+ {
+ if (OperatingSystem.IsWindows())
+ {
+ foreach (var d in DriveInfo.GetDrives())
+ {
+ if (!d.IsReady) continue;
+ string label = string.IsNullOrWhiteSpace(d.VolumeLabel) ? d.Name.TrimEnd('\\') : $"{d.VolumeLabel} ({d.Name.TrimEnd('\\')})";
+ list.Add((label, d.RootDirectory.FullName));
+ }
+ }
+ else if (OperatingSystem.IsMacOS())
+ {
+ list.Add((VolumeLabel("/"), "/"));
+ if (Directory.Exists("/Volumes"))
+ foreach (var v in Directory.EnumerateDirectories("/Volumes"))
+ {
+ // The boot volume appears here too, as a symlink to "/".
+ var info = new DirectoryInfo(v);
+ if (info.LinkTarget is not null) continue;
+ if (info.Name.StartsWith('.')) continue;
+ list.Add((info.Name, v));
+ }
+ }
+ else
+ {
+ list.Add(("/", "/"));
+ string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
+ if (home.Length > 0) list.Add((Path.GetFileName(home), home));
+ string user = Environment.UserName;
+ foreach (var parent in new[] { $"/media/{user}", $"/run/media/{user}", "/mnt" })
+ if (Directory.Exists(parent))
+ foreach (var m in Directory.EnumerateDirectories(parent)) list.Add((Path.GetFileName(m), m));
+ }
+ }
+ catch { /* best effort: an unreadable mount list leaves what was found */ }
+ return list;
+ }
+
+ // "/" on macOS shows the boot volume's name when it can be found (Macintosh HD).
+ private static string VolumeLabel(string root)
+ {
+ if (OperatingSystem.IsMacOS() && root == "/")
+ {
+ try
+ {
+ if (Directory.Exists("/Volumes"))
+ foreach (var v in Directory.EnumerateDirectories("/Volumes"))
+ if (new DirectoryInfo(v).LinkTarget is "/") return Path.GetFileName(v);
+ }
+ catch { }
+ return "/";
+ }
+ return root.TrimEnd('\\', '/') is { Length: > 0 } r ? r : root;
+ }
+
+ private static void Push(List<string> stack, string value)
+ {
+ stack.Add(value);
+ if (stack.Count > HistoryCap) stack.RemoveAt(0);
+ }
+
+ private static string Pop(List<string> stack)
+ {
+ var v = stack[^1];
+ stack.RemoveAt(stack.Count - 1);
+ return v;
+ }
+
+ /// <summary>Tests: how many steps Back holds.</summary>
+ public int BackCount => _back.Count;
+}
diff --git a/src/managed/Nota.Application/Browser/PathInput.cs b/src/managed/Nota.Application/Browser/PathInput.cs
new file mode 100644
index 00000000..eef5ef44
--- /dev/null
+++ b/src/managed/Nota.Application/Browser/PathInput.cs
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Turns what the user typed or pasted into the Files tab's path bar (spec 092, #580) into
+// a folder to open and, for a file path, the file to select. Pasted paths come quoted
+// (Finder's "Copy as Pathname" in a shell, Explorer's "Copy as path"), as file:// URLs, or
+// with "~" for home — all accepted.
+
+using System.IO;
+
+namespace Nota.Application.Browser;
+
+public static class PathInput
+{
+ /// <summary>The folder to open and the file to select (null for a folder path), or
+ /// null when the text names nothing that exists.</summary>
+ public static (string Folder, string? SelectFile)? Parse(string? text)
+ {
+ if (string.IsNullOrWhiteSpace(text)) return null;
+ string t = text.Trim();
+ if (t.Length >= 2 && (t[0] == '"' && t[^1] == '"' || t[0] == '\'' && t[^1] == '\'')) t = t[1..^1].Trim();
+ if (t.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
+ {
+ try { t = new Uri(t).LocalPath; } catch { return null; }
+ }
+ if (t == "~" || t.StartsWith("~/", StringComparison.Ordinal) || t.StartsWith("~\\", StringComparison.Ordinal))
+ t = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), t.Length > 2 ? t[2..] : "");
+ if (!Path.IsPathRooted(t)) return null;
+
+ string p = SampleFolderRules.Normalize(t);
+ try
+ {
+ if (Directory.Exists(p)) return (p, null);
+ if (File.Exists(p)) return (Path.GetDirectoryName(p) ?? p, p);
+ }
+ catch { /* unreadable: treated as missing */ }
+ return null;
+ }
+}
diff --git a/src/managed/Nota.Application/Browser/ProjectSummary.cs b/src/managed/Nota.Application/Browser/ProjectSummary.cs
new file mode 100644
index 00000000..c2861788
--- /dev/null
+++ b/src/managed/Nota.Application/Browser/ProjectSummary.cs
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// What the browser's Projects tab (spec 092, #582) says about a project without opening
+// it: when it was last saved, its tempo, key, length and track count. The date rule lives
+// here so the Projects tab and the Welcome window show the same date for a project.
+
+using System.Globalization;
+using System.IO;
+
+namespace Nota.Application.Browser;
+
+/// <summary>A project's details as read from its manifest. <see cref="LengthBeats"/> is the
+/// end of its last arrangement clip.</summary>
+public sealed record ProjectSummary(double Bpm, string? Key, int TrackCount, double LengthBeats)
+{
+ /// <summary>The length as m:ss at the project's tempo ("3:42").</summary>
+ public string LengthText
+ {
+ get
+ {
+ double sec = Bpm > 0 ? LengthBeats * 60.0 / Bpm : 0;
+ int s = (int)Math.Round(sec);
+ return $"{s / 60}:{s % 60:00}";
+ }
+ }
+}
+
+/// <summary>Reads project summaries (cached; may touch the disk — call off the UI thread).</summary>
+public interface IProjectSummaries
+{
+ /// <summary>The summary of the bundle at <paramref name="bundlePath"/>, or null when its
+ /// manifest can't be read.</summary>
+ ProjectSummary? Get(string bundlePath);
+}
+
+public static class ProjectDates
+{
+ /// <summary>The manifest's name inside a <c>.nota</c> bundle.</summary>
+ public const string ManifestName = "project.json";
+
+ /// <summary>When the project was last saved: its manifest's write time (every save
+ /// rewrites it), else the bundle folder's; null when neither can be read.</summary>
+ public static DateTime? Modified(string bundlePath)
+ {
+ try
+ {
+ var manifest = Path.Combine(bundlePath, ManifestName);
+ if (File.Exists(manifest)) return File.GetLastWriteTime(manifest);
+ if (Directory.Exists(bundlePath)) return Directory.GetLastWriteTime(bundlePath);
+ }
+ catch { /* unreadable */ }
+ return null;
+ }
+
+ /// <summary>"11/12/2026 14:20" — the Welcome window's recent-projects format.</summary>
+ public static string Format(DateTime when) => when.ToString("MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture);
+}
diff --git a/src/managed/Nota.Application/Browser/SampleFolderRules.cs b/src/managed/Nota.Application/Browser/SampleFolderRules.cs
new file mode 100644
index 00000000..ad004dc3
--- /dev/null
+++ b/src/managed/Nota.Application/Browser/SampleFolderRules.cs
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The rules of the sample-folder list (spec 092, #346 / #268), kept free of the settings
+// file so the smoke test can pin them: one folder may not be added twice, nor sit inside or
+// around another (every file would be listed and indexed twice), exactly one folder is the
+// default, and a settings file from before the list migrates to a one-entry list.
+
+using System.Collections.Generic;
+using System.IO;
+
+namespace Nota.Application.Browser;
+
+public static class SampleFolderRules
+{
+ /// <summary>Path comparison as the file system does it: case-insensitive on macOS and
+ /// Windows, sensitive on Linux.</summary>
+ public static StringComparer PathComparer
+ => OperatingSystem.IsLinux() ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
+
+ /// <summary>An absolute path without a trailing separator (a volume root keeps its own).
+ /// "" stays "".</summary>
+ public static string Normalize(string path)
+ {
+ if (string.IsNullOrWhiteSpace(path)) return "";
+ string full;
+ try { full = Path.GetFullPath(path.Trim()); } catch { full = path.Trim(); }
+ string root = Path.GetPathRoot(full) ?? "";
+ while (full.Length > root.Length && (full.EndsWith('/') || full.EndsWith('\\')))
+ full = full[..^1];
+ return full;
+ }
+
+ /// <summary>True when <paramref name="path"/> is <paramref name="folder"/> or lies inside
+ /// it. Separator-aware: "/A/Drum" is not inside "/A/Drums".</summary>
+ public static bool IsSameOrInside(string path, string folder)
+ {
+ path = Normalize(path); folder = Normalize(folder);
+ if (path.Length == 0 || folder.Length == 0) return false;
+ var cmp = PathComparer;
+ if (cmp.Equals(path, folder)) return true;
+ if (path.Length <= folder.Length) return false;
+ if (!path.StartsWith(folder, cmp == StringComparer.Ordinal ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase))
+ return false;
+ // A root like "/" or "C:\" already ends with a separator.
+ char last = folder[^1];
+ if (last == '/' || last == '\\') return true;
+ char next = path[folder.Length];
+ return next == '/' || next == '\\';
+ }
+
+ /// <summary>Whether <paramref name="candidate"/> may join <paramref name="existing"/>
+ /// (paths, list order). Does not look at the disk.</summary>
+ public static SampleFolderResult Check(IReadOnlyList<string> existing, string candidate)
+ {
+ candidate = Normalize(candidate);
+ if (candidate.Length == 0) return new(SampleFolderOutcome.NotADirectory);
+ var cmp = PathComparer;
+ for (int i = 0; i < existing.Count; i++)
+ if (cmp.Equals(Normalize(existing[i]), candidate)) return new(SampleFolderOutcome.AlreadyPresent, i);
+ for (int i = 0; i < existing.Count; i++)
+ {
+ if (IsSameOrInside(candidate, existing[i])) return new(SampleFolderOutcome.Inside, i);
+ if (IsSameOrInside(existing[i], candidate)) return new(SampleFolderOutcome.Contains, i);
+ }
+ return new(SampleFolderOutcome.Added);
+ }
+
+ /// <summary>Brings a loaded list into shape: a missing/empty list becomes one default
+ /// entry at <paramref name="legacyFolder"/> (the pre-092 Samples folder, already resolved
+ /// to a real path); paths are normalised; an entry equal to, inside or around an earlier
+ /// one is dropped (returned, for the log); exactly one default remains (the first marked
+ /// one, else the first entry).</summary>
+ public static (List<SampleFolderEntry> List, List<string> Dropped) Repair(List<SampleFolderEntry>? list, string legacyFolder)
+ {
+ var dropped = new List<string>();
+ var result = new List<SampleFolderEntry>();
+ if (list is { Count: > 0 })
+ {
+ foreach (var e in list)
+ {
+ if (e is null) continue;
+ var path = Normalize(e.Path);
+ if (path.Length == 0) { dropped.Add(e.Path ?? ""); continue; }
+ if (!Check(result.ConvertAll(r => r.Path), path).Ok) { dropped.Add(path); continue; }
+ result.Add(new SampleFolderEntry
+ {
+ Path = path,
+ Name = string.IsNullOrWhiteSpace(e.Name) ? null : e.Name.Trim(),
+ IsDefault = e.IsDefault,
+ });
+ }
+ }
+ if (result.Count == 0)
+ result.Add(new SampleFolderEntry { Path = Normalize(legacyFolder), IsDefault = true });
+
+ int def = result.FindIndex(e => e.IsDefault);
+ if (def < 0) def = 0;
+ for (int i = 0; i < result.Count; i++) result[i].IsDefault = i == def;
+ return (result, dropped);
+ }
+
+ /// <summary>The label a folder shows: its name, else the folder's own name (a volume root
+ /// shows itself).</summary>
+ public static string Label(SampleFolderEntry e)
+ {
+ if (!string.IsNullOrWhiteSpace(e.Name)) return e.Name!;
+ var name = Path.GetFileName(Normalize(e.Path));
+ return name.Length > 0 ? name : e.Path;
+ }
+}
diff --git a/src/managed/Nota.Application/Engine/IAudioEngine.cs b/src/managed/Nota.Application/Engine/IAudioEngine.cs
index 35a2eb67..2c29961f 100644
--- a/src/managed/Nota.Application/Engine/IAudioEngine.cs
+++ b/src/managed/Nota.Application/Engine/IAudioEngine.cs
@@ -618,6 +618,12 @@ public interface IAudioEngine : IDisposable
string SampleName(long sampleId);
/// <summary>Remember the source name of a sample (a project reload restores it).</summary>
void SetSampleName(long sampleId, string name);
+ /// <summary>The full path the sample was loaded from, or "" when unknown (a recording, a
+ /// render, a project's own copy). Managed-side only, like <see cref="SampleName"/>; Locate
+ /// uses it and projects save it (spec 092, #581).</summary>
+ string SampleSource(long sampleId) => "";
+ /// <summary>Restore a sample's source path (project load).</summary>
+ void SetSampleSource(long sampleId, string path) { }
int AddMidiClip(int trackId, double startBeat, double lengthBeats);
// --- Hosted plugins (M3-3) ---------------------------------------------
diff --git a/src/managed/Nota.Application/Localization/en.json b/src/managed/Nota.Application/Localization/en.json
index 7c6830ee..730796f1 100644
--- a/src/managed/Nota.Application/Localization/en.json
+++ b/src/managed/Nota.Application/Localization/en.json
@@ -361,6 +361,8 @@
"audition.preset_audition.racks_play_what_their_chains": "Racks play what their chains hold — nothing to preview on its own.",
"audition.preset_audition.the_effect_rack_plays_what": "The Effect Rack plays what its chains hold — nothing to preview on its own.",
"browser.add_audio_files_to_your": "Add audio files to your Samples folder (Settings → Library) or install free packs from Settings → Downloads → Sample packs, then browse them here as a folder tree. You can also drag files in from Finder.",
+ "browser.add_folder": "Add folder…",
+ "browser.add_this_folder": "Add to the browser",
"browser.add_to_favorites": "Add to favorites",
"browser.analysing": " · analysing {0} %",
"browser.any_key": "Any key",
@@ -369,12 +371,18 @@
"browser.audio_effect": "Audio effect",
"browser.audio_effects": "Audio Effects",
"browser.audio_effects_2": "Audio effects",
+ "browser.back_tip": "Back ⌘[",
+ "browser.bpm": "{0} BPM",
"browser.bpm_caps": "BPM",
+ "browser.browse": "Browse",
"browser.built_in": "{0} built-in · {1}",
"browser.built_in_caps": "BUILT-IN",
+ "browser.cant_open": "Can't open {0}",
"browser.category_chips": "Category chips",
"browser.collapse": "Collapse",
"browser.collapse_browser": "Collapse browser",
+ "browser.computer": "Computer",
+ "browser.copy_path": "Copy path",
"browser.couldnt_analyse_that_sample": "Couldn't analyse that sample",
"browser.create_multisample": "Create multisample…",
"browser.delete": "Delete…",
@@ -384,13 +392,23 @@
"browser.external_drop_named_no_files": "External drop named no files Nota can read. Formats: {0}",
"browser.favorites": "Favorites",
"browser.favorites_first": "Favorites first",
+ "browser.file": "File",
"browser.files": "Files",
"browser.filter_by_key_a_key": "Filter by key — a key also shows its relative (A minor ↔ C major)",
"browser.filter_by_tempo": "Filter by tempo",
"browser.finding_sounds_like": "Finding sounds like {0}…",
"browser.folder": "Folder",
+ "browser.folder_added": "{0} added to the browser",
+ "browser.folder_already_added": "Already in the browser",
+ "browser.folder_contains": "Contains {0} — remove it from the browser first",
+ "browser.folder_empty": "No audio or MIDI files here",
+ "browser.folder_inside": "Inside {0} — already in the browser",
+ "browser.folder_label": "Name shown in the browser",
+ "browser.folder_unreadable": "Nota can't read this folder",
+ "browser.forward_tip": "Forward ⌘]",
"browser.group_by_source": "Group by source",
"browser.history": "History",
+ "browser.home_tip": "Home — the default sample folder",
"browser.key": "Key",
"browser.like": "Like {0}",
"browser.loops": "Loops",
@@ -410,6 +428,7 @@
"browser.no_presets_yet": "No presets yet",
"browser.no_projects_yet": "No projects yet",
"browser.no_samples_yet": "No samples yet",
+ "browser.not_a_folder": "Not a folder Nota can open",
"browser.nota_is_still_analysing_your": "Nota is still analysing your samples — more matches appear as it goes.",
"browser.nota_kits": "Nota Kits",
"browser.notas_built_in_effects_plus": "Nota's built-in effects plus your VST/AU plug-ins. Scan your plug-ins in Settings → Plug-ins to add more.",
@@ -418,6 +437,7 @@
"browser.packs": "Packs",
"browser.pads": "{0} · {1} pads",
"browser.pads_8_on_the_voices": "{0} · {1} pads, 8 on the voices",
+ "browser.path_copied": "Path copied",
"browser.plug_ins": { "one": "{0} plug-in", "other": "{0} plug-ins" },
"browser.plug_ins_caps": "PLUG-INS",
"browser.preset": "Preset",
@@ -425,24 +445,47 @@
"browser.presets_n": { "one": "{0} preset", "other": "{0} presets" },
"browser.project": "Project",
"browser.project_key": "Project key · {0}",
+ "browser.project_open": "Open now",
"browser.project_tempo_5": "Project tempo ±5 %",
"browser.projects": "Projects",
+ "browser.project_tracks": { "one": "{0} track", "other": "{0} tracks" },
"browser.projects_n": { "one": "{0} project", "other": "{0} projects" },
+ "browser.remove_default_confirm": "{0} becomes the default folder, where downloaded sample packs go. Nothing on disk changes.",
+ "browser.remove_default_title": "Remove the default folder?",
+ "browser.remove_from_browser": "Remove from browser",
"browser.remove_from_favorites": "Remove from favorites",
+ "browser.rename_folder": "Rename folder",
"browser.right_click_a_device_header": "Right-click a device header and choose Save preset; it appears here grouped by category and device.",
"browser.sample_packs_installed_from_settings": "sample packs installed from Settings → Downloads",
"browser.samples": { "one": "{0} sample", "other": "{0} samples" },
"browser.save_a_project_s_into": "Save a project (⌘S) into your Projects folder (Settings → Library) and it shows up here.",
"browser.search": "Search",
+ "browser.set_as_default": "Set as default",
"browser.show_similar_sounds": "Show similar sounds",
"browser.show_type_tags": "Show type tags",
+ "browser.size_b": "{0} B",
+ "browser.size_gb": "{0} GB",
+ "browser.size_kb": "{0} KB",
+ "browser.size_mb": "{0} MB",
"browser.sort_and_view": "Sort and view",
+ "browser.sort_date": "Date",
+ "browser.sort_name": "Name",
+ "browser.sort_projects": "Order projects by last saved or by name",
"browser.sounds_like_closest_first_click": "Sounds like {0}, closest first — click to go back to all samples",
"browser.tags": "Tags",
"browser.track_inspector": "Track inspector",
"browser.transpose_to_project_key": "Transpose to project key",
+ "browser.tree": "Tree",
"browser.try_a_different_search_or": "Try a different search or clear the filters.",
+ "browser.unavailable": "Unavailable",
+ "browser.unavailable_tip": "{0} — unavailable",
+ "browser.up_tip": "Up ⌘↑",
"browser.warp_loops_to_project_tempo": "Warp loops to project tempo",
+ "clip.locate": "Locate",
+ "clip.locate_in_browser": "In browser",
+ "clip.locate_in_explorer": "In Explorer",
+ "clip.locate_in_file_manager": "In file manager",
+ "clip.locate_in_finder": "In Finder",
"clip_adsr.attack": "Attack {0}",
"clip_adsr.decay_sustain": "Decay {0} · Sustain {1}",
"clip_adsr.release": "Release {0}",
@@ -3293,6 +3336,7 @@
"preferences.add_an_instrument_audio_or": "Add an instrument, audio or return track · rename or delete one",
"preferences.add_folder": "Add folder…",
"preferences.add_plugin_scan_folder": "Add plugin scan folder",
+ "preferences.add_sample_folder": "Add sample folder",
"preferences.add_the_track_to_the": "Add the track to the selection · again to remove it",
"preferences.add_this_config_or_the": "Add this config (or the URL) as an MCP server in Claude Desktop / Claude Code. Loopback only; off by default.",
"preferences.adding_a_plug_in_from": "Adding a plug-in from the browser, by drag and drop or from the palette opens its editor. Loading a project, undo and paste never do.",
@@ -3323,10 +3367,12 @@
"preferences.audio_settings_are_unavailable_in": "Audio settings are unavailable in this window.",
"preferences.audio_subtitle": "Sample rate, buffer and latency",
"preferences.audio_system": "Audio system",
+ "preferences.back_forward_in_the_browse": "Back · forward through the folders you opened (Browse)",
"preferences.back_to_the_standard_height": "Back to the standard height",
"preferences.bars": "Bars",
"preferences.bend_range": "Bend range",
"preferences.black_keys_sharps": "Black keys (sharps)",
+ "preferences.browser_files_after_a_click": "Browser · Files (after a click in its list)",
"preferences.browser_preview": "Browser · preview",
"preferences.buffer_size": "Buffer size",
"preferences.bypass_the_selected_device": "Bypass the selected device",
@@ -3397,6 +3443,7 @@
"preferences.dark": "Dark",
"preferences.deactivate_activate_the_selected_clip": "Deactivate / activate the selected clip(s)",
"preferences.default": "default",
+ "preferences.default_unavailable": "default · unavailable",
"preferences.delete_device_selected": "Delete (device selected)",
"preferences.delete_the_selected_clip_or": "Delete the selected clip or scene",
"preferences.delete_the_selected_clip_range": "Delete the selected clip / range",
@@ -3540,6 +3587,7 @@
"preferences.menu_bar_hidden": "Hidden",
"preferences.menu_bar_shown": "Shown",
"preferences.open_the_menu": "Open the menu (Windows, Linux)",
+ "preferences.open_the_selected_folder_browse": "Open the selected folder (Browse)",
"preferences.outputs_pairs": "Output pairs",
"preferences.outputs_click": "Click",
"preferences.outputs_click_both": "Both",
@@ -3771,8 +3819,9 @@
"preferences.right_click_track_headers": "Right-click track headers",
"preferences.right_click_velocity_stem": "Right-click velocity stem",
"preferences.round_trip": " · round trip {0}",
+ "preferences.sample_folders": "Sample folders",
+ "preferences.sample_folders_caption": "The browser's Files tab shows every folder here. Downloaded sample packs go into the default folder. Removing a folder only takes it out of the browser — nothing on disk changes.",
"preferences.sample_rate": "Sample rate",
- "preferences.samples": "Samples",
"preferences.samples.credit": "Credit: {0}",
"preferences.samples.download_samples_on_disk": "{0} download · {1} samples · {2} on disk · {3}",
"preferences.samples.free_sample_packs_from_the": "Free sample packs from the Nota sample registry, licensed for any music, commercial releases included. Each pack downloads from where its author publishes it, is checked against the registry's checksum and unpacked into your Samples folder.",
@@ -3907,9 +3956,11 @@
"preferences.type_a_value_units_like": "Type a value (units like k, ms, dB, L / R work) · double-click its value does the same",
"preferences.type_first_to_filter_actions": "Type first to filter: actions, tracks, devices, presets, Modular nodes",
"preferences.type_its_values_a_node": "Type its values — a node with several (frequency · gain · Q, decay · sustain) takes Tab between them",
+ "preferences.type_or_paste_a_path": "Type or paste a path to open (switches to Browse)",
"preferences.type_the_preview_volume_double": "Type the preview volume · double-click resets it to 0 dB",
"preferences.type_value_reset_to_default": "Type value… · Reset to default",
"preferences.undo_redo": "Undo / redo",
+ "preferences.up_to_the_parent_folder": "Up to the folder above, then to the drives (Browse)",
"preferences.update_to": "Update to {0}",
"preferences.updates": "Updates",
"preferences.updates.automatic_updates": "Automatic updates",
diff --git a/src/managed/Nota.Application/Ports/ISampleIndex.cs b/src/managed/Nota.Application/Ports/ISampleIndex.cs
index a4cbb36c..b26059d3 100644
--- a/src/managed/Nota.Application/Ports/ISampleIndex.cs
+++ b/src/managed/Nota.Application/Ports/ISampleIndex.cs
@@ -33,9 +33,13 @@ public interface ISampleIndex
/// <summary>Records an analysis made elsewhere (the import path already decoded the file).</summary>
SampleInfo Store(string path, SampleAnalysis analysis);
- /// <summary>Indexes everything under <paramref name="root"/> in the background (replaces
- /// any running scan). Files the index already knows are skipped.</summary>
- void Watch(string root);
+ /// <summary>Indexes everything under the sample folders <paramref name="roots"/> in the
+ /// background (replaces any running scan). Files the index already knows are skipped; a
+ /// folder that is missing (an unplugged drive) keeps what was analysed under it.</summary>
+ void Watch(IReadOnlyList<string> roots);
+
+ /// <summary>One sample folder.</summary>
+ void Watch(string root) => Watch(new[] { root });
/// <summary>Moves <paramref name="folder"/> to the front of the queue — a pack just installed.</summary>
void Prioritize(string folder);
diff --git a/src/managed/Nota.Application/Settings.cs b/src/managed/Nota.Application/Settings.cs
index 64c035b1..6f2221c6 100644
--- a/src/managed/Nota.Application/Settings.cs
+++ b/src/managed/Nota.Application/Settings.cs
@@ -11,6 +11,9 @@ namespace Nota.Application;
public enum ToolbarSide { Left, Right }
+/// <summary>How the browser's Projects tab orders projects (spec 092, #582).</summary>
+public enum ProjectsSortOrder { Date, Name }
+
/// <summary>The appearance before colour themes (spec 011). Still written, in step with
/// the chosen theme's kind, so an older Nota opening this settings file gets a sensible
/// variant; read only to migrate (see <see cref="Appearance"/>).</summary>
@@ -49,8 +52,21 @@ public sealed class Settings
/// <summary>Whether Session view shows its inspector column (toolbar toggle). On by default;
/// folding it gives the clip grid its width back on small windows.</summary>
public bool SessionInspectorOpen { get; set; } = true;
- /// <summary>Browser sample library folder ("" = default ~/Music/Nota Samples). M7-4.</summary>
+ /// <summary>Browser sample library folder ("" = default ~/Music/Nota Samples). M7-4.
+ /// Since spec 092 a mirror of the default <see cref="SampleFolders"/> entry, rewritten on
+ /// every save: older versions and Nota Mosaic's <c>samples:</c> refs read it.</summary>
public string SamplesFolder { get; set; } = "";
+ /// <summary>The sample folders the browser's Files tab shows (spec 092, #346 / #268), in
+ /// order; exactly one is the default (packs install there). Null in settings written by
+ /// older versions — migrated from <see cref="SamplesFolder"/> on load.</summary>
+ public List<SampleFolderEntry>? SampleFolders { get; set; }
+ /// <summary>The Files tab shows the file-system browse view instead of the folder tree
+ /// (spec 092, #580).</summary>
+ public bool FilesBrowseMode { get; set; }
+ /// <summary>The folder the Files tab's browse view showed last ("" = the default folder).</summary>
+ public string FilesBrowseFolder { get; set; } = "";
+ /// <summary>The Projects tab's order: newest first (the default) or by name (#582).</summary>
+ public ProjectsSortOrder ProjectsSort { get; set; } = ProjectsSortOrder.Date;
/// <summary>Browser projects folder ("" = default ~/Documents/Nota Projects). M7-4.</summary>
public string ProjectsFolder { get; set; } = "";
/// <summary>Last app version whose "What's New" the user has already seen ("" = never).
@@ -250,6 +266,28 @@ public sealed class Settings
public bool PianoRollLabelAllNotes { get; set; } = false;
}
+/// <summary>One sample folder in <see cref="Settings.SampleFolders"/>. <see cref="Path"/> is
+/// absolute and normalised; <see cref="Name"/> is only the label Nota shows (null = the
+/// folder's name) — renaming never touches the disk.</summary>
+public sealed class SampleFolderEntry
+{
+ public string Path { get; set; } = "";
+ public string? Name { get; set; }
+ public bool IsDefault { get; set; }
+}
+
+/// <summary>A sample folder as the UI sees it: list index, absolute path, label, default
+/// flag, and whether the folder could be found at the last look.</summary>
+public sealed record ResolvedSampleFolder(int Index, string Path, string Label, bool IsDefault, bool Available);
+
+public enum SampleFolderOutcome { Added, AlreadyPresent, Inside, Contains, NotADirectory }
+
+/// <summary>What adding a folder did; <see cref="Other"/> is the index of the entry it clashed with (−1 otherwise).</summary>
+public readonly record struct SampleFolderResult(SampleFolderOutcome Outcome, int Other = -1)
+{
+ public bool Ok => Outcome == SampleFolderOutcome.Added;
+}
+
public interface ISettingsService
{
Settings Current { get; }
@@ -257,8 +295,26 @@ public interface ISettingsService
/// <summary>Fired after Save() so views can re-apply settings live.</summary>
event Action? Changed;
- /// <summary>The sample library folder to browse (resolved default, created). M7-4.</summary>
+ /// <summary>The default sample folder (resolved, created) — where packs install and what
+ /// Nota Mosaic's <c>samples:</c> refs resolve against. M7-4; spec 092.</summary>
string ResolvedSamplesFolder();
+
+ // --- sample folders (spec 092) -------------------------------------------------------
+ // Defaults keep simple implementations (test doubles) working with one folder.
+
+ /// <summary>Every sample folder, in list order. Never creates
+ /// folders other than the default.</summary>
+ IReadOnlyList<ResolvedSampleFolder> ResolvedSampleFolders()
+ {
+ var p = ResolvedSamplesFolder();
+ return new[] { new ResolvedSampleFolder(0, p, System.IO.Path.GetFileName(p.TrimEnd('/', '\\')), true, System.IO.Directory.Exists(p)) };
+ }
+ SampleFolderResult AddSampleFolder(string path) => new(SampleFolderOutcome.NotADirectory);
+ bool RemoveSampleFolder(int index) => false;
+ void RenameSampleFolder(int index, string? name) { }
+ void SetDefaultSampleFolder(int index) { }
+ /// <summary>Raised after the list of sample folders changed (added, removed, renamed, default moved).</summary>
+ event Action? SampleFoldersChanged { add { } remove { } }
/// <summary>The projects folder to browse (resolved default, created). M7-4.</summary>
string ResolvedProjectsFolder();
/// <summary>App-managed presets folder (created). M7-4.</summary>
diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Import.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Import.cs
index 46d0d385..67acd226 100644
--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Import.cs
+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Import.cs
@@ -13,7 +13,7 @@ public sealed partial class NotaEngine
{
ThrowIfDisposed();
var h = NativeMethods.AudioImportOpen(path);
- return h == IntPtr.Zero ? null : new AudioImport(h);
+ return h == IntPtr.Zero ? null : new AudioImport(h, path);
}
/// <summary>Places a finished import on a track. Returns the clip index, or -1.</summary>
@@ -21,7 +21,9 @@ public sealed partial class NotaEngine
{
ThrowIfDisposed();
if (import is not AudioImport ai) throw new ArgumentException("Not a NotaEngine import.", nameof(import));
- return NativeMethods.TrackAddImportedClip(_handle, trackId, ai.Handle, startBeat);
+ int c = NativeMethods.TrackAddImportedClip(_handle, trackId, ai.Handle, startBeat);
+ RememberClipSource(trackId, c, ai.Path); // Locate finds it, and it saves as the clip's source (#581)
+ return c;
}
/// <summary>Auto-warp with an already-detected tempo. Returns the BPM used (0 = failed).</summary>
@@ -31,7 +33,10 @@ public sealed partial class NotaEngine
private sealed class AudioImport : IAudioImport
{
private IntPtr _h;
- public AudioImport(IntPtr h) => _h = h;
+ public AudioImport(IntPtr h, string path) { _h = h; Path = path; }
+
+ /// <summary>The file being decoded.</summary>
+ internal string Path { get; }
internal IntPtr Handle => _h != IntPtr.Zero ? _h : throw new ObjectDisposedException(nameof(AudioImport));
diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Session.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Session.cs
index 5e025267..10898146 100644
--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Session.cs
+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Session.cs
@@ -129,11 +129,26 @@ public sealed partial class NotaEngine
/// <summary>Loads a file into a session audio slot (looped over lengthBeats). False on failure.</summary>
public bool AddSessionAudioClip(int trackId, int scene, string path, double lengthBeats, double sourceOffsetFrames, long lengthFrames, float gain)
- { ThrowIfDisposed(); return NativeMethods.SessionAddAudioClip(_handle, trackId, scene, path, lengthBeats, sourceOffsetFrames, lengthFrames, gain) != 0; }
+ {
+ ThrowIfDisposed();
+ bool ok = NativeMethods.SessionAddAudioClip(_handle, trackId, scene, path, lengthBeats, sourceOffsetFrames, lengthFrames, gain) != 0;
+ if (ok) RememberSlotSource(trackId, scene, path);
+ return ok;
+ }
/// <summary>Drops a whole audio file into a session slot, auto-computing loop length (M7-5).</summary>
public bool AddSessionAudioFile(int trackId, int scene, string path)
- { ThrowIfDisposed(); return NativeMethods.SessionAddAudioFile(_handle, trackId, scene, path) != 0; }
+ {
+ ThrowIfDisposed();
+ bool ok = NativeMethods.SessionAddAudioFile(_handle, trackId, scene, path) != 0;
+ if (ok) RememberSlotSource(trackId, scene, path);
+ return ok;
+ }
+
+ private void RememberSlotSource(int trackId, int scene, string path)
+ {
+ if (NativeMethods.SessionGetAudioSlot(_handle, trackId, scene, out var info) != 0) RememberSampleSource(info.SampleId, path);
+ }
// --- Session P0 -------------------------------------------------------------
diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs
index 584c0d57..a820c059 100644
--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs
+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs
@@ -20,7 +20,9 @@ public sealed partial class NotaEngine
public int AddAudioClip(int trackId, string path, double startBeat)
{
ThrowIfDisposed();
- return NativeMethods.AddAudioClip(_handle, trackId, path, startBeat);
+ int c = NativeMethods.AddAudioClip(_handle, trackId, path, startBeat);
+ RememberClipSource(trackId, c, path);
+ return c;
}
public void SetTrackVolume(int trackId, float volume) { ThrowIfDisposed(); Check(NativeMethods.SetTrackVolume(_handle, trackId, volume)); }
@@ -917,6 +919,51 @@ public sealed partial class NotaEngine
{
if (sampleId == 0) return;
lock (_sampleNames) _sampleNames[sampleId] = System.IO.Path.GetFileNameWithoutExtension(path);
+ RememberSampleSource(sampleId, path);
+ }
+
+ // Where each loaded sample came from on disk (spec 092, #581): Locate finds the file a
+ // clip was made from, and the project keeps the path across a reload. A project's own
+ // copy (…/X.nota/samples/…) isn't a source: loading a project restores the real one.
+ private readonly Dictionary<long, string> _sampleSources = new();
+
+ private void RememberSampleSource(long sampleId, string path)
+ {
+ if (sampleId == 0 || string.IsNullOrEmpty(path) || IsBundleCopy(path)) return;
+ string full;
+ try { full = System.IO.Path.GetFullPath(path); } catch { return; }
+ // Freezes, stems and other renders are written to the temp folder and loaded from
+ // there: a scratch file, not a source anyone should be led back to.
+ if (Nota.Application.Browser.SampleFolderRules.IsSameOrInside(full, System.IO.Path.GetTempPath())) return;
+ lock (_sampleSources) _sampleSources[sampleId] = full;
+ }
+
+ private void RememberClipSource(int trackId, int clipIndex, string path)
+ {
+ if (clipIndex >= 0 && NativeMethods.GetAudioClipInfo(_handle, trackId, clipIndex, out var info) != 0)
+ RememberSampleSource(info.SampleId, path);
+ }
+
+ /// <summary>A path inside a project bundle's samples folder (a copy, not a source).</summary>
+ internal static bool IsBundleCopy(string path)
+ {
+ var dir = System.IO.Path.GetDirectoryName(path);
+ if (dir is null || !string.Equals(System.IO.Path.GetFileName(dir), "samples", StringComparison.OrdinalIgnoreCase)) return false;
+ var bundle = System.IO.Path.GetDirectoryName(dir);
+ return bundle is not null && bundle.EndsWith(".nota", StringComparison.OrdinalIgnoreCase);
+ }
+
+ public string SampleSource(long sampleId)
+ { lock (_sampleSources) return _sampleSources.TryGetValue(sampleId, out var p) ? p : ""; }
+
+ public void SetSampleSource(long sampleId, string path)
+ {
+ if (sampleId == 0) return;
+ lock (_sampleSources)
+ {
+ if (string.IsNullOrEmpty(path)) _sampleSources.Remove(sampleId);
+ else _sampleSources[sampleId] = path;
+ }
}
public string SampleName(long sampleId)
@@ -994,7 +1041,12 @@ public sealed partial class NotaEngine
/// <summary>Adds an audio clip restoring its source offset/length/gain. Returns clip index or -1.</summary>
public int AddAudioClipEx(int trackId, string path, double startBeat, double sourceOffsetFrames, long lengthFrames, float gain)
- { ThrowIfDisposed(); return NativeMethods.AddAudioClipEx(_handle, trackId, path, startBeat, sourceOffsetFrames, lengthFrames, gain); }
+ {
+ ThrowIfDisposed();
+ int c = NativeMethods.AddAudioClipEx(_handle, trackId, path, startBeat, sourceOffsetFrames, lengthFrames, gain);
+ RememberClipSource(trackId, c, path);
+ return c;
+ }
/// <summary>Decoded-sample metadata by id. False if the id isn't found in the live graph.</summary>
public bool TryGetSampleInfo(long sampleId, out NotaSampleInfo info)
diff --git a/src/managed/Nota.Infrastructure/Persistence/ClipFiles.cs b/src/managed/Nota.Infrastructure/Persistence/ClipFiles.cs
new file mode 100644
index 00000000..4cf3fa9b
--- /dev/null
+++ b/src/managed/Nota.Infrastructure/Persistence/ClipFiles.cs
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Which file on disk an audio clip stands for (spec 092, #581): the file it was made from
+// when Nota knows it and it is still there, else the project's own copy of its audio
+// (samples/<hash>.wav in the saved bundle). Locate → In Finder shows that file.
+
+namespace Nota.Infrastructure;
+
+public static class ClipFiles
+{
+ /// <summary>The clip's source file when it is known and exists; null otherwise.</summary>
+ public static string? Source(IAudioEngine engine, long sampleId)
+ => sampleId > 0 && engine.SampleSource(sampleId) is { Length: > 0 } p && File.Exists(p) ? p : null;
+
+ /// <summary>The bundle's copy of the sample's audio, when the project is saved and holds
+ /// it; null otherwise. May hash the audio once (cached per sample).</summary>
+ public static string? BundleCopy(IAudioEngine engine, long sampleId, string? bundleDir)
+ {
+ if (sampleId <= 0 || string.IsNullOrEmpty(bundleDir)) return null;
+ if (!engine.TryGetSampleInfo(sampleId, out var info)) return null;
+ if (BundleContent.SampleHash(engine, sampleId, info) is not { } hash) return null;
+ var path = Path.Combine(bundleDir, BundleContent.SampleRel(hash));
+ return File.Exists(path) ? path : null;
+ }
+}
diff --git a/src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs b/src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs
index 3bbfd7ba..e026ef36 100644
--- a/src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs
+++ b/src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs
@@ -445,6 +445,9 @@ public sealed class AudioClipDto
// Ends that play at full level where take sections meet: 1 head, 2 tail (v29, optional;
// absent = both fade). A flatten keeps such a join after its takes are gone.
public int? JoinedEdges { get; set; }
+ /// <summary>The file the clip's audio came from (spec 092, #581) — Locate opens it.
+ /// Optional; absent for recordings, renders and projects saved before it existed.</summary>
+ public string? Source { get; set; }
[JsonExtensionData] public Dictionary<string, JsonElement>? Extra { get; set; }
}
@@ -457,6 +460,8 @@ public sealed class AudioTakeDto
public int Number { get; set; } // "Take N" as shown on the lane
public int Group { get; set; } // takes of one recording share a group
public string Sample { get; set; } = "";
+ /// <summary>The file the take's audio came from (spec 092); absent for a recording.</summary>
+ public string? Source { get; set; }
public double OriginBeat { get; set; } // beat of the sample's frame 0
public double SourceOffsetFrames { get; set; }
public long LengthFrames { get; set; }
diff --git a/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs b/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs
index e990c1da..f070d161 100644
--- a/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs
+++ b/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs
@@ -260,6 +260,7 @@ public sealed class ProjectService
if (rel == null) continue;
var dto = AudioClipState.Capture(engine, ti.Id, c, ac);
dto.Sample = rel;
+ dto.Source = SourceOf(engine, ac.SampleId);
int take = engine.ClipTakeId(ti.Id, c);
if (take != 0) dto.TakeId = take;
int joined = engine.ClipJoinedEdges(ti.Id, c);
@@ -273,7 +274,7 @@ public sealed class ProjectService
if (rel == null) continue;
(t.Takes ??= new List<AudioTakeDto>()).Add(new AudioTakeDto
{
- Id = tk.Id, Number = tk.Number, Group = tk.Group, Sample = rel,
+ Id = tk.Id, Number = tk.Number, Group = tk.Group, Sample = rel, Source = SourceOf(engine, tk.SampleId),
OriginBeat = tk.OriginBeat, SourceOffsetFrames = tk.SourceOffsetFrames, LengthFrames = tk.LengthFrames,
});
}
@@ -307,6 +308,7 @@ public sealed class ProjectService
? AudioClipState.Capture(engine, ti.Id, SessionClip.Index(s), sac)
: new AudioClipDto { SourceOffsetFrames = sa.SourceOffsetFrames, LengthFrames = sa.LengthFrames, Gain = sa.Gain };
audio.Sample = rel;
+ audio.Source = SourceOf(engine, sa.SampleId);
audio.Name = null; // the slot carries its own name
t.SessionSlots.Add(WithClipProps(engine, ti.Id, new SessionSlotDto
{
@@ -845,6 +847,7 @@ public sealed class ProjectService
if (engine.TryGetTakeInfo(id, k, out var lti) && lti.Id == nid)
{
BundleContent.SeedSample(engine, lti.SampleId, tk.Sample);
+ if (tk.Source is { Length: > 0 } tsrc) engine.SetSampleSource(lti.SampleId, tsrc);
break;
}
}
@@ -857,7 +860,11 @@ public sealed class ProjectService
if (ac.TakeId is int oldTake && takeIds.TryGetValue(oldTake, out int newTake))
engine.SetClipTakeId(id, ci, newTake);
if (ac.JoinedEdges is int je && je != 0) joinedEdges.Add((ci, je));
- if (engine.TryGetAudioClipInfo(id, ci, out var lci)) BundleContent.SeedSample(engine, lci.SampleId, ac.Sample);
+ if (engine.TryGetAudioClipInfo(id, ci, out var lci))
+ {
+ BundleContent.SeedSample(engine, lci.SampleId, ac.Sample);
+ if (ac.Source is { Length: > 0 } src) engine.SetSampleSource(lci.SampleId, src);
+ }
}
// After every clip is in: a join is kept only where both of its clips are there.
if (joinedEdges.Count > 0)
@@ -886,7 +893,10 @@ public sealed class ProjectService
else
{
if (engine.TryGetSessionAudioSlot(id, sl.Scene, out var lsa))
+ {
BundleContent.SeedSample(engine, lsa.SampleId, sa.Sample);
+ if (sa.Source is { Length: > 0 } ssrc) engine.SetSampleSource(lsa.SampleId, ssrc);
+ }
AudioClipState.ApplyShape(engine, id, SessionClip.Index(sl.Scene), sa);
engine.SetSessionSlotLength(id, sl.Scene, sl.LengthBeats); // clip edits resync it; the saved loop wins
}
@@ -1185,6 +1195,10 @@ public sealed class ProjectService
// Records `sampleId` under a bundle-relative path named by its content hash
// (identical audio shares one file) and returns that path, or null if the sample
// is missing from the live graph.
+ // The file a clip's audio came from (spec 092, #581), or null when unknown.
+ private static string? SourceOf(IAudioEngine engine, long sampleId)
+ => sampleId > 0 && engine.SampleSource(sampleId) is { Length: > 0 } p ? p : null;
+
private static string? RegisterSample(ProjectDocument doc, IAudioEngine engine, long sampleId, List<string> warnings)
{
if (sampleId <= 0) return null;
diff --git a/src/managed/Nota.Infrastructure/Persistence/ProjectSummaryReader.cs b/src/managed/Nota.Infrastructure/Persistence/ProjectSummaryReader.cs
new file mode 100644
index 00000000..83315f34
--- /dev/null
+++ b/src/managed/Nota.Infrastructure/Persistence/ProjectSummaryReader.cs
@@ -0,0 +1,186 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The browser's Projects tab details (spec 092, #582) — tempo, key, length, track count —
+// read straight from a bundle's project.json without binding the whole document or
+// touching the engine, and cached by the manifest's write time and size so a folder of
+// projects is read once. The cache is disposable: missing or corrupt, it is rebuilt.
+
+using System.Text.Json;
+using Nota.Application.Browser;
+
+namespace Nota.Infrastructure;
+
+public sealed class ProjectSummaryReader : IProjectSummaries
+{
+ private sealed class Entry
+ {
+ public string Stamp { get; set; } = "";
+ public double Bpm { get; set; }
+ public string? Key { get; set; }
+ public int Tracks { get; set; }
+ public double LengthBeats { get; set; }
+ }
+
+ private readonly string _cacheFile;
+ private readonly object _gate = new();
+ private Dictionary<string, Entry>? _cache;
+
+ public ProjectSummaryReader() : this(Path.Combine(NotaPaths.SubDir("cache"), "project-summaries.json")) { }
+
+ /// <summary>Tests: a cache kept in <paramref name="cacheFile"/>.</summary>
+ public ProjectSummaryReader(string cacheFile) { _cacheFile = cacheFile; }
+
+ public ProjectSummary? Get(string bundlePath)
+ {
+ var manifest = Path.Combine(bundlePath, ProjectDates.ManifestName);
+ FileInfo fi;
+ try { fi = new FileInfo(manifest); if (!fi.Exists) return null; }
+ catch { return null; }
+ string stamp = $"{fi.LastWriteTimeUtc.Ticks}:{fi.Length}";
+
+ lock (_gate)
+ {
+ var cache = Load();
+ if (cache.TryGetValue(bundlePath, out var hit) && hit.Stamp == stamp)
+ return new ProjectSummary(hit.Bpm, hit.Key, hit.Tracks, hit.LengthBeats);
+ }
+
+ var sum = Read(bundlePath);
+ if (sum is null) return null;
+ lock (_gate)
+ {
+ var cache = Load();
+ cache[bundlePath] = new Entry { Stamp = stamp, Bpm = sum.Bpm, Key = sum.Key, Tracks = sum.TrackCount, LengthBeats = sum.LengthBeats };
+ Save(cache);
+ }
+ return sum;
+ }
+
+ /// <summary>Reads the summary of one bundle (no cache); null when its manifest is missing
+ /// or not a project.</summary>
+ public static ProjectSummary? Read(string bundlePath)
+ {
+ try
+ {
+ using var doc = JsonDocument.Parse(File.ReadAllBytes(Path.Combine(bundlePath, ProjectDates.ManifestName)));
+ var root = doc.RootElement;
+ if (root.ValueKind != JsonValueKind.Object) return null;
+ double bpm = 120;
+ string? key = null;
+ if (Prop(root, "transport") is { ValueKind: JsonValueKind.Object } tr)
+ {
+ if (Prop(tr, "bpm") is { ValueKind: JsonValueKind.Number } b) bpm = b.GetDouble();
+ if (Prop(tr, "key") is { ValueKind: JsonValueKind.String } k && k.GetString() is { Length: > 0 } ks) key = ks;
+ }
+ int tracks = 0;
+ double end = 0;
+ if (Prop(root, "tracks") is { ValueKind: JsonValueKind.Array } arr)
+ {
+ foreach (var t in arr.EnumerateArray())
+ {
+ if (t.ValueKind != JsonValueKind.Object) continue;
+ int type = Prop(t, "type") is { ValueKind: JsonValueKind.Number } ty ? ty.GetInt32() : 0;
+ if (type != 2) tracks++; // return tracks are buses, not tracks you make music on
+ if (Prop(t, "midiClips") is { ValueKind: JsonValueKind.Array } mc)
+ foreach (var c in mc.EnumerateArray())
+ end = Math.Max(end, Num(c, "startBeat") + Num(c, "lengthBeats"));
+ if (Prop(t, "audioClips") is { ValueKind: JsonValueKind.Array } ac)
+ foreach (var c in ac.EnumerateArray())
+ end = Math.Max(end, Num(c, "startBeat") + AudioBeats(bundlePath, c, bpm));
+ }
+ }
+ return new ProjectSummary(bpm, key, tracks, end);
+ }
+ catch { return null; }
+ }
+
+ // How many beats an audio clip covers: a warped clip says so in beats; an unwarped one
+ // plays its frames at the file's rate (read from the WAV header when the clip runs to
+ // the end of its sample).
+ private static double AudioBeats(string bundle, JsonElement c, double bpm)
+ {
+ if (Num(c, "warpEnabled") != 0)
+ {
+ double ps = Num(c, "warpPlayStart"), pe = Num(c, "warpPlayEnd");
+ return pe > 0 ? Math.Max(0, pe - ps) : Num(c, "warpBeats");
+ }
+ long frames = (long)Num(c, "lengthFrames");
+ string? sample = Prop(c, "sample") is { ValueKind: JsonValueKind.String } s ? s.GetString() : null;
+ var (rate, total) = sample is { Length: > 0 } ? WavInfo(Path.Combine(bundle, sample)) : (0, 0L);
+ if (frames <= 0) frames = Math.Max(0, total - (long)Num(c, "sourceOffsetFrames"));
+ if (rate <= 0) rate = 48000;
+ // Transposing an unwarped clip resamples it, as the engine does: +12 st plays it in half the time.
+ return frames / (double)rate * bpm / 60.0 / Math.Pow(2.0, Num(c, "pitchSemitones") / 12.0);
+ }
+
+ // Sample rate and frame count from a WAV header; (0, 0) when it isn't one.
+ internal static (int Rate, long Frames) WavInfo(string path)
+ {
+ try
+ {
+ using var f = File.OpenRead(path);
+ using var r = new BinaryReader(f);
+ if (new string(r.ReadChars(4)) != "RIFF") return (0, 0);
+ r.ReadInt32();
+ if (new string(r.ReadChars(4)) != "WAVE") return (0, 0);
+ int rate = 0, blockAlign = 0;
+ while (f.Position + 8 <= f.Length)
+ {
+ string id = new(r.ReadChars(4));
+ uint size = r.ReadUInt32();
+ if (id == "fmt ")
+ {
+ long start = f.Position;
+ r.ReadInt16(); r.ReadInt16();
+ rate = r.ReadInt32();
+ r.ReadInt32();
+ blockAlign = r.ReadInt16();
+ f.Position = start + size;
+ }
+ else if (id == "data")
+ return blockAlign > 0 ? (rate, size / blockAlign) : (rate, 0);
+ else f.Position += size + (size & 1);
+ }
+ }
+ catch { }
+ return (0, 0);
+ }
+
+ private static JsonElement? Prop(JsonElement e, string name)
+ => e.ValueKind == JsonValueKind.Object && e.TryGetProperty(name, out var v) ? v : null;
+
+ private static double Num(JsonElement e, string name)
+ => Prop(e, name) switch
+ {
+ { ValueKind: JsonValueKind.Number } n => n.GetDouble(),
+ { ValueKind: JsonValueKind.True } => 1,
+ _ => 0,
+ };
+
+ // --- cache --------------------------------------------------------------------------------
+
+ private Dictionary<string, Entry> Load()
+ {
+ if (_cache is not null) return _cache;
+ try
+ {
+ if (File.Exists(_cacheFile))
+ _cache = JsonSerializer.Deserialize<Dictionary<string, Entry>>(File.ReadAllText(_cacheFile));
+ }
+ catch { _cache = null; }
+ return _cache ??= new Dictionary<string, Entry>();
+ }
+
+ // Written after each new read; bundles that are gone are dropped on the way.
+ private void Save(Dictionary<string, Entry> cache)
+ {
+ try
+ {
+ foreach (var gone in cache.Keys.Where(k => !Directory.Exists(k)).ToList()) cache.Remove(gone);
+ Directory.CreateDirectory(Path.GetDirectoryName(_cacheFile)!);
+ File.WriteAllText(_cacheFile, JsonSerializer.Serialize(cache));
+ }
+ catch { /* a cache — best effort */ }
+ }
+}
diff --git a/src/managed/Nota.Infrastructure/SampleStore/SampleLibraryIndex.cs b/src/managed/Nota.Infrastructure/SampleStore/SampleLibraryIndex.cs
index b05a1b52..566c5739 100644
--- a/src/managed/Nota.Infrastructure/SampleStore/SampleLibraryIndex.cs
+++ b/src/managed/Nota.Infrastructure/SampleStore/SampleLibraryIndex.cs
@@ -59,7 +59,7 @@ public sealed class SampleLibraryIndex : ISampleIndex, IDisposable
private readonly Dictionary<string, Entry> _entries = new(PathComparer);
private readonly List<string> _priority = new();
private bool _loaded;
- private string? _root;
+ private IReadOnlyList<string> _roots = Array.Empty<string>(); // the sample folders (spec 092)
private CancellationTokenSource? _scanCts;
private int _scanGen;
private int _done, _total;
@@ -124,35 +124,38 @@ public sealed class SampleLibraryIndex : ISampleIndex, IDisposable
return info;
}
- public void Watch(string root)
+ public void Watch(string root) => Watch(new[] { root });
+
+ public void Watch(IReadOnlyList<string> roots)
{
+ var list = roots.Where(r => !string.IsNullOrEmpty(r)).ToList();
CancellationTokenSource cts;
int gen;
lock (_gate)
{
- if (_root is null || !PathComparer.Equals(_root, root))
+ if (!list.SequenceEqual(_roots, PathComparer))
{
- _root = root;
+ _roots = list;
foreach (var e in _entries.Values) e.Info = null; // folder hints are relative to the root
}
_scanCts?.Cancel();
_scanCts = cts = new CancellationTokenSource();
gen = ++_scanGen;
}
- var thread = new Thread(() => Scan(root, gen, cts.Token)) { IsBackground = true, Name = "Sample index", Priority = ThreadPriority.BelowNormal };
+ var thread = new Thread(() => Scan(list, gen, cts.Token)) { IsBackground = true, Name = "Sample index", Priority = ThreadPriority.BelowNormal };
thread.Start();
}
public void Prioritize(string folder)
{
- string? root;
+ IReadOnlyList<string> roots;
lock (_gate)
{
_priority.Remove(folder);
_priority.Insert(0, folder);
- root = _root;
+ roots = _roots;
}
- if (root is not null) Watch(root); // re-scan: the new files sort to the front
+ if (roots.Count > 0) Watch(roots); // re-scan: the new files sort to the front
}
public IReadOnlyList<SimilarSample> Similar(string path, int count)
@@ -205,14 +208,19 @@ public sealed class SampleLibraryIndex : ISampleIndex, IDisposable
// --- scan -----------------------------------------------------------------------------
- private void Scan(string root, int gen, CancellationToken ct)
+ private void Scan(IReadOnlyList<string> roots, int gen, CancellationToken ct)
{
try
{
List<string> pending;
lock (_gate) EnsureLoaded();
WarmInfos(gen, ct);
- var found = Enumerate(root, ct);
+ // Folders that are there now; one that is missing (an unplugged drive) keeps its
+ // analyses for when it comes back.
+ var live = roots.Where(r => { try { return Directory.Exists(r); } catch { return false; } }).ToList();
+ var away = roots.Except(live, PathComparer).ToList();
+ var found = new List<string>();
+ foreach (var r in live) found.AddRange(Enumerate(r, ct));
var present = new HashSet<string>(found, PathComparer);
var stamps = new Dictionary<string, (long Size, long Ticks)>(found.Count, PathComparer);
foreach (var p in found)
@@ -226,7 +234,10 @@ public sealed class SampleLibraryIndex : ISampleIndex, IDisposable
if (gen != _scanGen) return;
// Forget files that left the library (anything outside it, dragged in from
// elsewhere, stays until its file is gone).
- var gone = _entries.Keys.Where(p => IsUnder(p, root) ? !present.Contains(p) : !File.Exists(p)).ToList();
+ var gone = _entries.Keys.Where(p =>
+ away.Any(r => IsUnder(p, r)) ? false
+ : live.Any(r => IsUnder(p, r)) ? !present.Contains(p)
+ : !File.Exists(p)).ToList();
foreach (var p in gone) _entries.Remove(p);
if (gone.Count > 0) { _mutations++; _dirty = true; }
@@ -359,7 +370,14 @@ public sealed class SampleLibraryIndex : ISampleIndex, IDisposable
private static bool Fresh(Entry e, FileInfo fi) => e.Size == fi.Length && e.Ticks == fi.LastWriteTimeUtc.Ticks;
private SampleInfo InfoOf(string path, Entry e)
- => e.Info ??= SampleClassifier.Classify(path, SampleNameHints.Parse(path, _root), e.Analysis);
+ => e.Info ??= SampleClassifier.Classify(path, SampleNameHints.Parse(path, RootOf(path)), e.Analysis);
+
+ // The sample folder holding `path` — folder-name hints are read below it.
+ private string? RootOf(string path)
+ {
+ foreach (var r in _roots) if (IsUnder(path, r)) return r;
+ return null;
+ }
// Per-dimension mean / spread over the library, so a dB band and a 0..1 flatness weigh alike.
private (float[] Mean, float[] Std) Stats()
diff --git a/src/managed/Nota.Infrastructure/Settings/SettingsService.cs b/src/managed/Nota.Infrastructure/Settings/SettingsService.cs
index 0e7b320a..ca708e9e 100644
--- a/src/managed/Nota.Infrastructure/Settings/SettingsService.cs
+++ b/src/managed/Nota.Infrastructure/Settings/SettingsService.cs
@@ -6,6 +6,7 @@
// (settings.json).
using System.Text.Json;
+using Nota.Application.Browser;
namespace Nota.Infrastructure;
@@ -18,9 +19,14 @@ public sealed class SettingsService : ISettingsService
public event Action? Changed;
- public SettingsService()
+ public event Action? SampleFoldersChanged;
+
+ public SettingsService() : this(Path.Combine(NotaPaths.DataDir, "settings.json")) { }
+
+ /// <summary>Tests: settings kept in <paramref name="path"/>.</summary>
+ public SettingsService(string path)
{
- _path = Path.Combine(NotaPaths.DataDir, "settings.json");
+ _path = path;
try
{
@@ -31,18 +37,130 @@ public sealed class SettingsService : ISettingsService
{
Current = new Settings(); // corrupt/older file → defaults
}
+ RepairSampleFolders();
}
public void Save()
{
+ MirrorDefaultSampleFolder();
try { File.WriteAllText(_path, JsonSerializer.Serialize(Current, JsonOpts)); }
catch { /* best-effort; not fatal */ }
Changed?.Invoke();
}
+ /// <summary>Where samples live when the user never chose a folder.</summary>
+ public static string DefaultSamplesLocation() => Path.Combine(UserDirs.GetMusicDir(), "Nota Samples");
+
public string ResolvedSamplesFolder()
- => EnsureDir(string.IsNullOrWhiteSpace(Current.SamplesFolder)
- ? Path.Combine(UserDirs.GetMusicDir(), "Nota Samples") : Current.SamplesFolder);
+ {
+ FollowLegacyField();
+ var def = Current.SampleFolders?.Find(e => e.IsDefault)?.Path;
+ if (string.IsNullOrWhiteSpace(def)) def = string.IsNullOrWhiteSpace(Current.SamplesFolder) ? DefaultSamplesLocation() : Current.SamplesFolder;
+ return EnsureDir(def);
+ }
+
+ // --- sample folders (spec 092) ---------------------------------------------------------
+
+ // A pre-092 file has only SamplesFolder: it becomes the one (default) entry. Bad entries
+ // (nested, duplicate) are dropped with a log line.
+ private void RepairSampleFolders()
+ {
+ string legacy = string.IsNullOrWhiteSpace(Current.SamplesFolder) ? DefaultSamplesLocation() : Current.SamplesFolder;
+ var (list, dropped) = SampleFolderRules.Repair(Current.SampleFolders, legacy);
+ Current.SampleFolders = list;
+ foreach (var d in dropped) Console.Error.WriteLine($"[settings] Sample folders: dropped '{d}' (empty, duplicate or nested in another folder)");
+ MirrorDefaultSampleFolder();
+ }
+
+ // SamplesFolder stays the default folder's path, for older versions and Mosaic refs.
+ private void MirrorDefaultSampleFolder()
+ {
+ var def = Current.SampleFolders?.Find(e => e.IsDefault);
+ if (def is not null) Current.SamplesFolder = def.Path;
+ }
+
+ // Code that still sets the single field (older harnesses, scripts) moves the default
+ // folder with it: a folder already in the list becomes the default, any other one
+ // takes the default entry's place.
+ private void FollowLegacyField()
+ {
+ var list = Current.SampleFolders;
+ if (list is null || string.IsNullOrWhiteSpace(Current.SamplesFolder)) return;
+ var legacy = SampleFolderRules.Normalize(Current.SamplesFolder);
+ var def = list.Find(e => e.IsDefault);
+ if (def is null || SampleFolderRules.PathComparer.Equals(def.Path, legacy)) return;
+ var hit = list.Find(e => SampleFolderRules.PathComparer.Equals(e.Path, legacy));
+ if (hit is not null) { foreach (var e in list) e.IsDefault = ReferenceEquals(e, hit); }
+ else { def.Path = legacy; def.Name = null; }
+ }
+
+ private List<SampleFolderEntry> Folders
+ {
+ get
+ {
+ FollowLegacyField();
+ return Current.SampleFolders ??= SampleFolderRules.Repair(null, DefaultSamplesLocation()).List;
+ }
+ }
+
+ public IReadOnlyList<ResolvedSampleFolder> ResolvedSampleFolders()
+ {
+ var list = Folders;
+ var result = new List<ResolvedSampleFolder>(list.Count);
+ for (int i = 0; i < list.Count; i++)
+ {
+ var e = list[i];
+ string path = e.IsDefault ? ResolvedSamplesFolder() : e.Path; // only the default is created
+ bool ok;
+ try { ok = Directory.Exists(path); } catch { ok = false; }
+ result.Add(new ResolvedSampleFolder(i, path, SampleFolderRules.Label(e), e.IsDefault, ok));
+ }
+ return result;
+ }
+
+ public SampleFolderResult AddSampleFolder(string path)
+ {
+ path = SampleFolderRules.Normalize(path);
+ bool isDir;
+ try { isDir = path.Length > 0 && Directory.Exists(path); } catch { isDir = false; }
+ if (!isDir) return new(SampleFolderOutcome.NotADirectory);
+ var r = SampleFolderRules.Check(Folders.ConvertAll(e => e.Path), path);
+ if (!r.Ok) return r;
+ Folders.Add(new SampleFolderEntry { Path = path });
+ Save();
+ SampleFoldersChanged?.Invoke();
+ return r;
+ }
+
+ public bool RemoveSampleFolder(int index)
+ {
+ var list = Folders;
+ if (list.Count <= 1 || index < 0 || index >= list.Count) return false;
+ bool wasDefault = list[index].IsDefault;
+ list.RemoveAt(index);
+ if (wasDefault) list[Math.Min(index, list.Count - 1)].IsDefault = true;
+ Save();
+ SampleFoldersChanged?.Invoke();
+ return true;
+ }
+
+ public void RenameSampleFolder(int index, string? name)
+ {
+ var list = Folders;
+ if (index < 0 || index >= list.Count) return;
+ list[index].Name = string.IsNullOrWhiteSpace(name) ? null : name.Trim();
+ Save();
+ SampleFoldersChanged?.Invoke();
+ }
+
+ public void SetDefaultSampleFolder(int index)
+ {
+ var list = Folders;
+ if (index < 0 || index >= list.Count || list[index].IsDefault) return;
+ for (int i = 0; i < list.Count; i++) list[i].IsDefault = i == index;
+ Save();
+ SampleFoldersChanged?.Invoke();
+ }
public string ResolvedProjectsFolder()
=> EnsureDir(string.IsNullOrWhiteSpace(Current.ProjectsFolder)
diff --git a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
index 9103e8cc..f4ca0860 100644
--- a/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
+++ b/src/managed/Nota.Presentation/ViewModels/BrowserViewModel.cs
@@ -24,11 +24,17 @@ public enum BrowserItemKind
Group,
/// <summary>A Standard MIDI File (.mid) — drops as MIDI clip(s).</summary>
MidiFile,
+ /// <summary>A file the Files browse view lists but Nota can't add (spec 092): shown
+ /// faded, never dragged, opened or auditioned.</summary>
+ OtherFile,
}
/// <summary>Active library filter for the device tabs (Instr / FX / MIDI).</summary>
public enum BrowserFilter { None, Favorites, Tag }
+/// <summary>The Files browse view's list: filled, an empty folder, or a folder Nota can't read.</summary>
+public enum BrowseListState { Ok, Empty, Unreadable }
+
public sealed class BrowserItem : INotifyPropertyChanged
{
private SampleInfo? _sample;
@@ -83,6 +89,58 @@ public sealed class BrowserItem : INotifyPropertyChanged
public bool IsExpanded { get; set; } // toggled by the view-model
/// <summary>The Files tab's Downloaded folder (installed sample packs): its own icon, listed first.</summary>
public bool IsDownloads { get; init; }
+ /// <summary>A top-level sample folder of the Files tab (spec 092): its index in the
+ /// settings' folder list, or −1 for any other row.</summary>
+ public int PlaceIndex { get; init; } = -1;
+ /// <summary>A sample folder that can't be found (an unplugged drive): shown dimmed, empty.</summary>
+ public bool Unavailable { get; init; }
+ /// <summary>A drive / volume row of the browse view's Computer level.</summary>
+ public bool IsVolume { get; init; }
+ /// <summary>A browse-view file's size in bytes (shown in its own column); null elsewhere.</summary>
+ public long? Size { get; init; }
+
+ /// <summary>Projects tab (spec 092, #582): when the project was last saved; null if unknown.</summary>
+ public DateTime? Modified { get; init; }
+
+ private Nota.Application.Browser.ProjectSummary? _summary;
+ /// <summary>Projects tab: tempo, key, length, tracks — read in the background, null until then.</summary>
+ public Nota.Application.Browser.ProjectSummary? Summary
+ {
+ get => _summary;
+ set
+ {
+ if (ReferenceEquals(_summary, value)) return;
+ _summary = value;
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Summary)));
+ }
+ }
+
+ private bool _isOpen;
+ /// <summary>Projects tab: this is the project open in Nota.</summary>
+ public bool IsOpen
+ {
+ get => _isOpen;
+ set
+ {
+ if (_isOpen == value) return;
+ _isOpen = value;
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsOpen)));
+ }
+ }
+
+ private bool _located;
+ /// <summary>The row is the source file of the clip selected in the arrangement / Session
+ /// (spec 092, #581): the view marks it.</summary>
+ public bool Located
+ {
+ get => _located;
+ set
+ {
+ if (_located == value) return;
+ _located = value;
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Located)));
+ }
+ }
public string Display => string.IsNullOrEmpty(Sub) ? Name : $"{Name} · {Sub}";
public override string ToString() => Display;
@@ -198,8 +256,10 @@ public sealed partial class BrowserViewModel : ObservableObject
public BrowserViewModel(IPluginCatalog catalog, IPresetLibrary presets, IFactoryPresets factory,
ISettingsService? settings = null, IBrowserLibrary? library = null,
- IDrumKits? kits = null, ISampleIndex? sampleIndex = null, IMosaicPacks? mosaic = null)
+ IDrumKits? kits = null, ISampleIndex? sampleIndex = null, IMosaicPacks? mosaic = null,
+ Nota.Application.Browser.IProjectSummaries? projectSummaries = null)
{
+ _projectSummaries = projectSummaries;
_mosaic = mosaic;
_index = sampleIndex;
_catalog = catalog;
@@ -493,7 +553,7 @@ public sealed partial class BrowserViewModel : ObservableObject
public void FilterTree(int tab, string query)
{
if (tab >= 0 && tab < _treeQuery.Length) _treeQuery[tab] = query ?? "";
- if (tab == 3) RebuildSampleVisible();
+ if (tab == 3) { RebuildSampleVisible(); RebuildBrowseVisible(); }
else if (tab == 4) RebuildPresetVisible();
else RebuildVisible(tab);
}
@@ -624,43 +684,215 @@ public sealed partial class BrowserViewModel : ObservableObject
/// <summary>Scans the configured samples folder into a navigable folder tree (M7-4a).
/// Folders become expandable parent nodes; audio and MIDI files are leaves. Only folders
/// on a path to such a file appear.</summary>
+ // A newer rebuild cancels the one still walking the disk.
+ private CancellationTokenSource? _samplesCts;
+
+ /// <summary>Rebuilds the Files tree from every sample folder (spec 092). On the UI thread
+ /// the folders are walked in the background and the tree swapped in when done; without a
+ /// synchronisation context (tests) it runs inline.</summary>
public void RebuildSamples()
{
- _sampleTree.Clear();
- _sampleLeaves.Clear();
- Samples.Clear();
- if (_settings is null) return;
- var root = _settings.ResolvedSamplesFolder();
- _index?.Watch(root); // analyses whatever it doesn't know yet, in the background
-
- // Folder nodes keyed by absolute directory path (reused while placing files).
- var folders = new Dictionary<string, BrowserItem>(StringComparer.OrdinalIgnoreCase);
- foreach (var path in EnumerateFilesSafe(root)
- .Where(p => SampleExts.Contains(Path.GetExtension(p).ToLowerInvariant())
- || Nota.Application.Midi.MidiFileReader.IsMidiFile(p))
- .OrderBy(p => p, StringComparer.OrdinalIgnoreCase)
- .Take(MaxSamples))
- {
- var dir = Path.GetDirectoryName(path) ?? root;
- var parentChildren = GetOrCreateFolder(root, dir, folders, out int depth);
- var leaf = new BrowserItem
+ if (SynchronizationContext.Current is null) { RebuildSamplesAsync().GetAwaiter().GetResult(); return; }
+ _ = RebuildSamplesAsync();
+ }
+
+ /// <summary>The background form of <see cref="RebuildSamples"/>; completes once the new tree is shown.</summary>
+ public async Task RebuildSamplesAsync()
+ {
+ _samplesCts?.Cancel();
+ if (_settings is null)
+ {
+ ApplySampleTree(new List<BrowserItem>(), new List<BrowserItem>());
+ return;
+ }
+ var cts = _samplesCts = new CancellationTokenSource();
+ SamplesBuilding = true;
+ var all = _settings.ResolvedSampleFolders();
+ // Every root, unplugged ones too: the index keeps an offline folder's analyses for
+ // when its drive comes back, and only knows it's offline if it's in the list.
+ _index?.Watch(all.Select(f => f.Path).ToList()); // analyses whatever it doesn't know yet, in the background
+ _sampleAvailability = Availability(all);
+ // The default folder leads the Files tab (FR-004); each keeps its own PlaceIndex.
+ var folders = all.OrderByDescending(f => f.IsDefault).ToList();
+ var expanded = new HashSet<string>(_expandedTreeKeys, StringComparer.OrdinalIgnoreCase);
+ var ctx = SynchronizationContext.Current;
+
+ (List<BrowserItem> Tree, List<BrowserItem> Leaves) built;
+ if (ctx is null) built = BuildSampleTree(folders, expanded, cts.Token);
+ else
+ {
+ // A first build over a big library: show the folders' first level at once, the
+ // files follow when the walk ends (SC-005).
+ if (_sampleTree.Count == 0)
{
- Name = Path.GetFileName(path),
- Kind = Nota.Application.Midi.MidiFileReader.IsMidiFile(path) ? BrowserItemKind.MidiFile : BrowserItemKind.Sample,
- Sub = "",
- Path = path,
- Depth = depth,
- };
- if (leaf.Kind == BrowserItemKind.Sample) { leaf.Sample = _index?.Get(path); _sampleLeaves.Add(leaf); }
- parentChildren.Add(leaf);
+ try
+ {
+ var skeleton = await Task.Run(() => BuildSampleSkeleton(folders, expanded), cts.Token);
+ if (cts.IsCancellationRequested) return;
+ if (_sampleTree.Count == 0) ApplySampleTree(skeleton, new List<BrowserItem>());
+ }
+ catch (OperationCanceledException) { return; }
+ }
+ try { built = await Task.Run(() => BuildSampleTree(folders, expanded, cts.Token), cts.Token); }
+ catch (OperationCanceledException) { return; }
+ }
+ if (cts.IsCancellationRequested) return;
+ SamplesBuilding = false; // before the swap: SamplesRebuilt handlers see a whole tree
+ ApplySampleTree(built.Tree, built.Leaves);
+ }
+
+ private void ApplySampleTree(List<BrowserItem> tree, List<BrowserItem> leaves)
+ {
+ // The walk used the folders open when it began; keep what was opened or closed since.
+ void Reopen(List<BrowserItem> nodes)
+ {
+ foreach (var n in nodes)
+ if (n.Kind == BrowserItemKind.Folder)
+ {
+ n.IsExpanded = _expandedTreeKeys.Contains(n.Path);
+ Reopen(n.Children);
+ }
}
+ Reopen(tree);
+ _sampleTree.Clear();
+ _sampleTree.AddRange(tree);
+ _sampleLeaves.Clear();
+ _sampleLeaves.AddRange(leaves);
+ foreach (var leaf in _sampleLeaves) leaf.Sample = _index?.Get(leaf.Path);
AppendKitFolders();
- SortSampleTree(_sampleTree);
_similarAnchor = null; // the anchor row is gone; its list would point at stale rows
_similarRows.Clear();
+ ApplyLocated();
RebuildSampleVisible();
+ SamplesRebuilt?.Invoke();
}
+ /// <summary>Raised after the Files tree was rebuilt (folders changed, rescan).</summary>
+ public event Action? SamplesRebuilt;
+
+ /// <summary>True while a Files tree rebuild is walking the disk; the tree on show may not
+ /// hold every file yet.</summary>
+ public bool SamplesBuilding { get; private set; }
+
+ // Which folders were reachable at the last rebuild ("1" / "0" per folder, in list order).
+ private string _sampleAvailability = "";
+
+ private static string Availability(IReadOnlyList<ResolvedSampleFolder> folders)
+ => string.Concat(folders.Select(f => f.Available ? '1' : '0'));
+
+ /// <summary>The Files tab came into view: rebuilds the tree when a folder's drive was
+ /// plugged in or pulled out since the last rebuild.</summary>
+ public void RefreshSampleAvailability()
+ {
+ if (_settings is null || SamplesBuilding) return;
+ if (Availability(_settings.ResolvedSampleFolders()) != _sampleAvailability) RebuildSamples();
+ }
+
+ // Walks every folder (worker thread; touches no shared state). One folder keeps today's
+ // flat tree; with several, each becomes a top-level node holding its files.
+ private static (List<BrowserItem> Tree, List<BrowserItem> Leaves) BuildSampleTree(
+ IReadOnlyList<ResolvedSampleFolder> folders, HashSet<string> expanded, CancellationToken ct)
+ {
+ var tree = new List<BrowserItem>();
+ var leaves = new List<BrowserItem>();
+ bool places = folders.Count > 1;
+ foreach (var f in folders)
+ {
+ ct.ThrowIfCancellationRequested();
+ List<BrowserItem> top = tree;
+ int baseDepth = 0;
+ if (places)
+ {
+ var place = new BrowserItem
+ {
+ Name = f.Label,
+ Kind = BrowserItemKind.Folder,
+ Sub = "",
+ Tip = f.Available ? f.Path : Loc.F("browser.unavailable_tip", f.Path),
+ Path = f.Path,
+ Depth = 0,
+ PlaceIndex = f.Index,
+ Unavailable = !f.Available,
+ IsExpanded = expanded.Contains(f.Path),
+ };
+ tree.Add(place);
+ top = place.Children;
+ baseDepth = 1;
+ }
+ if (!f.Available) continue;
+
+ // Folder nodes keyed by absolute directory path (reused while placing files).
+ var nodes = new Dictionary<string, BrowserItem>(StringComparer.OrdinalIgnoreCase);
+ foreach (var path in EnumerateFilesSafe(f.Path)
+ .Where(IsSampleOrMidi)
+ .Take(MaxSamples)
+ .OrderBy(p => p, StringComparer.OrdinalIgnoreCase))
+ {
+ ct.ThrowIfCancellationRequested();
+ var dir = Path.GetDirectoryName(path) ?? f.Path;
+ var parentChildren = GetOrCreateFolder(f.Path, dir, nodes, top, baseDepth, expanded, out int depth);
+ var leaf = new BrowserItem
+ {
+ Name = Path.GetFileName(path),
+ Kind = Nota.Application.Midi.MidiFileReader.IsMidiFile(path) ? BrowserItemKind.MidiFile : BrowserItemKind.Sample,
+ Sub = "",
+ Path = path,
+ Depth = depth,
+ };
+ if (leaf.Kind == BrowserItemKind.Sample) leaves.Add(leaf);
+ parentChildren.Add(leaf);
+ }
+ }
+ foreach (var n in tree)
+ if (places) SortSampleTree(n.Children);
+ if (!places) SortSampleTree(tree);
+ return (tree, leaves);
+ }
+
+ // The first level only: each folder's subfolders (and, with several folders, the folder
+ // nodes themselves) — what a big library shows while its files are still being found.
+ private static List<BrowserItem> BuildSampleSkeleton(IReadOnlyList<ResolvedSampleFolder> folders, HashSet<string> expanded)
+ {
+ var tree = new List<BrowserItem>();
+ bool places = folders.Count > 1;
+ var opts = new EnumerationOptions { IgnoreInaccessible = true, AttributesToSkip = FileAttributes.Hidden | FileAttributes.System };
+ foreach (var f in folders)
+ {
+ List<BrowserItem> top = tree;
+ if (places)
+ {
+ var place = new BrowserItem
+ {
+ Name = f.Label, Kind = BrowserItemKind.Folder, Sub = "", Path = f.Path, Depth = 0,
+ Tip = f.Available ? f.Path : Loc.F("browser.unavailable_tip", f.Path),
+ PlaceIndex = f.Index, Unavailable = !f.Available, IsExpanded = expanded.Contains(f.Path),
+ };
+ tree.Add(place);
+ top = place.Children;
+ }
+ if (!f.Available) continue;
+ try
+ {
+ foreach (var d in Directory.EnumerateDirectories(f.Path, "*", opts).OrderBy(d => d, StringComparer.OrdinalIgnoreCase))
+ {
+ var name = Path.GetFileName(d);
+ top.Add(new BrowserItem
+ {
+ Name = name, Kind = BrowserItemKind.Folder, Sub = "", Path = d, Depth = places ? 1 : 0,
+ IsDownloads = string.Equals(name, SamplePacks.FolderName, StringComparison.OrdinalIgnoreCase),
+ });
+ }
+ }
+ catch { /* unreadable: the full walk says what it can */ }
+ }
+ foreach (var n in tree) if (places) SortSampleTree(n.Children);
+ if (!places) SortSampleTree(tree);
+ return tree;
+ }
+
+ private static bool IsSampleOrMidi(string p)
+ => SampleExts.Contains(Path.GetExtension(p).ToLowerInvariant()) || Nota.Application.Midi.MidiFileReader.IsMidiFile(p);
+
// --- smart samples: tags, filter, similar ------------------------------------------
/// <summary>The Files tab's sample filter ("loops · 120–128 · A minor").</summary>
@@ -701,13 +933,13 @@ public sealed partial class BrowserViewModel : ObservableObject
var index = _index;
string path = item.Path;
var hits = await Task.Run(() => index.Similar(path, count));
- var root = _settings?.ResolvedSamplesFolder();
+ var roots = _settings?.ResolvedSampleFolders().Select(f => f.Path).ToList() ?? new List<string>();
_similarRows = hits.Select(h => new BrowserItem
{
Name = Path.GetFileName(h.Info.Path),
Kind = BrowserItemKind.Sample,
Sub = "",
- Tip = FolderOf(h.Info.Path, root),
+ Tip = FolderOf(h.Info.Path, roots.FirstOrDefault(r => Nota.Application.Browser.SampleFolderRules.IsSameOrInside(h.Info.Path, r))),
Path = h.Info.Path,
Depth = 0,
}).ToList();
@@ -735,6 +967,176 @@ public sealed partial class BrowserViewModel : ObservableObject
return rel == "." ? "" : rel.StartsWith("..", StringComparison.Ordinal) ? dir : rel;
}
+ // --- Files: browse mode (spec 092, #580) -------------------------------------------------
+
+ private List<BrowserItem> _browseAll = new();
+ private CancellationTokenSource? _browseCts;
+
+ /// <summary>The browse view's rows: the current folder's subfolders, then its audio and
+ /// MIDI files (or, at the Computer level, the drives), filtered by the Files search.</summary>
+ public BulkObservableCollection<BrowserItem> BrowseItems { get; } = new();
+
+ /// <summary>Where the browse view is; created on first use at the remembered folder.</summary>
+ public Nota.Application.Browser.FileBrowseState Browse
+ => _browse ??= CreateBrowseState();
+ private Nota.Application.Browser.FileBrowseState? _browse;
+
+ /// <summary>Why the browse list is empty: <see cref="BrowseListState.Ok"/>, an empty folder
+ /// or one Nota can't read.</summary>
+ public BrowseListState BrowseState { get; private set; }
+
+ /// <summary>The file a navigation asked to select (a pasted file path, Locate), or null.</summary>
+ public string? BrowseSelect { get; private set; }
+
+ /// <summary>Raised on the UI thread after <see cref="BrowseItems"/> was refilled.</summary>
+ public event Action? BrowseRefreshed;
+
+ /// <summary>The Files tab shows the browse view instead of the tree (remembered).</summary>
+ public bool BrowseMode
+ {
+ get => _settings?.Current.FilesBrowseMode ?? _browseModeNoSettings;
+ set
+ {
+ if (BrowseMode == value) return;
+ if (_settings is not null) { _settings.Current.FilesBrowseMode = value; _settings.Save(); }
+ else _browseModeNoSettings = value;
+ if (value) _ = RefreshBrowseAsync();
+ }
+ }
+ private bool _browseModeNoSettings;
+
+ private Nota.Application.Browser.FileBrowseState CreateBrowseState()
+ {
+ string start = _settings?.Current.FilesBrowseFolder ?? "";
+ try { if (start.Length == 0 || !Directory.Exists(start)) start = _settings?.ResolvedSamplesFolder() ?? Nota.Application.Browser.FileBrowseState.Computer; }
+ catch { start = Nota.Application.Browser.FileBrowseState.Computer; }
+ var b = new Nota.Application.Browser.FileBrowseState(start);
+ b.Changed += () =>
+ {
+ if (!b.IsComputer && _settings is not null && _settings.Current.FilesBrowseFolder != b.Location)
+ {
+ _settings.Current.FilesBrowseFolder = b.Location;
+ _settings.Save();
+ }
+ _ = RefreshBrowseAsync();
+ };
+ return b;
+ }
+
+ /// <summary>Home: back to the default sample folder, where browsing starts (one Back step returns).</summary>
+ public void BrowseHome()
+ {
+ if (_settings is null) return;
+ Browse.Go(_settings.ResolvedSamplesFolder());
+ }
+
+ /// <summary>The browse view already shows the default sample folder.</summary>
+ public bool BrowseAtHome => _settings is not null
+ && Nota.Application.Browser.SampleFolderRules.PathComparer.Equals(Browse.Location,
+ Nota.Application.Browser.SampleFolderRules.Normalize(_settings.ResolvedSamplesFolder()));
+
+ /// <summary>Opens <paramref name="folder"/> in the browse view, selecting
+ /// <paramref name="selectFile"/> once listed.</summary>
+ public void BrowseTo(string folder, string? selectFile = null)
+ {
+ BrowseSelect = selectFile;
+ if (Nota.Application.Browser.SampleFolderRules.PathComparer.Equals(
+ Nota.Application.Browser.SampleFolderRules.Normalize(folder), Browse.Location))
+ _ = RefreshBrowseAsync();
+ else Browse.Go(folder);
+ }
+
+ /// <summary>Re-lists the current browse location (worker thread when on the UI thread).</summary>
+ public async Task RefreshBrowseAsync()
+ {
+ _browseCts?.Cancel();
+ var cts = _browseCts = new CancellationTokenSource();
+ string loc = Browse.Location;
+ (List<BrowserItem> Rows, BrowseListState State) listed;
+ if (SynchronizationContext.Current is null) listed = ListBrowse(loc);
+ else
+ {
+ try { listed = await Task.Run(() => ListBrowse(loc), cts.Token); }
+ catch (OperationCanceledException) { return; }
+ }
+ if (cts.IsCancellationRequested) return;
+ _browseAll = listed.Rows;
+ foreach (var r in _browseAll) if (r.Kind == BrowserItemKind.Sample) r.Sample = _index?.Get(r.Path);
+ BrowseState = listed.State;
+ RebuildBrowseVisible();
+ ApplyLocated();
+ BrowseRefreshed?.Invoke();
+ BrowseSelect = null;
+ }
+
+ // One folder's usable entries (worker thread): subfolders, then audio + MIDI files,
+ // each by name; hidden entries skipped. The Computer level lists the volumes.
+ public static (List<BrowserItem> Rows, BrowseListState State) ListBrowse(string location)
+ {
+ var rows = new List<BrowserItem>();
+ if (location.Length == 0)
+ {
+ foreach (var (label, path) in Nota.Application.Browser.FileBrowseState.Volumes())
+ rows.Add(new BrowserItem { Name = label, Kind = BrowserItemKind.Folder, Sub = "", Tip = path, Path = path, Depth = 0, IsVolume = true });
+ return (rows, BrowseListState.Ok);
+ }
+ var opts = new EnumerationOptions { IgnoreInaccessible = true, AttributesToSkip = FileAttributes.Hidden | FileAttributes.System };
+ try
+ {
+ if (!Directory.Exists(location)) return (rows, BrowseListState.Unreadable);
+ foreach (var d in Directory.EnumerateDirectories(location, "*", opts).OrderBy(d => Path.GetFileName(d), StringComparer.OrdinalIgnoreCase))
+ rows.Add(new BrowserItem { Name = Path.GetFileName(d), Kind = BrowserItemKind.Folder, Sub = "", Path = d, Depth = 0 });
+ // Every file is listed; what Nota can't add is marked so the view fades it (spec 092).
+ foreach (var f in Directory.EnumerateFiles(location, "*", opts).OrderBy(f => Path.GetFileName(f), StringComparer.OrdinalIgnoreCase))
+ {
+ long size;
+ try { size = new FileInfo(f).Length; } catch { size = 0; }
+ rows.Add(new BrowserItem
+ {
+ Name = Path.GetFileName(f),
+ Kind = !IsSampleOrMidi(f) ? BrowserItemKind.OtherFile
+ : Nota.Application.Midi.MidiFileReader.IsMidiFile(f) ? BrowserItemKind.MidiFile : BrowserItemKind.Sample,
+ Sub = "",
+ Path = f,
+ Depth = 0,
+ Size = size,
+ });
+ }
+ }
+ catch (UnauthorizedAccessException) { return (new List<BrowserItem>(), BrowseListState.Unreadable); }
+ catch (IOException) { return (new List<BrowserItem>(), BrowseListState.Unreadable); }
+ return (rows, rows.Count == 0 ? BrowseListState.Empty : BrowseListState.Ok);
+ }
+
+ // The Files search filters the current folder only (no recursive walk).
+ private void RebuildBrowseVisible()
+ {
+ string q = _treeQuery[3].Trim();
+ BrowseItems.ReplaceAll(q.Length == 0 ? _browseAll : _browseAll.Where(r => Matches(r, q)).ToList());
+ }
+
+ // --- Locate (spec 092, #581) -----------------------------------------------------------
+
+ private string? _locatedPath;
+
+ /// <summary>The source file of the clip selected in the arrangement / Session, or null.
+ /// Marks the matching Files row (tree or browse list) — never expands, scrolls or
+ /// switches tabs: a row the user can't see stays unmarked until they open its folder.</summary>
+ public void SetLocatedPath(string? path)
+ {
+ _locatedPath = string.IsNullOrEmpty(path) ? null : path;
+ ApplyLocated();
+ }
+
+ public string? LocatedPath => _locatedPath;
+
+ private void ApplyLocated()
+ {
+ var cmp = Nota.Application.Browser.SampleFolderRules.PathComparer;
+ foreach (var leaf in _sampleLeaves) leaf.Located = _locatedPath is not null && cmp.Equals(leaf.Path, _locatedPath);
+ foreach (var row in BrowseItems) row.Located = _locatedPath is not null && cmp.Equals(row.Path, _locatedPath);
+ }
+
// Files rows the sample filter lets through: audio the index has analysed and that
// matches; a MIDI file has no tempo or key, so any filter hides it.
private bool PassesSampleFilter(BrowserItem leaf)
@@ -787,16 +1189,17 @@ public sealed partial class BrowserViewModel : ObservableObject
if (rootNode.Children.Count > 0) _sampleTree.Add(rootNode);
}
- // Ensures the folder chain from root down to `dir` exists, returning the child list the
- // file should join and the file's tree depth. Root-level files land directly in the roots.
- private List<BrowserItem> GetOrCreateFolder(string root, string dir,
- Dictionary<string, BrowserItem> folders, out int fileDepth)
+ // Ensures the folder chain from root down to `dir` exists under `top` (the tree, or a
+ // sample folder's node), returning the child list the file should join and the file's
+ // tree depth. Files right in the root land directly in `top`.
+ private static List<BrowserItem> GetOrCreateFolder(string root, string dir, Dictionary<string, BrowserItem> folders,
+ List<BrowserItem> top, int baseDepth, HashSet<string> expanded, out int fileDepth)
{
var rel = Path.GetRelativePath(root, dir);
- if (rel == "." || rel.StartsWith("..", StringComparison.Ordinal)) { fileDepth = 0; return _sampleTree; }
+ if (rel == "." || rel.StartsWith("..", StringComparison.Ordinal)) { fileDepth = baseDepth; return top; }
var segments = rel.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
- List<BrowserItem> children = _sampleTree;
+ List<BrowserItem> children = top;
string abs = root;
for (int i = 0; i < segments.Length; i++)
{
@@ -811,8 +1214,8 @@ public sealed partial class BrowserViewModel : ObservableObject
Sub = "",
Tip = downloads ? Loc.T("browser.sample_packs_installed_from_settings") : "",
Path = abs,
- Depth = i,
- IsExpanded = _expandedTreeKeys.Contains(abs),
+ Depth = baseDepth + i,
+ IsExpanded = expanded.Contains(abs),
IsDownloads = downloads,
};
folders[abs] = node;
@@ -820,7 +1223,7 @@ public sealed partial class BrowserViewModel : ObservableObject
}
children = node.Children;
}
- fileDepth = segments.Length;
+ fileDepth = baseDepth + segments.Length;
return children;
}
@@ -898,30 +1301,141 @@ public sealed partial class BrowserViewModel : ObservableObject
return true;
}
- /// <summary>Scans the configured projects folder for .nota bundles (M7-4b).</summary>
+ // --- Projects tab (M7-4b; spec 092, #582) --------------------------------------------------
+
+ private readonly Nota.Application.Browser.IProjectSummaries? _projectSummaries;
+ private CancellationTokenSource? _projectsCts;
+ private string? _openProjectPath;
+
+ /// <summary>The project open in Nota (its bundle path), marked in the Projects tab.</summary>
+ public string? OpenProjectPath
+ {
+ get => _openProjectPath;
+ set
+ {
+ _openProjectPath = value;
+ foreach (var p in Projects) p.IsOpen = IsOpenProject(p.Path);
+ }
+ }
+
+ private bool IsOpenProject(string path)
+ => _openProjectPath is { Length: > 0 } open
+ && Nota.Application.Browser.SampleFolderRules.PathComparer.Equals(
+ Nota.Application.Browser.SampleFolderRules.Normalize(open), Nota.Application.Browser.SampleFolderRules.Normalize(path));
+
+ /// <summary>The Projects tab's order (remembered in settings).</summary>
+ public ProjectsSortOrder ProjectsSort
+ {
+ get => _settings?.Current.ProjectsSort ?? _projectsSortNoSettings;
+ set
+ {
+ if (ProjectsSort == value) return;
+ if (_settings is not null) { _settings.Current.ProjectsSort = value; _settings.Save(); }
+ else _projectsSortNoSettings = value;
+ RebuildProjects();
+ }
+ }
+ private ProjectsSortOrder _projectsSortNoSettings;
+
+ /// <summary>Scans the configured projects folder for .nota bundles: newest first (or by
+ /// name), each with its save date; tempo, key, length and tracks follow from a background
+ /// read (cached), filling the rows in place.</summary>
public void RebuildProjects()
{
+ _projectsCts?.Cancel();
Projects.Clear();
if (_settings is null) return;
var root = _settings.ResolvedProjectsFolder();
+ var rows = new List<BrowserItem>();
try
{
foreach (var dir in Directory.EnumerateDirectories(root)
- .Where(d => d.EndsWith(".nota", StringComparison.OrdinalIgnoreCase))
- .OrderBy(d => d, StringComparer.OrdinalIgnoreCase))
+ .Where(d => d.EndsWith(".nota", StringComparison.OrdinalIgnoreCase)))
{
- Projects.Add(new BrowserItem
+ var modified = Nota.Application.Browser.ProjectDates.Modified(dir);
+ rows.Add(new BrowserItem
{
Name = Path.GetFileNameWithoutExtension(dir),
Kind = BrowserItemKind.Project,
- Sub = "project",
+ Sub = modified is { } m ? Nota.Application.Browser.ProjectDates.Format(m) : "",
Path = dir,
+ Modified = modified,
+ IsOpen = IsOpenProject(dir),
});
}
}
catch { /* folder missing/unreadable — empty list */ }
+
+ IEnumerable<BrowserItem> ordered = ProjectsSort == ProjectsSortOrder.Name
+ ? rows.OrderBy(r => r.Name, StringComparer.OrdinalIgnoreCase)
+ : rows.OrderByDescending(r => r.Modified.HasValue).ThenByDescending(r => r.Modified).ThenBy(r => r.Name, StringComparer.OrdinalIgnoreCase);
+ foreach (var r in ordered) Projects.Add(r);
+ FillProjectSummaries();
}
+ /// <summary>Completes once every visible project's details were read (tests).</summary>
+ public Task ProjectSummariesTask { get; private set; } = Task.CompletedTask;
+
+ private void FillProjectSummaries()
+ {
+ if (_projectSummaries is null || Projects.Count == 0) return;
+ var reader = _projectSummaries;
+ var rows = Projects.ToList();
+ var cts = _projectsCts = new CancellationTokenSource();
+ var ctx = SynchronizationContext.Current;
+ ProjectSummariesTask = Task.Run(() =>
+ {
+ foreach (var row in rows)
+ {
+ if (cts.IsCancellationRequested) return;
+ Nota.Application.Browser.ProjectSummary? sum;
+ try { sum = reader.Get(row.Path); } catch { sum = null; }
+ if (sum is null) continue;
+ if (ctx is null) row.Summary = sum;
+ else ctx.Post(_ => row.Summary = sum, null);
+ }
+ });
+ }
+
+ // --- Locate in the tree ------------------------------------------------------------------
+
+ /// <summary>Opens the Files tree down to <paramref name="path"/> (search, filters and
+ /// "similar" cleared) and returns its row in <see cref="Samples"/>, or null when the tree
+ /// doesn't hold it.</summary>
+ public BrowserItem? RevealSample(string path)
+ {
+ var cmp = Nota.Application.Browser.SampleFolderRules.PathComparer;
+ var chain = new List<BrowserItem>();
+ bool Find(List<BrowserItem> nodes)
+ {
+ foreach (var n in nodes)
+ {
+ if (n.Kind != BrowserItemKind.Folder)
+ {
+ if (cmp.Equals(n.Path, path)) { chain.Add(n); return true; }
+ continue;
+ }
+ chain.Add(n);
+ if (Find(n.Children)) return true;
+ chain.RemoveAt(chain.Count - 1);
+ }
+ return false;
+ }
+ if (!Find(_sampleTree)) return null;
+ foreach (var folder in chain.Take(chain.Count - 1))
+ {
+ folder.IsExpanded = true;
+ _expandedTreeKeys.Add(folder.Path);
+ }
+ _treeQuery[3] = "";
+ _sampleFilter = SampleFilter.Empty;
+ _similarAnchor = null;
+ _similarRows.Clear();
+ RebuildSampleVisible();
+ return chain[^1];
+ }
+
+
/// <summary>Lists saved presets from the app presets folder, grouped into a tree:
/// category (Instruments / Audio Effects / MIDI Effects) → device → preset (M7-4c).</summary>
public void RebuildPresets()
@@ -989,9 +1503,18 @@ public sealed partial class BrowserViewModel : ObservableObject
return node;
}
+ // Unreadable subfolders (permissions, a drive going away mid-walk) are skipped, not fatal;
+ // hidden and system entries stay out of the tree.
+ private static readonly EnumerationOptions WalkOptions = new()
+ {
+ RecurseSubdirectories = true,
+ IgnoreInaccessible = true,
+ AttributesToSkip = FileAttributes.Hidden | FileAttributes.System,
+ };
+
private static IEnumerable<string> EnumerateFilesSafe(string root)
{
- try { return Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories); }
+ try { return Directory.EnumerateFiles(root, "*", WalkOptions); }
catch { return Enumerable.Empty<string>(); }
}
}
diff --git a/tests/Nota.SmokeTest/ClipSourceTests.cs b/tests/Nota.SmokeTest/ClipSourceTests.cs
new file mode 100644
index 00000000..99fcf0c0
--- /dev/null
+++ b/tests/Nota.SmokeTest/ClipSourceTests.cs
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Where a clip's audio came from (spec 092, #581): the engine wrapper remembers the file a
+// clip or Session take was loaded from, a split keeps it, a project saves it next to its own
+// copy and gives it back on reload, and neither a project's copy nor a render in the temp
+// folder counts as a source. Part of `--browser-files`.
+
+using System.Text.Json;
+using Nota.Infrastructure;
+
+namespace Nota.SmokeTest;
+
+internal static class ClipSourceTests
+{
+ public static IEnumerable<(bool Ok, string Label)> Run()
+ {
+ // Outside the temp folder: renders there are deliberately not sources.
+ string lib = Path.Combine(AppContext.BaseDirectory, "nota092-src-" + Guid.NewGuid().ToString("N")[..8]);
+ Directory.CreateDirectory(lib);
+ string wav = Path.Combine(lib, "Kick 01.wav");
+ WavWriter.WriteSine(wav, 0.5, 110, 44100);
+ string scratch = Path.Combine(Path.GetTempPath(), "nota092-render-" + Guid.NewGuid().ToString("N")[..8] + ".wav");
+ WavWriter.WriteSine(scratch, 0.5, 220, 44100);
+ string bundle = Path.Combine(Path.GetTempPath(), "nota092-" + Guid.NewGuid().ToString("N")[..8] + ".nota");
+ var transport = new TransportState(120.0, 1.0, false, false);
+ try
+ {
+ using var src = new NotaEngine();
+ int trk = src.AddAudioTrack();
+ int c0 = src.AddAudioClip(trk, wav, 0);
+ src.TryGetAudioClipInfo(trk, c0, out var a0);
+ yield return (src.SampleSource(a0.SampleId) == Path.GetFullPath(wav), "source: an audio clip remembers the file it was made from");
+
+ src.SplitClip(trk, c0, 0.25);
+ bool both = src.TryGetAudioClipInfo(trk, 0, out var s0) && src.TryGetAudioClipInfo(trk, 1, out var s1)
+ && src.SampleSource(s0.SampleId) == wav && src.SampleSource(s1.SampleId) == wav;
+ yield return (both, "source: both halves of a split still lead to it");
+
+ int r = src.AddAudioClip(trk, scratch, 8);
+ src.TryGetAudioClipInfo(trk, r, out var ri);
+ yield return (src.SampleSource(ri.SampleId) == "", "source: a render in the temp folder isn't one");
+
+ yield return (src.AddSessionAudioFile(trk, 0, wav) && src.TryGetSessionAudioSlot(trk, 0, out var sa) && src.SampleSource(sa.SampleId) == wav,
+ "source: a Session take remembers its file too");
+
+ // Double-click, drop and File → Import decode in the background, then place the clip.
+ using (var imp = new NotaEngine())
+ {
+ int it = imp.AddAudioTrack();
+ using var job = imp.OpenAudioImport(wav);
+ while (job is not null && job.Step(1 << 16) > 0) { }
+ int ic = job is null ? -1 : imp.AddImportedAudioClip(it, job, 0);
+ yield return (ic >= 0 && imp.TryGetAudioClipInfo(it, ic, out var ii) && imp.SampleSource(ii.SampleId) == Path.GetFullPath(wav),
+ "source: a clip imported in the background remembers its file");
+ }
+
+ var w = new List<string>();
+ ProjectService.Save(ProjectService.Capture(src, transport, w), bundle, src);
+ var json = JsonDocument.Parse(File.ReadAllText(Path.Combine(bundle, ProjectService.ManifestName))).RootElement;
+ var clips = json.GetProperty("tracks").EnumerateArray().SelectMany(t => t.TryGetProperty("audioClips", out var a) ? a.EnumerateArray() : Enumerable.Empty<JsonElement>()).ToList();
+ int withSource = clips.Count(c => c.TryGetProperty("source", out var s) && s.GetString() == wav);
+ int without = clips.Count(c => !c.TryGetProperty("source", out _));
+ yield return (withSource == 2 && without == 1, $"save: project.json keeps the source of the two halves, none for the render ({withSource}/{without})");
+
+ using var dst = new NotaEngine();
+ var lw = ProjectService.Apply(ProjectService.Load(bundle), dst, bundle);
+ int dTrk = -1;
+ for (int i = 0; i < dst.TrackCount; i++) if (dst.TryGetTrackInfo(i, out var ti) && ti.Type == 0) { dTrk = ti.Id; break; }
+ bool reloaded = dTrk > 0 && dst.TryGetAudioClipInfo(dTrk, 0, out var d0) && dst.SampleSource(d0.SampleId) == wav;
+ yield return (lw.Count == 0 && reloaded, "load: a reopened project's clip still knows its file (not the bundle copy)");
+ yield return (dTrk > 0 && dst.TryGetSessionAudioSlot(dTrk, 0, out var dsa) && dst.SampleSource(dsa.SampleId) == wav,
+ "load: …and so does its Session take");
+ yield return (dTrk > 0 && dst.TryGetAudioClipInfo(dTrk, 2, out var dr) && dst.SampleSource(dr.SampleId) == ""
+ && ClipFiles.BundleCopy(dst, dr.SampleId, bundle) is { } copy && File.Exists(copy) && copy.StartsWith(bundle, StringComparison.Ordinal),
+ "locate: a clip with no source reveals the project's own copy");
+
+ File.Delete(wav);
+ yield return (dTrk > 0 && dst.TryGetAudioClipInfo(dTrk, 0, out var g0) && ClipFiles.Source(dst, g0.SampleId) is null,
+ "locate: a source that was deleted is not offered");
+
+ // A project from before spec 092: no "source" at all.
+ var manifest = Path.Combine(bundle, ProjectService.ManifestName);
+ File.WriteAllText(manifest, System.Text.RegularExpressions.Regex.Replace(File.ReadAllText(manifest), ",\\s*\"source\": \"[^\"]*\"", ""));
+ using var old = new NotaEngine();
+ var ow = ProjectService.Apply(ProjectService.Load(bundle), old, bundle);
+ int oTrk = -1;
+ for (int i = 0; i < old.TrackCount; i++) if (old.TryGetTrackInfo(i, out var ti) && ti.Type == 0) { oTrk = ti.Id; break; }
+ yield return (oTrk > 0 && old.TryGetAudioClipInfo(oTrk, 0, out var o0) && old.SampleSource(o0.SampleId) == "",
+ $"load: an older project without sources loads, with none ({ow.Count} warnings)");
+ }
+ finally
+ {
+ try { Directory.Delete(lib, true); } catch { }
+ try { File.Delete(scratch); } catch { }
+ try { Directory.Delete(bundle, true); } catch { }
+ }
+ }
+}
diff --git a/tests/Nota.SmokeTest/FileBrowseTests.cs b/tests/Nota.SmokeTest/FileBrowseTests.cs
new file mode 100644
index 00000000..9c2975d9
--- /dev/null
+++ b/tests/Nota.SmokeTest/FileBrowseTests.cs
@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The Files tab's browse view (spec 092, #580): Back / Forward / Up like a web browser, the
+// Computer level above the drives, what a typed or pasted path opens, and which entries a
+// folder lists. Part of `--browser-files`.
+
+using Nota.Application.Browser;
+using Nota.Application.Samples;
+using Nota.Infrastructure;
+using Nota.Presentation;
+
+namespace Nota.SmokeTest;
+
+internal static class FileBrowseTests
+{
+ public static IEnumerable<(bool Ok, string Label)> Run()
+ {
+ string dir = Path.Combine(Path.GetTempPath(), "nota092b-" + Guid.NewGuid().ToString("N")[..8]);
+ string a = Path.Combine(dir, "A"), b = Path.Combine(a, "B"), c = Path.Combine(dir, "C");
+ Directory.CreateDirectory(b); Directory.CreateDirectory(c);
+ try
+ {
+ // ---- history ----
+ var st = new FileBrowseState(a);
+ st.Go(b); st.Go(c);
+ st.GoBack();
+ bool backOk = st.Location == b && st.CanGoForward;
+ st.GoForward();
+ bool fwdOk = st.Location == c && !st.CanGoForward;
+ st.GoBack(); st.GoBack();
+ st.Go(c);
+ yield return (backOk && fwdOk && st.Location == c && !st.CanGoForward && st.CanGoBack,
+ "browse: Back and Forward walk the visited folders; opening a folder after Back clears Forward");
+
+ st.Go(c);
+ yield return (st.BackCount == 1, "browse: opening the folder already shown adds no history");
+
+ var cap = new FileBrowseState(a);
+ for (int i = 0; i < 150; i++) cap.Go(i % 2 == 0 ? b : c);
+ yield return (cap.BackCount == 100, "browse: history keeps the last 100 steps");
+
+ // ---- up ----
+ var up = new FileBrowseState(b);
+ up.Up();
+ bool parent = up.Location == a;
+ string root = Path.GetPathRoot(a)!;
+ up.Go(root);
+ up.Up();
+ yield return (parent && up.IsComputer && !up.CanGoUp, "browse: Up goes to the parent, from a drive root to Computer, then stops");
+ yield return (FileBrowseState.Volumes() is { Count: > 0 } v
+ && (OperatingSystem.IsWindows() ? v.All(x => Path.GetPathRoot(x.Path) == x.Path) : v.Any(x => x.Path == "/")),
+ "browse: Computer lists the drives (the system disk among them)");
+ var seg = new FileBrowseState(b).Segments();
+ yield return (seg.Count >= 3 && seg[^1].Path == b && seg[^2].Path == a, "browse: the path bar has a segment per folder, outermost first");
+
+ // ---- typed / pasted paths ----
+ string wav = Path.Combine(a, "x.wav");
+ WavWriter.WriteSine(wav, 0.05, 220, 44100);
+ yield return (PathInput.Parse(a) == (a, null) && PathInput.Parse(a + Path.DirectorySeparatorChar) == (a, null),
+ "path: a folder opens itself, trailing separator or not");
+ yield return (PathInput.Parse(wav) == (a, wav), "path: a file opens its folder with the file selected");
+ yield return (PathInput.Parse($"\"{a}\"") == (a, null) && PathInput.Parse($"'{a}'") == (a, null), "path: quoted pasted paths are unquoted");
+ yield return (PathInput.Parse(new Uri(wav).AbsoluteUri) == (a, wav), "path: file:// URLs are understood");
+ string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
+ yield return (PathInput.Parse("~")?.Folder == SampleFolderRules.Normalize(home), "path: ~ is the home folder");
+ yield return (PathInput.Parse(Path.Combine(dir, "nope")) is null && PathInput.Parse("relative/path") is null && PathInput.Parse(" ") is null,
+ "path: a missing, relative or empty path opens nothing");
+
+ // ---- listing ----
+ File.WriteAllText(Path.Combine(a, "notes.txt"), "x");
+ File.WriteAllText(Path.Combine(a, ".secret.wav"), "x");
+ Directory.CreateDirectory(Path.Combine(a, ".git"));
+ TestFiles.Hide(Path.Combine(a, ".secret.wav"));
+ TestFiles.Hide(Path.Combine(a, ".git"));
+ Directory.CreateDirectory(Path.Combine(a, "a-first"));
+ WavWriter.WriteSine(Path.Combine(a, "Zed.wav"), 0.05, 220, 44100);
+ var (rows, state) = BrowserViewModel.ListBrowse(a);
+ var names = rows.Select(r => r.Name).ToList();
+ yield return (state == BrowseListState.Ok && names.SequenceEqual(new[] { "a-first", "B", "notes.txt", "x.wav", "Zed.wav" }),
+ $"browse: folders first, then every file, each by name; hidden entries left out [{string.Join(", ", names)}]");
+ var notes = rows.Single(r => r.Name == "notes.txt");
+ var xw = rows.Single(r => r.Name == "x.wav");
+ yield return (notes.Kind == BrowserItemKind.OtherFile && notes.Size == 1 && xw.Kind == BrowserItemKind.Sample && xw.Size == new FileInfo(wav).Length
+ && rows.Where(r => r.Kind == BrowserItemKind.Folder).All(r => r.Size is null),
+ "browse: a file Nota can't add is marked as such; files carry their size, folders none");
+ yield return (BrowserViewModel.ListBrowse(c).State == BrowseListState.Empty
+ && BrowserViewModel.ListBrowse(Path.Combine(dir, "nope")).State == BrowseListState.Unreadable,
+ "browse: an empty folder and a missing one say so");
+
+ var vm = new BrowserViewModel(new EmptyPluginCatalog(), new EmptyPresetLibrary(), new FactoryPresetCatalog());
+ vm.BrowseTo(a);
+ vm.RefreshBrowseAsync().GetAwaiter().GetResult();
+ vm.FilterTree(3, "zed");
+ yield return (vm.BrowseItems.Count == 1 && vm.BrowseItems[0].Name == "Zed.wav", "browse: search filters the folder shown");
+ vm.FilterTree(3, "");
+ vm.SetLocatedPath(wav);
+ yield return (vm.BrowseItems.Single(r => r.Located).Path == wav, "browse: the selected clip's file is marked in the list");
+
+ string sfile = Path.Combine(dir, "settings.json");
+ File.WriteAllText(sfile, $"{{ \"SamplesFolder\": {System.Text.Json.JsonSerializer.Serialize(b)} }}");
+ var hvm = new BrowserViewModel(new EmptyPluginCatalog(), new EmptyPresetLibrary(), new FactoryPresetCatalog(), settings: new SettingsService(sfile));
+ hvm.BrowseTo(c);
+ bool away = !hvm.BrowseAtHome;
+ hvm.BrowseHome();
+ bool atHome = hvm.Browse.Location == b && hvm.BrowseAtHome;
+ hvm.Browse.GoBack();
+ yield return (away && atHome && hvm.Browse.Location == c, "browse: Home opens the default sample folder; Back returns");
+ }
+ finally { try { Directory.Delete(dir, true); } catch { } }
+ }
+}
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index acc521bc..766b4c66 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -214,6 +214,17 @@ if (args.Length >= 1 && args[0] == "--browser")
Console.WriteLine(failures == 0 ? "BROWSER PASSED" : $"BROWSER FAILED ({failures})");
return failures == 0 ? 0 : 1;
}
+// Browser files (spec 092: sample folders, browse mode, clip sources, Projects tab) alone: `--browser-files`.
+if (args.Length >= 1 && args[0] == "--browser-files")
+{
+ Console.WriteLine("-- browser files (spec 092) --");
+ foreach (var (ok, label) in SampleFoldersTests.Run()) Check(ok, label);
+ foreach (var (ok, label) in FileBrowseTests.Run()) Check(ok, label);
+ foreach (var (ok, label) in ClipSourceTests.Run()) Check(ok, label);
+ foreach (var (ok, label) in ProjectSummaryTests.Run()) Check(ok, label);
+ Console.WriteLine(failures == 0 ? "BROWSER FILES PASSED" : $"BROWSER FILES FAILED ({failures})");
+ return failures == 0 ? 0 : 1;
+}
// Get Plug-ins alone: `--store`; live installs from a registry index: `--store-live <index> <id>…`.
if (args.Length >= 1 && args[0] == "--store")
{
@@ -15654,6 +15665,13 @@ Console.WriteLine("-- background audio import --");
Console.WriteLine("-- browser: device categories --");
foreach (var (ok, label) in BrowserCategoryTests.Run()) Check(ok, label);
+// --- browser files (spec 092): sample folders, browse mode, clip sources, Projects tab ---
+Console.WriteLine("-- browser files (spec 092) --");
+foreach (var (ok, label) in SampleFoldersTests.Run()) Check(ok, label);
+foreach (var (ok, label) in FileBrowseTests.Run()) Check(ok, label);
+foreach (var (ok, label) in ClipSourceTests.Run()) Check(ok, label);
+foreach (var (ok, label) in ProjectSummaryTests.Run()) Check(ok, label);
+
// --- piano roll Fold (specs/045): scale rows, Drum Rack pads, saved per track ---
Console.WriteLine("-- piano roll fold --");
foreach (var (ok, label) in FoldTests.Run()) Check(ok, label);
diff --git a/tests/Nota.SmokeTest/ProjectSummaryTests.cs b/tests/Nota.SmokeTest/ProjectSummaryTests.cs
new file mode 100644
index 00000000..3263643e
--- /dev/null
+++ b/tests/Nota.SmokeTest/ProjectSummaryTests.cs
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The browser's Projects tab (spec 092, #582): what is read from a project.json without
+// opening it (tempo, key, tracks, length — MIDI clips, warped and unwarped audio), the
+// cache that keeps a folder of projects from being read twice, and the tab's order and
+// open-project mark. Part of `--browser-files`.
+
+using Nota.Application.Browser;
+using Nota.Infrastructure;
+using Nota.Presentation;
+
+namespace Nota.SmokeTest;
+
+internal static class ProjectSummaryTests
+{
+ public static IEnumerable<(bool Ok, string Label)> Run()
+ {
+ string dir = Path.Combine(Path.GetTempPath(), "nota092p-" + Guid.NewGuid().ToString("N")[..8]);
+ Directory.CreateDirectory(dir);
+ try
+ {
+ // 120 BPM; a MIDI clip to beat 16; a warped clip 20 → 28; an unwarped 2 s WAV at 30 (4 beats) → 34.
+ string a = Bundle(dir, "Alpha", """
+ { "transport": { "bpm": 120, "key": "Am" },
+ "tracks": [
+ { "type": 1, "midiClips": [ { "startBeat": 0, "lengthBeats": 16 } ] },
+ { "type": 0, "audioClips": [
+ { "sample": "samples/x.wav", "startBeat": 20, "warpEnabled": 1, "warpBeats": 32, "warpPlayStart": 2, "warpPlayEnd": 10 },
+ { "sample": "samples/x.wav", "startBeat": 30, "lengthFrames": 0 } ] },
+ { "type": 2 } ] }
+ """);
+ Directory.CreateDirectory(Path.Combine(a, "samples"));
+ WavWriter.WriteSine(Path.Combine(a, "samples", "x.wav"), 2.0, 220, 44100);
+
+ var s = ProjectSummaryReader.Read(a);
+ yield return (s is { Bpm: 120, Key: "Am", TrackCount: 2 }, $"summary: tempo, key and tracks (returns aren't counted) [{s}]");
+ yield return (s is not null && Math.Abs(s.LengthBeats - 34) < 0.01 && s.LengthText == "0:17",
+ $"summary: length runs to the end of the last clip — MIDI, warped and unwarped audio ({s?.LengthBeats:0.##} beats, {s?.LengthText})");
+
+ // The same 2 s clip an octave up plays in 1 s (2 beats), as the engine resamples it: → 32.
+ string up = Bundle(dir, "Up", """
+ { "transport": { "bpm": 120 },
+ "tracks": [ { "type": 0, "audioClips": [ { "sample": "samples/x.wav", "startBeat": 30, "lengthFrames": 0, "pitchSemitones": 12 } ] } ] }
+ """);
+ Directory.CreateDirectory(Path.Combine(up, "samples"));
+ WavWriter.WriteSine(Path.Combine(up, "samples", "x.wav"), 2.0, 220, 44100);
+ var su = ProjectSummaryReader.Read(up);
+ yield return (su is not null && Math.Abs(su.LengthBeats - 32) < 0.01, $"summary: a transposed unwarped clip is as long as it plays ({su?.LengthBeats:0.##} beats)");
+ Directory.Delete(up, true); // the Projects list below counts this folder's bundles
+
+ string bad = Bundle(dir, "Broken", "{ not json");
+ yield return (ProjectSummaryReader.Read(bad) is null, "summary: an unreadable project gives none");
+
+ string cacheFile = Path.Combine(dir, "cache.json");
+ var reader = new ProjectSummaryReader(cacheFile);
+ var first = reader.Get(a);
+ var manifest = Path.Combine(a, ProjectDates.ManifestName);
+ var stamp = File.GetLastWriteTimeUtc(manifest);
+ File.WriteAllText(manifest, File.ReadAllText(manifest).Replace("\"bpm\": 120", "\"bpm\": 99.5"));
+ File.SetLastWriteTimeUtc(manifest, stamp);
+ // Same write time but a different size: read again.
+ var changed = new ProjectSummaryReader(cacheFile).Get(a);
+ yield return (first?.Bpm == 120 && changed?.Bpm == 99.5, "cache: a project that changed on disk is read again");
+ File.WriteAllText(manifest, File.ReadAllText(manifest).Replace("\"bpm\": 99.5", "\"bpm\": 777"));
+ File.SetLastWriteTimeUtc(manifest, stamp);
+ var c1 = new ProjectSummaryReader(cacheFile).Get(a); // reads 777, caches it under this stamp
+ File.Delete(Path.Combine(a, "samples", "x.wav")); // the cache needn't look at the audio again
+ var c2 = new ProjectSummaryReader(cacheFile).Get(a);
+ yield return (c1?.Bpm == 777 && c2 is { Bpm: 777 } && Math.Abs(c2.LengthBeats - c1.LengthBeats) < 0.001,
+ "cache: an unchanged project is answered from the cache");
+
+ // ---- the Projects tab ----
+ string b = Bundle(dir, "Bravo", """{ "transport": { "bpm": 90 }, "tracks": [] }""");
+ string c = Bundle(dir, "charlie", """{ "transport": { "bpm": 100 }, "tracks": [] }""");
+ var now = DateTime.Now;
+ File.SetLastWriteTime(Path.Combine(a, ProjectDates.ManifestName), now.AddHours(-3));
+ File.SetLastWriteTime(Path.Combine(b, ProjectDates.ManifestName), now.AddHours(-1));
+ File.SetLastWriteTime(Path.Combine(c, ProjectDates.ManifestName), now.AddHours(-2));
+ File.SetLastWriteTime(Path.Combine(bad, ProjectDates.ManifestName), now.AddHours(-4));
+
+ string settingsFile = Path.Combine(dir, "settings.json");
+ File.WriteAllText(settingsFile, $"{{ \"ProjectsFolder\": {System.Text.Json.JsonSerializer.Serialize(dir)} }}");
+ var settings = new SettingsService(settingsFile);
+ var vm = new BrowserViewModel(new EmptyPluginCatalog(), new EmptyPresetLibrary(), new FactoryPresetCatalog(),
+ settings: settings, projectSummaries: new ProjectSummaryReader(Path.Combine(dir, "cache2.json")));
+ var names = vm.Projects.Select(p => p.Name).ToList();
+ yield return (names.SequenceEqual(new[] { "Bravo", "charlie", "Alpha", "Broken" }), $"projects: newest first [{string.Join(", ", names)}]");
+ yield return (vm.Projects[0].Sub == ProjectDates.Format(now.AddHours(-1)), $"projects: each row carries its save date ({vm.Projects[0].Sub})");
+
+ vm.ProjectSummariesTask.Wait(TimeSpan.FromSeconds(10));
+ yield return (vm.Projects.First(p => p.Name == "Bravo").Summary?.Bpm == 90 && vm.Projects.First(p => p.Name == "Broken").Summary is null,
+ "projects: details fill in from the background read; a broken project keeps just its date");
+
+ vm.ProjectsSort = ProjectsSortOrder.Name;
+ var byName = vm.Projects.Select(p => p.Name).ToList();
+ yield return (byName.SequenceEqual(new[] { "Alpha", "Bravo", "Broken", "charlie" }) && new SettingsService(settingsFile).Current.ProjectsSort == ProjectsSortOrder.Name,
+ $"projects: sorting by name works and is remembered [{string.Join(", ", byName)}]");
+
+ vm.OpenProjectPath = c + Path.DirectorySeparatorChar;
+ yield return (vm.Projects.Single(p => p.IsOpen).Name == "charlie", "projects: the open project is marked");
+ }
+ finally { try { Directory.Delete(dir, true); } catch { } }
+ }
+
+ private static string Bundle(string dir, string name, string json)
+ {
+ var b = Path.Combine(dir, name + ".nota");
+ Directory.CreateDirectory(b);
+ File.WriteAllText(Path.Combine(b, ProjectDates.ManifestName), json);
+ return b;
+ }
+}
diff --git a/tests/Nota.SmokeTest/SampleFoldersTests.cs b/tests/Nota.SmokeTest/SampleFoldersTests.cs
new file mode 100644
index 00000000..96e0cee9
--- /dev/null
+++ b/tests/Nota.SmokeTest/SampleFoldersTests.cs
@@ -0,0 +1,222 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Sample folders (spec 092, #346 / #268): the list's rules (no duplicate, no folder inside
+// another, one default, migration from the single Samples folder), the settings file
+// keeping the old field as a mirror, the Files tree with one and with several folders, and
+// the sample index scanning several roots. Runnable alone with the other spec 092 checks:
+// `dotnet run --project tests/Nota.SmokeTest -- --browser-files`.
+
+using Nota.Application.Browser;
+using Nota.Application.Samples;
+using Nota.Infrastructure;
+using Nota.Presentation;
+
+namespace Nota.SmokeTest;
+
+internal static class SampleFoldersTests
+{
+ public static IEnumerable<(bool Ok, string Label)> Run()
+ {
+ foreach (var r in Rules()) yield return r;
+ foreach (var r in Service()) yield return r;
+ foreach (var r in Tree()) yield return r;
+ foreach (var r in Index()) yield return r;
+ }
+
+ private static string Temp()
+ {
+ var d = Path.Combine(Path.GetTempPath(), "nota092-" + Guid.NewGuid().ToString("N")[..8]);
+ Directory.CreateDirectory(d);
+ return d;
+ }
+
+ // ---- rules -------------------------------------------------------------------------------
+
+ private static IEnumerable<(bool, string)> Rules()
+ {
+ // Expected paths go through the same normalising: on Windows "/x/A" becomes "C:\x\A".
+ string xa = SampleFolderRules.Normalize("/x/A"), xb = SampleFolderRules.Normalize("/x/B");
+ var (m1, _) = SampleFolderRules.Repair(null, "/x/A");
+ yield return (m1.Count == 1 && m1[0].Path == xa && m1[0].IsDefault, "folders: an old settings file becomes one default folder");
+
+ var (m2, dropped) = SampleFolderRules.Repair(new List<SampleFolderEntry>
+ {
+ new() { Path = "/x/A", IsDefault = true }, new() { Path = "/x/B/", IsDefault = true },
+ new() { Path = "/x/A/Drums" }, new() { Path = "/x/A" },
+ }, "/ignored");
+ yield return (m2.Count == 2 && m2[1].Path == xb && m2.Count(e => e.IsDefault) == 1 && m2[0].IsDefault && dropped.Count == 2,
+ "folders: on load, one default survives, trailing separators go, nested and duplicate entries are dropped");
+
+ var (m3, _) = SampleFolderRules.Repair(new List<SampleFolderEntry> { new() { Path = "/x/A" }, new() { Path = "/x/B" } }, "/ignored");
+ yield return (m3[0].IsDefault && !m3[1].IsDefault, "folders: a list with no default makes the first one the default");
+
+ var list = new List<string> { "/x/A", "/x/B" };
+ yield return (SampleFolderRules.Check(list, "/x/B/") is { Outcome: SampleFolderOutcome.AlreadyPresent, Other: 1 },
+ "folders: adding a folder already in the list is refused");
+ if (!OperatingSystem.IsLinux())
+ yield return (SampleFolderRules.Check(list, "/X/a") is { Outcome: SampleFolderOutcome.AlreadyPresent },
+ "folders: …in any letter case where the file system ignores it");
+ yield return (SampleFolderRules.Check(list, "/x/A/Drums") is { Outcome: SampleFolderOutcome.Inside, Other: 0 },
+ "folders: a folder inside one in the list is refused");
+ yield return (SampleFolderRules.Check(list, "/x") is { Outcome: SampleFolderOutcome.Contains, Other: 0 },
+ "folders: a folder around one in the list is refused");
+ yield return (SampleFolderRules.Check(new List<string> { "/x/Drums" }, "/x/Drum").Ok
+ && !SampleFolderRules.IsSameOrInside("/x/Drums2/a", "/x/Drums") && SampleFolderRules.IsSameOrInside("/x/Drums/a", "/x/Drums"),
+ "folders: /x/Drum is not inside /x/Drums (separator-aware)");
+ yield return (SampleFolderRules.Label(new SampleFolderEntry { Path = "/x/Splice" }) == "Splice"
+ && SampleFolderRules.Label(new SampleFolderEntry { Path = "/x/Splice", Name = "My packs" }) == "My packs",
+ "folders: the label is the name given, else the folder's name");
+ }
+
+ // ---- settings file -------------------------------------------------------------------------
+
+ private static IEnumerable<(bool, string)> Service()
+ {
+ string dir = Temp();
+ try
+ {
+ string a = Path.Combine(dir, "A"), b = Path.Combine(dir, "B"), c = Path.Combine(dir, "C");
+ foreach (var d in new[] { a, b, c }) Directory.CreateDirectory(d);
+ string file = Path.Combine(dir, "settings.json");
+ File.WriteAllText(file, $"{{ \"SamplesFolder\": {System.Text.Json.JsonSerializer.Serialize(a)} }}");
+
+ var s = new SettingsService(file);
+ var f0 = s.ResolvedSampleFolders();
+ yield return (f0.Count == 1 && f0[0].Path == a && f0[0].IsDefault && s.ResolvedSamplesFolder() == a,
+ "settings: a pre-092 Samples folder migrates to the one default folder");
+
+ int changed = 0;
+ s.SampleFoldersChanged += () => changed++;
+ var added = s.AddSampleFolder(b);
+ string sub = Path.Combine(a, "Sub");
+ Directory.CreateDirectory(sub);
+ var nested = s.AddSampleFolder(sub);
+ var missing = s.AddSampleFolder(Path.Combine(dir, "nope"));
+ yield return (added.Ok && nested.Outcome == SampleFolderOutcome.Inside && missing.Outcome == SampleFolderOutcome.NotADirectory && changed == 1,
+ "settings: Add takes a new folder, refuses a nested or missing one, and tells listeners once");
+
+ s.AddSampleFolder(c);
+ s.RenameSampleFolder(1, " Splice ");
+ s.SetDefaultSampleFolder(1);
+ var re = new SettingsService(file);
+ var f1 = re.ResolvedSampleFolders();
+ yield return (f1.Count == 3 && f1[1].Label == "Splice" && f1[1].IsDefault && re.ResolvedSamplesFolder() == b
+ && re.Current.SamplesFolder == b,
+ "settings: names and the default survive a reload; SamplesFolder mirrors the default");
+
+ yield return (re.RemoveSampleFolder(1) && re.ResolvedSampleFolders() is { Count: 2 } f2 && f2[1].IsDefault && f2[1].Path == c,
+ "settings: removing the default makes the next folder the default");
+ re.RemoveSampleFolder(0);
+ yield return (!re.RemoveSampleFolder(0) && re.ResolvedSampleFolders().Count == 1, "settings: the last folder can't be removed");
+
+ // Code that still writes the single old field moves the default with it.
+ var legacy = new SettingsService(file);
+ string dd = Path.Combine(dir, "D");
+ Directory.CreateDirectory(dd);
+ legacy.Current.SamplesFolder = dd;
+ yield return (legacy.ResolvedSamplesFolder() == dd && legacy.ResolvedSampleFolders().Single(f => f.IsDefault).Path == dd,
+ "settings: setting the old SamplesFolder field still moves the default folder");
+
+ re.AddSampleFolder(b);
+ Directory.Delete(b);
+ var f3 = re.ResolvedSampleFolders();
+ yield return (f3.Count == 2 && !f3[1].Available && f3[0].Available, "settings: a folder that went away stays listed, unavailable");
+ }
+ finally { try { Directory.Delete(dir, true); } catch { } }
+ }
+
+ // ---- Files tree --------------------------------------------------------------------------
+
+ private static IEnumerable<(bool, string)> Tree()
+ {
+ string dir = Temp();
+ try
+ {
+ string a = Path.Combine(dir, "A"), b = Path.Combine(dir, "Bee");
+ Directory.CreateDirectory(Path.Combine(a, "Drums"));
+ Directory.CreateDirectory(Path.Combine(a, SamplePacks.FolderName, "Pack"));
+ Directory.CreateDirectory(b);
+ WavWriter.WriteSine(Path.Combine(a, "Drums", "kick.wav"), 0.1, 60, 44100);
+ WavWriter.WriteSine(Path.Combine(a, SamplePacks.FolderName, "Pack", "p.wav"), 0.1, 60, 44100);
+ WavWriter.WriteSine(Path.Combine(a, "top.wav"), 0.1, 60, 44100);
+ WavWriter.WriteSine(Path.Combine(b, "loop.wav"), 0.1, 60, 44100);
+ File.WriteAllText(Path.Combine(b, ".hidden.wav"), "x");
+ TestFiles.Hide(Path.Combine(b, ".hidden.wav"));
+
+ string file = Path.Combine(dir, "settings.json");
+ File.WriteAllText(file, $"{{ \"SamplesFolder\": {System.Text.Json.JsonSerializer.Serialize(a)} }}");
+ var s = new SettingsService(file);
+ var vm = new BrowserViewModel(new EmptyPluginCatalog(), new EmptyPresetLibrary(), new FactoryPresetCatalog(), settings: s);
+ vm.RebuildSamples();
+ yield return (vm.Samples.Count > 0 && vm.Samples[0].IsDownloads && vm.Samples.All(r => r.Depth == 0 && r.PlaceIndex < 0),
+ "tree: one folder looks as before — its contents at the top, Downloaded first");
+
+ s.AddSampleFolder(b);
+ s.RenameSampleFolder(1, "Loops");
+ vm.RebuildSamples();
+ var roots = vm.Samples.Where(r => r.Depth == 0).ToList();
+ yield return (roots.Count == 2 && roots[0].PlaceIndex == 0 && roots[0].Name == "A" && roots[1].PlaceIndex == 1 && roots[1].Name == "Loops",
+ "tree: two folders are two top-level nodes, default first, with their labels");
+
+ vm.ToggleExpand(roots[0]);
+ vm.ToggleExpand(roots[1]);
+ yield return (vm.Samples.Any(r => r.Name == "loop.wav" && r.Depth == 1) && !vm.Samples.Any(r => r.Name == ".hidden.wav")
+ && vm.Samples.SkipWhile(r => r.PlaceIndex != 0).Skip(1).First().IsDownloads,
+ "tree: files sit under their folder, Downloaded leads inside the default one, hidden files stay out");
+
+ vm.FilterTree(3, "loop");
+ yield return (vm.Samples.Any(r => r.Name == "loop.wav") && !vm.Samples.Any(r => r.Name == "kick.wav"), "tree: search finds files in the second folder");
+ vm.FilterTree(3, "");
+
+ s.SetDefaultSampleFolder(1);
+ vm.RebuildSamples();
+ var swapped = vm.Samples.Where(r => r.Depth == 0).ToList();
+ yield return (swapped.Count == 2 && swapped[0].Name == "Loops" && swapped[0].PlaceIndex == 1 && swapped[1].PlaceIndex == 0,
+ "tree: a new default moves to the top and keeps its place in the list");
+ s.SetDefaultSampleFolder(0);
+ vm.RebuildSamples();
+
+ Directory.Delete(b, true);
+ vm.RebuildSamples();
+ var gone = vm.Samples.FirstOrDefault(r => r.PlaceIndex == 1);
+ yield return (gone is { Unavailable: true, HasChildren: false }, "tree: a missing folder shows as unavailable and empty");
+ }
+ finally { try { Directory.Delete(dir, true); } catch { } }
+ }
+
+ // ---- index ---------------------------------------------------------------------------------
+
+ private static IEnumerable<(bool, string)> Index()
+ {
+ string dir = Temp();
+ try
+ {
+ string a = Path.Combine(dir, "A"), loops = Path.Combine(dir, "Loops");
+ Directory.CreateDirectory(a); Directory.CreateDirectory(loops);
+ string fa = Path.Combine(a, "tone.wav"), fb = Path.Combine(loops, "hit.wav");
+ WavWriter.WriteSine(fa, 0.3, 220, 44100);
+ WavWriter.WriteSine(fb, 0.3, 330, 44100);
+
+ string file = Path.Combine(dir, "index.bin");
+ var index = new SampleLibraryIndex(new SampleAnalyzer(), file);
+ var done = new ManualResetEventSlim();
+ index.Changed += () => { if (index.Progress.Total == 0 && index.Get(fa) is not null && index.Get(fb) is not null) done.Set(); };
+ index.Watch(new[] { a, loops });
+ bool ok = done.Wait(TimeSpan.FromSeconds(60));
+ yield return (ok, "index: a scan over two folders analyses the files of both");
+ yield return (index.Get(fb) is { } ib && ib.KindSource != SampleFactSource.Folder,
+ $"index: hints are read below each folder — a folder named Loops doesn't make its files loops [{index.Get(fb)?.Describe()}]");
+
+ Directory.Move(loops, loops + "-away");
+ done.Reset();
+ index.Changed += () => { if (index.Progress.Total == 0) done.Set(); };
+ index.Watch(new[] { a, loops });
+ done.Wait(TimeSpan.FromSeconds(30));
+ Thread.Sleep(200);
+ yield return (index.Get(fb) is not null && index.Get(fa) is not null, "index: an unplugged folder keeps its analyses");
+ index.Dispose();
+ }
+ finally { try { Directory.Delete(dir, true); } catch { } }
+ }
+}
diff --git a/tests/Nota.SmokeTest/TestFiles.cs b/tests/Nota.SmokeTest/TestFiles.cs
new file mode 100644
index 00000000..720149d4
--- /dev/null
+++ b/tests/Nota.SmokeTest/TestFiles.cs
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+
+namespace Nota.SmokeTest;
+
+internal static class TestFiles
+{
+ /// <summary>Makes a fixture hidden the way its platform means it: a leading dot hides it on
+ /// macOS and Linux, Windows needs the Hidden attribute too (git sets it on .git there).</summary>
+ public static void Hide(string path)
+ {
+ if (!OperatingSystem.IsWindows()) return;
+ File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
+ }
+}