Skip to content

Issue #345: activity stack — one progress indicator for long-running tasks - #601

Merged
echelon merged 20 commits into
storytold:mainfrom
cajax:issue-345-activity
Oct 10, 2026
Merged

echelon merged 20 commits into
storytold:mainfrom
cajax:issue-345-activity

Conversation

@cajax

@cajax cajax commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Implements #345 (one progress indicator for every long-running task), without pause. Every long-running job is on the stack, the docs are updated, and a whole-branch review pass is done.

Jobs on the activity stack

Job Row ✕ cancels
✅ Export (side by side in lanes, #504) "Exporting" · 3 of 24 · file name yes
✅ Contact sheet PDF (#563) "Exporting contact sheet" · photos placed of total yes
✅ Import (incl. Auto Import, reading a folder for Local) "Importing" · count · file name yes
✅ Folder scan before import "Scanning folder" · sweep, then count yes
✅ Synchronize Folder (#604): the scan in its dialog, then the run "Looking for changes" / "Synchronizing folder" · count · folder yes (a stopped scan closes the dialog; a stopped run keeps what it did, as one undo step)
✅ Build Previews / Build Smart Previews / Discard Smart Previews count of photos yes
✅ Lightroom catalog inspect / import "Reading / Importing Lightroom catalog" · count · phase while reading; not once photos are being added
✅ Photo Merge (final HDR / panorama merge) "Merging" · % · stage yes ("HDR merge cancelled")
✅ Model downloads: SAM 3, face models, AI Denoise models "Downloading model" · MB of MB · model name yes
✅ Face scan "Finding faces" · photos done of the most left no (switched off in Settings)
✅ AI Denoise "AI Denoise" · % of the photo's tiles · file name no
✅ Find Missing Photos sweep (total unknown) no (the auto-import folder listing stays quiet)
  • docs/parity.md (LR-BEHAV-BG-TASKS, and the import / Build Previews rows) and docs/whats-new.md
  • every new string in all 9 catalogs (French and Ukrainian too, since the rebase)
  • whole-branch review pass (fresh reviewer): no critical findings; the one important finding is fixed (a ✕ clicked in the frame its task ended put "no task N" in the status bar), and the minor ones are listed under Follow-ups below

What's in

  • A task registry in the engine (crates/engine/src/activity.rs, Session::activity). A job holds a TaskGuard while it runs: dropping it, including during a panic unwind, removes the row, so a dead worker can't leave a stuck bar. The guard adopts the job's existing cancel flag, so nothing below the engine changes. Progress is done / total plus a unit (count, bytes, percent) that the UI words and translates.
  • Commands activity.list and activity.cancel {id | all}. The UI, the control channel, the CLI and MCP all list and cancel tasks the same way.
  • The activity stack: rows float in the top-left corner under the top bar once a task is 0.5 s old. Each row has the task's name, a progress bar (a sweep while the total isn't known), the count and what it is working on, and ✕ for tasks that can be cancelled ("Stopping…" until they do). Three rows, then "+N more" / "Show less". ui.inspect reports the same list as activity.
  • Quit asks first while a cancellable task runs: "1 task is still running: Exporting. Quitting stops it." Quit Anyway cancels the tasks (unsaved changes still get their own prompt afterwards), Cancel keeps working. Tasks already stopping, and tasks without ✕, don't trigger it.
  • The old per-job progress UI is gone: the export panel (bottom left), the Importing window, the folder-scan, Lightroom and Synchronize Folder progress windows, and the merge and Build Previews progress toasts. Result toasts are unchanged.
  • The rule for new jobs: CLAUDE.md now asks every job that runs off the UI thread and can take more than a moment to hold a TaskGuard, with no progress UI of its own. docs/background-tasks.md explains how: kind, label, progress and units, detail, the three ways to cancel, examples and tests.
  • New strings in all 9 catalogs.

No pause: none of the current jobs can pause, so this does cancel only.

Screenshots

Three real tasks at once (an export, Build Previews and a Lightroom catalog inspect) in the app, rendered by lightcraft-cli snapshot (headless, same UI and tasks):

Activity stack with Exporting 0 of 24, Building previews 1 of 24, Reading Lightroom catalog 13 of 14

The stack with five tasks: three rows, then "+2 more", and expanded. Finding faces has no ✕, the download counts megabytes, and the folder scan (total not known yet) has a sweeping bar. Rendered by the headless test harness with registered tasks; the drawing code is the app's own.

Activity stack: Importing, Exporting, Finding faces, +2 more Activity stack expanded to five rows with Show less

In the running app (Linux, Wayland): a background export after ✕ ("Stopping…" until the photo in progress is written), and quitting while it runs:

Exporting row after its cross: Stopping…

Quit while tasks are running? 1 task is still running: Exporting. Quitting stops it. Quit Anyway / Cancel

How to try it

  • Export several photos (File → Export): an "Exporting" row appears top-left with "3 of 24 · IMG_….jpg"; ✕ stops it after the photo in progress.
  • Import a folder of a few hundred photos: "Scanning folder", then "Importing"; ✕ stops either, and what was added stays as one undo step.
  • Import a Lightroom catalog: the row stops from ✕ while the catalog is read, and loses its ✕ once photos are being added.
  • Quit while an export runs: the quit prompt asks first.
  • Agents: engine.execute {"command": "activity.list"} / {"command": "activity.cancel", "params": {"id": 1}}.

Testing

Related PRs and issues

Follow-ups (minor, not done here)

  • Photo Merge's stage names ("Aligning", "Deghosting", …) show untranslated on the merge row, as they did in the old toast.
  • The command labels "Background Tasks" / "Cancel Background Task" aren't in the catalogs yet (no menu entry uses them).
  • The indeterminate sweep steps at 10 fps; repainting at 50 ms while a shown task has no total would smooth it.
  • Quitting while a Lightroom import is saving its index (not cancellable) doesn't ask; it could wait for or warn about that step.

Noticed along the way (not changed here)

  • Cancelling a Lightroom catalog inspect takes a few seconds on a big catalog (the reader checks between tables), and its count is tables, not photos, as in the old progress window.
  • With the control channel, after ui.resize the real Wayland window can keep its size while headless screenshots lay out at the requested size, and ui.clickWidget then clicks at the screenshot layout's coordinates.

🤖 Generated with Claude Code

cajax added a commit to cajax/lightcraft that referenced this pull request Oct 10, 2026
@cajax cajax changed the title Issue #345: activity stack — one progress indicator for long-running tasks (draft) Issue #345: activity stack — one progress indicator for long-running tasks Oct 10, 2026
@cajax
cajax marked this pull request as ready for review October 10, 2026 01:14
@echelon

echelon commented Oct 10, 2026

Copy link
Copy Markdown
Member

Thank you @cajax! One activity stack instead of five progress UIs is a great clean-up, and activity.list / activity.cancel work from every front end. TaskGuard removing its row even during a panic is a nice detail.

Before it can land:

  1. Move lightcraft-merge to [dev-dependencies] in crates/ui-egui/Cargo.toml. Only tests_activity.rs uses it.
  2. Rebase onto main. Integrate 59 community PRs (batches 21–23) #657 landed Synchronize Folder (LRC-LIB-LIBFOLDERS: Synchronize Folder (stacked on #597) #604), whose sync::progress_window should move onto a TaskGuard, as your description anticipates, and the contact-sheet PDF export (Export a contact sheet of photos to a paginated PDF #563) and parallel export lanes (LR-BEHAV-BG-TASKS: render export batches side by side (issue #496) #504), which still draw the old export progress panel.
  3. Check the tests that click the removed widget ids (button:importCancel, button:scanCancel, button:lightroomCancel, exportCancel), e.g. tests_offline.rs and headless.rs on main.

Please join our Discord if you haven't already: https://discord.gg/artcraft

@cajax

cajax commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Sure, will do now 👌

cajax and others added 18 commits October 10, 2026 08:44
A registry of the background tasks in flight on Session: a job holds a
TaskGuard while it runs (dropping it, also during a panic unwind, removes
the row), adopts its existing cancel flag, and reports done/total in a
unit the frontend words. Groundwork for one progress stack for imports,
exports, preview builds and the other long jobs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The registry is reachable as commands, so the UI, the control channel,
the CLI and MCP list and cancel background tasks the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every task in the engine's activity registry floats as a row under the
top bar once it is half a second old: its name, a progress bar (a sweep
while the amount of work isn't known), the count and what it is working
on, and a cross for the ones that can be cancelled. Three rows, then
"+N more". ui.inspect reports the same list as activity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quitting while an import, an export or another task that can be
cancelled is running asks first: Quit Anyway cancels them (then any
unsaved changes still get their own question), Cancel keeps working.
Tasks without a cross (the face scan, AI Denoise) pick up again on the
next launch and don't ask.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A background export registers in the activity stack with the photos done
of the total and the file in progress; its cross and activity.cancel set
the export's own cancel flag. The separate export panel at the bottom
left is gone; the result toast is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An import (and Auto Import, and reading a folder for Local) registers in
the activity stack with the files done of the total; its cross and
activity.cancel set the import's cancel flag, so nothing new starts and
the result still reads "Import cancelled · N added" as one undo step.
The separate Importing window is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cross sits at the right edge of its row (the name's area kept only
the text's width, so the cross followed short names). Seen in the
running app; a test pins it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The import review's folder scan (and reading a folder for Local) is a
row in the activity stack: "Looking for photos…" while the folders are
listed, then the files read of the total. Its cross drops the scan at
once, without waiting for the file being read, as the old Cancel did.
The separate Scanning window is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build Previews, Build Smart Previews and Discard Smart Previews show a row
with the photo count and stop from its cross; the start toast goes, the
finish toast stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inspecting and importing a Lightroom catalog show a row instead of the
progress window; reading the catalog stops from its cross, adding the
photos and saving the index run to the end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The final HDR / panorama merge shows a row with its percentage and stage
instead of the progress toast, and stops from its cross ("HDR merge
cancelled"). The activity tests now let the first renders finish before
they run, and the half-second check tolerates a slow frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Downloading the SAM 3, face and AI Denoise models shows a row with the
model's name and the megabytes so far; its cross stops the download like
the Settings button. The denoise download tests get their own scratch
folders (they shared the face tests' names and could delete each
other's files).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While photos are left to search for faces the stack shows "Finding
faces" with how many are done (no cross: the scan is switched off in
Settings). The engine keeps the scan's peak, so Settings and the stack
agree. Also translates the "Downloading model" label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While a photo's AI Denoise picture is being made or waits its turn, the
stack shows "AI Denoise" with the running photo's tiles as a percentage
and its file name (no cross: what is made follows the Denoise amounts and
Settings). The row goes when the queue is idle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Find Missing Photos shows a row (a sweep: the amount of work isn't known,
no cross) while it searches; the auto-import folder listing, which runs
every few seconds, stays quiet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LR-BEHAV-BG-TASKS now cites activity.list / activity.cancel and lists
every job on the stack; the import and Build Previews rows no longer
describe progress windows and toasts; a what's-new entry.

Fixes the stack not growing when tasks arrive while it already shows a
row (an egui area lays out in last frame's size, and the scroll area took
that as all the room, so later rows were cut off), and adds the Russian
"Quit Anyway".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cross clicked in the frame its task ended no longer puts "no task N"
in the status bar: the row's cancel goes to the engine directly instead
of through the app's command runner, which reports every error there.

The face-scan row test scans demo photos no other scan test uses, so it
no longer joins the scan deadlock of storytold#630 (with one of the existing pump
tests it hung 13 of 20 runs; now 0 of 20).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…activity stack

Synchronize Folder (storytold#604) shows its scan ("Looking for changes", while
its dialog is open) and its run ("Synchronizing folder") as rows: the
scan's cross stops it and closes the dialog, the run's stops it like
Cancel did (what was done stays, as one undo step; the end says Stopped).
Its progress window is gone. The contact-sheet PDF export (storytold#563), which
went through the export task already, gets a test for its row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cajax
cajax force-pushed the issue-345-activity branch from 161c137 to 56dfc8d Compare October 10, 2026 07:25
…and guide)

CLAUDE.md gains the rule (a TaskGuard for every job that runs off the UI
thread and can take more than a moment; no progress window, panel or
toast of its own), and docs/background-tasks.md says how: kind, label,
progress, units, detail, the three ways to cancel, examples and tests.
Photo Merge's and the face scan's docs no longer describe the old
progress toast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cajax

cajax commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Rebased onto main (5436951) and pushed:

  1. lightcraft-merge is already a dev-dependency: it's under [dev-dependencies] in crates/ui-egui/Cargo.toml (next to lightcraft-faces), and only tests_activity.rs uses it. Nothing changed there.
  2. Rebase:
    • Synchronize Folder (LRC-LIB-LIBFOLDERS: Synchronize Folder (stacked on #597) #604): its scan and its run now each hold a TaskGuard. The rows are "Looking for changes" while the dialog scans and "Synchronizing folder" after Synchronize, with Cancel::Flag(progress.files.cancel). ✕ on the scan stops it and closes the dialog. ✕ on the run stops it like Cancel did: what was done stays, as one undo step, and the end says "Stopped". sync::progress_window is gone. New tests are in tests_sync.rs.
    • Contact-sheet PDF (Export a contact sheet of photos to a paginated PDF #563): it goes through the same ExportTask, so it now has a row too ("Exporting contact sheet", with ✕ to stop it). There's a test in export_task.rs.
    • Parallel export lanes (LR-BEHAV-BG-TASKS: render export batches side by side (issue #496) #504): nothing extra was needed. run_batch reports the photo each lane starts, so the export row's count and file name read as before.
    • Translations: French and Ukrainian are added for every string this PR introduces. The build needs each format string in every catalog, and each rebased commit compiles on its own.
  3. Removed widget ids: tests_offline.rs (import) and headless.rs (folder scan) now click the row's ✕ (activity:cancel:<id>). No test, doc or script refers to button:importCancel, button:scanCancel, button:lightroomCancel, button:exportCancel or button:syncCancel any more.

So that the next background job lands on the stack too (#604 and #563 were written alongside this PR, and each added its own progress window), CLAUDE.md now has a rule: anything that runs off the UI thread and can take more than a moment holds a TaskGuard, and has no progress window, panel or toast of its own. docs/background-tasks.md is the how-to. If you'd like it enforced too, cargo xtask could fail on an egui::ProgressBar outside an allowlist (the stack, and the inline bars in dialogs and Settings). It's a heuristic, so I left it out; say if you want it.

Every cargo xtask ci step passes on the new head except three tests that are flaky on main too (details in the PR description). Each one passes alone:

  • mcp e2e::export_progress_and_cancel fails about half the runs on main on a 22-thread machine (4 of 8 at 5436951). With 4 export lanes (LR-BEHAV-BG-TASKS: render export batches side by side (issue #496) #504), the 8-photo batch can finish before the cancel arrives.
  • engine::tests_export::export_falls_back_to_the_cpu_when_gpu_work_is_lost: another test's GPU failure can overwrite the process-wide fallback reason.
  • catalog::tests_lock::second_opener_is_refused_until_the_first_lets_go: catalog code identical to main.

🤖 Generated with Claude Code

@cajax

cajax commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Hi @echelon ! Here are the fixes and conflict resolution. As you see this PR also exposed some issue in existing code. They are not related directly to my PR, I will file separate tickets for them

…ews (timed out on a loaded machine)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echelon

echelon commented Oct 10, 2026

Copy link
Copy Markdown
Member

Thank you @cajax! The activity stack landed in #692. Thanks for the quick rework onto Synchronize Folder and the contact sheet. One small change on your branch: the preview-build test builds small previews, because it timed out on a heavily loaded machine.

Please join our Discord if you haven't already: https://discord.gg/artcraft

mysbryce pushed a commit to mysbryce/lightcraft that referenced this pull request Oct 10, 2026
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 10, 2026
)

Rebased onto the activity stack (storytold#601). An export adding its files to
Photos keeps its row through that step, with "Adding to Apple Photos…" as
the detail. The worker turns the row's ✕ off (TaskHandle::set_cancellable)
before its last look at the cancel flag and reports what it saw, so a
cancel either stops the export before Photos is asked or is refused, never
both "cancelled" and imported. activity: a per-task gate orders a cancel's
decision against a step switching cancelling off, so a cancel can't be
accepted between the switch and the step's look at the flag and then be
ignored. An import of its own (export.addToPhotos, or
the Photos step left running after a foreground app.export) holds a row of
kind applePhotos while Photos works: no ✕, no count, the album as detail.
The desktop app refuses export.addToPhotos {wait: true}: its window's
thread never waits for Photos. The label is in every catalog; tests assert
the rows, the refused cancel and the refused wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 10, 2026
)

Rebased onto the activity stack (storytold#601). An export adding its files to
Photos keeps its row through that step, with "Adding to Apple Photos…" as
the detail. The worker turns the row's ✕ off (TaskHandle::set_cancellable)
before its last look at the cancel flag and reports what it saw, so a
cancel either stops the export before Photos is asked or is refused, never
both "cancelled" and imported. activity: a per-task gate orders a cancel's
decision against a step switching cancelling off, so a cancel can't be
accepted between the switch and the step's look at the flag and then be
ignored. An import of its own (export.addToPhotos, or
the Photos step left running after a foreground app.export) holds a row of
kind applePhotos while Photos works: no ✕, no count, the album as detail.
The desktop app refuses export.addToPhotos {wait: true}: its window's
thread never waits for Photos. The label is in every catalog; tests assert
the rows, the refused cancel and the refused wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 11, 2026
)

Rebased onto the activity stack (storytold#601). An export adding its files to
Photos keeps its row through that step, with "Adding to Apple Photos…" as
the detail. The worker turns the row's ✕ off (TaskHandle::set_cancellable)
before its last look at the cancel flag and reports what it saw, so a
cancel either stops the export before Photos is asked or is refused, never
both "cancelled" and imported. activity: a per-task gate orders a cancel's
decision against a step switching cancelling off, so a cancel can't be
accepted between the switch and the step's look at the flag and then be
ignored. An import of its own (export.addToPhotos, or
the Photos step left running after a foreground app.export) holds a row of
kind applePhotos while Photos works: no ✕, no count, the album as detail.
The desktop app refuses export.addToPhotos {wait: true}: its window's
thread never waits for Photos. The label is in every catalog; tests assert
the rows, the refused cancel and the refused wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
emmertex added a commit to clydecbrown/lightcraft that referenced this pull request Oct 26, 2026
LRC-LIB-LIBFOLDERS: Copy Path and New Folder on Disk in every folder menu (upstream storytold#2959)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants