# Tunal Tunal is our own desktop file manager for Linux (Wayland and X11), written in Rust with Slint and Material You styling: tabs, split view, places, file operations, `.directory` metadata, sudo elevation, thumbnails, a music tag editor, a quick audio player, iOS/Android device browsing and SFTP locations. Final deliverable: the `tunal` binary built from this Cargo workspace, with README.md and FEATURES.md, for the user (astar76) on Arch Linux. Vision: [PLAN.md](PLAN.md). Full brief: [PROMPT.md](PROMPT.md) (read only the section your plan names). ## 0. Session rules — read first 1. You are started with **one plan**: `Plans//SNNN-*.md`. Read only: this file, **your plan**, the **last 3 entries** of `docs/PROGRESS.md`, and the files/sections your plan names. 2. **Do not open other files in `Plans/`** (nor `ORCHESTRATOR.md`, nor all of `PLAN.md`). 3. **Tick each checkbox in your plan file the moment it is done**, one by one, never in batches. Right after each tick, sync the tracker (§Tracker). An interrupted plan resumes at its first unchecked box. 4. **Stay in scope.** Out-of-scope ideas go to `docs/PROGRESS.md` (“Later”), not into the code. 5. **Invent nothing**: check the code/docs; if a fact is still missing, ask — the **orchestrator** if you were started by one (never the user directly), otherwise the user. 6. **End of session**: (a) end criteria verified **by commands**, not memory; (b) `docs/PROGRESS.md` entry (≤ 15 lines: done, not done, later); (c) `docs/DECISIONS.md` if a decision binds later plans; (d) tick your line in `Plans/INDEX.md` (no commentary); (e) commit `SNNN: …`; (f) short report: done, not done, what the user/orchestrator must do, and any instruction that cost more than it gave. 8. **Cost (D-036)**: first action of every session: invoke the `caveman:caveman` skill and keep it on (short replies, short reports). Read only what your plan names; don't re-read files; one smoke run or screenshot per end criterion, no extra variants. 7. **Languages**: answer in English. Code, comments, README.md and FEATURES.md in English. Internal docs (`CLAUDE.md`, `Plans/`, `PROGRESS.md`) in English. ## Tracker Live checklist of every plan: https://claude.ai/artifact/4X8YCk3cQjUGyuyCqGuU7v (collection `plans`, one doc per plan id). After ticking a box: `ArtifactData` `update` with `url` = the tracker, `collection: "plans"`, `doc_id: "SNNN"`, `data: {"status": "running" or "done" (all boxes ticked), "items": [{"text": "", "done": true/false}, … every checkbox of the plan in order], "updated": ""}` and `if_version` = the version returned by your previous write (first time: `get` the doc once to read it; a doc that doesn't exist yet takes no `if_version`). Load the tool with ToolSearch `select:ArtifactData` once. If the tracker call fails, keep working and say so in the report: the plan file is the source of truth. ## 1. Repository layout Root: `/home/astar76/Projects/Tunal` (target layout; phase 1 creates the crates) ``` Cargo.toml workspace (members = crates/*) crates/ tunal/ app binary: main, Slint UI (ui/*.slint), Theme + Motion globals, components tunal-core/ filesystem model, file operations, the location layer (local first) tunal-theme/ XDG Settings portal (zbus), material-colors scheme generation tunal-dirmeta/ .directory read/write (desktop entry format) tunal-elevate/ root operations behind a password prompt tunal-thumbs/ thumbnails (images, video frame, embedded album art) tunal-tags/ lofty tags, MusicBrainz + Cover Art Archive client tunal-player/ audio playback, waveform data tunal-devices/ iOS (AFC) and Android (MTP) locations tunal-net/ SFTP locations, ~/.ssh/config hosts, known_hosts assets/ tunal.svg / .png / .ico; fonts/ (Material Symbols Rounded + its license) docs/ PROGRESS.md, DECISIONS.md, STATUS.md, HANDOFF.md Plans/ INDEX.md, _TEMPLATE.md, /SNNN-*.md README.md FEATURES.md PLAN.md PROMPT.md ORCHESTRATOR.md ``` Never modify: `PROMPT.md` (the user's brief), the user's other projects under `~/Projects` (Damson, Mulberry, Nacre …) and the old prototype in `~/Documents/Apps/tunal-files/`, the reference app checkout (`/home/astar76/Projects/Tunal-reference`, outside the repo), anything under `/usr`, `~/.ssh/` (read only). ## 2. Facts - **Reference app**: the repository URL in PROMPT.md §Project, cloned (shallow) to `/home/astar76/Projects/Tunal-reference` when a plan needs it. Use it to learn *features and behaviour only*. Never copy its code, strings, names, icons or branding (it is GPL). Never write its name, its desktop's name or any other file manager's name in code, identifiers, UI text, binaries, README, FEATURES.md or commit messages; say “the reference app” in internal docs. - **Toolchain**: rustc/cargo 1.99.1 on Arch Linux. License GPL-3.0-or-later (D-015). GUI: **Slint 1.19**. Own components on a `Theme` global (colour/shape/type tokens) and a `Motion` global (durations, easings, reduced-motion flag); std-widgets only for scrollbars and text input, style `material`. - **Theme**: `org.freedesktop.portal.Settings` → `org.freedesktop.appearance` `accent-color` (rgb doubles) and `color-scheme` (0 none, 1 dark, 2 light) via `zbus` blocking API, plus `SettingChanged` for live re-theme. Schemes from `material-colors` 0.5 (`ThemeBuilder::with_source`, tonal spot). Fixed fallback seed when no accent. - **Icons**: Material Symbols Rounded, from `/usr/share/fonts/TTF/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf` (package `ttf-material-symbols-variable`, Apache-2.0; license in `/usr/share/licenses/ttf-material-symbols-variable/`). Copy font + license into `assets/fonts/`; draw glyphs by codepoint (folder `e2c7`, home `e88a`). App icon: `assets/tunal.svg` / `.png` / `.ico`. - **Crates already chosen**: `slint` 1.19, `zbus` (blocking), `material-colors` 0.5, `lofty` (tags), `russh` + `russh-sftp` (SFTP, preferred). Later option: `rusty-chromaprint` (AcoustID). - **MusicBrainz / Cover Art Archive**: no API key; ≤ 1 request/s across the whole app; User-Agent `Tunal/ ( https://astar76.com/git/astar76/Tunal )`. - **Native dependencies (decided, D-004–D-007, D-014, D-016, D-019)**: video frames via the `ffmpeg` CLI subprocess; audio `cpal` (alsa-lib) + symphonia; iOS `idevice` over system `usbmuxd`; MTP own pure-Rust client on `nusb`; native DnD via Slint's libwayland connection and `x11rb`; TLS/SSH crypto rustls + ring. No new system packages: optional tools missing → that feature off, no error. Any other non-Rust dependency: ask first. - **User validates personally (🧑)**, all in phase 12 (D-009): visual review (S035), the polkit password prompt, real iPhone/Android devices, native drag/clipboard with other apps, a real SFTP host (S036). Plans that need these stop at that step and report. - **Design references (read only, D-027, D-028)**: the user's own Material You apps — `~/Projects/Damson` (`src/theme.rs`, `src/motion.rs`, `src/ui/`), `~/Projects/Mulberry` (`src/theme.rs`, `src/ui/`), `~/Projects/Nacre` (`src/theme.rs`, `src/ui/widgets.rs`, `src/ui/chrome.rs`). They use egui, not Slint: borrow look and feel (colour roles, state layers, shapes, spacing, motion curves and timings) and port the idea to our Slint tokens; never change our stack, never edit them. Their code is the user's own, so copying is allowed where it fits. Also the user's old, buggy Tunal prototype in `/home/astar76/Documents/Apps/tunal-files/tunal/` (Python): look at its elements for ideas only, never copy its code — the new UI is meant to be new. A library default that looks off is not a reason to accept it: build the control ourselves on `Theme`/`Motion`. - **Motion rules** (`app-taste` skill): tokens only, hover tint and press squeeze on every control, interruptible motion, honour reduced motion, no idle animation, repaint only while something moves. Build new motion with the `animate` skill; `/unslop` and `/improve-animations` run in phase 12 (S034, S035; there is no `/review-animations`). - Remote: `origin` = `forgejo:astar76/Tunal.git` (Astar Hub, private), since 2026-11-25. ## 3. Code rules - Write like the neighbouring code. KISS, DRY, YAGNI; no abstraction without ≥ 2 uses. - Phases 1–11: no new tests (D-013); verify with build, clippy, fmt and a smoke run or screenshot. Phase 12 writes the tests; from then on a bug fix gets a regression test when feasible. - All Rust, pure-Rust crates preferred. `cargo fmt` and `cargo clippy --workspace --all-targets -- -D warnings` clean before commit. - Back-end crates (`tunal-core`, `-theme`, `-dirmeta`, …) have no Slint dependency; the app crate adapts them to the UI. - Views talk only to the location layer in `tunal-core` (a trait for list/stat/read/write/copy/move/rename/delete/trash). Local, device and SFTP backends implement it; views never know which protocol they show. - Blocking work (D-Bus, disk, network, devices) runs off the UI thread; results return with `slint::invoke_from_event_loop` or a `Weak` handle. - UI values come from `Theme` / `Motion` tokens only: no literal colours, durations or radii in components. - Secrets (sudo and SSH passwords, key passphrases): held in `zeroize`/`secrecy` types, never logged, never in argv or env, never written to disk, zeroed after use. ## 4. Domain pitfalls (all agents) - Slint animates only property changes: animate state, not timers. A running `animate` or `Timer` keeps repainting; stop it when idle (no idle animation). - The portal may be missing (no `xdg-desktop-portal`) or return no accent: fall back, never panic. - `.directory` files are desktop entry INI (`[Desktop Entry] Icon=…`, plus view sections); keep unknown keys and comments when writing back. - File ops on large trees: progress, cancel, conflicts (skip/overwrite/rename) and partial failures; trash follows the freedesktop Trash spec (`~/.local/share/Trash`, `.trashinfo`). - Symlinks, permission-denied folders, non-UTF-8 file names and very large folders (10 000+ entries, virtualized ListView) must not break a view. - Tests never touch the real home: use temp dirs. Never connect to Tor or proxies in tests; network tests use a local server or mocks. - Run the app offscreen or in a hidden session unless the user asks to watch. There is no `kwin_wayland` installed: screenshots use Slint's software renderer to PNG. ## 5. Verification tools | Tool | Role | Available after | |---|---|---| | `cargo build --workspace` / `cargo test --workspace` | build, unit + integration tests | phase 1 | | `cargo clippy --workspace --all-targets -- -D warnings`, `cargo fmt --check` | lint, format | phase 1 | | `busctl --user call org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings ReadOne ss org.freedesktop.appearance accent-color` | inspect portal values | now | | `fc-list` | check bundled/system fonts | now | | `cargo run -p tunal -- --screenshot [--dark] [--size WxH]` (software renderer, offscreen, default 960x640; env `TUNAL_SEED=#rrggbb`, `TUNAL_REDUCED_MOTION=1`, `TUNAL_VIEW=grid`) | single-PNG visual check; full state matrix in phase 12 | S003 | | `XDG_CONFIG_HOME= cargo run -p tunal -- […] [--split ] --screenshot [--dark] --size 1200x760` | one tab per folder, `--split` adds a split tab (last tab current); no folders = restore `session.toml`. Copy `~/.config/user-dirs.dirs` into `` for the places | S010 | | `XDG_DATA_HOME=/data cargo run -p tunal-core --example ops -- ` (refuses unless XDG_DATA_HOME is inside ``) | job engine + trash smoke run: conflicts, cancel, trash/restore/empty | S007 | | `cargo run -p tunal -- --gallery --screenshot [--dark] --size 1200x1000` (`--gallery` alone opens it in a window) | every control in rest/hover/pressed/focused/disabled; press squeeze not drawn by the software renderer | S004 | | `cargo run -p tunal -- --gallery --page menu\|dialog --screenshot [--dark] --size 960x640` | open menu + submenu + two toasts, or dialog + indeterminate toast, over a stand-in folder | S005 | | `TUNAL_SETTINGS=<0-7> cargo run -p tunal -- --screenshot --size 1000x700` (`XDG_CONFIG_HOME=`) | settings dialog page over a folder (6 Mouse, 7 Shortcuts); add `TUNAL_KEYS=:` to record that chord on the Shortcuts page (a taken chord shows the conflict row) | S013 | | `TUNAL_DRAG=x1,y1,x2,y2[,hold] TUNAL_REDUCED_MOTION=1 cargo run -p tunal -- --screenshot --size 1200x760` (`XDG_CONFIG_HOME=`) | drags between window points and drops (drop menu) or holds (glow + drag image) before the frame | S014 | | `Xvfb :97 &` then `env -u WAYLAND_DISPLAY DISPLAY=:97 target/debug/tunal &` and `DISPLAY=:97 target/debug/examples/xdnd_probe x1 y1 x2 y2` (or `in x y `) | X11 native DnD: fake XTEST drag out of the window onto a probe target, or a probe source dropping into the app; Xvfb only. Also `xdnd_probe click x y [count] [gap_ms] [hover_ms] [button]` (2 = middle) and `xdnd_probe key ctrl+t f3 alt+2 …` (focuses the window under the pointer, then presses each chord), `xdnd_probe press x1 y1 x2 y2 [hold_ms]` (plain left drag, e.g. a selection box; screenshot while it holds); screenshot with `import -window root ` | S031 | | same, with `SLINT_BACKEND=winit-software` (so `DISPLAY=:97 import -window root ` captures it), then `DISPLAY=:97 target/debug/examples/xdnd_probe click x y [count] [gap_ms] [hover_ms]` | real clicks (XTEST) on a window point after resting `hover_ms` there, e.g. the split toggle with a tooltip showing; Xvfb only | split/tooltip fix | | `TUNAL_APPEARANCE=1 XDG_CONFIG_HOME= cargo run -p tunal -- --screenshot --size 1000x760` | folder appearance dialog for `` (theme icons looked up at once); `cargo run -p tunal-dirmeta --example roundtrip -- ` sets `Icon` in `/.directory` and prints the old values | S015 | | `TUNAL_PLAY=