S008: folder model, playlist sort and details view

FolderModel loads and watches folders off the UI thread, sorts (natural
name, size, type, modified, playlist), groups, filters and keeps the
selection; the details view shows it in a virtualized list with a
click-to-sort header, filter chip and empty/loading/error states.
tunal-core::playlist reads m3u/m3u8/pls/xspf/wpl (D-030). tunal <dir>
opens a folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-18 13:43:43 -06:00
commit 048581938e

View file

@ -69,5 +69,13 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done,
- Not done: workspace-wide clippy currently fails in `tunal-core` (S008's in-progress `playlist.rs`), not in this plan's files. Real MusicBrainz JSON shape checked against docs only, not live. No search by AcoustID.
- Later: `inc` for labels/barcode; honour `Retry-After`; cache of lookups.
## S008 — Folder model and details view
- Done: `crates/tunal/src/folder/` `FolderModel` (Slint `Model<Data = DetailRow>`, rows formatted on demand): `attach(&MainWindow, Locations) -> Rc<FolderModel>` wires rows, `FolderState`, sort menu and view callbacks; `open(Uri)` (worker thread: watch, chunked list flushed at most every 60 ms, playlist lookup; a generation drops stale results), `open_blocking` (screenshots), `sort_column`, `sort_menu`/`sort_menu_activated`, `set_filter`/`type_filter`, `toggle_hidden`, `click(row, ctrl, shift)`, `navigate(NavKey, shift, page) -> row`, `select_all`, `clear_selection`, `activate(row)` (opens folders). Selection, cursor and anchor are kept by raw name across sorts and watch diffs. Sort name (natural)/size/type/modified/playlist, desc, folders first; groups type/date/size with header rows; hidden toggle; filter chip; empty/loading/error states; Type column hidden below 640 px.
- `tunal-core::playlist` (D-030): `read`, `parse`, `candidates(folder, entries)` (preselected first), `Ranks`, `music_dir`, `shared_dir`. `icons.rs`: `Category::of(entry)`, `glyph`, `group_label`, `link_badge`, `type_label`. Shared components gained `StateLayer.focusable/modifiers/double-clicked`, `ListRow.badge`, 3 icons. `tunal <dir>` opens a folder (also with `--screenshot`).
- Verified: workspace build, clippy -D warnings, fmt --check, literal grep empty; looked at 10 000-file light + dark, mixed folder (links, broken link, non-UTF-8 name, groups, selection, filter chip, 720x480), permission-denied / missing / empty folder. A temporary uncommitted hook dumped row order for every sort/group/filter/selection case, injected keys through the window (arrows, Shift, End, Ctrl+A, Ctrl+H, typing, Backspace, Esc), checked playlist sort on m3u/xspf/pls/cp1252/UTF-16 wpl, and drove the watch path (insert, remove, rename, playlist edit and removal re-sort) through a message queue.
- Not done: no live window run (pointer clicks, double-click, header/indicator motion, sort menu, PageUp/Down page size not exercised in a real event loop). No folder item counts in the Size column.
- Found: the local watch (S006) also reports reads (opening a file, listing the folder). The model ignores events whose stat is unchanged, and the folder's own event unless it is gone; the shared playlist watch compares mtime/size. Without that, listing and watch looped.
- Later: filter access events in `LocalLocation::watch` itself (debouncer-mini hides the event kind); back/up navigation and per-folder sort in `.directory` (S010, S015).
## Later
-