# Files in Ask, slice 1 (web): Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** On the web, the person attaches files to a message in Ask, with
the paperclip, by pasting or by dropping. They watch each file upload as a
chip, and send. Their files show in the thread as thumbnails and pills, and
the Assistant reads them.

**Spec:** `docs/superpowers/specs/2026-11-26-ask-attachments-design.md`:
rulings R1 to R8, decisions D1 to D8, and sections 2.1 and 3. Equipo's
half is `oficina/equipo`
`docs/superpowers/specs/2026-11-26-assistant-attachments-design.md`, with a
plan of the same name as this one.

**Review:** this revision answers Fable's plan review of 2026-11-26: B1 to
B6, and the cheap nits. Fable's re-review approved it with two edits, B7
(P11) and B8 (P12), folded in here with the Base nits it took (P1, P3,
P10, P11).

**Branch:** `design/ask-attachments` holds the spec and this plan, and the
build goes on the same branch (the controller's call, 2026-11-26), from
`origin/main` `0a6e8bc`.

**Order between the repos:**

- **Equipo first.** Equipo's slice 1 ships to production first.
- **Building here.** This branch can be built and tested at any time
  against the fake (`internal/equipo/equipotest`), which learns Equipo's
  new contract in Task 1.
- **Merging here.** It merges and deploys only once production Equipo
  answers `can_attach` in the Assistant's snapshot (Task 12).
- **The paperclip waits too.** It shows only when `can_attach` is true
  (D3). An older Equipo never sends the field, so Base offers nothing until
  it does.

**Gates for every task:**

- Write a failing test first, and watch it fail for the right reason.
- Then run `make test`, or the one package with `-run` through the Make
  toolchain (`GOTOOLCHAIN=go1.26.11`).
- Then run `make vet fmt-check staticcheck budget`.
- The browser tasks also run `make browser` with `RASTRILLO_CHROME` set,
  at least `-run 'TestAsk'`. See memory "Base review gates" for the
  Chromium path.
- `make ci` and the full `make browser` run before hand-over (Task 11).

## Plan decisions

- **P1. Base keeps no bytes (R1), and its bounds hold** (Fable B3).
  - **The order.** `askUpload` first checks the declared `Content-Length`
    (over 10 MiB is `413` at once). Then it takes a slot from a
    process-wide semaphore of 4. Only then does it read the body.
  - **The read.** It reads under `http.ResponseController.SetReadDeadline`
    of 60 s, into memory, to at most 10 MiB plus 1 byte. A stalled body
    fails at the deadline and gives its slot back. Peak memory is about
    4 × 10 MiB.
  - **No deadline, no read** (Fable nit). If `SetReadDeadline` fails (a
    middleware that wraps the writer without `Unwrap`), the upload is
    logged and refused `503` before the body is read, never read without
    a deadline. The webtest goes through the whole router, so it would
    catch such a middleware.
  - **A client gone mid-flight** (Fable nit). The relay to Equipo runs on
    a context that outlives the request (`context.WithoutCancel`, 60 s),
    so an upload Equipo takes is never half-known. If the page has gone
    (Remove aborted the XHR) by the time Equipo answers, Base deletes the
    upload at once.
  - **Waiting.** A request that waits more than 10 s for a slot is `503`
    with `Retry-After: 2`.
  - **The page.** `ask-attach.js` uploads two files at a time, and retries
    a `503` after `Retry-After` by itself, up to 5 times.
  - **Sending on.** The body goes to Equipo with `Content-Length`, because
    Equipo's `ReadUpload` wants a known length. Nothing is written to disk.
  - **Downloads** stream through `io.Copy`, and are never buffered.
- **P2. New client calls, not `call`.** `call` caps answers at 4 MiB and
  times out after 20 s.
  - `Upload` gets 60 s, and sends **no** `Idempotency-Key`: Equipo's upload
    takes none (Fable nit).
  - `OpenAttachment` returns the `*http.Response` for the handler to
    stream. It is bounded by the request's context and a 60 s header
    timeout.
  - `DeleteAttachment` treats `204` and `404` as done.
- **P3. Base decides the download headers (D7, Fable B4).**
  - **Inline.** Only `image/png`, `image/jpeg`, `image/webp` and
    `image/gif`.
  - **Download.** The other five types (PDF, text, Markdown, CSV, JSON).
    Text types get `; charset=utf-8`.
  - **Anything else** is `application/octet-stream`, as a download.
  - **The name.** Base parses the file name out of Equipo's
    `Content-Disposition` (`mime.ParseMediaType`, `filename`), the only
    place a read gives it. Base then builds its own header from that name
    with `mime.FormatMediaType` and its own disposition. Equipo's header
    is never passed on.
  - **Always.**
    - `X-Content-Type-Options: nosniff`.
    - `Content-Security-Policy: default-src 'none'; img-src 'self'; style-src 'unsafe-inline'; sandbox`.
  - **Caching.** Previews are `Cache-Control: private, max-age=3600` with
    `Vary: Cookie`. Originals are `Cache-Control: no-store`.
  - **`/preview`** answers only for the four image types; anything else is
    `404`.
  - **Failures.**
    - Equipo's error bodies never come through.
    - A `401` drops the link, as `askDone` does, and answers `404`.
    - A `5xx` or a timeout answers `502` with an empty body.
- **P4. Thumbnails come from Base's origin,** at
  `/ask/attachments/{id}/preview`, so the page CSP (`img-src 'self' data:`)
  is unchanged. A chip shows its thumbnail once the upload answers. Until
  then it shows a file mark, never a `blob:` URL, which the CSP would
  refuse.
- **P5. The attach script is its own module,**
  `internal/look/static/ask-attach.js`, imported by `ask.js`.
  - `ask.js` (2,160 lines) grows only by the hooks.
  - It follows Equipo's `chat-attach.js`: XHR for progress, and the
    server's word is final.
- **P6. The no-script page shows files but can't attach them (R4).**
  - `chat.html` draws thumbnails as links to the full image, and pills as
    download links.
  - The paperclip and the chips exist only when the script adds them.
- **P7. Equipo IDs only.** A client never sees an Equipo URL.
  - Message JSON carries `attachments` (`id`, `kind`, `name`,
    `media_type`, `size`, `width`, `height`), and each client builds
    `/ask/attachments/{id}`.
  - IDs must match `at_[a-z0-9]{8,60}` before Equipo is called.
- **P8. Text may be empty with files.**
  - `askSend` accepts an empty `text` when at least one `attachments` is
    present.
  - `ask.js`'s submit skips its `field.value.trim()` early return in that
    case.
  - The textarea loses `required` once script runs. It keeps `required`
    without script.
- **P9. The installed native apps get a names line before the web ships.**
  - They decode `attachments` and show a person bubble's files as one
    plain line of names under the text, so a files-only message is never
    an empty bubble.
  - That build is released before or with the web (Task 12; Fable nit).
- **P10. Refused files never take Ask down (D5, Fable B1 and B2).**
  - **Runner can't take files.** A send with files refused by Equipo's
    `409 attachments_unavailable`, or `409 runner_too_old`, answers
    `409 {"state":"ready","files":"unavailable"}`.
    - The page keeps Ask ready, sets `can_attach` false (the paperclip
      goes), keeps the chips, and marks them with the "can't be read right
      now" line.
    - The words stay in the field. Sending again without the chips works.
  - **Stale upload.** Equipo's `422` on a send with files (an upload
    expired, or already sent) answers `422 {"state":"ready","files":"stale"}`.
    The page marks every chip "attach it again", and Remove clears them.
  - **Only an attachment's `422` is stale** (Fable nit). Base checks the
    text as Equipo does before relaying (valid UTF-8, no NUL, at most
    16 KiB after trimming) and the key's reserved prefixes (`reply:`,
    `card:`, `handoff:`). Bad text is Base's own `422 {"state":"ready"}`,
    with no `files`. So an Equipo `422` on a send with files can only be
    the files.
  - **Words alone.** A send with no files keeps today's mapping.
