Skip to content

feat: multi-select assets in the file manager to add many at once #414

Description

@tristan-mouchet

Feature request

When picking assets, allow selecting multiple assets at once in the file manager and confirming with a single Add {n} button, instead of picking them one at a time. The most obvious use case is a CMS asset field with multiple = true, where you often want to add many images in one go.

Problem

Today the file manager has two separate "selection" concepts:

  • Picker mode (choosing an asset for a field/layer) is single-select only. openFileManager(onSelect, assetId, category) takes one callback that fires for a single asset and closes the dialog.
  • Bulk management mode (checkbox multi-select) only exists for move/delete operations inside the manager.

As a result, populating a multiple = true asset field means repeating the whole flow for every asset:

  • In CollectionItemSheet.tsx, each asset is added via the Add {label} button → openFileManager(...) → pick one → dialog closes → repeat.
  • Same one-at-a-time pattern in the field default editor (AssetDefaultMultiple in FieldFormDialog.tsx).

For an item with 10–20 images this is tedious (open, pick, reopen, pick, ...).

Proposed solution

Add a multi-select picker mode to FileManagerDialog:

  • When opened from a context that accepts multiple assets, show the existing checkboxes for selection (reuse the selectedAssetIds: Set<string> machinery already used for bulk move/delete).
  • Show a confirm button labelled Add {n} (reflecting the number of selected assets), disabled when nothing is selected — mirroring the Export {n} pattern referenced in feat: export collection items to CSV #348.
  • Return the full array of selected assets to the caller in one callback, instead of firing per-asset.
  • Keep single-select behavior unchanged for existing single-asset consumers (image/video/icon/link settings, etc.).

Then wire the multi-select mode into the multi-asset flows:

  • CollectionItemSheet.tsx — the Add {label} button for isMultipleAssetField(field) opens the picker in multi-select mode, appends all chosen assets (with the existing type validation via isValidAssetForField and dedupe), and stores the resulting JSON.stringify(assetIds).
  • AssetDefaultMultiple in FieldFormDialog.tsx — same treatment for field default values.

Implementation notes

  • openFileManager would need to support a multi-select variant, e.g. an onSelectMany?: (assets: Asset[]) => void callback or a multiple?: boolean flag (stores/useEditorStore.ts, consumed in YCodeBuilderMain.tsx).
  • The checkbox UI already exists on FileGridItem (currently gated to bulk move/delete) — the main work is letting picker mode reuse it and swapping the footer action to Add {n}.
  • Category/type filtering (getFileManagerCategory, isValidAssetForField) should still apply so only valid assets can be added.

Context

  • Main manager: app/(builder)/ycode/components/FileManagerDialog.tsx
  • Multi-asset field flow: app/(builder)/ycode/components/CollectionItemSheet.tsx, FieldFormDialog.tsx (AssetDefaultMultiple)
  • Detection/util: isMultipleAssetField in lib/collection-field-utils.ts, parseMultiAssetFieldValue in lib/multi-asset-utils.ts
  • Opener state: stores/useEditorStore.ts (openFileManager), wired in YCodeBuilderMain.tsx

Open questions

  • Should multi-select be a distinct mode, or should any picker allow it when the target field accepts multiple?
  • Should selection persist across folder navigation within a single picker session?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions