Tunal/docs/DECISIONS.md
astar76 7257b00b0c S016: root operations through a pkexec helper
Helper mode tunal --elevated-helper over a framed stdin/stdout protocol,
pkexec launcher, ElevatedLocal backend, per-job-thread Elevation for the
job engine, Retry as administrator in the error dialog, polkit policy and
a helper smoke example.

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

42 lines
14 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.

# Decisions
`D-NNN — date — decision — why — plans affected`. Never rewrite an entry; supersede it with a new one.
D-001 — 2026-11-18 — Brief decisions adopted as binding: name Tunal / binary `tunal`; Slint 1.19 with own components on Theme + Motion globals; zbus blocking portal + material-colors 0.5; Material Symbols Rounded by codepoint; MusicBrainz + Cover Art Archive (1 req/s, User-Agent); lofty; russh + russh-sftp preferred — PROMPT.md §Decisions — all plans.
D-002 — 2026-11-18 — Workflow: at most 2 parallel sessions, look-ahead 3, Sonnet medium by default and Opus high for theming/motion, elevation, devices and SFTP; git local only (no remote, no push) — user's answers at setup — all plans.
D-003 — 2026-11-18 — 🧑 checkpoints: visual review at end of phases 2, 3, 6; real-password sudo test (phase 5); real devices (phase 9); every C library before it is added — user's answers at setup — phases 2, 3, 5, 6, 8, 9.
D-004 — 2026-11-18 — Video frame thumbnails: run the installed `ffmpeg`/`ffprobe` CLI as a subprocess (no linking); missing ffmpeg → plain icon — user, plan-generate — S017, S018.
D-005 — 2026-11-18 — Audio: symphonia decoding (pure Rust) + cpal output (links alsa-lib, approved) — user — S022, S023.
D-006 — 2026-11-18 — iOS: `idevice` crate over the system usbmuxd socket (approved); usbmuxd missing → iOS hidden — user — S024.
D-007 — 2026-11-18 — Android: own pure-Rust MTP/PTP client on `nusb` (no libmtp) — user — S025, S026.
D-008 — 2026-11-18 — Extras in scope: Open / Open with (portal OpenURI, .desktop apps), details + icon grid views, type-to-filter (no recursive search), desktop entry + install script — user — S008, S009, S012, S037.
D-009 — 2026-11-18 — Phases restructured: 11 Native drag and drop, 12 Testing, 13 Packaging added; 🧑 checks of D-003 all move to phase 12 (S035 visual, S036 password/devices/apps/server) — user ("testing after there's a solid app") — all plans; supersedes the timing in D-003.
D-010 — 2026-11-18 — Models: D-002 categories get Opus high; other design-heavy plans (location layer, ops, views, shell, DnD, tag UI, player) Opus medium; well-specified work Sonnet — plan-generate — all plans.
D-011 — 2026-11-18 — Tag editor edits one or many files (mixed values shown as Keep); lookup applies per release — user — S019–S021.
D-012 — 2026-11-18 — Planner defaults: config in `$XDG_CONFIG_HOME/tunal/*.toml`; own bookmarks file seeded from XDG user dirs; shared freedesktop thumbnail cache; trash browsable as `trash:///`; video frame at 10% of duration by default; delete on devices/SFTP is permanent with confirm; reduced motion follows portal `enable-animations` with an app override; removable drives (UDisks) and recursive search are Later — plan-generate, shown to user — S002, S003, S007, S010, S013, S017, S024–S029.
D-013 — 2026-11-18 — Less testing while building: feature plans (phases 1–11) add no tests and verify with build, clippy, fmt and a smoke run/screenshot; automated tests, the screenshot matrix, /unslop, /improve-animations and all 🧑 checks run in phase 12 once the app is solid — user — all plans; supersedes CLAUDE.md §3 "new pure logic gets a test" for phases 1–11.
D-014 — 2026-11-18 — Drag and drop: in-app (S014) plus native in/out with other apps on Wayland (wl_data_device on Slint's own libwayland connection, our own wl_pointer/wl_keyboard for serials) and X11 (XDND via x11rb); Move/Copy/Link/Cancel menu on drop, Shift = move, Ctrl = copy, Ctrl+Shift = link; file clipboard interop in the same plans. Slint 1.19's winit backend has no native DnD, hence own code — user — S014, S030, S031, S036.
D-015 — 2026-11-18 — License: GPL-3.0-or-later — user — S001.
D-016 — 2026-11-18 — No extra system packages: all crates compile into the `tunal` binary; only libraries a desktop already has are used (libwayland/libX11 via Slint, fontconfig, alsa-lib); optional runtime tools (ffmpeg, usbmuxd, polkit agent) disable only their feature when missing, without errors — user — all plans.
D-017 — 2026-11-18 — `.directory`: standard `[Desktop Entry]` `Icon` and `Name`; our view settings and Material glyph in an `[X-Tunal]` group; never write another app's groups — plan-generate — S015.
D-018 — 2026-11-18 — Elevation via pkexec/polkit: `tunal --elevated-helper` over stdin/stdout pipes; the polkit agent asks for the password, Tunal never sees it; policy file in assets/polkit, installed by the install script (needs root, printed not run) — user — S016, S036, S037.
D-019 — 2026-11-18 — TLS and SSH crypto on rustls + ring (no aws-lc-rs, no OpenSSL) — user — S020, S028.
D-020 — 2026-11-18 — Accepted SSH host keys go to `$XDG_CONFIG_HOME/tunal/known_hosts`, read together with `~/.ssh/known_hosts`; Tunal never writes under ~/.ssh — plan-generate — S027–S029.
D-021 — 2026-11-18 — Playlist sort: a sort option "Playlist sort" offered only in folders under XDG_MUSIC_DIR that contain a playlist file (.m3u, .m3u8, .pls, .xspf); listed files first in playlist order, unlisted entries after in natural name order; several playlists → one option each; desc reverses; re-sorts when the playlist changes; stored as the folder's sort in `.directory` like other sorts — user request (details chosen by orchestrator, user may revise) — S008, S015.
D-022 — 2026-11-18 — Fallback theme seed `#3F6FB5` (muted blue) when the portal gives no accent; palettes are `material-colors` 0.5 `ThemeBuilder` defaults (tonal spot, spec 2021) exported as ARGB `Palette` structs; library warnings go to stderr as one `tunal-theme: …` line (no logging crate yet) — S002 — S002, S003.
D-023 — 2026-11-18 — Window minimum size 720×480 px (preferred 960×640): fits a 240 px sidebar plus a usable content column; Slint 1.19 can't drive the icon font's variation axes (font-weight doesn't reach `wght`), so `Icon` has size only and draws the default instance (wght 400, FILL 0); easing tokens live in an internal `Motion` global and Rust sets the reduced flag through `MotionPrefs` (easing properties can't be exported) — S003 — S003 and every UI plan.
D-024 — 2026-11-18 — Location URIs are `scheme://authority/path` with the path as raw bytes (percent-encoded only in Display); every backend implements the object-safe blocking `Location` trait in `tunal-core` (chunked `list` with a `ControlFlow` sink, `watch` returning a drop guard), unsupported ops return `Error::Unsupported`, and views gate actions on `capabilities()` — S006 — S007–S014, S024–S029.
D-025 — 2026-11-18 — Controls: every control inherits `StateLayer` (tint drawn above content, `clicked` for users and `activated` for the control's own toggling; inherited properties must be written `root.x`); `TextField` is built on the builtin `TextInput` because std `LineEdit` (material) takes its colours from the fixed `MaterialPalette` and can't use our tokens; the software renderer ignores `transform-scale`, so press squeeze shows only in a real window — S004 — every UI plan, S035.
D-026 — 2026-11-18 — File operations run as jobs in `tunal-core::ops`: `Jobs::new(locations, sink)` (one worker thread runs long jobs in order; mkdir/rename get their own thread), `submit(JobKind) -> JobHandle` (`progress()`, `cancel()`); the sink gets `JobEvent::{Progress, Conflict(Box<ConflictRequest>), Error(ErrorRequest), Finished(Report)}` on the job thread, requests block the job until answered through `Reply::send` (dropped = Skip). Folder onto folder with Overwrite merges. Trash item URIs are `trash:///<id>:<name>[/sub]` with `<id>` = `home` or the hex path of a per-mount trash dir; entries' `name` is that key, `display_name` the original name; jiff 0.2 for local DeletionDate — S007 — S010, S011, S012, S013 and every plan that changes files.
D-027 — 2026-11-18 — UI sessions look at the user's other Material You apps (Damson, Mulberry, Nacre; egui) as design references for colour roles, state layers, shape, spacing and motion, porting ideas to our Slint Theme/Motion tokens; the stack (Slint 1.19) stays; library defaults that don't match are replaced by own components — user — all UI plans (S004–S031, S034, S035).
D-028 — 2026-11-18 — The user's old, buggy Tunal prototype (`/home/astar76/Documents/Apps/tunal-files/tunal/`, Python) is a UI reference only: look at its screens and elements for ideas (layout, panels, playlists, tag editor, dialogs), never copy its code, never port its bugs; the new UI should be fresh, not a re-skin — user — all UI plans, S008 (playlist sort), S021, S023.
D-029 — 2026-11-18 — Orchestration: backend-only plans whose dependencies are done and whose files are a crate of their own (S017, S019, S020, S022, S025, S027) may run out of INDEX order in the second parallel slot beside the UI chain; still at most 2 sessions at once; each commits with explicit paths — orchestrator (user asked to keep everything runnable going) — S017–S027.
D-030 — 2026-11-18 — Playlist sort refined (supersedes D-021's details, keeps its UI): candidate playlists come from the viewed folder and from <Music>/Playlists (also playlists/Playlist/playlist); only playlists with ≥ 1 track in the viewed folder are offered, one "Playlist sort" option each; preselected = the playlist named after the folder, else the one with most tracks from it; subfolders sort by their first listed track; tracks that moved still match by file name; formats .m3u .m3u8 .pls .xspf .wpl, text decoded utf-8 → utf-16 → cp1252 → latin-1; ordering stays listed-first in playlist order, rest natural name order, desc reverses — orchestrator, from the user's old prototype behaviour (D-028) — S008.
D-031 — 2026-11-18 — Floating surfaces don't use `PopupWindow` (it closes without exit motion): `Menu` and `Dialog` inherit `Overlay` and `ToastStack` is a plain layer, each placed last in the window at `width: 100%; height: 100%` in the order ToastStack, Dialog, Menu; they open with window coordinates and play exit motion by animating a `progress` that reverses mid-flight. Dialogs never close themselves (owner calls `close()` from `action`); toast models are owned outside (`closing` ends one, `removed(index)` drops it). Tooltips stay on `PopupWindow` (fade in, leave at once) — S005 — every UI plan with menus, dialogs or toasts (S010–S013, S018–S031).
D-032 — 2026-11-18 — Folder views use `folder::FolderModel` (one per view, `Rc`, a Slint `Model` of `DetailRow`s formatted on demand; worker results reach it through `upgrade_in_event_loop` + `as_any` downcast and carry a generation); selection is a set of raw names (`click`, `navigate`, `select_all`); sort menus are built in Rust as `[MenuItem]` and opened at window level (D-031); list rows set `StateLayer.focusable: false` and the view's `FocusScope` owns the keys; watch events are hints (unchanged stat is ignored: the local backend also reports reads) — S008 — S009–S015.
D-033 — 2026-11-18 — View mode and list motion: `ViewMode { details, grid }` (views/details-view.slint) lives in `folder::Settings::mode`, so one per `FolderModel` = per pane, carried over between folders like the sort, and reaches the views as `FolderState.mode` (`set_mode`); `.directory` view settings read and write that field. `FolderView` (views/view-switch.slint) stacks both views and cross-fades them; `ViewSwitch` is the segmented control. List changes (sort, filter, hidden, watch, playlist re-sort; not listing chunks) animate from Rust-computed per-row `from`/`to` offsets and leaving copies, drawn from one `MotionClock` (motion.slint, `animation-tick()` while running only), length `MotionPrefs.list-change` (0 under reduced motion = no transition); instant above 2000 rows. Opening with `open_travel(uri, Travel)` slides content from the right (into, forward) or left (up, back) — S009 — S010, S015, S018 (grid thumbnails in `GridCell`).
D-034 — 2026-11-18 — Window shell API: MainWindow holds `panes: [PaneData { rows, lines, folder, title, glyph }]` for the current tab and every folder-view callback takes the pane index first (`sort-by(int, SortColumn)`, `row-activated(int, int)`, `view-mode-selected(int, ViewMode)`, …); toolbar, breadcrumb, sort menu and status follow `active-pane`. Rust side: `shell::Shell` owns tabs/panes and binds those callbacks; one `FolderModel` per `shell::pane::Pane`, worker results routed by pane id; `folder::attach` is gone. Config goes through `config::{load, store}` (TOML in `$XDG_CONFIG_HOME/tunal/`), later settings are new fields on `config::Settings`; sidebar sections Devices/Network are filled with `Places::set_section` — S010 — S011–S015, S024–S029.
D-035 — 2026-11-18 — Visual direction: the user finds the current UI bland and wants it closer to their old prototype: Material 3 Expressive — shaped glyph containers (cookie/clover/scallop), pills and rounded surface cards, ripples, shape morphing, visible (token-driven) motion. New plan S038 restyles S003–S013 before S014; later UI plans build on its `Shape` component — user — S014+, S018, S021, S023, S029, S034, S035.
D-036 — 2026-11-18 — Cost: the user saw ~50 % of a day's credits go; every session runs the `caveman:caveman` skill (short replies and reports), reads only what its plan names, and skips extra verification variants; the orchestrator keeps look-ahead at 1–2 fresh sessions, avoids reusing long sessions when it can start a fresh one, and uses one-shot wake-ups at a usage-limit reset instead of a 30-minute heartbeat — user — all plans; overrides ORCHESTRATOR.md look-ahead 3.
D-037 — 2026-11-18 — Dates: relative stamps by default (Just now, N minutes/hours ago, Yesterday/weekday with time, then date + time), 12-hour clock by default, both configurable (date style Relative/Absolute, clock 12/24-hour) — plan S039. The user expects a lot of configuration: every UI plan exposes its user-visible choices in Settings — user — S039, all UI plans.
D-038 — 2026-11-18 — Elevation is per job thread: `tunal_elevate::Elevation` is the jobs' `file://` backend and sends an elevated thread's calls to one shared pkexec helper (other threads and views stay local); polkit action id `org.tunal.Tunal.elevated-helper`, exec path `/usr/bin/tunal`; non-job root writes use `Elevation::write_file` — S016 — S015, S036, S037.