Tunal/CLAUDE.md
astar76 c94b868b2e S005: overlay layer, menu with submenu, modal dialog, toast stack
Menus, dialogs and toasts draw on an own full-window layer so they can
play exit motion; gallery pages show them open for screenshots.

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

12 KiB

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. Full brief: PROMPT.md (read only the section your plan names).

0. Session rules — read first

  1. You are started with one plan: Plans/<NN Category>/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.
  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": "<step>", "done": true/false}, … every checkbox of the plan in order], "updated": "<ISO date-time>"} 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, <NN Category>/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/<version> ( https://archlinux.tail7c4f5e.ts.net/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).
  • No Forgejo remote yet: the user wants local-only git for now.

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 <png> [--dark] [--size WxH] (software renderer, offscreen, default 960x640; env TUNAL_SEED=#rrggbb, TUNAL_REDUCED_MOTION=1) single-PNG visual check; full state matrix in phase 12 S003
XDG_DATA_HOME=<dir>/data cargo run -p tunal-core --example ops -- <dir> (refuses unless XDG_DATA_HOME is inside <dir>) job engine + trash smoke run: conflicts, cancel, trash/restore/empty S007
cargo run -p tunal -- --gallery --screenshot <png> [--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 <png> [--dark] --size 960x640 open menu + submenu + two toasts, or dialog + indeterminate toast, over a stand-in folder S005

Don't assume a tool exists: check first. When your plan creates a tool, add its row here.

6. Git

Local repository only; no remote and no push until the user says so. .gitignore covers target/. One commit per logical step, message SNNN: … in English. No reset --hard / force push without an explicit request.

7. Definition of done

A plan is done when: all end criteria are verified by command or test; planned builds/tests are green; nothing regressed; PROGRESS / DECISIONS are up to date; the INDEX line and tracker are ticked; the work is committed. Say explicitly what was not done or verified.