Tunal/Plans/03 File browsing/S008-folder-model-details.md
astar76 985f44f50f 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]>
2026-11-18 13:43:43 -06:00

3.3 KiB

S008 — Folder model and details view

Category 03 File browsing · Model: Opus · Effort: medium · Depends on: S006, S005 · Size: L · Human: no Files touched: crates/tunal-core/src/playlist.rs, crates/tunal/src/folder/**, crates/tunal/src/icons.rs, crates/tunal/ui/views/details-view.slint, crates/tunal/src/main.rs, crates/tunal/ui/app.slint

Goal

A folder model fed from the location layer off the UI thread (sorting, grouping, hidden files, type-to-filter, live updates, selection) shown in a virtualized details view.

Read

CLAUDE.md §3, §4; crates/tunal-core trait; crates/tunal/ui/components/list-row.slint, menu.slint.

Steps

  • FolderModel: load off-thread in chunks, apply watch diffs (insert/remove/change) keeping selection; a Slint Model that stays fast at 10 000+ rows.
  • Sorting (natural name order, size, type, modified; folders first toggle; asc/desc) and grouping (none, type, modified date buckets, size buckets) with group header rows.
  • Playlist sort (D-021, details D-030): in folders under XDG_MUSIC_DIR, playlists from the folder itself and from <Music>/Playlists (also playlists/Playlist/playlist) that place at least one entry here are offered as Playlist sort (one entry per playlist, the one named like the folder, else the one placing most entries, first); listed entries first in playlist order (subfolders by their first track, moved tracks by file name), the rest in natural name order; desc reverses; playlist changes re-sort. Parser in tunal-core::playlist (.m3u .m3u8 .pls .xspf .wpl; relative/absolute paths, file:// URLs, percent-decoding, #EXT lines skipped; UTF-8 → UTF-16 → cp1252/Latin-1).
  • Hidden files toggle (dot files) and type-to-filter (typing filters by substring, a filter chip shows the text, Esc clears).
  • Mime → Material Symbols glyph map (folder, image, audio, video, text, code, archive, PDF, executable, generic, symlink badge).
  • Details view: ListView rows on ListRow, column header with click-to-sort and animated indicator, empty/loading/error states.
  • Selection: click, Ctrl, Shift range, Ctrl+A, arrows/Home/End/PageUp/PageDown, Enter on a folder opens it. Temporary: tunal <dir> opens that folder.
  • PROGRESS entry, INDEX line, commit S008: …

End criteria

  • cargo build --workspace, cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --check pass.
  • tunal <scratch dir with 10 000 files> --screenshot renders in light and dark; you looked at both.
  • grep -rnE '#[0-9a-fA-F]{6}|[0-9]+ms' crates/tunal/ui/components crates/tunal/ui/views crates/tunal/ui/shell crates/tunal/ui/dialogs 2>/dev/null finds no literal colour or duration outside theme.slint/motion.slint.

Pitfalls

  • Never build the whole row list on the UI thread for big folders.
  • Natural sort must handle non-UTF-8 names (sort on lossy display name, keep raw name).
  • Load the app-taste and animate skills before writing motion; tokens only, hover tint + press squeeze, interruptible, reduced motion honoured, nothing animates while idle.
  • No new tests in this plan (D-013): verify with build, clippy and the smoke run; tests come in phase 12.

Handoff (→ PROGRESS.md)

FolderModel API (open, sort, group, filter, selection) used by grid view, tabs and actions.