Add the post-editor Add Gallery Images workflow #13

Closed
opened 2026-07-18 20:22:02 +00:00 by hugo · 1 comment
Owner

Goal

Implement the bDS2-compatible post-editor batch workflow that imports selected images, links them to the current post, enriches them when AI is available, and inserts the gallery macro.

Current state

  • Generic concurrent media import already exists in crates/bds-ui/src/app.rs through Message::MediaFilesPicked.
  • Native multi-file image selection already exists in crates/bds-ui/src/platform/dialog.rs.
  • Post-media link, sidecar, translation, thumbnail, and one-shot AI engines already exist.
  • There is no post-editor Add Gallery Images action or post-specific import pipeline.
  • specs/media.allium, PostEditorGalleryImportSurface and BatchImportProcessLinkImages, is normative.

Required behavior

Add a localized post-editor quick action named Add Gallery Images for a persisted post.

  1. Gate the action through the existing AI endpoint rules:
    • online mode uses the configured online endpoint;
    • airplane mode proceeds only with a configured local endpoint;
    • airplane mode without a local endpoint does not open the picker and writes the explanatory Output entry used by bDS2.
  2. Open the native image-only multi-file picker. Cancellation is a no-op; picker errors go to Output.
  3. Process selected paths with project image_import_concurrency, default 4 and clamped to 1 through 8.
  4. For each valid image, import it and link it to the post before any AI call. The link must survive analysis, metadata-update, or translation failure.
  5. Best-effort AI enrichment updates title, alt, and caption, then upserts translations for the unique set of project main language plus blog languages, excluding the source language.
  6. Write one Output entry per successful image and per failed image.
  7. After every worker finishes, including partial failures, insert \n[[gallery]]\n into the current editor, refresh linked media/editor state, and write the final selected-count summary.

All metadata changes must continue to flush through the normal sidecar path and remain compatible with metadata diff and rebuild-from-filesystem.

Implementation notes

  • Read docs/UI_STYLE_GUIDE.md before changing the editor UI.
  • Reuse generic media import, post_media, AI, translation, task/output, and dialog code. Do not create a second media pipeline.
  • Add all user-facing strings to the relevant localization resources.
  • Follow red/green TDD.
  • Use ../bDS2/lib/bds/desktop/shell_live/gallery_import.ex, the add_gallery_images handlers in shell_live.ex, and gallery pipeline tests when the spec is silent.

Acceptance criteria

  • The action is visible and working from an open persisted post editor.
  • Import/link happens even when enrichment fails; a regression test proves linked media remains attached.
  • Airplane-mode behavior is covered for configured and unconfigured local endpoints.
  • Concurrency bounds, translation target de-duplication, partial failure, picker cancellation, Output messages, macro insertion, and editor refresh are tested.
  • Sidecars contain the resulting links/metadata and rebuild restores them.
  • allium check specs/*.allium, cargo fmt --all -- --check, cargo build --workspace, and cargo test --workspace pass.
## Goal Implement the bDS2-compatible post-editor batch workflow that imports selected images, links them to the current post, enriches them when AI is available, and inserts the gallery macro. ## Current state - Generic concurrent media import already exists in `crates/bds-ui/src/app.rs` through `Message::MediaFilesPicked`. - Native multi-file image selection already exists in `crates/bds-ui/src/platform/dialog.rs`. - Post-media link, sidecar, translation, thumbnail, and one-shot AI engines already exist. - There is no post-editor `Add Gallery Images` action or post-specific import pipeline. - `specs/media.allium`, `PostEditorGalleryImportSurface` and `BatchImportProcessLinkImages`, is normative. ## Required behavior Add a localized post-editor quick action named `Add Gallery Images` for a persisted post. 1. Gate the action through the existing AI endpoint rules: - online mode uses the configured online endpoint; - airplane mode proceeds only with a configured local endpoint; - airplane mode without a local endpoint does not open the picker and writes the explanatory Output entry used by bDS2. 2. Open the native image-only multi-file picker. Cancellation is a no-op; picker errors go to Output. 3. Process selected paths with project `image_import_concurrency`, default 4 and clamped to 1 through 8. 4. For each valid image, import it and link it to the post before any AI call. The link must survive analysis, metadata-update, or translation failure. 5. Best-effort AI enrichment updates title, alt, and caption, then upserts translations for the unique set of project main language plus blog languages, excluding the source language. 6. Write one Output entry per successful image and per failed image. 7. After every worker finishes, including partial failures, insert `\n[[gallery]]\n` into the current editor, refresh linked media/editor state, and write the final selected-count summary. All metadata changes must continue to flush through the normal sidecar path and remain compatible with metadata diff and rebuild-from-filesystem. ## Implementation notes - Read `docs/UI_STYLE_GUIDE.md` before changing the editor UI. - Reuse generic media import, `post_media`, AI, translation, task/output, and dialog code. Do not create a second media pipeline. - Add all user-facing strings to the relevant localization resources. - Follow red/green TDD. - Use `../bDS2/lib/bds/desktop/shell_live/gallery_import.ex`, the `add_gallery_images` handlers in `shell_live.ex`, and gallery pipeline tests when the spec is silent. ## Acceptance criteria - The action is visible and working from an open persisted post editor. - Import/link happens even when enrichment fails; a regression test proves linked media remains attached. - Airplane-mode behavior is covered for configured and unconfigured local endpoints. - Concurrency bounds, translation target de-duplication, partial failure, picker cancellation, Output messages, macro insertion, and editor refresh are tested. - Sidecars contain the resulting links/metadata and rebuild restores them. - `allium check specs/*.allium`, `cargo fmt --all -- --check`, `cargo build --workspace`, and `cargo test --workspace` pass.
hugo added the enhancement label 2026-07-18 20:22:02 +00:00
Author
Owner

Implemented in commit 055dd5e. Added the localized post-editor Add Gallery Images action, airplane/local-endpoint gating, native image-only multi-selection, bounded concurrent import, mandatory post linking before best-effort AI enrichment, deduplicated media translations, per-image and final Output entries, gallery macro insertion, and editor/media refresh. Regression coverage verifies partial failure, link survival when AI fails, metadata and translation sidecars, rebuild restoration, concurrency bounds, picker cancellation, and configured local AI enrichment. README, core/extension plans, and AGENTS.md definition-of-done guidance were updated. Verified with allium check specs/*.allium, cargo fmt --all -- --check, cargo build --workspace, and cargo test --workspace --quiet.

Implemented in commit 055dd5e. Added the localized post-editor Add Gallery Images action, airplane/local-endpoint gating, native image-only multi-selection, bounded concurrent import, mandatory post linking before best-effort AI enrichment, deduplicated media translations, per-image and final Output entries, gallery macro insertion, and editor/media refresh. Regression coverage verifies partial failure, link survival when AI fails, metadata and translation sidecars, rebuild restoration, concurrency bounds, picker cancellation, and configured local AI enrichment. README, core/extension plans, and AGENTS.md definition-of-done guidance were updated. Verified with allium check specs/*.allium, cargo fmt --all -- --check, cargo build --workspace, and cargo test --workspace --quiet.
hugo closed this issue 2026-07-19 07:54:00 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hugo/RuDS#13