Mediabibliotheek en Hero: kopie-schakelaar in de deploy-workflow (test), kiezer enkel en meervoud, hint bij gedeelde uitsnede, plan uitsnede per gebruik
Continuous Integration / config-sls (pull_request) Successful in 8s
Continuous Integration / config-asf (pull_request) Successful in 6s
Continuous Integration / changes (pull_request) Successful in 13s
Continuous Integration / backend-build (pull_request) Successful in 1m53s
Continuous Integration / compile-sites (pull_request) Successful in 1m54s
Continuous Integration / vulnerability-scan (pull_request) Successful in 1m56s
Continuous Integration / frontend-prepare (pull_request) Successful in 2m24s
Continuous Integration / frontend-build (pull_request) Successful in 35s
Continuous Integration / frontend-lint (pull_request) Successful in 38s
Continuous Integration / backend-test (pull_request) Successful in 4m18s
Continuous Integration / frontend-test (pull_request) Successful in 2m35s
Continuous Integration / publish-sls-test (pull_request) Skipped
Continuous Integration / publish-sls-production (pull_request) Skipped
Continuous Integration / deploy-sls-test (pull_request) Skipped
Continuous Integration / deploy-sls-production (pull_request) Skipped
Continuous Integration / publish-asf-test (pull_request) Skipped
Continuous Integration / deploy-asf-test (pull_request) Skipped
Continuous Integration / smoke-sls-test (pull_request) Skipped
Continuous Integration / smoke-asf-test (pull_request) Skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 17:20:09 +01:00
co-authored by Claude Sonnet 5.5
parent e09304c2e9
commit 9bc4153c70
11 changed files with 228 additions and 23 deletions
@@ -67,3 +67,6 @@ Kept while Bryan is away (2026-11-17): no questions to him, a most probable assu
| 36 | **Choose from the library in a hero slide** (built 2026-11-17 at Bryan's request, before the migration). | Each slide has "Choose from library" next to its photo: the shared `ImagePicker` lists the library photos of the modules that can be chosen (now the hero's own photos, also those in no slide, never the trash) and a new photo can be uploaded on the spot with the hero's own upload (same checks, limits and background processing). Choosing only sets the slide's existing image id (no data model change). A photo that is already in another slide can be chosen again: it is the same photo, so its **crop is shared by the slides that use it** (the crop belongs to the photo in the hero today; a crop per slide comes with the library's own use records). | A separate crop per slide now would need the use records of phase 2 (or a copy of the photo). | `features/hero/components/LibraryPickerDialog.tsx`, `HeroPage.tsx` |
| 37 | **Removing from the trash for good** (Bryan, 2026-11-17). | `POST media-library/purge {ids}` (at most 100) or `{all:true}` (the server empties the whole trash in batches). Only photos that are in the trash and used nowhere are removed; the module checks it again and answers per photo (`purged`, `notInTrash`, `inUse`, `failed`). The original and the cut set go through `IMediaStore`; a file another photo still shares stays. The UI asks a clear confirmation that says it cannot be undone and names the number (and the size for the whole trash); "Empty the trash" is disabled when the trash is empty. No separate waiting period. | A short undo window for a purge: not built (the trash itself is the undo). | `MediaLibraryService.PurgeAsync`, `HeroImageService.PurgeAsync`, `PurgeDialog` |
| 38 | **A new crop applies at once, without saving the hero** (Bryan, 2026-11-17; replaces Hero assumption 1 of 2026-11-16, which said a focus change only takes effect when the hero is saved). | The focus dialog's Apply sends the crop at once (`PUT hero/images/{id}/focus`); the server cuts the new variants in the background and the photo switches to them when they are complete, so what is live changes only then, without another Save. The photo shows "Wordt verwerkt…", a 0-100% bar and the percentage on itself (no spinner); the upload keeps its own display. The counter "x of y processed" counts the current upload batch only. | Back to applying only on Save: restore the focus edits kept locally in `HeroPage`. | `HeroImageService.SetFocusAsync`, `HeroPage.applyFocus`, `RecutThumbnail` |
| 39 | **Crop PER USE, not per photo** (Bryan, 2026-11-17: a photo on two slides can have its own crop on each slide). | Decided, **not built yet**: it is too large and risky for the hero as it is today, because the cut sets, their set hash and the public output all hang on the photo (`HeroImage.SetHash`, `Variants`), so a crop per slide means a set per slide. The smallest safe step is built instead: a photo may be chosen for several slides, the crop is shared and the slide says so ("This photo is in more slides; the crop applies to all of them"). Design of the rest in `inception/application-design/per-use-crop.md`: it comes with phase 2 of the migration, because the library's own use records (`MediaUses.Crops`, `MediaUses.SetHash`) are where a crop per slide lives and the renderer then cuts a set per distinct crop. No public address or set hash changes until then. | An additive nullable focus on the slide (x, y, zoom) that overrides the photo's default focus, with a set per (photo, crop) and the public hero choosing the slide's set: possible without the library tables, but it rebuilds the renderer and the public mapping of the hero first; then phase 2 would have to move it again. | `HeroSlide`, `HeroImageService.RenderNextPendingAsync`, `HeroMapping` |
| 40 | **Switching the copy on at the test hosts without access to the Pi** (Bryan, 2026-11-17: the copy may run on test). | The deploy workflow has a new input `media_library_copy` (unchanged, on, off; dispatch input of the CI workflow, passed to the SLS test and ASF test deploys). A step edits ONLY the key `Media__Library__CopyOnStartup` in `<deploy_path>/shared/env` over the deploy account's SSH access (refuses any environment that is not `test`, accepts only on, off or unchanged, never prints the file), before the service restart; after the restart a step shows the journal line `Media library copy verified: N photos and M uses`. `off` removes the key again. | Set the variable by hand in `shared/env` on the Pi (needs a shell there). | `.gitea/workflows/deploy-scp.yaml`, `continuous_integration.yaml` |
| 41 | **The picker has a single and a multiple mode** (Bryan, 2026-11-17). | `ImagePicker` takes `mode="single"` (default, radio group, used by the hero slides) or `mode="multiple"` (checkboxes, several photos, several files per upload, ready for the gallery). Both use the same upload checks. | n/a | `ImagePicker.tsx` |
@@ -107,3 +107,13 @@ After that deploy, check in the log:
5. Switch it off again (remove the variable, restart) when done: the copy can be repeated at any time; it is a mirror.
**Rollback:** remove the variable (the tables stay, unused), or drop the tables with the EF `Down` migration of the Media module; the Hero's own tables are never changed by the copy.
## Switching the copy on at the test hosts (no shell on the Pi needed)
The application reads `Media__Library__CopyOnStartup` from the host's `shared/env` (the file the service starts with). The deploy workflow can set exactly this one key, so nobody needs a shell on the Raspberry Pi:
1. Dispatch the CI workflow (`Continuous Integration`) on the branch with **deploy_sls_test** and/or **deploy_asf_test** checked and **media_library_copy = on**. Each test deploy then sets `Media__Library__CopyOnStartup=true` in its own `shared/env` before restarting the service, and the run log shows the line `Media library copy verified: N photos and M uses from hero` (or the error line that says the copy was rolled back).
2. Check N and M against the hero (photos and slides) and the library screen.
3. Dispatch once more with **media_library_copy = off** (and the deploy flags again): the key is removed and the next start does not copy. (`unchanged`, the default, never touches the file.)
The input is refused for any environment other than `test`, and only the three values are accepted; the workflow never prints the file (it holds secrets). Production is not reachable.
@@ -0,0 +1,24 @@
# Crop per use (decision of Bryan, 2026-11-17)
A photo on two slides can have its own crop on each slide. Decided; **not built yet**. What exists today, why it waits, and the plan.
## Today
- The crop (default focus and the `wide` and `tall` overrides) is a property of the **photo** (`HeroImage`). The cut set (`SetHash`, `Variants`) belongs to the photo too, and so does the public output of the hero. A photo chosen for two slides therefore has one crop; the slide says so.
- The set hash is `MediaPaths.SetHash(originalSha256, crops)`, so a set is already addressed by photo plus crops; the formula does not have to change.
## Why not now
A crop per slide means a set per (photo, crop). The renderer (`HeroRenderService`), the public hero mapping and the admin all assume one set per photo. Changing that on the hero's own tables and then moving it again when the library takes over (`MediaUses` already has `Crops` and `SetHash` per use) would be done twice and puts the public output at risk before the library is accepted.
## Plan (with phase 2 of the migration)
1. The library's `MediaUses` (one per slide) carry the crops and the set hash of that use (the copy already fills them from the photo).
2. The hero slide gets its own crop (nullable focus overriding the photo's default; empty = the default), edited in the same focus dialog, applied at once like today.
3. The renderer cuts one set per distinct (photo, crops); a set that two uses share (same crops) is cut once; a set nobody uses any more is cleaned up like a retired set.
4. The public hero maps each slide to the set of its use. With no override the set is exactly today's set hash, so existing addresses and the golden files do not change.
5. Tests: two slides with one photo and different crops give two sets and two addresses; with the same crop one set; no override gives today's hash.
## Smallest safe step built now
A photo may be chosen for several slides and the slide shows "This photo is in more slides; the crop applies to all of them" (assumption 36 and 39).