- **P11. Remove frees the upload (D6, Fable B6).**
  - Remove calls `DELETE /ask/attachments/{id}` once the upload has an ID.
    A Remove during the upload aborts the XHR, then deletes if an ID came
    back.
  - On `pagehide`, `navigator.sendBeacon` posts the unsent IDs to
    `POST /ask/attachments/discard`. Base deletes each as best it can, and
    always answers `204`.
  - **Not a send in flight** (Fable B7). The beacon leaves out every ID
    that is part of a send still on its way: the send links them, and a
    delete racing it would lose the message. If that send fails after
    all, the 24-hour drop takes them.
  - **Back and forward** (Fable B7). A page kept in the back/forward cache
    comes back with chips whose uploads the beacon deleted. On `pageshow`
    with `persisted`, the page clears its chips.
  - Chips don't survive a reload.
  - **The words in the field** (Fable nit). Leaving the page drops the
    chips and the words alike: a new page draws an empty composer, as
    today (the field is `autocomplete="off"`, so the browser doesn't
    restore it). The docked panel and the Ask page behave the same. The one
    exception is the back/forward cache, which brings the whole page back:
    the words are still there, and only the chips go, since their uploads
    are gone.
- **P12. Paste (D8, Fable B5 and B8).** On `paste`, with files on the
  clipboard:
  - **Words win** only when there are real words: `text/html` whose text
    (parsed inertly, as `pasteMarkdown` does) has non-space characters,
    or `text/plain` that is more than the files' own names (each line
    trimmed, every line that is one of the files' names dropped, and
    something left). Then the existing text path runs (`pasteMarkdown` or
    plain), and nothing is attached. Word, Excel, Pages and Numbers land
    here.
  - **Otherwise the files are attached,** and the default is prevented, so
    no name is typed into the field.
  - **What B8 turned out to be** (checked 2026-11-26 in Chrome for Testing
    159 on macOS, with a real paste from the system pasteboard holding a
    file as Finder's Copy writes it: its file URL and its name as plain
    text). Chrome gives the page `types: ["Files"]` and no `text/plain`,
    so "text wins" would not have stopped the file. But Chrome's own
    default then types the file's name into the field, which this rule
    prevents. A clipboard with text, HTML and an image (as Office writes)
    gives all three, and the words win. Safari, and Finder's own Copy
    (its automation was refused here), are still to check by hand in
    Task 12; the narrowed rule covers a browser that does put the name in
    `text/plain`.
