S017: details panel, file actions, reveal in folder

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
astar76 2026-11-25 14:28:13 -06:00
commit d4eb7faf95
14 changed files with 816 additions and 11 deletions

View file

@ -12,14 +12,14 @@ FEATURES 7.2, 7.3, 7.4, 9.3 in place.
- crates/core/src/{verify,mirror}*
## Steps
- [ ] Side panel or bottom sheet by width: overview, parts map, graph, log, headers, mirrors, checksum
- [ ] File actions: open, show in folder (D-Bus FileManager1), move, rename, copy link, redownload, bin, "file is gone" state
- [ ] Tags and notes; tag colours from theme roles only
- [ ] Live edits: limit, parts, priority, queue, link, login
- [ ] Log with copy, filter and redaction; properties copyable
- [ ] Error section: what, why, when tried, next try, all fixes
- [ ] Test file `docs/tests/S017-details.md`, with the checks below
- [ ] `docs/PROGRESS.md` entry, tick `Plans/INDEX.md`, commit `S017: …`, push
- [x] Side panel or bottom sheet by width: overview, parts map, graph, log, headers, mirrors, checksum
- [x] File actions: open, show in folder (D-Bus FileManager1), move, rename, copy link, redownload, bin, "file is gone" state
- [x] Tags and notes; tag colours from theme roles only
- [x] Live edits: limit, parts, priority, queue, link, login
- [x] Log with copy, filter and redaction; properties copyable
- [x] Error section: what, why, when tried, next try, all fixes
- [x] Test file `docs/tests/S017-details.md`, with the checks below
- [x] `docs/PROGRESS.md` entry, tick `Plans/INDEX.md`, commit `S017: …`, push
## End criteria
`nice cargo check -q -j 2 -p medlar` clean

View file

@ -28,7 +28,7 @@ Tracker: https://claude.ai/artifact/XouimfVJS6FYVKskGJ8s7H
- [x] [S014](03%20Interface/S014-wavy-parts-shapes.md) Wavy bars, parts map, shapes and speed graph
- [x] [S015](03%20Interface/S015-main-window.md) Main window and list
- [x] [S016](03%20Interface/S016-add-dialog.md) Add dialog, batch and duplicates
- [ ] [S017](03%20Interface/S017-details.md) Details panel and file actions
- [x] [S017](03%20Interface/S017-details.md) Details panel and file actions
- [x] [S018](03%20Interface/S018-settings-palette.md) Settings, colour, shortcuts and first run
## 04 Control

View file

