Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5e2a54b
LR-BEHAV-BG-TASKS: a preview build asked for while another runs can w…
nledford Oct 24, 2026
31f374d
LR-BEHAV-BG-TASKS: a build replaced by the one waiting behind it is s…
nledford Oct 24, 2026
7a5d4f0
Sidebars: several albums, folders, keywords or dates can be shown at …
nledford Oct 11, 2026
eba8273
Sidebars: gaps.md entry for the sidebar multi-selection still to wire…
nledford Oct 22, 2026
5739ecd
Sidebars: album.setRules says [] (not null) clears the list fields
nledford Oct 22, 2026
1eb39f7
Sidebars: library.filter refuses a single album beside an album source
nledford Oct 22, 2026
fe5ed2b
Sidebars: a view of albums that are all gone shows All Photos, not an…
nledford Oct 22, 2026
2d41475
Sidebars: an album filter put aside does not come back beside an albu…
nledford Oct 24, 2026
e6eff73
Sidebars: deleting every keyword of the filter Enable Filters put asi…
nledford Oct 24, 2026
bfb014b
Sidebars: keyword, album and folder chips join their values with the …
nledford Oct 25, 2026
cf9a2df
Sidebars: a view of several albums with a smart one among them grays …
nledford Oct 25, 2026
08d66c0
Sidebars: a folder filter put aside by Enable Filters follows its fol…
nledford Oct 25, 2026
14608fa
LR-LIB-FOLDER: a refused command says why
nledford Oct 21, 2026
03f599d
LR-LIB-FOLDER: a refusal keeps the toast the command made
nledford Oct 22, 2026
d4f1109
LR-LIB-FOLDER: refusal toasts join once, and a host dialog's command …
nledford Oct 22, 2026
acfb121
LR-LIB-FOLDER: Auto straighten's refusal is told like every other com…
nledford Oct 23, 2026
d35af75
LR-LIB-FOLDER: a refused command says why: the histogram and parametr…
nledford Oct 24, 2026
b3a5ec8
LR-LIB-FOLDER: a key that follows one that opened a dialog in the sam…
nledford Oct 25, 2026
92b251b
LR-LIB-FOLDER: the point color and red eye drags go through act, so a…
nledford Oct 25, 2026
b326b21
LR-LIB-FOLDER: the refusals check moves to its own change, after this…
nledford Oct 25, 2026
b7ae06f
LR-BEHAV-BG-TASKS: the frame that starts a waiting build looks at it …
nledford Oct 26, 2026
5f914d6
LR-BEHAV-BG-TASKS: imports and Synchronize Folder wait for each other…
nledford Oct 15, 2026
6fbcfef
LR-BEHAV-BG-TASKS: a task waiting in line shows in the activity stack…
nledford Oct 24, 2026
d0d7368
LR-BEHAV-BG-TASKS: review fixes: Auto Import waits in line, a waiting…
nledford Oct 24, 2026
91605d7
Merge remote-tracking branch 'fork/library-lane' into wc-sync
nledford Oct 26, 2026
b832fd6
Merge remote-tracking branch 'fork/sidebar-multi-select' into wc-sync
nledford Oct 26, 2026
d30a8fa
Merge remote-tracking branch 'fork/fix/report-refused-commands' into …
nledford Oct 26, 2026
e3c8e6a
Sidebars: several albums, keywords or folders are deleted, moved or l…
nledford Oct 11, 2026
db8191f
Sidebars: Cmd/Ctrl+click and Shift+click choose several albums, folde…
nledford Oct 22, 2026
54a4297
LR-BEHAV-MULTISELECT: Synchronize several folders at once, one after …
nledford Oct 22, 2026
f736ec8
Sidebars: the closed-folder Shift+click test crosses a folder it can …
nledford Oct 22, 2026
0078c75
LR-BEHAV-MULTISELECT: What's New and parity wording for Cut, Copy and…
nledford Oct 26, 2026
9715357
Merge remote-tracking branch 'origin/main' into wc-sync
nledford Oct 26, 2026
1c0977d
LR-BEHAV-MULTISELECT: What's New no longer says the sidebars' Cmd+cli…
nledford Oct 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ of it. Full standard: `../craftrules/standards/never-crash.md`
- **Pure Rust** in the product. No C/C++ dependencies.
- **Layering** (`plan/architecture.md` §3, enforced by `cargo xtask layers`): nothing below L5 depends on egui/eframe/winit/rfd.
- **Everything is a command** (`crates/engine`): id, label, menu path, shortcut, params, enabled(), run(). UI, CLI, control channel and MCP all dispatch by id. Every slider is a `develop` control spec.
- **A refused command says why.** In the interface, run a command for the person (a click, a drop, a slider, a key)
with `app.act(id, params)`: a refusal shows its reason in a toast. It returns `None` then: say a success of your own
only on `Some`, or it writes over the reason. `app.quiet(…)` is for the few calls where a refusal is expected (say
why at the call); `app.run(…)` hands the `Result` back for code that deals with it (and for agents). Never
`let _ = app.run(…)`, nor `let _ = app.session.execute(…)` round it. A dropped `session.execute` that is meant
(not a person's action, or already inside `run`) says so on its line or the one above:
`// refusal expected: <reason>`. Better still, don't offer what would be refused.
- **Long-running work shows in the activity stack** ([`docs/background-tasks.md`](docs/background-tasks.md)): anything
that runs off the UI thread and can take more than a moment holds a `TaskGuard` from `session.activity.start(kind,
label, cancel)` for its whole run. It adopts the cancel flag the job already checks (`Cancel::Flag`), or uses
Expand Down
60 changes: 60 additions & 0 deletions crates/catalog/src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,66 @@ impl Catalog {
Ok(Op::Batch { ops })
}

/// [`Self::delete_keyword_ops`] for several keywords at once: one batch, so one undo step.
pub fn delete_keywords_ops(&self, keywords: &[String]) -> Result<Op> {
let gone: Vec<String> = keywords.iter().map(|k| clean(k)).collect();
if gone.is_empty() || gone.iter().any(String::is_empty) {
return Err(CatalogError::Invalid("empty keyword".into()));
}
let goes = |k: &str| gone.iter().any(|g| is_under(k, g));
let mut ops = self.keyword_ops(|kws| kws.iter().filter(|x| !goes(x)).cloned().collect());
ops.extend(self.list_ops(|list| list.retain(|_, l| !goes(&l.path))));
Ok(Op::Batch { ops })
}

/// Move several keywords (each with the keywords below it) inside `parent`, or to the top
/// level (`None`), as one batch. Each keeps its name. Of a keyword and one below it only the
/// upper one moves (the lower goes with it). Nothing merges here: a name that is taken where
/// they go ([`CatalogError::KeywordExists`]), or two of them with one name, refuses the whole
/// move. Returns the batch and each move as `(from, to)`.
pub fn move_keywords_ops(&self, keywords: &[String], parent: Option<&str>) -> Result<(Op, Vec<(String, String)>)> {
let mut from: Vec<String> = Vec::new();
for k in keywords {
let path = self.keyword_path(k).ok_or_else(|| CatalogError::Invalid(format!("no keyword “{}”", clean(k))))?;
if !from.iter().any(|f| same(f, &path)) {
from.push(path);
}
}
if from.is_empty() {
return Err(CatalogError::Invalid("no keyword to move".into()));
}
// the upper ones only
let all = from.clone();
from.retain(|f| !all.iter().any(|o| !same(o, f) && is_under(f, o)));
let parent = parent.map(clean).filter(|p| !p.is_empty()).map(|p| self.keyword_path(&p).unwrap_or(p));
if let Some(p) = &parent
&& from.iter().any(|f| is_under(p, f))
{
return Err(CatalogError::Invalid("can't move a keyword inside itself".into()));
}
let mut moves: Vec<(String, String)> = Vec::new();
for f in &from {
let leaf = f.rsplit(SEP).next().unwrap_or(f);
let to = parent.as_deref().map_or_else(|| leaf.to_string(), |p| format!("{p}{SEP}{leaf}"));
if moves.iter().any(|(_, t)| same(t, &to)) {
return Err(CatalogError::Invalid(format!("two of them are named “{leaf}”: move them one at a time")));
}
moves.push((f.clone(), to));
}
// one that is there already stays; the others must find their name free
moves.retain(|(f, t)| !same(f, t));
if let Some((_, taken)) = moves.iter().find(|(_, t)| self.has_keyword(t)) {
return Err(CatalogError::KeywordExists(taken.clone()));
}
let moved = |k: &str| moves.iter().find(|(f, _)| is_under(k, f)).map(|(f, t)| reparent(k, f, t));
let mut ops = self.keyword_ops(|kws| kws.iter().map(|k| moved(k).unwrap_or_else(|| k.clone())).collect());
// (the moves touch apart parts of the list: each one's listings are its own)
for (f, t) in &moves {
ops.extend(self.list_move_ops(std::slice::from_ref(f), t));
}
Ok((Op::Batch { ops }, moves))
}

/// Merge several keywords (with their children) into `into`.
pub fn merge_keywords_ops(&self, from: &[String], into: &str) -> Result<Op> {
let into = clean(into);
Expand Down
9 changes: 4 additions & 5 deletions crates/catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,9 @@ impl Catalog {
/// A loop through `filter`'s own album field (not its rules): smart album `owner` filtered to
/// itself, or to an album that leads back to it.
pub fn album_filter_problem(&self, filter: &Filter, owner: Option<AlbumId>) -> Option<rules::Problem> {
let (a, owner) = (filter.album?, owner?);
(a == owner || self.album_reaches(a, owner)).then(|| rules::Problem {
let owner = owner?;
let a = filter.albums_wanted().into_iter().find(|a| *a == owner || self.album_reaches(*a, owner))?;
Some(rules::Problem {
path: Vec::new(),
field: Some("album".into()),
issue: rules::Issue::AlbumLoop,
Expand Down Expand Up @@ -528,9 +529,7 @@ impl Catalog {
if rules.deleted {
return Err(CatalogError::Invalid("smart album rules can't select deleted photos".into()));
}
if let Some(a) = rules.album
&& self.albums.get(&a).is_some_and(Album::is_smart)
{
if rules.albums_wanted().iter().any(|a| self.albums.get(a).is_some_and(Album::is_smart)) {
return Err(CatalogError::Invalid("smart album rules can't reference another smart album".into()));
}
Ok(())
Expand Down
166 changes: 146 additions & 20 deletions crates/catalog/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,29 @@ pub struct Filter {
pub kind: Option<MediaKind>,
pub edited: Option<bool>,
pub album: Option<AlbumId>,
/// More albums beside [`Filter::album`] (several albums chosen in the sidebar): a photo in any
/// of them matches; empty = no more.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub albums: Vec<AlbumId>,
/// Show "Recently Deleted" instead of the library.
pub deleted: bool,
/// Capture date prefix (`2026`, `2026-04`, `2026-04-12`).
pub date: Option<String>,
/// More capture date prefixes beside [`Filter::date`]: a photo of any of them matches.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub dates: Vec<String>,
/// A folder the library's photos were imported from: those photos and the ones imported from
/// the folders inside it (see [`crate::folders`]). Photos only browsed in Local are never part
/// of it, unlike [`Filter::folder`].
pub library_folder: Option<String>,
/// More folders beside [`Filter::library_folder`]: a photo of any of them matches.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub library_folders: Vec<String>,
/// A keyword; hierarchical keywords match their children too (`travel` finds `travel|italy`).
pub keyword: Option<String>,
/// More keywords beside [`Filter::keyword`]: a photo with any of them matches.
#[serde(skip_serializing_if = "Vec::is_empty")]
pub keywords: Vec<String>,
/// A person: photos with a named face region of this name (case-insensitive), as read from XMP.
pub person: Option<String>,
pub camera: Option<String>,
Expand Down Expand Up @@ -141,7 +154,8 @@ fn shuffle_rank(seed: u64, id: PhotoId) -> u64 {

/// What [`Filter::prepare`] works out once for a pass over many photos.
pub(crate) struct Prepared {
root: Option<String>,
/// The library folders' identities ([`Filter::library_roots`]): a photo in any of them.
roots: Vec<String>,
only: Option<std::collections::HashSet<PhotoId>>,
}

Expand Down Expand Up @@ -286,13 +300,16 @@ impl Filter {
if let Some(e) = self.edited {
v.push(if e { "edited".into() } else { "unedited".into() });
}
let (keywords, dates, folders) = (self.keywords_wanted().join(" or "), self.dates_wanted().join(" or "), self.library_folders_wanted());
let folders = folders.join(" or ");
let some = |s: String| (!s.is_empty()).then_some(s);
for (name, val) in [
("keyword", &self.keyword),
("keyword", &some(keywords)),
("person", &self.person),
("camera", &self.camera),
("lens", &self.lens),
("date", &self.date),
("folder", &self.library_folder),
("date", &some(dates)),
("folder", &some(folders)),
("imported", &self.imported),
] {
if let Some(x) = val {
Expand All @@ -316,7 +333,7 @@ impl Filter {

/// The albums this filter tests: its album field and its rules' Album rules.
pub fn albums_tested(&self) -> Vec<crate::AlbumId> {
let mut out: Vec<crate::AlbumId> = self.album.into_iter().collect();
let mut out: Vec<crate::AlbumId> = self.albums_wanted();
out.extend(self.rule_set.as_ref().map(crate::RuleSet::albums_tested).unwrap_or_default());
out
}
Expand All @@ -332,20 +349,79 @@ impl Filter {

/// [`Filter::prepare`] for testing one photo (the `only` ids are looked through, not hashed).
pub(crate) fn prepare_one(&self) -> Prepared {
Prepared { root: self.library_root(), only: None }
Prepared { roots: self.library_roots(), only: None }
}

/// What [`Filter::matches_in`] needs worked out once for a pass over many photos rather than
/// once per photo: the library folder's identity and the `only` ids as a set.
pub(crate) fn prepare(&self) -> Prepared {
Prepared { root: self.library_root(), only: (!self.only.is_empty()).then(|| self.only.iter().copied().collect()) }
Prepared { roots: self.library_roots(), only: (!self.only.is_empty()).then(|| self.only.iter().copied().collect()) }
}

/// The albums a photo may be in: [`Filter::album`] and [`Filter::albums`], each once (in that
/// order); empty = no constraint.
pub fn albums_wanted(&self) -> Vec<AlbumId> {
let mut out: Vec<AlbumId> = Vec::new();
for a in self.album.iter().chain(&self.albums) {
if !out.contains(a) {
out.push(*a);
}
}
out
}

/// [`Filter::library_folder`] as a folder identity ([`folder_key`]); `None` without a choice.
fn library_root(&self) -> Option<String> {
/// The keywords a photo may have: [`Filter::keyword`] and [`Filter::keywords`], each once
/// (whatever its case).
pub fn keywords_wanted(&self) -> Vec<String> {
let mut out: Vec<String> = Vec::new();
for k in self.keyword.iter().chain(&self.keywords) {
if !out.iter().any(|o| crate::keywords::same(o, k)) {
out.push(k.clone());
}
}
out
}

/// The capture date prefixes a photo may have: [`Filter::date`] and [`Filter::dates`], each once.
pub fn dates_wanted(&self) -> Vec<String> {
let mut out: Vec<String> = Vec::new();
for d in self.date.iter().chain(&self.dates) {
if !out.contains(d) {
out.push(d.clone());
}
}
out
}

/// The folders a photo may be in: [`Filter::library_folder`] and [`Filter::library_folders`],
/// as given, each once (by folder identity). A blank one is no folder.
pub fn library_folders_wanted(&self) -> Vec<String> {
let mut out: Vec<String> = Vec::new();
let mut keys: Vec<String> = Vec::new();
// as given: a folder may be named with spaces at its edge, and trimming would make it
// another folder
self.library_folder.as_deref().filter(|d| !d.trim().is_empty()).map(folder_key)
for d in self.library_folder.iter().chain(&self.library_folders).filter(|d| !d.trim().is_empty()) {
let key = folder_key(d);
if !keys.contains(&key) {
keys.push(key);
out.push(d.clone());
}
}
out
}

/// The folders wanted ([`Filter::library_folders_wanted`]) as folder identities
/// ([`folder_key`]); empty without a choice.
fn library_roots(&self) -> Vec<String> {
// (each folder's identity is worked out once: this runs per photo for a smart album)
let mut roots: Vec<String> = Vec::new();
for d in self.library_folder.iter().chain(&self.library_folders).filter(|d| !d.trim().is_empty()) {
let key = folder_key(d);
if !roots.contains(&key) {
roots.push(key);
}
}
roots
}

/// [`Filter::matches`] with what [`Filter::prepare`] works out done already, so a query over a
Expand Down Expand Up @@ -401,9 +477,7 @@ impl Filter {
_ => return false,
}
}
if let Some(a) = self.album
&& !cat.album_contains(a, p)
{
if (self.album.is_some() || !self.albums.is_empty()) && !self.album.iter().chain(&self.albums).any(|a| cat.album_contains(*a, p)) {
return false;
}
if let Some(from) = &self.date_from
Expand All @@ -427,14 +501,12 @@ impl Filter {
{
return false;
}
if let Some(d) = &self.date
&& !p.captured.as_deref().is_some_and(|c| c.starts_with(d.as_str()))
if (self.date.is_some() || !self.dates.is_empty())
&& !p.captured.as_deref().is_some_and(|c| self.date.iter().chain(&self.dates).any(|d| c.starts_with(d.as_str())))
{
return false;
}
if let Some(root) = prepared.root.as_deref()
&& !photo_in_root(p, root)
{
if !prepared.roots.is_empty() && !prepared.roots.iter().any(|root| photo_in_root(p, root)) {
return false;
}
if let Some(d) = &self.imported
Expand All @@ -447,8 +519,8 @@ impl Filter {
{
return false;
}
if let Some(k) = &self.keyword
&& !p.meta.keywords.iter().any(|x| crate::keywords::is_under(x, k))
if (self.keyword.is_some() || !self.keywords.is_empty())
&& !p.meta.keywords.iter().any(|x| self.keyword.iter().chain(&self.keywords).any(|k| crate::keywords::is_under(x, k)))
{
return false;
}
Expand Down Expand Up @@ -702,6 +774,60 @@ pub fn folder_rest(path: &str, root: &str) -> Option<Vec<String>> {
Some(split_path(path, false).parts.into_iter().skip(depth).collect())
}

impl Catalog {
/// For each of `folders`, whether the library holds a photo imported from it or from a folder
/// inside it (one pass over the library, however many folders).
pub fn folders_holding(&self, folders: &[String]) -> Vec<bool> {
let roots: Vec<String> = folders.iter().map(|d| folder_key(d)).collect();
let mut holds = vec![false; roots.len()];
let mut left = roots.len();
for p in self.photos().filter(|p| !p.deleted) {
for (h, root) in holds.iter_mut().zip(&roots) {
if !*h && photo_in_root(p, root) {
*h = true;
left -= 1;
}
}
if left == 0 {
break;
}
}
holds
}

/// For each of `folders`: whether the library holds a photo imported from it (or from a
/// folder inside it), and whether some of those photos are on a disk (not the startup disk)
/// the folder does not lie in, which makes it a way to several disks (`/Volumes`, `/mnt`…)
/// and not a folder of one. One pass over the library, however many folders.
pub fn folders_scan(&self, folders: &[String]) -> Vec<FolderScan> {
let roots: Vec<String> = folders.iter().map(|d| folder_key(d)).collect();
let mut out = vec![FolderScan::default(); roots.len()];
for p in self.photos().filter(|p| !p.deleted) {
let mut volume: Option<Option<String>> = None;
for (scan, root) in out.iter_mut().zip(&roots) {
if (scan.holds && scan.other_disks) || !photo_in_root(p, root) {
continue;
}
scan.holds = true;
let v = volume.get_or_insert_with(|| crate::folders::volume_of(p));
if v.as_deref().is_some_and(|v| v != "/" && !key_within(root, v)) {
scan.other_disks = true;
}
}
}
out
}
}

/// What [`Catalog::folders_scan`] finds for one folder.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct FolderScan {
/// The library holds a photo imported from it or from a folder inside it.
pub holds: bool,
/// Some of its photos are on another disk than the one the folder lies in.
pub other_disks: bool,
}

/// Whether a library photo (not one only browsed in Local) lies in the folder whose
/// [`folder_key`] is `root`. A plain POSIX path (no `\`, `.`, `..`, repeated or trailing
/// separators) is its own identity, so it is read without building a key for it: the check runs
Expand Down
16 changes: 16 additions & 0 deletions crates/catalog/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,22 @@ impl RuleSet {
out
}

/// Give every Album rule, groups included, the album `to` makes of the one it names (a copy
/// of a set of albums tests the copies). A rule whose album isn't a valid id is left alone.
pub fn remap_albums(&mut self, to: &impl Fn(crate::AlbumId) -> crate::AlbumId) {
for rule in &mut self.rules {
match rule {
Rule::Group { group } => group.remap_albums(to),
Rule::Field { field, value, .. } if field == "album" => {
if let Some(id) = album_rule_id(value) {
*value = Value::from(to(id).0);
}
}
Rule::Field { .. } => {}
}
}
}

fn check_into(&self, cat: &Catalog, owner: Option<crate::AlbumId>, path: &mut Vec<usize>, out: &mut Vec<Problem>) {
for (i, rule) in self.rules.iter().enumerate() {
path.push(i);
Expand Down
Loading
Loading