- **P13. The flag is `can_attach`** (Fable nit), in Equipo's snapshot and
  in `/ask/state`. Each message's list is `attachments`.

## File map

| File | Change |
|---|---|
| `internal/equipo/chat.go` | `Attachment`; `Message.Attachments`; `Snapshot.CanAttach`; `Send(…, files)`; `Upload`; `OpenAttachment`; `DeleteAttachment`; `ErrAttachmentsUnavailable` |
| `internal/equipo/equipo_test.go` | the client's new calls |
| `internal/equipo/equipotest/chat.go` | the fake: upload, read, delete, send with files, `can_attach`, `FilesReady(bool)`, `HoldNextUpload`, `ExpireUploads`, `ServeHostile(type, disposition)` |
| `internal/web/ask.go` | routes; `askView.CanAttach`; `/ask/state` `can_attach`; status words for turn reasons |
| `internal/web/ask_files.go` | new: `askUpload`, `askAttachment`, `askDiscard`, `askDeleteAttachment`; the slot semaphore |
| `internal/web/ask_relay.go` | split `askBearer` so a raw body is never parsed as a form; `askSend` with files (P10); `project()` keeps files |
| `internal/web/templates/partials/chat.html` | the files row in person bubbles; the composer's `data-*` words |
| `internal/look/static/ask.js` | hooks: send with files, the files-only submit, files in `addMessage`, P10 answers, the paste hand-off (P12) |
| `internal/look/static/ask-attach.js` | new: paperclip, picker, paste, drop, chips, progress, queue of two, retry, Remove, beacon, viewer, announcements |
| `internal/look/static/app.css` | chips, drop outline, files row, viewer sheet; light and dark |
| `internal/webtest/ask_files_test.go` | new |
| `internal/web/relay_internal_test.go` | `project()` keeps files |
| `internal/browsertest/attach_test.go` | new |
| `internal/browsertest/testdata/attach/` | `note.md` and `shot.png`; big and HEIC files made at run time |
| `docs/api/base-native-v1.md` | `can_attach`, message `attachments`, the routes |
| `internal/webtest/ask_native_contract_test.go` | pins the new fields |
| `native/apple/Sources/BaseKit/API/Models.swift`, `Ask/Thread.swift` | decode `attachments`; the names line (P9) |
| `docs/copy-pending.md` | the next free review number (13 at the time of writing): the strings |

## Task 1: the Equipo client and its fake learn files

- [ ] **Test first** (`internal/equipo/equipo_test.go`, against
  `equipotest`):
  - **`Upload`** sends the bytes, `Content-Type`, an RFC 5987
    `Content-Disposition` and the bearer, and no `Idempotency-Key`. It
    returns the `Attachment`.
  - **Refusals.** It maps `413 attachment_too_large`,
    `415 attachment_type`, `415 attachment_heic`, `413 attachment_pixels`
    and `409 attachment_limit` to an `*Error` with that `Code`.
  - **`Send`** with two IDs posts `attachments` in order. With none, the
    body is byte-identical to today's. A `409 attachments_unavailable` is
    `ErrAttachmentsUnavailable`.
  - **`OpenAttachment(…, preview)`** returns the response unread. A `404`
    is `ErrNotFound`.
  - **`DeleteAttachment`.** `204` and `404` are nil, and `409` is an
    `*Error`.
  - **Decoding.** `"can_attach": true` decodes into `Snapshot.CanAttach`,
    and messages decode their `attachments`.
- [ ] **Implement** in `chat.go`, with a `do` helper beside `call` for raw
  bodies and streamed answers. `call` is unchanged.
- [ ] **The fake** (`equipotest/chat.go`):
  - **`POST /api/v1/attachments`** works per bearer. It sniffs PNG and
    text, and refuses over 10 MiB, `image/heic`, and the 21st unsent file.
  - **`GET /api/v1/attachments/{id}[/preview]`** works per bearer: another
    person's file is `404`. `ServeHostile` makes it answer a set type and
    disposition (`text/html` inline, `image/svg+xml`).
  - **`DELETE /api/v1/attachments/{id}`.** Your own unsent upload is
    `204`; a sent one is `409 attachment_sent`; an unknown one is `404`.
  - **Send** accepts `attachments`: yours and unsent, at most 5, with empty
    text allowed when there are files. A replayed key is checked against
    the files too.
    - `FilesReady(false)` refuses files with
      `409 attachments_unavailable`.
    - `ExpireUploads()` makes the next send with files `422`.
  - **The snapshot** says `can_attach` from `FilesReady`, false by default.
  - **Messages and events** carry the files.
  - **`HoldNextUpload()`** holds one upload, as `HoldNextSnapshot` does.
- [ ] **Gate:** `make test vet fmt-check staticcheck`.

## Task 2: `POST /ask/attachments` (P1)

- [ ] **Test first** (`internal/webtest/ask_files_test.go`):
  - **A member's upload** reaches the fake with their bearer, name and
    type. The answer is `201` with the JSON and `Cache-Control: no-store`.
  - **Too big.** A declared length over 10 MiB is `413` before the body is
    read. So is a body over 10 MiB sent with no length. The fake sees no
    call in either case.
  - **Equipo's refusals** come back as `code`, with Equipo's status.
  - **Not ready.** Each Ask state that isn't ready is `409 {"state": …}`,
    as for the other writes.
  - **Other refusals.**
    - A cross-site `Origin` is refused by CSRF.
    - Signed out, JSON gets `401`.
    - A `401` from Equipo drops the link.
  - **A stalled body** (Fable B3): send headers and half a body, then
    stop. Within the read deadline (set short in the test), the request
    fails and its slot is free. Then four more uploads all succeed. The
    test goes through the whole router, so a middleware that hides the
    deadline fails it.
  - **A client gone mid-flight** (nit): with the upload held in the fake,
    the client gives up; once the fake answers, Base deletes the upload.
  - **Busy.** With 4 uploads held in the fake, a fifth waits, then gets
    `503` and `Retry-After`.
  - **The slot comes first.** A test hook records the slot count when the
    body read starts. It is never above 4 with 8 clients sending at once.
- [ ] **Implement:**
  - write `ask_files.go`;
  - split `askBearer` into the state check and the form parse;
  - mount the route in `askRoutes`.
- [ ] **Gate:** `make test`.

## Task 3: `GET /ask/attachments/{id}` and `/preview` (P3)

- [ ] **Test first:**
  - **Inline images.** A PNG streams `inline` with P3's headers. A preview
    has `max-age=3600` and `Vary: Cookie`, and an original has `no-store`.
  - **Downloads.** A CSV is an `attachment`, with `text/csv;
    charset=utf-8`.
  - **Hostile upstream** (Fable B4):
    - Equipo answering `text/html` with `inline` is served as a
      download;
    - `image/svg+xml` is served as an `application/octet-stream`
      download;
    - `/preview` for either is `404`.
  - **Streaming.** A 9 MiB file streams to the end from a fake that writes
    slowly, and the test reads as it comes.
  - **`404`, with no Equipo call:** another member's ID, and an ID that
    doesn't match `at_[a-z0-9]{8,60}`.
  - **`404`, never a redirect:** when Ask isn't connected.
  - **Upstream failures:**
    - a `401` drops the link and answers `404`;
    - a `500`, or a timeout, answers `502` with an empty body;
    - Equipo's error body never comes through.
  - **`HEAD`** works.
- [ ] **Implement:** `askAttachment(preview bool)` in `ask_files.go`.
- [ ] **Gate:** `make test`.

## Task 4: Remove and discard (P11, Fable B6)

- [ ] **Test first:**
  - **Remove.** `DELETE /ask/attachments/{id}` relays with the bearer and
    answers `204`. Equipo's `404` is `204` too. Equipo's
    `409 attachment_sent` is `409`.
  - **The slot is free.** After 20 uploads and one Remove, a 21st upload
    passes.
  - **Discard.** `POST /ask/attachments/discard` takes up to 5 `id`
    fields, deletes each, and answers `204` even when some fail. A
    malformed ID is skipped.
  - **CSRF** refuses a cross-site discard. A same-origin beacon (with
    `Sec-Fetch-Site: same-origin`) passes.
- [ ] **Implement:** `askDeleteAttachment` and `askDiscard`.
- [ ] **Gate:** `make test`.

## Task 5: sending with files (P8, P10, Fable B1 and B2)

- [ ] **Test first** (`ask_files_test.go`, and `TestAskFormsCarryKeys` and
  `TestAskSendRelaysWithBearer` extended):
  - **What sends.** `text` and two `attachments` relay in order.
    `attachments` with empty `text` sends.
  - **Base's own `422`s:** six files, a malformed ID, an empty message
    with no files, and text with a NUL or bad UTF-8 beside files (no
    `files` in the answer, and no call to Equipo).
  - **`FilesReady(false)`.** A send with files is
    `409 {"state":"ready","files":"unavailable"}`. Nothing in the link
    changes, and the page's state stays `ready`. A words-only send right
    after it is `201`.
  - **`ExpireUploads()`.** A send with files is
    `422 {"state":"ready","files":"stale"}`.
  - **Words only, refused.** Equipo's `409 runner_too_old` is still the
    `oldrunner` state, as today.
  - **Plain text** is unchanged: the fake sees no `attachments` key.
- [ ] **Implement** in `askSend`. When files were sent, map
  `ErrAttachmentsUnavailable`, `ErrRunnerTooOld` and Equipo's `422`
  before `askDone`.
- [ ] **Gate:** `make test`.

## Task 6: state, events and `can_attach`

- [ ] **Test first:**
  - **`relay_internal_test.go`.** A `message` event's `attachments`
    survive `project()`, with only P7's fields. An Equipo URL in an extra
    field never comes through.
  - **`webtest`.** `/ask/state` carries messages' `attachments`, and
    `"can_attach": true` only when the fake says so.
    `TestAskEventsRelay` carries a message with files.
  - **The native contract test** pins the new fields and routes.
- [ ] **Implement** in `chat.go` (the types), `ask.go` (`askView.CanAttach`
  and the state JSON) and `ask_relay.go` (`project()`).
- [ ] **Document** it in `docs/api/base-native-v1.md`.
- [ ] **Gate:** `make test`.

## Task 7: files in the thread, drawn by the server

- [ ] **Test first** (`webtest`, scripts off). A person message with an
  image and a CSV draws a files row:
  - **The image.** An `<a href="/ask/attachments/{id}">` around
    `<img src="/ask/attachments/{id}/preview" alt="{name}" width height>`.
  - **The CSV.** A pill `<a href="/ask/attachments/{id}" download>` with
    the name and the size in the member's locale ("1.2 MB", "820 KB").
  - **Files only.** A files-only message draws no empty text paragraph.
  - **No Equipo.** `TestAskNamesNoEquipo` still passes.
  - **The CSP** is unchanged.
- [ ] **Implement** in `chat.html`, with a size helper in the template funcs
  (rastrillo locales), and the CSS in `app.css` (light and dark).
- [ ] **Gate:** `make test`.

## Task 8: the composer, with script

- [ ] **Test first, browser** (`internal/browsertest/attach_test.go`, with
  `askBase`, `openPanel` and `FilesReady(true)`):
  - **The paperclip.** It shows in the panel and on the Ask page. With
    `FilesReady(false)` it doesn't, and drop and paste attach nothing.
  - **The picker.** Setting two files on the hidden input through CDP
    (`DOM.setFileInputFiles`) makes two chips that reach "done". The image
    chip then shows its thumbnail from `/ask/attachments/…/preview`.
  - **A PDF.** Its chip shows "Ask can't read PDFs yet" (D4), and it still
    sends.
  - **Paste** (P12, Fable B5 and B8):
    - a `DataTransfer` holding only a PNG `File` attaches it, and the field
      is unchanged;
    - one holding a PNG **and** `text/html` with a table pastes the table
      as Markdown and attaches nothing;
    - one holding a PNG and `text/plain` pastes the text and attaches
      nothing;
    - one holding a `.md` `File` and its own name as `text/plain` (a file
      copied in the Finder, as a browser may hand it over) attaches the
      file and types nothing;
    - one holding a PNG and `text/html` with only `<img>` (Copy Image in
      a browser) attaches it;
    - the existing paste tests pass unchanged.
  - **Drop.** `dragenter`, `dragover` and `drop` with a `File` attach it.
    The outline shows during the drag and goes after.
  - **Progress and Remove** (P11):
    - with `HoldNextUpload`, the chip shows the uploading word and a
      progress ring with `aria-valuenow`;
    - Remove during the upload aborts it;
    - Remove after it sends `DELETE` (seen in the fake);
    - a removed file is never sent.
  - **The queue** (Fable B3). Five files from one page reach the fake at
    most two at a time, and all five finish. A fake `503` with
    `Retry-After: 1` on the third is retried by itself and succeeds.
  - **Refusals:**
    - over 10 MiB, a sixth file, and a `.heic` are refused on the chip with
      no request;
    - `415 attachment_type` shows its words on the chip.
  - **Send:**
    - with chips uploading, Send waits, then sends once with the IDs in
      chip order;
    - files with no text send;
    - the chips clear on success;
    - a network failure keeps them, with "That didn't send. Try again."
  - **Send refused** (P10, Fable B1 and B2):
    - with `FilesReady` turned false after the paperclip showed, the send
      gives the "can't be read right now" line on the chips; the paperclip
      goes; Ask is not in its "needs an update" state; and Send after
      Remove sends the words;
    - with `ExpireUploads()`, the chips say "attach it again".
  - **Beacon.** On `pagehide` with two unsent chips, the fake sees both
    deleted.
    - **A send in flight** (B7): with the send held in the fake, `pagehide`
      deletes nothing, and the message lands with its files.
    - **Back/forward** (B7): a `pageshow` with `persisted` clears the
      chips, and the words stay.
  - **The thread.** The sent message shows thumbnails and pills from the
    `message` event, drawn like the server's.
  - **The viewer.**
    - Clicking a thumbnail opens the sheet with focus on Close.
    - Escape closes it and focus returns to the thumbnail.
    - Tab stays inside while it is open.
  - **Announcements.** The live region says when an upload finishes and
    when one is refused.
  - **The CSP.** The console shows no CSP violation through the whole test
    (the harness captures the console).
  - **Mobile width.** The chips scroll sideways, and the paperclip has a
    44 px target. Take a screenshot to `BASE_BROWSER_ARTIFACTS`.
- [ ] **Implement:**
  - write `ask-attach.js`;
  - add the `ask.js` hooks: `post()` appends `attachments`, so the key's
    signature includes them; the files-only submit; P10's answers; the
    paste hand-off; `addMessage` drawing the files row with the server's
    markup.
  - The words come from `data-*` attributes on the composer, written by
    `chat.html`.
- [ ] **Gate:** `make test` and `make browser` (`-run 'TestAsk'`).

## Task 9: turn failures in words (Fable B1)

- [ ] **Test first** (browser and webtest):
  - A failed turn with reason `attachment_unavailable`,
    `runner_storage_full` or `runner_too_old` shows its own line in the
    status. Without script, the status line shows it too.
  - Any other reason keeps "That didn't get an answer. Try again."
- [ ] **Implement** in `ask.js` `setTurn`, and in the no-script status line
  in `ask.go`.
