Skip to content
Toolkit

ADR-0164: An asset field offers the workspace's uploads

  • Status: Accepted
  • Date: 2026-09-17
  • Deciders: Owner ("build the gallery", with re-use of existing uploads); workstream 012

Context

The upload API has existed since migration 000003 — list, create, delete, workspace-scoped — and no screen used it. /uploads was a nine-line placeholder in the navigation, and every block field that takes an image or a file was a bare URL input whose placeholder read https://... or /uploads/...: the product told the user to type the address of a file it gave them no way to store or find. The owner decided to build the gallery, and that it must serve re-use as well as upload.

Decision

  1. One gallery, two mounts. components/uploads/UploadGallery draws the workspace's uploads once. UploadsPage mounts it in manage mode (copy address, delete); UploadPicker mounts it in pick mode inside a Modal — a picker answers one question, which is what a modal is for (interaction-patterns.md). A second grid is a defect.
  2. One form. UploadForm is the only caller of POST /api/v1/uploads. The page puts it in a Drawer; the picker puts it under the grid, and a file added there is chosen in the same step, so both ways of answering end in one onSelect.
  3. A field that takes an asset mounts AssetField. It keeps the URL input — an asset hosted elsewhere is as valid as one stored here — and adds Choose from uploads. A field whose kind is image opens the picker on images only and uploads as image. BlockSettingsForm's image and file kinds are the first consumers; a new asset field that draws its own URL input instead is the defect this ADR names.
  4. Upload.type is a closed vocabulary. The contract declares the five types as an enum, so the handler refuses any other word (400) instead of storing it and treating it as a plain file.
  5. Catalogue rule C4 follows one hop. A page may satisfy "renders a form control" through a component of the app's own that it imports by relative path and mounts. An unmounted import does not count (watched failing).

Consequences

  • /uploads leaves EXCLUDED_SURFACES and is a catalogue product (upload, Tools) from packages/product-model; ?new=1 opens its drawer.

  • The picker's image list is type=image on the server, so an avatar, logo or favicon — images too — is not offered to an image field. A MIME-kind filter on GET /api/v1/uploads is a ROADMAP → NEXT row.

    Amended 2026-09-17. Landed the same day: the list takes kind=image|document, matched on MIME type, and the gallery and the picker send it. AssetField also gained onPick, for a form that saves text on blur and must commit a pick at once.

  • Surfaces that still take an asset address by hand — biolink settings (avatar, background), PWA icons, the splash generator's icon, QR logos — are a NEXT row each batch can take one of; they adopt AssetField, not a copy of it.

  • Deleting an upload does not check what uses its address; the confirmation says so. Reference tracking is not built and not promised.

Verification

components/uploads/uploads.test.tsx (nine cases: list, server-side filter, create on arrival, refusal shown, confirmed delete, empty state, re-use without an upload, upload-and-choose, typed address). Go: TestUploadHandler_Upload_UnknownTypeIsRefused, watched storing "type":"banana" with the guard off. Running stack: evidence .station/jobs/012-steady-state/evidence/visual-2026-09-17.md.

Source: docs/decisions/0164-an-asset-field-offers-the-workspaces-uploads.md

Library