Tunal/docs/PROGRESS.md
astar76 c51e63a4a9 S007: file operations engine, freedesktop trash and trash:/// backend
Jobs with progress, cancel, conflict and error requests; scan pass,
copy_file_range and stream copies, rename moves; per-filesystem trash
with .trashinfo, restore and empty; ops smoke example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 10:04:31 -06:00

46 lines
9.7 KiB
Markdown

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Progress
One entry per session, newest last, ≤ 15 lines: done, verified how, not done, later.
## S001 — Workspace, crates, README and feature map
- Done: workspace (resolver 3, edition 2024, GPL-3.0-or-later); crates `tunal` (bin, Slint window "Tunal" with assets/tunal.png) and `tunal-core/-theme/-dirmeta/-elevate/-thumbs/-tags/-player/-devices/-net` (crate doc only); font + license in `assets/fonts/MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf`; FEATURES.md (plan-id tables, updated by later plans); README.md; reference app cloned to /home/astar76/Projects/Tunal-reference.
- Verified: cargo build, clippy -D warnings, fmt --check, fc-query font family, grep for forbidden names empty, window smoke run 5 s no errors.
- Not done: nothing. Tracker item texts for S001 were shortened when syncing.
- Later: —
## S002 — Portal theme and Material schemes
- Done: `tunal-theme` with `read() -> Appearance`, `watch(F: Fn(Appearance) + Send + 'static) -> JoinHandle<()>`, `Appearance { accent: Option<Accent>, scheme: ColorScheme, animations: Option<bool> }` (+ `seed()`, `palette()`), `Accent { red, green, blue: f64 }` (`rgb() -> 0xRRGGBB`), `Palettes::from_seed(u32) -> { light, dark: Palette }`, `Palette` = 34 M3 roles as ARGB u32. Fallback seed `FALLBACK_SEED = 0x3F6FB5` (D-022). zbus 5.19 blocking-api + async-io, no tokio. Example `dump` (`--watch` prints changes).
- Verified: build, clippy -D warnings, fmt --check; dump accent = busctl (0.901961, 0.176471, 0.258824); `Read` fallback forced once; no bus (`unix:path=/nonexistent`) and bare bus without portal → one stderr line, defaults, exit 0; watcher against a fake portal (private bus) reported accent, scheme and animations changes, ignored other namespaces, out-of-range accent → None.
- Not done: nothing. Missing-setting warnings are `eprintln!` lines prefixed `tunal-theme:` (no logging crate).
- Later: —
## S003 — Window, Theme and Motion globals, screenshot command
- Done: `ui/theme.slint` `Theme` (34 M3 roles as `primary`, `on-primary`, … `scrim`; `dark`; `corner-none/xs/sm/md/lg/xl` 0/4/8/12/16/28 + `corner-full(h)`; `space-1/2/3/4/6/8`; `hairline`; `icon-font`; `TypeStyle` `title-large/title-medium/body-medium/body-small/label-large/label-medium`; `state-hover/focus/press/drag`, `disabled-content/container`). `ui/motion.slint` `Motion` (`short1…long4`, `emphasized(-decelerate/-accelerate)`, `standard(-decelerate/-accelerate)`, `time(d)` → 0 ms when reduced) fed by exported `MotionPrefs.reduced`. `Icon { glyph, size }` + `Icons.folder/home`. `src/theme_bridge.rs` (read at start, `watch` → `upgrade_in_event_loop`), env `TUNAL_SEED=#rrggbb`, `TUNAL_SCHEME=light|dark`, `TUNAL_REDUCED_MOTION=1`. `src/screenshot.rs`: `tunal --screenshot <png> [--dark] [--size WxH]`. Window min 720×480 (D-023); ui entry renamed `ui/app.slint`; `png` 0.18 dep.
- Verified: build, clippy -D warnings, fmt --check; looked at light, dark, `TUNAL_SEED=#2e7d32 --dark --size 720x480`, and no-bus (fallback blue) PNGs; real window ran 4 s on a private bus and with invalid env values (one stderr line each), no panic.
- Not done: live re-theme not observed end to end (no D-Bus Python bindings for a fake portal); the path is `watch` (verified in S002) → `apply` (verified by screenshots). Icon weight/fill: not settable in Slint 1.19 (D-023).
- Later: icon weight/fill if Slint gains font variations; screenshot hover/press states need a controlled clock (phase 12).
## S006 — Location layer and local backend
- Done: `tunal-core` types `Uri` (scheme, authority, path as raw bytes; `Uri::from_path/parse/to_path/join/parent/file_name`, Display percent-encodes the path, e.g. `file:///a/b%FFc`), `Entry { name: Vec<u8>, display_name, kind: Kind, size, mtime: Option<SystemTime>, mode (0o7777), uid, gid, hidden, mime: &'static str }`, `Kind::{File, Dir, Special, Symlink { target: Vec<u8>, target_type: Option<FileType> }}` (`None` = broken), `Error::{NotFound, PermissionDenied, Exists, NotEmpty, Unsupported, Cancelled, Io(String), Remote(String)}` + `needs_elevation()`, `From<io::Error>`.
- Trait `Location: Send + Sync` (object-safe, blocking): `scheme()`, `capabilities() -> Capabilities { write, trash, symlink, watch, permissions }`, `list(&Uri, &mut dyn FnMut(Vec<Entry>) -> ControlFlow<()>)` (Break → `Cancelled`), `stat` (lstat), `open_read -> Box<dyn Read + Send>`, `open_write(&Uri, WriteMode::{CreateNew, Overwrite})`, `mkdir`, `rename` (`Exists` if target taken), `delete` (file/link/empty dir), `trash`, `symlink(link, target: &[u8])`, `watch(&Uri, Box<dyn Fn(WatchEvent) + Send>) -> Watch` (drop stops; `WatchEvent::{Changed(Vec<Uri>), Error}`); defaults → `Unsupported`. `Locations` registry (`with_local()`, `register`, `get`, `resolve`). `LocalLocation` (`file`): 256-entry chunks, `notify-debouncer-mini` 0.7 (200 ms, non-recursive); trash Unsupported until S007. `mime::mime_type(name, kind)` (`mime_guess`; dirs `inode/directory`, broken links `inode/symlink`, links by own name then target; local fifo/socket/devices `inode/*`). Example `ls [--watch] <dir>...`.
- Verified: workspace build, clippy -D warnings, fmt --check; scratch dir (non-UTF-8 name shown raw as `%FF`, broken/dir/file links, fifo, hidden, `chmod 000` folder → PermissionDenied, 10 000 files in 36 ms debug / 15 ms release); `--watch` reported create/modify/delete/mkdir once per path.
- Not done: nothing. URI schemes `trash:///`, `ios://`, `mtp://`, `sftp://user@host:port/path` come with their plans.
- Later: local `rename` uses a check-then-rename (race); `renameat2(RENAME_NOREPLACE)` would need `libc`/`rustix`.
## S004 — Base animated controls
- Done: `components/state-layer.slint`: `ForceState { none, hover, pressed, focused }`; `Tooltip { text }`; `StateLayer` (base via `inherits`; `enabled`, `force-state`, `tint`, `fill-tint`, `squeeze`, `tooltip`, `ring-offset`; out `hovered/pressed/focused/tint-opacity`; `clicked` for users, `activated` for the control itself; `activate()`; Space/Enter; ring only on Tab focus; tooltip Timer runs only while hovered).
- `Button { text, icon, kind: ButtonKind { filled, tonal, outlined, text } }` · `IconButton { icon, toggle, checked, size, icon-size }` (circle → squircle on press) · `Chip { text, icon, kind: ChipKind { filter, assist }, checked }` (fixed width, label slides, check fades/scales) · `Switch { checked }` (thumb slides/grows, halo tint) · `ListRow { icon, title, supporting, selected, trailing @children }` · `Tab { title, icon, active, closable; close() }` · `TabBar { tabs: [TabItem { title, icon }], current, max-tab-width; selected(int), close(int) }` (equal widths, sliding indicator) · `TextField { label, placeholder, supporting, error, enabled, force-state, text; edited, accepted; out focused }`.
- Tokens: `Motion.squeeze-small/squeeze/squeeze-large`, `Motion.tooltip-delay`; `Theme.focus-ring-width/offset`; Icons check, close, cancel, add, search, star, grid-view, music-note, description. `theme_bridge::Themed` trait (MainWindow, Gallery); `screenshot::run(options, new)`; `tunal --gallery [--screenshot …]` (screenshot forces reduced motion).
- Verified: workspace build, clippy -D warnings, fmt --check, literal grep empty; gallery PNGs light + dark looked at (all states), bad argument → usage, exit 1.
- Not done: press squeeze is invisible in PNGs (software renderer ignores `transform-scale`, D-025); live hover/tooltip/animation not watched (no hidden session); `TextField` uses `TextInput`, not `LineEdit` (D-025).
- Later: focus ring on `TextField` is its 2 px border only; long tab bars (more tabs than fit) need scrolling.
## S007 — File operations engine and trash
- Done: `tunal-core::ops` — `Jobs`/`JobHandle`/`JobKind::{Copy, Move, Delete, Trash, Restore, EmptyTrash, Mkdir, Rename, Link}`, `Progress { phase: Queued/Scanning/Running/Finished, total/done files+bytes, current }` (event ≤ every 100 ms), `ConflictRequest { source, source_entry, target, target_entry, reply }` → `ConflictChoice { action: Skip/Overwrite/Rename(name)/AutoRename, apply_to_all }`, `ErrorRequest { uri, error, reply, needs_elevation() }` → `ErrorAction::{Retry, Skip, SkipAll, Abort}`, `Report { done_files, done_bytes, failures, cancelled }`; `numbered`/`auto_rename` (`name (2).ext`, `.tar.*` kept), `is_inside`. Scan pass, local `io::copy` chunks (copy_file_range), stream copy for other backends, same-fs move = rename, else copy + delete; mtime/mode kept on local targets; partial files removed on cancel/error.
- `tunal-core::trash`: home trash + `$topdir/.Trash/$uid` (sticky check) / `.Trash-$uid` from mountinfo; exclusive `.trashinfo` reservation, percent-encoded Path, local DeletionDate (jiff 0.2); `items()`, `original()`, `restore()`, `TrashLocation` (`trash:///<id>:<name>`, list/stat/open_read/delete), registered by `Locations::with_local()`; `LocalLocation::trash` now works. Example `ops` (refuses unless `XDG_DATA_HOME` is inside its dir). URI format and job API: D-026.
- Verified: workspace build, clippy -D warnings, `cargo fmt --check -p tunal-core`; `XDG_DATA_HOME=<scratch>/data cargo run -p tunal-core --example ops -- <scratch>`: progress, auto-rename conflict, same-folder copy → `a (3).txt`, folder-into-itself refused, merge move, trash/list/restore with rename conflict, duplicate names `dup (2).txt`, non-UTF-8 name encoded `%FF`, copy out of trash by original name (stream path), cancel mid-file (partial removed), chmod 000 → PermissionDenied flagged, rest copied; empty trash; real `~/.local/share/Trash` untouched.
- Not verified: per-mount `.Trash-$uid` trash and cross-device move (no second filesystem inside the scratchpad). Workspace `cargo fmt --check` fails only on S005's in-progress `crates/tunal/src/main.rs`.
- Later: trash `directorysizes` cache; orphan `.trashinfo` cleanup on empty; trash watch for live trash view; checking free space before copy.
## Later
-