@ -373,6 +373,7 @@ fn open(engine: bool, show: fn(&mut App, &mut Ui)) -> ExitCode {
}
app.paths = Some(paths.clone());
app.main.outside = open_outside;
app.main.reveal = crate::views::main::reveal_outside;
app.main.remember(paths.data.join("view.json"));
if let Some(damage) = damage {
app.main.toasts.error(damage_words(&damage), None);

View file

@ -23,6 +23,7 @@ pub enum Action {
SelectAll,
OpenOrRun,
Toggle,
Details,
Show,
Copy,
Page,
@ -88,6 +89,7 @@ pub const ALL: &[Entry] = &[
entry(Action::SelectAll, "select_all", "select_all", Group::List, "Ctrl+A"),
entry(Action::OpenOrRun, "open", "open_in_new", Group::List, "Enter"),
entry(Action::Toggle, "toggle", "play_circle", Group::List, "Space"),
entry(Action::Details, "details", "info", Group::List, "Alt+Enter"),
entry(Action::Show, "show", "folder_open", Group::List, "Ctrl+O"),
entry(Action::Copy, "copy", "content_copy", Group::List, "Ctrl+C"),
entry(Action::Page, "page", "public", Group::List, ""),

View file

@ -0,0 +1,198 @@
//! The details panel of one download: a side panel in a wide window, a sheet at the bottom in a narrow one.
mod tabs;
use super::list::Order;
use crate::bridge::{self, Bridge, Lists};
use crate::theme::Theme;
use crate::tokens::{radius, size, space, text};
use crate::ui::graph;
use crate::ui::widgets::{Button, Tab, cr, tabs};
use crate::fonts;
use eframe::egui::{Key, Rect, RichText, ScrollArea, Ui, UiBuilder, vec2};
use medlar_core::model::{State, TaskId};
use medlar_core::snapshot::{Snapshot, TaskView};
use medlar_core::tr;
use std::path::PathBuf;
use std::time::{Duration, Instant};
use tokio::sync::oneshot;
/// Windows at least this wide get a side panel.
const SIDE_FROM: f32 = 900.0;
/// How often a finished file is looked for.
const LOOK: Duration = Duration::from_secs(3);
/// Seconds the speed graph shows.
const SPAN: usize = 300;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
pub enum Pane {
#[default]
Overview,
Parts,
Speed,
Log,
Headers,
Mirrors,
Checksum,
}
impl Pane {
const ALL: [(Pane, &'static str, &'static str); 7] = [
(Pane::Overview, "info", "details.tab.overview"),
(Pane::Parts, "view_list", "details.tab.parts"),
(Pane::Speed, "speed", "details.tab.graph"),
(Pane::Log, "description", "details.tab.log"),
(Pane::Headers, "list", "details.tab.headers"),
(Pane::Mirrors, "public", "details.tab.mirrors"),
(Pane::Checksum, "verified", "details.tab.checksum"),
];
}
pub struct Details {
/// The download shown; None when the panel is closed.
pub open: Option<TaskId>,
pub tab: Pane,
/// What the log is filtered by.
pub filter: String,
note: (TaskId, String),
paste: String,
graph: graph::History,
seen: u64,
/// The finished file is not where it was left.
missing: bool,
looked: Instant,
looking: Option<oneshot::Receiver<bool>>,
/// For the slots of later plans (media, archive): tabs they add.
pub extra: Vec<Extra>,
}
/// A tab added by another part of the program (the media and archive plans).
pub struct Extra {
pub name: String,
pub icon: &'static str,
pub body: fn(&mut Ui, &Theme, &TaskView),
}
impl Default for Details {
fn default() -> Details {
Details {
open: None,
tab: Pane::Overview,
filter: String::new(),
note: (0, String::new()),
paste: String::new(),
graph: graph::History::new(SPAN + 2),
seen: 0,
missing: false,
looked: Instant::now(),
looking: None,
extra: vec![],
}
}
}
impl Details {
/// Takes the room of the panel from `body`: the rest and the panel.
pub fn split(&mut self, body: Rect, shot: &Snapshot) -> (Rect, Option<Rect>) {
if self.open.is_some_and(|id| shot.get(id).is_none()) {
self.close();
}
if self.open.is_none() {
return (body, None);
}
let wide = body.width() + 2.0 * space::XL >= SIDE_FROM;
let (rest, panel) = if wide {
let width = (size::SHEET + size::DIALOG_S * 0.5).min(body.width() / 2.0);
let (rest, panel) = body.split_left_right_at_x(body.right() - width);
(rest.with_max_x(rest.right() - space::M), panel)
} else {
let (rest, panel) = body.split_top_bottom_at_y(body.bottom() - (body.height() * 0.55).max(size::DIALOG_S.min(body.height())));
(rest.with_max_y(rest.bottom() - space::S), panel)
};
(rest, Some(panel))
}
fn close(&mut self) {
self.open = None;
self.missing = false;
self.looking = None;
}
/// Keeps the speed graph and the "file is gone" state up with the download.
fn follow(&mut self, ui: &Ui, v: &TaskView) {
let h = &v.history;
if h.pushed() < self.seen {
self.graph = graph::History::new(SPAN + 2);
self.seen = 0;
}
let new = (h.pushed() - self.seen).min(h.samples().len() as u64) as usize;
for s in h.samples().skip(h.samples().len() - new) {
self.graph.push(f64::from(s));
}
self.seen = h.pushed();
if v.state() != State::Done {
self.missing = false;
self.looking = None;
return;
}
if let Some(rx) = &mut self.looking {
if let Some(answer) = bridge::poll(rx, ui.ctx()) {
self.looking = None;
self.looked = Instant::now();
self.missing = answer.unwrap_or(false);
}
} else if self.looked.elapsed() >= LOOK {
let file: PathBuf = v.task.folder.join(&v.task.name);
self.looking = Some(bridge::beside(move || file.is_absolute() && !file.exists()));
}
ui.ctx().request_repaint_after(LOOK);
}
/// Draws the panel in `rect`. What needs the window comes back as orders.
pub fn show(&mut self, ui: &mut Ui, t: &Theme, rect: Rect, shot: &Snapshot, lists: &Lists, bridge: &Bridge) -> Vec<Order> {
let Some(v) = self.open.and_then(|id| shot.get(id)).cloned() else { return vec![] };
if self.open != Some(self.note.0) {
self.note = (v.id(), v.task.notes.clone());
self.graph = graph::History::new(SPAN + 2);
self.seen = 0;
}
self.follow(ui, &v);
let mut orders = vec![];
let p = ui.painter();
p.rect_filled(rect, cr(radius::L), t.container);
let inner = rect.shrink(space::L);
let mut ui = ui.new_child(UiBuilder::new().max_rect(inner).id_salt(("details", v.id())));
let ui = &mut ui;
ui.horizontal(|ui| {
let name = super::list::model::title(&v);
ui.add_sized(vec2((inner.width() - size::HIT - space::S).max(0.0), size::HIT), eframe::egui::Label::new(RichText::new(name).font(fonts::semi(text::TITLE)).color(t.on_surface)).truncate());
if Button::icon("close", &tr!("details.close")).show(ui, t).clicked() {
self.close();
}
});
let mut at = Pane::ALL.iter().position(|(k, ..)| *k == self.tab).unwrap_or(0);
let words: Vec<String> = Pane::ALL.iter().map(|(_, _, key)| medlar_core::strings::text(key, &[])).collect();
let options: Vec<Tab> = Pane::ALL.iter().zip(&words).map(|((_, icon, _), text)| Tab { icon, text, count: None }).collect();
if tabs(ui, t, "details", &options, &mut at) {
self.tab = Pane::ALL[at].0;
}
ui.add_space(space::S);
let tab = self.tab;
ScrollArea::vertical().auto_shrink(false).id_salt(("details-body", tab as u8)).show(ui, |ui| {
let mut cx = tabs::Cx { t, v: &v, lists, bridge, orders: &mut orders, missing: self.missing };
match tab {
Pane::Overview => tabs::overview(ui, &mut cx, &mut self.note),
Pane::Parts => tabs::parts(ui, &mut cx),
Pane::Speed => tabs::speed(ui, &mut cx, &self.graph),
Pane::Log => tabs::log(ui, &mut cx, &mut self.filter),
Pane::Headers => tabs::headers(ui, &mut cx),
Pane::Mirrors => tabs::mirrors(ui, &mut cx),
Pane::Checksum => tabs::checksum(ui, &mut cx, &mut self.paste),
}
});
if ui.input(|i| i.key_pressed(Key::Escape)) && ui.memory(|m| m.focused().is_none()) {
self.close();
}
orders
}
}

View file

@ -0,0 +1,432 @@
//! The pages of the details panel.
use super::super::list::model::{Status, host_name, queue_name, span, title, when};
use super::super::list::row::state_label;
use super::super::list::{Act, Order, act_of_fix};
use crate::bridge::{Bridge, Lists};
use crate::theme::Theme;
use crate::tokens::{icon, radius, size, space, text};
use crate::ui::field::{Combo, Field, Number};
use crate::ui::graph;
use crate::ui::odometer::{amount, rate};
use crate::ui::parts::{self, Block};
use crate::ui::widgets::{Button, Chip, Kind};
use crate::fonts;
use eframe::egui::{Color32, Grid, Id, Label, RichText, ScrollArea, Sense, TextStyle, Ui, vec2};
use medlar_core::error::{Fix, Retry};
use medlar_core::manager::{Command, Files};
use medlar_core::model::{Priority, State, Tag, TaskId, Time, now};
use medlar_core::snapshot::{Log, TaskView};
use medlar_core::verify::{self, Checksum, Offer};
use medlar_core::{redact, tr};
pub struct Cx<'a> {
pub t: &'a Theme,
pub v: &'a TaskView,
pub lists: &'a Lists,
pub bridge: &'a Bridge,
pub orders: &'a mut Vec<Order>,
/// A finished file that is not on the disk.
pub missing: bool,
}
impl Cx<'_> {
fn id(&self) -> TaskId {
self.v.id()
}
fn act(&mut self, act: Act) {
self.orders.push(Order::Do(act, vec![self.id()]));
}
fn edit(&self, edit: impl FnOnce(&mut medlar_core::model::Task) + Send + 'static) {
self.bridge.send(Command::Edit { id: self.id(), edit: Box::new(edit) });
}
fn button(&mut self, ui: &mut Ui, icon: &str, words: &str, enabled: bool) -> bool {
Button::new(words).with_icon(icon).kind(Kind::Tonal).enabled(enabled).show(ui, self.t).clicked()
}
}
/// A tag's colour comes from the theme's roles: its own number picks one.
pub fn tag_colour(t: &Theme, tag: &Tag) -> Color32 {
[t.primary, t.tertiary, t.secondary, t.warning, t.success, t.error][tag.id.unsigned_abs() as usize % 6]
}
/// The lines of a log that hold `filter` (any case), as text for copying: time, then words. No secrets.
pub fn log_lines(log: &Log, filter: &str) -> Vec<String> {
let f = filter.trim().to_lowercase();
log.iter().filter(|l| f.is_empty() || l.text.to_lowercase().contains(&f)).map(|l| format!("{} {}", when(l.at), redact::text(&l.text))).collect()
}
fn small(ui: &mut Ui, t: &Theme, words: &str) {
ui.add(Label::new(RichText::new(words).font(fonts::ui(text::BODY)).color(t.on_variant)).wrap());
}
fn head(ui: &mut Ui, t: &Theme, words: &str) {
ui.add_space(space::M);
ui.label(RichText::new(words).font(fonts::semi(text::BODY)).color(t.on_surface));
ui.add_space(space::XS);
}
/// Rows of name and value; a click copies the value.
fn props(ui: &mut Ui, t: &Theme, id: &str, rows: &[(String, String)]) {
Grid::new(id).num_columns(2).spacing(vec2(space::L, space::XS)).show(ui, |ui| {
for (name, value) in rows {
ui.label(RichText::new(name).font(fonts::ui(text::LABEL)).color(t.on_variant));
let r = ui.add(Label::new(RichText::new(value).font(fonts::ui(text::BODY)).color(t.on_surface)).wrap().sense(Sense::click()));
if r.clicked() {
ui.ctx().copy_text(value.clone());
}
r.on_hover_text(tr!("details.copy"));
ui.end_row();
}
});
}
fn when_or(time: Option<Time>) -> String {
time.map(when).unwrap_or_else(|| tr!("details.p.unknown"))
}
/// What to say of the time to the next try.
fn next_try(v: &TaskView) -> String {
let Some(kind) = v.task.error.as_ref().and_then(|e| e.kind) else { return tr!("details.next.never") };
if let Some(at) = v.retry_at {
let left = (at - now()).max(0) / 1000;
return if left == 0 { tr!("details.next.soon") } else { tr!("details.next.at", span = span(left as u64)) };
}
match kind.retry() {
Retry::Network => tr!("details.next.network"),
Retry::Disk => tr!("details.next.disk"),
Retry::Wake => tr!("details.next.wake"),
Retry::Later { .. } | Retry::Never => tr!("details.next.never"),
}
}
pub fn overview(ui: &mut Ui, cx: &mut Cx, note: &mut (TaskId, String)) {
let (t, v) = (cx.t, cx.v);
let state = if cx.missing { Status::Failed.label() } else { state_label(v.state()) };
let share = v.progress().map(|p| format!(" ({:.0}%)", p * 100.0)).unwrap_or_default();
ui.label(RichText::new(format!("{state}{share}")).font(fonts::med(text::BODY)).color(t.primary));
if cx.missing || v.state() == State::Gone {
gone(ui, cx);
}
if v.task.error.is_some() && matches!(v.state(), State::Failed | State::Waiting) {
error(ui, cx);
}
// File actions.
ui.add_space(space::M);
let done = v.state() == State::Done && !cx.missing;
ui.horizontal_wrapped(|ui| {
if cx.button(ui, "open_in_new", &tr!("act.open"), done) {
cx.act(Act::Open);
}
if cx.button(ui, "folder_open", &tr!("act.show"), true) {
cx.act(Act::Show);
}
if cx.button(ui, "content_copy", &tr!("act.copy"), true) {
cx.act(Act::Copy);
}
if cx.button(ui, "edit", &tr!("act.rename"), true) {
cx.act(Act::EditName);
}
if cx.button(ui, "folder", &tr!("act.move"), true) {
cx.act(Act::EditFolder);
}
if cx.button(ui, "replay", &tr!("act.redownload"), true) {
cx.act(Act::Redownload);
}
if cx.button(ui, "delete", &tr!("act.delete"), true) {
cx.act(Act::Remove(Files::Bin));
}
});
head(ui, t, &tr!("details.tab.overview"));
let t_ = &v.task;
let unknown = tr!("details.p.unknown");
let mut rows = vec![
(tr!("details.p.name"), t_.name.clone()),
(tr!("details.p.folder"), t_.folder.to_string_lossy().into_owned()),
(tr!("details.p.link"), redact::url(&t_.url).into_owned()),
(tr!("details.p.size"), v.size.map(amount).unwrap_or_else(|| unknown.clone())),
(tr!("details.p.done"), amount(v.downloaded)),
(tr!("details.p.speed"), rate(v.speed)),
(tr!("details.p.server"), host_name(&v.server)),
(tr!("details.p.connections"), format!("{} / {}", v.connections, v.wanted)),
(tr!("details.p.resume"), v.resumable.map(|r| if r { tr!("details.p.yes") } else { tr!("details.p.no") }).unwrap_or(unknown)),
(tr!("details.p.queue"), super::super::list::model::queue_name(cx.lists, t_.queue)),
(tr!("details.p.added"), when(t_.added_at)),
];
if let Some(mime) = &t_.mime {
rows.push((tr!("details.p.type"), mime.clone()));
}
if let Some(page) = &t_.source_page {
rows.push((tr!("details.p.page"), redact::url(page).into_owned()));
}
if t_.finished_at.is_some() {
rows.push((tr!("details.p.finished"), when_or(t_.finished_at)));
}
props(ui, t, "props", &rows);
live_edits(ui, cx);
tags_and_notes(ui, cx, note);
}
fn gone(ui: &mut Ui, cx: &mut Cx) {
let t = cx.t;
ui.add_space(space::S);
eframe::egui::Frame::new().fill(t.error_container).corner_radius(radius::M).inner_margin(space::M).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.label(RichText::new(tr!("details.gone")).font(fonts::semi(text::BODY)).color(t.on_error_container));
ui.add(Label::new(RichText::new(tr!("details.gone_body")).font(fonts::ui(text::BODY)).color(t.on_error_container)).wrap());
ui.horizontal(|ui| {
if cx.button(ui, "replay", &tr!("act.redownload"), true) {
cx.act(Act::Redownload);
}
if cx.button(ui, "close", &tr!("act.remove"), true) {
cx.act(Act::Remove(Files::Keep));
}
});
});
}
/// What, why, when it was tried, when it is next, and every way out.
fn error(ui: &mut Ui, cx: &mut Cx) {
let (t, v) = (cx.t, cx.v);
let Some(err) = v.task.error.clone() else { return };
ui.add_space(space::S);
eframe::egui::Frame::new().fill(t.error_container).corner_radius(radius::M).inner_margin(space::M).show(ui, |ui| {
ui.set_width(ui.available_width());
let what = err.kind.map(|k| k.title()).unwrap_or_else(|| tr!("details.error.unknown"));
let last = v.log.back().map(|l| when(l.at)).unwrap_or_else(|| tr!("details.error.none_yet"));
let rows = [
(tr!("details.error.what"), what),
(tr!("details.error.why"), redact::text(&err.detail)),
(tr!("details.error.when"), last),
(tr!("details.error.next"), next_try(v)),
];
props(ui, t, "error", &rows);
ui.add_space(space::S);
ui.label(RichText::new(tr!("details.error.fixes")).font(fonts::med(text::LABEL)).color(t.on_error_container));
let first = err.kind.map(|k| k.fix());
let mut fixes: Vec<Fix> = first.into_iter().collect();
for f in [Fix::TryAgain, Fix::EditLink, Fix::ChangeFolder, Fix::Restart] {
if !fixes.contains(&f) {
fixes.push(f);
}
}
ui.horizontal_wrapped(|ui| {
for (i, fix) in fixes.into_iter().enumerate() {
let kind = if i == 0 { Kind::Filled } else { Kind::Tonal };
if Button::new(&fix.label()).kind(kind).show(ui, t).clicked() {
cx.act(act_of_fix(fix));
}
}
for offer in v.offers() {
if Button::new(&offer.label()).kind(Kind::Tonal).show(ui, t).clicked() {
cx.bridge.send(match offer {
Offer::Repair => Command::Resume(v.id()),
Offer::OtherMirror => Command::OtherMirror(v.id()),
Offer::Restart => Command::Redownload(v.id()),
});
}
}
});
});
}
/// Limit, parts, priority, queue, link and login, changed while the download goes on.
fn live_edits(ui: &mut Ui, cx: &mut Cx) {
let (t, v) = (cx.t, cx.v);
head(ui, t, &tr!("details.edit"));
let mut limit = v.task.speed_limit.map_or(0.0, |l| (l / 1024) as f64);
let unit = tr!("unit.kb_s");
let label = tr!("details.limit");
let help = tr!("details.limit_help");
if (Number { label: &label, unit: &unit, range: 0.0..=10_000_000.0, step: 100.0, enabled: true, width: 220.0, bare: false }).show(ui, t, &mut limit) {
let bytes = (limit.max(0.0) as u64) * 1024;
cx.edit(move |t| t.speed_limit = (bytes > 0).then_some(bytes));
}
small(ui, t, &help);
let mut parts = f64::from(v.task.max_parts.unwrap_or(v.wanted.max(1)));
let label = tr!("details.parts");
if (Number { label: &label, unit: "", range: 1.0..=32.0, step: 1.0, enabled: true, width: 160.0, bare: false }).show(ui, t, &mut parts) {
let n = parts.round().clamp(1.0, 32.0) as u32;
cx.edit(move |t| t.max_parts = Some(n));
}
let names: Vec<String> = Priority::ALL.iter().map(|p| medlar_core::strings::text(&format!("priority.{}", p.name()), &[])).collect();
let mut at = Priority::ALL.iter().position(|p| *p == v.task.priority).unwrap_or(0);
let label = tr!("details.priority");
if Combo::new(&label, &names, 220.0).show(ui, t, &mut at) {
let p = Priority::ALL[at];
cx.edit(move |t| t.priority = p);
}
if cx.lists.queues.len() > 1 {
let names: Vec<String> = cx.lists.queues.iter().map(|q| queue_name(cx.lists, q.id)).collect();
let mut at = cx.lists.queues.iter().position(|q| q.id == v.task.queue).unwrap_or(0);
let label = tr!("details.queue");
if Combo::new(&label, &names, 220.0).show(ui, t, &mut at) {
let q = cx.lists.queues[at].id;
cx.edit(move |t| t.queue = q);
}
}
ui.add_space(space::S);
ui.horizontal_wrapped(|ui| {
if cx.button(ui, "link", &tr!("fix.edit_link"), !matches!(v.state(), State::Done | State::Gone)) {
cx.act(Act::EditLink);
}
if cx.button(ui, "key", &tr!("details.login"), true) {
cx.act(Act::SignIn);
}
});
}
fn tags_and_notes(ui: &mut Ui, cx: &mut Cx, note: &mut (TaskId, String)) {
let (t, v) = (cx.t, cx.v);
head(ui, t, &tr!("details.tags"));
if cx.lists.tags.is_empty() {
small(ui, t, &tr!("details.no_tags"));
}
ui.horizontal_wrapped(|ui| {
for tag in &cx.lists.tags {
let on = v.task.tags.contains(&tag.id);
let (dot, _) = ui.allocate_exact_size(vec2(icon::S / 2.0, icon::S), Sense::hover());
ui.painter().circle_filled(dot.center(), icon::S / 4.0, tag_colour(t, tag));
if Chip::new(&tag.name).filter(on).show(ui, t).response.clicked() {
cx.act(Act::Tag(tag.id, !on));
}
}
});
head(ui, t, &tr!("details.notes"));
let r = Field::new(&tr!("details.notes")).rows(4).show(ui, t, &mut note.1);
if r.lost_focus() && note.1 != v.task.notes {
let words = note.1.clone();
cx.edit(move |t| t.notes = words);
} else if !r.has_focus() && note.1 != v.task.notes {
note.1 = v.task.notes.clone();
}
}
pub fn parts(ui: &mut Ui, cx: &mut Cx) {
let (t, v) = (cx.t, cx.v);
let size = v.size.unwrap_or(0);
if v.parts.is_empty() || size == 0 {
small(ui, t, &tr!("details.parts.empty"));
return;
}
let blocks: Vec<Block> = v
.parts
.iter()
.map(|p| Block { part: medlar_core::model::Part { start: p.start, end: p.end, done: p.done }, speed: p.speed, server: Some(&v.server), failed: p.fails > 0 })
.collect();
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), size::LARGE * 1.5), Sense::hover());
parts::map(ui, t, Id::unique(("parts", v.id())), rect, size, &blocks);
ui.add_space(space::S);
small(ui, t, &tr!("details.parts.count", n = v.connections, wanted = v.wanted));
}
pub fn speed(ui: &mut Ui, cx: &mut Cx, history: &graph::History) {
let (t, v) = (cx.t, cx.v);
if v.history.pushed() == 0 {
small(ui, t, &tr!("details.graph.empty"));
return;
}
ui.label(RichText::new(rate(v.speed)).font(fonts::semi(text::TITLE)).color(t.on_surface));
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), size::LARGE * 2.5), Sense::hover());
graph::graph(ui, t, Id::unique(("graph", v.id())), rect, history, v.task.speed_limit.map(|l| l as f64));
}
pub fn log(ui: &mut Ui, cx: &mut Cx, filter: &mut String) {
let (t, v) = (cx.t, cx.v);
let label = tr!("details.log.filter");
ui.horizontal(|ui| {
Field::new(&label).width((ui.available_width() - size::CONTROL - space::S).max(80.0)).show(ui, t, filter);
if Button::icon("content_copy", &tr!("details.log.copy")).show(ui, t).clicked() {
ui.ctx().copy_text(log_lines(&v.log, filter).join("\n"));
}
});
let lines = log_lines(&v.log, filter);
if lines.is_empty() {
small(ui, t, &tr!("details.log.empty"));
}
ScrollArea::vertical().id_salt("log").max_height(300.0).stick_to_bottom(true).show(ui, |ui| {
for l in &lines {
ui.add(Label::new(RichText::new(l).text_style(TextStyle::Monospace).color(t.on_variant)).wrap());
}
});
}
pub fn headers(ui: &mut Ui, cx: &mut Cx) {
let (t, v) = (cx.t, cx.v);
if v.task.headers.is_empty() {
small(ui, t, &tr!("details.headers.none"));
}
let rows: Vec<(String, String)> = v
.task
.headers
.iter()
.map(|(n, val)| (n.clone(), if redact::is_secret_header(n) { tr!("details.headers.hidden") } else { redact::text(val) }))
.collect();
props(ui, t, "headers", &rows);
if v.task.secret.is_some() {
ui.add_space(space::S);
small(ui, t, &tr!("details.headers.login"));
}
}
pub fn mirrors(ui: &mut Ui, cx: &mut Cx) {
let (t, v) = (cx.t, cx.v);
let mut rows = vec![(tr!("details.mirrors.first"), redact::url(&v.task.url).into_owned())];
rows.extend(v.task.mirrors.iter().enumerate().map(|(i, m)| ((i + 1).to_string(), redact::url(m).into_owned())));
props(ui, t, "mirrors", &rows);
if v.task.mirrors.is_empty() {
ui.add_space(space::S);
small(ui, t, &tr!("details.mirrors.none"));
}
ui.add_space(space::S);
if cx.button(ui, "link", &tr!("fix.edit_link"), !matches!(v.state(), State::Done | State::Gone)) {
cx.act(Act::EditLink);
}
}
pub fn checksum(ui: &mut Ui, cx: &mut Cx, paste: &mut String) {
let (t, v) = (cx.t, cx.v);
let state = v.verify();
let mut words = state.label();
if state == verify::State::Checking {
words = format!("{words}: {}", tr!("details.sum.progress", n = (v.checked * 100.0).round()));
}
ui.label(RichText::new(words).font(fonts::med(text::BODY)).color(if state == verify::State::Bad { t.error } else { t.on_surface }));
if let Some(sum) = &v.task.checksum {
props(ui, t, "sum", &[(tr!("details.sum.saved"), sum.clone())]);
}
let label = tr!("details.sum.paste");
let parsed = paste.trim().parse::<Checksum>();
let bad = !paste.trim().is_empty() && parsed.is_err();
let help = tr!("details.sum.bad");
Field::new(&label).error(bad.then_some(help.as_str())).show(ui, t, paste);
ui.horizontal_wrapped(|ui| {
if let Ok(sum) = parsed {
if cx.button(ui, "check", &tr!("details.sum.set"), true) {
let text = sum.to_string();
cx.edit(move |t| t.checksum = Some(text));
if v.state() == State::Done {
cx.bridge.send(Command::Verify(v.id()));
}
paste.clear();
}
}
let can = v.state() == State::Done && (v.task.checksum.is_some() || v.task.pieces.is_some());
if cx.button(ui, "refresh", &tr!("details.sum.check"), can) {
cx.bridge.send(Command::Verify(v.id()));
}
});
for offer in v.offers() {
if Button::new(&offer.label()).kind(Kind::Tonal).show(ui, t).clicked() {
cx.bridge.send(match offer {
Offer::Repair => Command::Resume(v.id()),
Offer::OtherMirror => Command::OtherMirror(v.id()),
Offer::Restart => Command::Redownload(v.id()),
});
}
}
let _ = title(v);
}

