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
- One gallery, two mounts.
components/uploads/UploadGallerydraws the workspace's uploads once.UploadsPagemounts it inmanagemode (copy address, delete);UploadPickermounts it inpickmode inside aModal— a picker answers one question, which is what a modal is for (interaction-patterns.md). A second grid is a defect. - One form.
UploadFormis the only caller ofPOST /api/v1/uploads. The page puts it in aDrawer; 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 oneonSelect. - 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 isimageopens the picker on images only and uploads asimage.BlockSettingsForm'simageandfilekinds are the first consumers; a new asset field that draws its own URL input instead is the defect this ADR names. Upload.typeis 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.- 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
/uploadsleavesEXCLUDED_SURFACESand is a catalogue product (upload, Tools) frompackages/product-model;?new=1opens its drawer.The picker's image list is
type=imageon the server, so an avatar, logo or favicon — images too — is not offered to an image field. A MIME-kind filter onGET /api/v1/uploadsis 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.AssetFieldalso gainedonPick, 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