- [ ] **Gate:** `make test` and `make browser` (`-run 'TestAsk'`).

## Task 10: the native apps show files as a line (P9)

- [ ] **Test first** (BaseKit tests):
  - A message JSON with `attachments` decodes, and so does one with an
    unknown `kind`.
  - A person bubble with files and text shows the names line under the
    text. A files-only bubble shows only the names.
- [ ] **Implement** in `Models.swift` and `Thread.swift`. Add the names
  line's accessibility label to `Localizable.xcstrings`.
- [ ] **Gate:** `make native-check`.

## Task 11: copy review, gates, hand-over

- [ ] **Copy review.** Add the rows to `docs/copy-pending.md` under the
  next free review number (13 at the time of writing; check again). Run
  the copy-review skill (`paulca/agent-skills` `copy-review`, `serve.sh`)
  for Luna's review, and check `result.json` before running it again.
  These are drafts. They reuse Equipo's approved words where they fit, and
  never name Equipo. Equipo's two new strings (its plan, P6) go in the same
  review.

  | Where | Text |
  |---|---|
  | Paperclip, label and tooltip | Attach files |
  | Drop outline | Drop files to attach them |
  | Chip, uploading | Uploading… |
  | Chip, Remove (label) | Remove {name} |
  | Chip, failed | Couldn't upload. Try again. |
  | Chip, sixth file | At most 5 files in one message. |
  | Chip, PDF (D4) | Ask can't read PDFs yet. |
  | Chip, files refused at send (P10) | Files can't be read right now. Remove them to send your message. |
  | Chip, stale (P10) | This file has expired. Attach it again. |
  | Refusal, too large | That file is over 10 MB. |
  | Refusal, type | Ask takes images (PNG, JPEG, WebP, GIF) and text, Markdown, CSV, JSON and PDF files. |
  | Refusal, HEIC | HEIC photos can't be read yet. Share it as a JPEG and try again. |
  | Refusal, pixels | That image is too large: at most 12,000 pixels on a side and 40 megapixels. |
  | Refusal, too many waiting | Too many files are waiting to send. Send or remove some first. |
  | Refusal, busy (after retries) | Too many uploads at once. Try again in a moment. |
  | Announcement, uploaded | {name} attached |
  | Announcement, refused | {name} not attached: {reason} |
  | Thread, files row (label) | Attached files |
  | Thread, pill (label) | {name}, {size}. Download |
  | Viewer, Close | Close (approved) |
  | Turn failed, file missing | A file didn't arrive whole. Attach it again. |
  | Turn failed, no room | There's no room left for these files. Try fewer or smaller ones. |
  | Turn failed, runner too old | Files can't be read right now. Send it again without them. |
  | Native, names line (label) | Attached: {names} |

- [ ] **Gates.** Run `make ci`, and the full `make browser` with
  `BASE_BROWSER_ARTIFACTS`. Put the outputs in the report. Known failures
  on main are listed in memory "Base review gates".
- [ ] **Review.** Get an independent review (Fable, else Codex Astra, with a
  self-contained prompt). Fix what it finds, and push.

## Task 12 (controller): merge and deploy, after Equipo

- [ ] **Wait for Equipo.** Equipo's Task 14 is done: production Equipo is
  live, and Paul's snapshot says `can_attach: true`.
- [ ] **Merge.** Paul approves the copy review. Then merge
  `feat/ask-attachments` to `main` on the hub.
- [ ] **Native first.** Release the native build with Task 10 (Mac Sparkle
  and TestFlight) before or with the web deploy (P9).
- [ ] **Deploy Base:** the usual `make release` and carlos deploy. Then
  `curl /api/version`, and restart if it is needed (memory "Calls gates
  report false green").
- [ ] **Check it live, as Paul:**
  - attach a screenshot and a `.md`, and ask about both;
  - copy a file in the Finder and paste it, in Chrome and in Safari (B8);
  - Copy Image in a browser and paste it (B8);
  - two messages later, ask about the `.md` again;
  - paste an image, and paste a table from Numbers;
  - remove a chip;
  - open the thumbnail;
  - check that the console shows no CSP errors.
- [ ] **Tell Paul.**

## Not in this plan

- The native attach UI (slice 2), and reading PDFs (slice 3).
- Files for jobs (R6), removing a sent file (R2), sealing the bytes (R8),
  and files into Oficina apps (R7).