View file

@ -36,6 +36,8 @@ use std::sync::Arc;
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Act {
Open,
/// Opens the details panel.
Details,
Show,
Copy,
OpenPage,
@ -536,6 +538,7 @@ impl List {
let ended = |s: State| matches!(s, State::Done | State::Gone);
let mut items = vec![
Item::new(tr!("act.open"), Act::Open).icon("open_in_new").keys(keys::label(Action::OpenOrRun)).enabled(one && first.state() == State::Done),
Item::new(tr!("act.details"), Act::Details).icon("info").keys(keys::label(Action::Details)).enabled(one),
Item::new(tr!("act.show"), Act::Show).icon("folder_open").keys(keys::label(Action::Show)).enabled(one),
Item::new(tr!("act.copy"), Act::Copy).icon("content_copy").keys(keys::label(Action::Copy)),
];
@ -642,6 +645,7 @@ impl List {
let any = self.listing.rows.iter().any(|v| self.selected.contains(&v.id()) && going(v.state()));
if any { Act::Pause } else { Act::Resume }
}
Action::Details if one => Act::Details,
Action::Show if one => Act::Show,
Action::Copy => Act::Copy,
Action::Page if one && first.task.source_page.is_some() => Act::OpenPage,

View file

@ -4,6 +4,7 @@ use super::list::model::{Filter, Group, Sort, Status, title};
use super::list::row::Column;
use super::list::{self, Act, List, Order, layout::Form};
use super::add::{self, Adding, Folders, Request};
use super::details::Details;
use super::{bar, rail};
use crate::bridge::{Bridge, Data, Lists};
use crate::keys::{Action, Group as Where};
@ -94,6 +95,9 @@ pub struct Main {
folders: Folders,
ask: Option<Ask>,
pub adding: Adding,
pub details: Details,
/// Shows a file in its folder in the file manager; false when it can't, so the folder is opened.
pub reveal: fn(&Path) -> bool,
focus_search: bool,
/// Orders from elsewhere, done in the next frame.
asked: Vec<Order>,
@ -115,6 +119,8 @@ impl Default for Main {
folders: Folders::default(),
ask: None,
adding: Adding::default(),
details: Details::default(),
reveal: |_| false,
focus_search: false,
asked: vec![],
wish: None,
@ -137,6 +143,20 @@ pub fn open_outside(what: &str) {
});
}
/// Shows the file in the file manager, from another thread; if that fails, its folder opens.
pub fn reveal_outside(file: &Path) -> bool {
let file = file.to_path_buf();
std::thread::spawn(move || {
if let Err(e) = medlar_core::files::reveal(&file) {
log::warn!("file manager: {e}");
if let Some(folder) = file.parent() {
open_outside(&folder.to_string_lossy());
}
}
});
true
}
/// The narrowest window with an open rail, unless the user wants it.
const RAIL_OPENS: f32 = 960.0;
/// Narrower than this, the rail is never open: the list would have no room.
@ -273,6 +293,7 @@ impl Main {
let pad = if window.width() < RAIL_FITS { space::M } else { space::XL };
let mut body = rest.shrink2(vec2(pad, space::L));
body.max.y = window.bottom();
let (body, panel) = self.details.split(body, shot);
if shot.is_empty() {
let add = tr!("add.button");
if self.state(ui, t, rest, Face::App, &tr!("empty.title"), &tr!("empty.body"), Some(("add", &add))) {
@ -315,6 +336,9 @@ impl Main {
} else {
self.list_in(ui, t, rest, lists, &mut orders);
}
if let Some(panel) = panel {
orders.extend(self.details.show(ui, t, panel, shot, lists, &self.bridge));
}
for order in orders {
self.order(ui, shot, order);
}
@ -487,8 +511,12 @@ impl Main {
(self.outside)(&path.to_string_lossy());
}
}
Act::Details => self.details.open = Some(first.id()),
Act::Show => {
if first.task.folder.is_absolute() {
let file = first.task.folder.join(&first.task.name);
if first.state() == State::Done && file.is_absolute() && (self.reveal)(&file) {
// Done.
} else if first.task.folder.is_absolute() {
(self.outside)(&first.task.folder.to_string_lossy());
}
}

View file

@ -2,6 +2,7 @@
pub mod add;
pub mod bar;
pub mod details;
pub mod firstrun;
pub mod list;
pub mod main;

View file

@ -634,5 +634,76 @@
"first.next": "Next",
"first.back": "Back",
"first.skip": "Skip",
"first.done": "Start"
"first.done": "Start",
"action.details": "Details",
"act.details": "Details",
"details.close": "Close details",
"details.copy": "Click to copy",
"details.copied": "Copied",
"details.tab.overview": "Overview",
"details.tab.parts": "Parts",
"details.tab.graph": "Speed",
"details.tab.log": "Log",
"details.tab.headers": "Headers",
"details.tab.mirrors": "Mirrors",
"details.tab.checksum": "Checksum",
"details.gone": "The file is gone",
"details.gone_body": "It was moved or deleted outside Medlar. Download it again, or remove it from the list.",
"details.error.what": "What failed",
"details.error.why": "Why",
"details.error.when": "Last tried",
"details.error.next": "Next try",
"details.error.fixes": "What you can do",
"details.error.none_yet": "Not tried in this session",
"details.error.unknown": "An error this version does not know",
"details.next.at": "in {span}",
"details.next.never": "Not by itself",
"details.next.network": "When the network is back",
"details.next.disk": "When the folder can be written to",
"details.next.wake": "When the computer is awake",
"details.next.soon": "Any moment",
"details.p.name": "Name",
"details.p.folder": "Folder",
"details.p.link": "Link",
"details.p.size": "Size",
"details.p.done": "Downloaded",
"details.p.state": "State",
"details.p.speed": "Speed",
"details.p.added": "Added",
"details.p.finished": "Finished",
"details.p.type": "Type",
"details.p.server": "Server",
"details.p.connections": "Connections",
"details.p.resume": "Can resume",
"details.p.page": "Source page",
"details.p.unknown": "Unknown",
"details.p.yes": "Yes",
"details.p.no": "No",
"details.edit": "Settings",
"details.limit": "Speed limit",
"details.limit_help": "0 for no limit",
"details.parts": "Parts",
"details.priority": "Priority",
"details.queue": "Queue",
"details.login": "Sign in",
"details.tags": "Tags",
"details.no_tags": "No tags yet. Make them in the sidebar.",
"details.notes": "Notes",
"details.log.filter": "Filter the log",
"details.log.copy": "Copy log",
"details.log.empty": "Nothing logged in this session.",
"details.parts.empty": "No parts yet. They show while the file is downloading.",
"details.parts.count": "{n} of {wanted} connections",
"details.graph.empty": "No speed to show.",
"details.headers.none": "No extra headers.",
"details.headers.hidden": "hidden",
"details.headers.login": "A login is kept in the keyring.",
"details.mirrors.first": "Main link",
"details.mirrors.none": "No mirrors. Add some by editing the link.",
"details.sum.saved": "Checksum",
"details.sum.paste": "Paste a checksum",
"details.sum.bad": "This is not a checksum Medlar knows.",
"details.sum.set": "Use and check",
"details.sum.check": "Check now",
"details.sum.progress": "Checked {n}%"
}

13
crates/core/src/files.rs Normal file
View file

@ -0,0 +1,13 @@
//! Showing a file in the desktop's file manager.
use std::path::Path;
/// Asks the file manager (`org.freedesktop.FileManager1`) to show the file selected in its folder. Blocks, so not on the
/// window's thread. An error when there is no such manager: open the folder instead.
pub fn reveal(file: &Path) -> zbus::Result<()> {
let uri = url::Url::from_file_path(file).map_err(|()| zbus::Error::Unsupported)?;
let bus = zbus::blocking::Connection::session()?;
let manager = zbus::blocking::Proxy::new(&bus, "org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1")?;
manager.call_method("ShowItems", &(vec![uri.as_str()], ""))?;
Ok(())
}

View file

@ -8,6 +8,7 @@ pub mod cookie;
pub mod disk;
pub mod duplicate;
pub mod error;
pub mod files;
pub mod events;
mod ftp;
pub mod host;

View file

@ -180,6 +180,11 @@ Verified: `nice cargo test -j 2 -p medlar-core --test stream` green (15; ffprobe
Not done: subtitles; rtsps (its certificate can't be checked); HLS low-latency parts; `Command::Continue` with a new link for a stream (edit the link instead); a pause drops pieces under way (up to 4); no UI for choice and Finish. RTSP and MMS were tried against stubs only (PCMU over TCP, ASF over HTTP), HLS and DASH against ffmpeg's own; no real server.
Seen: tested in a second checkout on the shared target; S009 saw stale artifacts from it. Use a target of its own for that. Boxes were ticked together at the end, against rule 3.
## S017 — Details panel and file actions (2026-11-25)
Done: `views::details` (side panel from 900 px, else bottom sheet; tabs Overview, Parts, Speed, Log, Headers, Mirrors, Checksum), `core::files::reveal` (FileManager1), `Act::Details`/`Action::Details` (Alt+Enter), `Main.reveal`. Overview has file actions, error section, live edits, tags, notes, "file is gone".
Slots for later plans (media, archive): `Details.extra: Vec<Extra>` is declared but not drawn yet; add a tab in `Pane` and `tabs.rs`.
Not done: per-server rows (`ServerView` is not in `TaskView`); tag colour is a theme role by id; compiled only, no tests, no shots. Test file `docs/tests/S017-details.md`.
## Later
-

View file

@ -0,0 +1,49 @@
# S017 — Details panel and file actions: test file
Written by the worker that built it, run by the test phase. Nothing here has been tested until its Result says so.
## Built
`crates/app/src/views/details/mod.rs` · panel frame, tabs, side or bottom by width, graph feed, "file is gone" probe. Open: select one download, press Alt+Enter or menu "Details".
`crates/app/src/views/details/tabs.rs` · Overview (file actions, error section, properties, live edits, tags, notes), Parts, Speed, Log, Headers, Mirrors, Checksum; `log_lines`, `tag_colour`.
`crates/core/src/files.rs` · `reveal(path)`: D-Bus FileManager1 ShowItems. `views::main::reveal_outside` runs it in a thread, falls back to opening the folder.
Wiring: `Act::Details`, `Action::Details`, `Main.details`, `Main.reveal`, strings `details.*`.
## Checks
Risk: HIGH = data loss, security, crash, wrong result · MED = feature broken · LOW = looks or comfort.
How: unit · integration · screen · by hand.
| # | Risk | Do this | Expect | How | Result |
|---|---|---|---|---|---|
| 1 | MED | Select one row, press Alt+Enter | Panel opens for it at 1080x720 on the right, list narrower | screen | — |
| 2 | MED | Same at 480x360 | Sheet at the bottom, list above, nothing overlaps | screen | — |
| 3 | MED | Click each of the 7 tabs | Each shows its page without panic; empty ones say so | screen | — |
| 4 | MED | Esc, or the close button | Panel closes; list gets its width back | screen | — |
| 5 | HIGH | Remove the shown download | Panel closes by itself, no panic | integration | — |
| 6 | HIGH | Failed download with a kind (Login, DiskFull, NotFound) | Error box: what, why, last tried, next try, fixes; first fix is filled | screen | — |
| 7 | HIGH | Checksum failure | Checksum tab says "does not match"; repair, other mirror and start over buttons send Resume, OtherMirror, Redownload | integration | — |
| 8 | HIGH | Done download, delete the file on disk, wait 4 s | "The file is gone" box with Download again and Remove | integration | — |
| 9 | MED | Change speed limit to 500 | Task `speed_limit` is 512000; 0 clears it | integration | — |
| 10 | MED | Change parts, priority, queue | Task fields change; running download keeps going | integration | — |
| 11 | MED | Click Rename, Move, Copy link, Redownload, Delete | Same dialogs, messages and commands as the list menu | integration | — |
| 12 | MED | Click Show on a done file | Reveal is called with the file path; without it the folder opens | integration | — |
| 13 | MED | Toggle a tag chip; type a note and leave the field | Tag list and notes of the task change | integration | — |
| 14 | HIGH | Log filter "retry"; copy | Only matching lines copied; secrets in lines come out redacted | unit | — |
| 15 | HIGH | Headers tab with Authorization and Cookie | Value shows "hidden", never the text | unit | — |
| 16 | HIGH | Paste a bad checksum, then a good SHA-256 | Error text first; then "Use and check" sets `checksum` and sends Verify for a done file | integration | — |
| 17 | LOW | Tag colours | Only theme roles; same tag same colour in light and dark | screen | — |
| 18 | MED | Running download, Speed tab | Graph moves, limit line at the limit; Parts tab blocks move | screen | — |
| 19 | MED | Real FileManager1 absent (no session bus) | Folder opens instead, a log line, no crash | by hand | — |
| 20 | MED | Move a file to another drive from the panel | Copied, checked, then source removed (core does it) | integration | — |
## Needs
Throwaway home; `crates/testserver`; fake `reveal` and `outside` functions; no real file manager. Shots of every tab and the error state, light and dark.
## Doubts
- Never compiled-run: only `cargo check`. All layout is unseen; sizes may clip at 480x360.
- Per-server rows (`http::Snapshot.servers`) are not in `TaskView`, so Mirrors shows links, not states or speeds. Needs a field in the snapshot.
- "Last tried" is the newest log line of this session, not a stored time. "Next try" uses `retry_at` or the kind's rule.
- Live edit of the link goes through the existing Edit link dialog; login through the existing sign-in wish. No new dialogs.
- Rename and Move do not show errors in the panel; they use the existing toast path.
- A Done file's absence is polled every 3 s while the panel is open (a repaint each 3 s).
- Tag colour is picked by tag id from six theme roles, not the tag's own hex.
- Alt+Enter may clash with a window manager. Existing tests that list all actions may need the new `details` key.