diff --git a/aidlc-docs/features/media-library/assumptions-and-open-questions.md b/aidlc-docs/features/media-library/assumptions-and-open-questions.md index 65796eb..9a8f09b 100644 --- a/aidlc-docs/features/media-library/assumptions-and-open-questions.md +++ b/aidlc-docs/features/media-library/assumptions-and-open-questions.md @@ -70,3 +70,4 @@ Kept while Bryan is away (2026-11-17): no questions to him, a most probable assu | 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 `/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` | +| 42 | **One progress pattern for upload, processing and a new crop** (Bryan, 2026-11-17, after seeing it on test). | A shared `ProcessingProgress` (text "Wordt verwerkt…", one 0-100% bar, the percentage, no spinner, no step counts) is used on every photo and for the batch. The batch bar covers upload and processing together; there are no byte counts from the upload, so a photo's percentage is staged: waiting 0, uploading 15, uploaded 30, then 30-100 from the server's processing steps. A new crop uses the full 0-100 from its steps. The counter "x van y verwerkt" stays per batch. | Real upload byte progress (needs XHR progress in the API client). | `features/media/components/ProcessingProgress.tsx`, `lib/photoProgress.ts`, `hero/components/ProcessingStatus.tsx` | diff --git a/frontend/src/features/hero/components/ProcessingStatus.tsx b/frontend/src/features/hero/components/ProcessingStatus.tsx index 7ac85d2..cb0bd91 100644 --- a/frontend/src/features/hero/components/ProcessingStatus.tsx +++ b/frontend/src/features/hero/components/ProcessingStatus.tsx @@ -1,6 +1,8 @@ import { Check, Loader2 } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { Button } from '@/components/ui/button'; +import { ProcessingProgress } from '@/features/media/components/ProcessingProgress'; +import { photoProgress, recutProgress, type UploadStage } from '@/features/media/lib/photoProgress'; import { useRetryHeroImage } from '../services/hooks'; import type { HeroImageDto } from '../services/types'; @@ -13,46 +15,32 @@ export function Spinner({ className = 'size-4' }: { className?: string }) { * Shown above the form while photos of the saved hero are still being prepared in the background: how many are ready, * what that means for the website, and a way to try again for a photo that failed. */ -export function ProcessingStatus({ images }: { images: HeroImageDto[] }) { +export function ProcessingStatus({ images, pendingUploads = [] }: { images: HeroImageDto[]; pendingUploads?: UploadStage[] }) { const { t } = useTranslation(); const retry = useRetryHeroImage(); - const total = images.length; const waiting = images.filter((image) => image.processing); - if (waiting.length === 0) return null; + if (waiting.length === 0 && pendingUploads.length === 0) return null; - const done = total - waiting.length; + // The counter and the one bar cover the current batch: the files that are still being uploaded and the photos that are + // being processed. The bar is the overall progress of the whole chain, upload and processing together. + const total = images.length + pendingUploads.length; + const done = images.length - waiting.length; const failed = waiting.filter((image) => image.failed); - const working = waiting.length - failed.length; - // The photo the server is busy with right now, and how far along it is (a photo that waits has no step yet). - const busy = waiting.find((image) => image.renderTotal) ?? null; - const fraction = busy && busy.renderTotal ? (busy.renderDone ?? 0) / busy.renderTotal : 0; - const percent = total === 0 ? 0 : Math.min(100, ((done + fraction) / total) * 100); + const working = waiting.length - failed.length + pendingUploads.length; + const percents = [ + ...images.map((image) => photoProgress({ ready: !image.processing, upload: 'done', renderDone: image.renderDone, renderTotal: image.renderTotal })), + ...pendingUploads.map((stage) => photoProgress({ upload: stage })), + ]; + const percent = percents.length === 0 ? 0 : percents.reduce((sum, value) => sum + value, 0) / percents.length; return (
{working > 0 && (
-

- - {t('hero.processing.count', { done, total })} +

+ {t('hero.processing.count', { done, total })}

-
-
-
- {busy && ( -

- {t('hero.processing.current', { n: done + 1, total, step: busy.renderDone ?? 0, steps: busy.renderTotal })} -

- )} +

{t('hero.processing.explain')}

{t('hero.processing.stuck')}{' '} @@ -97,16 +85,17 @@ export function PhotoPlaceholder({ failed, testId, step }: { failed: boolean; te const { t } = useTranslation(); return (

- {failed ? null : } - {failed ? t('hero.slides.failed') : t('hero.slides.processing')} - {!failed && step ? {step.done}/{step.total} : null} - {!failed && !step ? {t('hero.slides.queued')} : null} + {failed ? ( + {t('hero.slides.failed')} + ) : ( + + )}
); } @@ -118,7 +107,6 @@ export function PhotoPlaceholder({ failed, testId, step }: { failed: boolean; te */ export function RecutThumbnail({ src, failed, testId, step }: { src: string; failed: boolean; testId: string; step?: { done: number; total: number } | null }) { const { t } = useTranslation(); - const percent = step && step.total > 0 ? Math.min(100, Math.round((step.done / step.total) * 100)) : 0; return (
@@ -127,28 +115,7 @@ export function RecutThumbnail({ src, failed, testId, step }: { src: string; fai role="status" aria-busy={!failed} > - {failed ? ( - {t('hero.slides.failed')} - ) : ( - <> -
- {t('hero.slides.processing')} - {percent}% -
-
-
-
- - )} + {failed ? {t('hero.slides.failed')} : }
); diff --git a/frontend/src/features/hero/components/UploadProgress.tsx b/frontend/src/features/hero/components/UploadProgress.tsx index 13a8ded..ca0afb0 100644 --- a/frontend/src/features/hero/components/UploadProgress.tsx +++ b/frontend/src/features/hero/components/UploadProgress.tsx @@ -1,7 +1,6 @@ -import { AlertCircle, Check, Clock } from 'lucide-react'; +import { AlertCircle, Check, Clock, Upload } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { Button } from '@/components/ui/button'; -import { Spinner } from './ProcessingStatus'; export interface UploadItem { key: number; @@ -11,7 +10,7 @@ export interface UploadItem { message?: string; } -/** The files of the last choice, one row each: waiting, busy (spinner), added, or failed with the reason. */ +/** The files of the last choice, one row each: waiting, busy, added, or failed with the reason. */ export function UploadProgress({ items, busy, onClose }: { items: UploadItem[]; busy: boolean; onClose: () => void }) { const { t } = useTranslation(); if (items.length === 0) return null; @@ -27,7 +26,7 @@ export function UploadProgress({ items, busy, onClose }: { items: UploadItem[]; {items.map((item) => (
  • - {item.status === 'uploading' && } + {item.status === 'uploading' &&