Native slice 2 part 1 plan, revision 2: answer Fable's plan review
Human
Prompt
Fable reviewed the part 1 plan: 1 blocker, 13 should-fix, 12 nits. Revise the plan (and spec §7 where affected) to answer B1 and every S1–S13, and take the cheap nits. Calls: B1 upload a requirement with no default, forwarded in SwappableTransport and tested through it; S3 kit on its own branch with its own Fable review, Base repin after; S2 a ≥90 s per-request upload timeout; S4 state hub CI's native gate honestly, check-native.sh once at the native tasks' end and before merge, swift test --filter while iterating; S5 the real mechanism for Mac paste/drop and iPhone image paste; S6 no discard on iPhone background; S8 prepare at most 2 at once; S9 cap busy retry at ~3 with backoff; S11 exact cache paths, name sanitising, NSFileProtectionComplete, sweeps on launch and foreground; S12 the 503s, failed Start, invites aligned with 7.4; S13 server lands and deploys first, rollback SHA and live /api/version check.
From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.
Summary
Plan revision 2: server tasks on their own branch, deployed first; the kit's upload as a no-default requirement on its own reviewed branch, forwarded through SwappableTransport; honest gates (hub CI's native step is the catalog only; check-native.sh twice); Mac paste via the Edit menu's Paste command and drop on the pane, with Equipo's editor as the fallback; iPhone image paste; discard only on end(); a shared two-at-a-time gate; capped busy retries; the cache's paths, protection and sweeps; and the JSON routes' 503s, failed Start and invite answer. Spec 7.4 to 7.6 amended to match. 22 tasks.
Agent notes
Task 17's Mac paste and drop mechanism is proven by hand in its first step; if either fails, Base adopts Equipo's NSTextView ComposerEditor and the plan's Review records it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+592
−350
docs/superpowers/plans/2026-11-28-native-slice2-part1.md+528 −332docs/superpowers/specs/2026-11-23-base-native-design.md+64 −18
CI failed — run details
CI log
=== build === CGO_ENABLED=0 go build ./... === vet === go vet ./... === fmt-check === === staticcheck === go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./... === govulncheck === go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./... No vulnerabilities found. === gitleaks === [90m7:05PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net [90m7:05PM[0m [32mINF[0m [1m1 commits scanned.[0m [90m7:05PM[0m [32mINF[0m [1mscanned ~2797239 bytes (2.80 MB) in 757ms[0m [90m7:05PM[0m [32mINF[0m [1mno leaks found[0m === budget === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size budget size: 22 directories within budget === script-test === scripts/prepare-apps_test.sh ok releases lookup failure stops before ship ok app owned elsewhere stops the script ok apps listing failure stops before create ok ambiguous release dir is refused ok explicit version resolves the ambiguity ok releases match is exact, not substring ok shipped version is only promoted, existing app not created ok fresh account creates, ships, promotes to edge, enables ok failing promote stops the script ok ship is retried while uploads are rate limited all passed hack/fonts_test.sh fonts_test: ok === test === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -count=1 ./... budget: internal/webtest took 13.008s, over the 10s the default allows receipt: test step 14.78s against a 60s target (the gate's other steps are not in this figure) receipt: 16 packages ran, 0 cached, 6 without tests, 0 failed receipt: slow package 13.008s amadan.net/oficina/base/internal/webtest receipt: slow package 1.339s amadan.net/oficina/base/internal/issuer receipt: slow package 773ms amadan.net/oficina/base/internal/operations receipt: slow package 664ms amadan.net/oficina/base/internal/equipo receipt: slow package 432ms amadan.net/oficina/base/internal/consumer receipt: slow test 1.56s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot receipt: slow test 1.22s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce receipt: slow test 750ms amadan.net/oficina/base/internal/issuer TestAuthorizeSignsForInstalledApp receipt: slow test 630ms amadan.net/oficina/base/internal/webtest TestAskUploadStalledBodyFreesItsSlot receipt: slow test 550ms amadan.net/oficina/base/internal/operations TestOperationsRefusals rastrillo: budget test: 1 problem(s) exit status 1 make: *** [Makefile:47: test] Error 1 amadan: step test failed: exit status 2 amadan: job failed at step test — its output is above, not at the tail of this log
diff --git a/docs/superpowers/plans/2026-11-28-native-slice2-part1.md b/docs/superpowers/plans/2026-11-28-native-slice2-part1.md| index f912995..a133a9f 100644 |
| --- a/docs/superpowers/plans/2026-11-28-native-slice2-part1.md |
| +++ b/docs/superpowers/plans/2026-11-28-native-slice2-part1.md |
| @@ -2,19 +2,33 @@ |
| > **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. Every task is tests first: write the failing test, see it fail, make it pass, then run the task's gate. |
| -**Goal:** In the Mac and iPhone apps, a person opens Store and People natively instead of on the web, folds the Apps section away (remembered for them on that device), and attaches files in Ask. That means the paperclip or `+`, Photos, Camera and Files, paste, drop, HEIC to JPEG on the device, chips, files in the sent bubble, and Quick Look. |
| - |
| -**Spec:** `docs/superpowers/specs/2026-11-23-base-native-design.md` §7, approved by Paul on 2026-11-28 with every recommendation. Part 1 is 7.4, 7.5 (Apps folding only) and 7.6. The files design (`2026-11-26-ask-attachments-design.md`) binds too: R1, R3, R5, D1 to D8. The mockups are `.superpowers/mockups/native-s2/` (git-ignored; `python3 build.py`), sections 3 and 4. |
| +**Revision 2** (2026-11-28) answers Fable's plan review |
| +(`.superpowers/sdd/2026-11-28-native-slice2/plan-review.md`): B1, S1 to |
| +S13, and the nits taken. "Review" at the end maps each finding to where it |
| +is answered. |
| + |
| +**Goal:** In the Mac and iPhone apps, a person opens Store and People |
| +natively instead of on the web, and folds the Apps section away (remembered |
| +for them on that device). They also attach files in Ask: |
| +- the paperclip or `+`, with Photos, Camera, Files and Paste; |
| +- paste and drop; |
| +- HEIC to JPEG on the device; |
| +- chips, files in the sent bubble, and Quick Look. |
| + |
| +**Spec:** `docs/superpowers/specs/2026-11-23-base-native-design.md` §7, approved by Paul on 2026-11-28 with every recommendation. |
| +- Part 1 is 7.4, 7.5 (Apps folding only) and 7.6. |
| +- The files design (`2026-11-26-ask-attachments-design.md`) binds too: R1, R3, R5, D1 to D8. |
| +- The mockups are `.superpowers/mockups/native-s2/` (git-ignored; `python3 build.py`), sections 3 and 4. |
| **Not in part 1:** notifications (part 2), decisions on the cards (part 3), "Made with Base" and opening documents (part 4). |
| **Architecture:** |
| -- **Base's server** gains five JSON routes beside the Store and People pages. They use the same builders and the same owner checks, behind the member gate and the native session. Nothing else changes on the server: the files routes are live (Base `07ec2ec`, `docs/api/base-native-v1.md` "Files"). |
| -- **rastrillo/native** gains one transport call for uploads. Uploads need a `Content-Disposition` header and upload progress, and the kit's `NativeHTTP` offers neither (`responseDetails` takes a path, method, body and content type only; `bb989a7`). Base repins. |
| +- **Base's server** gains five JSON routes beside the Store and People pages, using the same builders and owner checks behind the member gate. They land and deploy first, on their own branch: they add no words, so they don't wait for copy review. The files routes are already live (`07ec2ec`, `docs/api/base-native-v1.md` "Files"). |
| +- **rastrillo/native** gains `NativeHTTP.upload`. Uploads need `Content-Disposition`, upload progress and their own timeout, and the kit has none of these: `responseDetails` takes a path, method, body and content type only (`bb989a7`). The change goes on its own kit branch with its own review. Base then repins and forwards `upload` through `SwappableTransport`, the transport its client actually uses (`BaseSession.swift:286-305`). |
| - **The app (BaseKit)** gains: |
| - Store and People models and screens, shared by both platforms; |
| - the Apps fold; |
| - - `BaseKit/Attachments/`, copied from Equipo (R5) and then adapted to Base's relay and its rules (two uploads at a time, Remove deletes, busy is retried, D5, D8). |
| + - `BaseKit/Attachments/`, copied from Equipo (R5) and then adapted to Base's relay and rules. |
| **Tech stack:** as slice 1. |
| - **Server:** Go (`GOTOOLCHAIN=go1.26.11`, `CGO_ENABLED=0`), chi, rastrillo. |
| @@ -22,436 +36,618 @@ |
| **Repositories and branches:** |
| -| Repo | Tasks | Branch | |
| -|---|---|---| |
| -| **rastrillo/native** | 4 | `upload` from `origin/main` | |
| -| **Base** (this repo) | 1 to 3, 5 to 18 | `native/slice2-part1` from `origin/main`, after `design/native-slice2` (this plan) lands | |
| -| Controller | 19 | copy review (Luna, from 2026-12-02), deploy, release | |
| +| Repo | Tasks | Branch | Lands | |
| +|---|---|---|---| |
| +| **Base** | 1 to 4 | `api/store-people` from `origin/main` | First. Deployed in Task 4, before any app change | |
| +| **rastrillo/native** | 5 | `upload` from `origin/main` | After its own Fable review | |
| +| **Base** | 6 to 21 | `native/slice2-part1` from `origin/main`, once `design/native-slice2` (this plan) and `api/store-people` have landed | After the review (Task 21) and Luna's copy review (Task 22) | |
| +| Controller | 22 | copy review (Luna, from 2026-12-02), land, release | | |
| -**Equipo** needs no change. The code it lends is copied from origin/main `8bd40ed1`. |
| +**Equipo** needs no change. The code it lends is copied from origin/main `8bd40ed1`. Its attachment files are unchanged at `57f370c5` (Fable). |
| ## Machine hygiene (every task) |
| -- **One heavy job at a time.** Before any `swift test`, `swift build`, `snapshots.sh`, `check-native.sh` or a Go test run, check: |
| +- **One heavy job at a time.** Before any `swift test`, `swift build`, `build-iphone.sh`, `snapshots.sh`, `check-native.sh` or Go test run, check: |
| ``` |
| sysctl -n vm.loadavg; pgrep -fl 'xcodebuild|swift-(build|test)|xctest|go (test|build|vet)' |
| ``` |
| Wait while the 1-minute load is over 20, or while two or more heavy jobs from other sessions are running. |
| -- **Cap the job's parallelism:** |
| - - `go test -p 4`; |
| - - `swift test --package-path native/apple -j 4`; |
| - - `xcodebuild -jobs 4`, where the scripts pass it through. |
| +- **Cap the job's parallelism:** `go test -p 4`, `swift test -j 4`, `swift build -j 4`. Task 6 makes `check-native.sh` pass `-j 4` too. |
| - **Give every heavy command a timeout in minutes.** |
| -- **While iterating, run the narrowest test:** `go test -p 4 ./internal/webtest -run TestAPIStore`, or `swift test --package-path native/apple -j 4 --filter BaseKitTests.StoreModelTests`. |
| -- **Never run the whole Go suite or `make ci` locally.** That's hub CI's job. |
| -- **`check-native.sh` runs once per task, at the task's end. `snapshots.sh` runs only in tasks that change a picture.** |
| +- **Never run the whole Go suite or `make ci` locally.** |
| - **Simulators:** reuse the "Rastrillo Snapshots" simulator that `snapshots.sh` uses. Never create one. |
| ## Gates |
| | Gate | Command | When | |
| |---|---|---| |
| -| Go, narrow | `GOTOOLCHAIN=go1.26.11 go test -p 4 -count=1 ./internal/web ./internal/webtest -run '<tests>'` (timeout 10 min) | Tasks 1 to 3 | |
| -| Swift, narrow | `swift test --package-path native/apple -j 4 --filter '<suite>'` (timeout 15 min) | While iterating, every native task | |
| -| Native gate | `native/scripts/check-native.sh` (timeout 30 min): the catalog, every BaseKit test, BaseMac, and the iPhone Simulator build | End of every native task | |
| -| Screenshots | `native/scripts/snapshots.sh compare mac`, then `iphone` (timeout 20 min each). `record` only for pictures the task means to change; review the contact sheets beside the mockups before committing them | Tasks 7, 9, 14, 15, 16 | |
| -| Hub CI | push, then `AMADAN_HOME=$HOME/.amadan-claude-agent amadan ci status oficina/base -branch native/slice2-part1 -json` | After each pushed task | |
| - |
| -**Hub CI** runs `make ci` (Go) and `95-native` (`check-native.sh`, or `--core-only` off a Mac). It never runs the screenshots, which are exact only on the OS that drew them. Read its verdict before calling a task done; a pass means only that what it ran passed. |
| +| **Go, narrow** | `GOTOOLCHAIN=go1.26.11 go test -p 4 -count=1 ./internal/web ./internal/webtest -run '<tests>'` (timeout 10 min) | Tasks 1 to 3 | |
| +| **Swift, narrow** | `swift test --package-path native/apple -j 4 --filter '<suites>'` (timeout 15 min). It compiles the package for macOS only | Every native task, while iterating and at its end | |
| +| **iPhone compile** | `native/scripts/build-iphone.sh simulator` (timeout 20 min) | Tasks that touch `#if os(iOS)` code: 10, 11, 18, 19 | |
| +| **Native gate** | `native/scripts/check-native.sh` (timeout 40 min): the catalog, every BaseKit test, BaseMac, and the iPhone Simulator build | **Twice only:** after Task 12 (the big copy), and in Task 21 before asking for the merge | |
| +| **Screenshots** | `native/scripts/snapshots.sh compare mac`, then `iphone` (timeout 20 min each) | Tasks that change a picture: 9, 10, 11, 17, 18, 19, and once in Task 21. Use `record` only for pictures the task means to change, and review the contact sheets beside the mockups before committing them | |
| +| **Hub CI** | push, then `AMADAN_HOME=$HOME/.amadan-claude-agent amadan ci status oficina/base -branch <branch> -json` | After each push | |
| + |
| +**What hub CI proves (checked 2026-11-28 on `382e86c`).** |
| +- It runs `make ci`: build, vet, fmt, staticcheck, govulncheck, gitleaks, budget, script tests, and the whole Go suite. |
| +- Its native step is `check-native.sh --core-only`. Its log shows only "strings: … in the catalog" and "worktree-lib_test: ok". |
| +- So it checks the string catalog and nothing else native. **No Swift is compiled or tested on the hub.** |
| +- A green hub verdict proves the Go and the catalog. Swift is proven only by the local gates above, and each task's commit says which ran. |
| ## Plan decisions |
| -- **P1. Five JSON routes, from the pages' own builders.** |
| - - The routes: `GET /api/v1/store`, `POST /api/v1/store/{app}/install`, `POST /api/v1/store/{app}/uninstall`, `GET /api/v1/people`, `POST /api/v1/people`. |
| - - **Shared builders.** Task 1 moves the reading the pages do into `storeContent` and `peopleContent`, and the writing into `invitePerson`. The page and the JSON answer then can't drift, as with `homeContent` and `/api/v1/home`. |
| - - **Writes** take JSON (`{"email": …}`) or no body. They need the native session and `Origin`, as every write does (Base's CSRF check). Never a form. |
| -- **P2. Answers to writes:** |
| +- **P1. Five JSON routes, from the pages' own builders** (spec 7.4, as amended). |
| + - The routes: |
| + - `GET /api/v1/store` |
| + - `POST /api/v1/store/{app}/install` |
| + - `POST /api/v1/store/{app}/uninstall` |
| + - `GET /api/v1/people` |
| + - `POST /api/v1/people` |
| + - **Shared builders.** Task 1 moves the reading into `storeContent` and `peopleContent`, and the invite into `invitePerson`. |
| + - **Writes** take JSON or no body. They need a member's session (the native one or the web cookie: the same gate) and pass Base's CSRF check, which the kit's `Origin` satisfies. |
| +- **P2. Answers.** Every answer is `Cache-Control: no-store`. |
| | Route | Answers | |
| |---|---| |
| - | `POST /api/v1/store/{app}/install` | `202 {"store": Store}` (the store as it now stands, the app installing); `403 {"code":"owner_only"}`; `404 {"code":"unknown_app"}` | |
| - | `POST /api/v1/store/{app}/uninstall` | `200 {"store": Store}`; `409 {"code":"busy"}` while it installs; `403`; `404` | |
| - | `POST /api/v1/people` | `200 {"people": People}`; `422 {"code":"bad_email"}`; `502 {"code":"mail_failed"}` (invite again to retry, as on the web); `403 {"code":"owner_only"}` | |
| - |
| - Every answer is `Cache-Control: no-store`. |
| -- **P3. The app falls back to the web for an older server.** If `GET /api/v1/store` or `/people` answers `404` (a Base from before Task 2), the sidebar row opens the web page, as slice 1 does. The app can therefore ship before or after the server. |
| -- **P4. Store polls while installing,** every 2 s with the app in front. It stops when nothing is installing, or when the screen goes away. That matches the web's `<meta refresh content=2>`. |
| -- **P5. Folding is local.** `SidebarFolds` keeps the Apps section's state in `UserDefaults.standard`, keyed `base.fold.apps.<sha256(origin)[0..16]>.<memberID>`. That is per person and per device, never synced. It starts open. The web's `rail_expanded` (migration 0007) is its own. |
| -- **P6. The upload transport is a kit call (Task 4):** |
| + | `GET /api/v1/store` | `200 {owner, rows}`; `503 {"code":"unavailable"}` when the installs can't be read | |
| + | `POST …/install` | `202 {"store"}` with the app installing. An app already installing answers `202` and one already installed answers `200`; neither calls `Start`. When `Start` fails, the store is read again: if the row now shows installing or failed, `202` as it stands; otherwise `503 unavailable`, and nothing was claimed. Also `403 owner_only`, `404 unknown_app` | |
| + | `POST …/uninstall` | `200 {"store"}`, also when already uninstalled; `409 {"code":"busy"}`; `403`; `404`; `503` | |
| + | `GET /api/v1/people` | `200 {owner, people: [{id, initial, name, email, role}]}`. `role` is `owner`, `member` or `invited`, so there's no `joined`. `503` when members can't be read | |
| + | `POST /api/v1/people` | `200 {"person"}`: the person invited, or already here. Also `422 {"code":"bad_email"}`; `502 {"code":"mail_failed"}` (invite again to retry); `403 owner_only`; `415` for a non-JSON body; `503` | |
| + |
| +- **P3. The app falls back to the web for an older server.** If a Store or People read answers `404`, the sidebar row opens the web page, as slice 1 does. With the server deployed first (Task 4) this is only a guard. |
| +- **P4. Store polling.** |
| + - It polls every 2 s while a row is installing and the screen is showing. |
| + - It stops when nothing is installing, or when the screen goes away. |
| + - On an error it backs off: 2, 4, 8, then every 15 s. |
| + - On `401` it stops, and the session handles it. |
| +- **P5. Folding is local.** |
| + - `SidebarFolds` keys the Apps state in `UserDefaults.standard` on `base.fold.apps.<accountKey>`. |
| + - `accountKey` is `sha256(origin + "\n" + account id)`, first 16 bytes, hex. The account id is the one the session holds (`BaseSession.account`), so the state is right before `/api/v1/me` loads, and offline. |
| + - It starts open, and is never synced. |
| +- **P6. The kit's upload** (Task 5): |
| ```swift |
| - NativeHTTP.upload(_ path: String, body: Data, contentType: String, |
| - filename: String, maxBytes: Int, |
| - progress: @Sendable (Double) -> Void) async throws -> NativeResponse |
| + func upload(_ path: String, body: Data, contentType: String, filename: String, |
| + maxBytes: Int, progress: @escaping @Sendable (Double) -> Void) async throws -> NativeResponse |
| ``` |
| - - It sends `Content-Disposition: attachment; filename*=UTF-8''<percent-encoded>`, as Equipo's client does (`EquipoKit/API/Attachments.swift:21-22`). |
| - - It reports progress from `didSendBodyData`. |
| - - `ScriptedTransport` records the filename and the body size for tests. |
| - - It is a protocol requirement on `NativeTransport`, with a default that throws, so other apps' fakes still build. |
| -- **P7. What's copied from Equipo, and from which revision.** The copy is from Equipo origin/main `8bd40ed1`. Each copied file starts with a line naming its source path and that SHA. |
| - - **Copied as they are:** |
| - - `native/share/Sources/EquipoShareCore/AttachmentFile.swift` and `FileAttachment.swift`: type sniffing, HEIC, HEIF and TIFF to JPEG, a 2560 px long edge, and the regular-file checks; |
| - - `EquipoKit/Attachments/AttachmentViews.swift`: the chips, the bubble's thumbnails and the preview; |
| - - `PhoneAttachmentPicker.swift`; |
| - - `EquipoMac/MacComposer.swift`'s paste and drop part, and `AttachmentPromises.swift`. |
| - - **Copied and then changed** (Task 12): `AttachmentDraft.swift` and the `Attachments.swift` client. |
| - - **Not copied:** `RecentScreenshot.swift` (spec 7.6: it needs Photos permission), `ShareFixture.swift`, and the share extension. |
| - - **Tests** are copied with their code: `AttachmentTests`, `AttachmentReviewTests`, `MacAttachmentTests`, and the fixtures under `Fixtures/attachments`. |
| + - It is a `NativeTransport` requirement with **no default** (B1). A conformer that doesn't forward it fails to compile. |
| + - It sends `Content-Length`; Base answers `411` without it. |
| + - It sends `Content-Disposition: attachment; filename*=UTF-8''<percent-encoded>`, as Equipo does (`EquipoKit/API/Attachments.swift:21-22`). |
| + - It sets `URLRequest.timeoutInterval = 90` on the upload only. The session's 30 s default stays for everything else. Base waits up to 10 s for a slot and 60 s for Equipo (S2). |
| + - Progress comes from `didSendBodyData`, and only grows. |
| + - `maxBytes` bounds the response body. |
| + - It returns any status, with headers. `401` handling is the caller's (S1). |
| +- **P7. What's copied from Equipo, file by file** (from origin/main `8bd40ed1`; each copy starts with a line naming its source path and SHA): |
| + |
| + | Equipo file | Base file | How | |
| + |---|---|---| |
| + | `native/share/Sources/EquipoShareCore/AttachmentFile.swift` | `Attachments/AttachmentFile.swift` | copied, then gains `convertedFrom` (the "from HEIC" line) and a size check before reading (Tasks 14, 16) | |
| + | `native/share/Sources/EquipoShareCore/FileAttachment.swift` | `Attachments/FileAttachment.swift` | as it is | |
| + | `EquipoKit/Attachments/AttachmentDraft.swift` | `Attachments/AttachmentDraft.swift` | copied, then Base's rules (Tasks 14, 15) | |
| + | `EquipoKit/Attachments/AttachmentViews.swift` | `Attachments/AttachmentViews.swift` | copied. Its full-size preview is deleted in Task 19, where Quick Look replaces it | |
| + | `EquipoKit/Attachments/PhoneAttachmentPicker.swift` | `Attachments/PhoneAttachmentPicker.swift` | copied without the screenshot rows (`RecentScreenshot` isn't copied) | |
| + | `EquipoMac/AttachmentPromises.swift` | `Attachments/AttachmentPromises.swift` | as it is | |
| + | `EquipoMac/MacComposer.swift` (only `accepts(_:)` and the pasteboard reading `onAttachments` does) | `Attachments/MacPasteboard.swift` | the reading only. `ComposerEditor`, the `NSTextView` subclass, isn't copied; Task 17 says why | |
| + | `EquipoKit/Attachments/AttachmentsFixture.swift`, `EquipoMac/MacAttachmentsFixture.swift` | `Tests/BaseSnapshots/AttachmentFixtures.swift` | adapted: draft items and sent messages with images generated in code, no session, no network | |
| + | Tests: `AttachmentTests`, `AttachmentReviewTests`, `MacAttachmentTests` | `Tests/BaseKitTests/` | copied | |
| + |
| + - **Not copied on purpose:** |
| + - `AttachmentFollowupTests` and `AttachmentHTTPTests`, which test Equipo's own transport; |
| + - `RecentScreenshot.swift`, which needs Photos permission (spec 7.6); |
| + - `ShareFixture.swift` and the share extension. |
| + - Equipo's `Fixtures/attachments/large.webp` is copied. Larger fixtures are generated in tests, never committed. |
| - **P8. Where Base differs from Equipo's native files code:** |
| - 1. **Remove deletes the upload** (`DELETE /ask/attachments/{id}`, D6). Equipo's `remove` only cancels (`AttachmentDraft.swift:53`). |
| - 2. **Uploads go two at a time, in order.** A `503 busy` is retried by itself after `Retry-After`. Equipo starts every upload at once. |
| - 3. **Unsent uploads are discarded** (`POST /ask/attachments/discard`, up to five ids a call) when the person signs out, switches account, or quits. On iPhone, also when the scene goes to the background with chips still unsent. This is best effort; Equipo's 24-hour drop catches the rest. |
| - 4. **The paperclip and `+` show only while `can_attach`** (`/ask/state`; `AskSnapshot` gains it). |
| - 5. **D5:** |
| - - A send refused with `409 files:"unavailable"` keeps Ask ready, drops `can_attach`, marks every chip with the web's words, and lets the words go alone. |
| + 1. **Remove deletes the upload** (`DELETE /ask/attachments/{id}`, D6). A `409 attachment_sent` means it went with a message: the chip just goes, with nothing shown or announced. Remove is disabled while a send is in flight. |
| + 2. **Two at a time, preparing and uploading.** One gate admits two files at once from preparing through to their upload's answer, in order (S8). |
| + 3. **Busy is retried three times.** A `503 busy` is retried after `max(Retry-After, 2 s / 4 s / 8 s)`. The ring restarts at 0 on each try. After the third, the chip shows "Too many uploads at once. Try again in a moment." with Retry (S9). |
| + 4. **Discard only when the session ends** (S6, S7). |
| + - `BaseSession.end()` captures the old client before clearing it, and starts a best-effort `POST /ask/attachments/discard` (five ids a call), bounded at 2 s. It never holds up `end()`. |
| + - `end()` covers the Sign out button, an account switch, a rejected session, and the kit's step change. When another Oficina app signed the ID out, the session is gone first and the discard fails silently. |
| + - Nothing is discarded on background or quit. Equipo's 24-hour drop catches those and a killed app. |
| + 5. **Uploads survive the background.** |
| + - On iPhone an upload in flight runs inside `beginBackgroundTask`, so it can finish. |
| + - If its answer is lost, the chip shows Retry. A retry is a second upload, since the route takes no key, so the orphan may count against the 20 for a day. That is accepted. |
| + 6. **The paperclip and `+` show only while `can_attach`** (`AskSnapshot` gains it). |
| + 7. **D5.** |
| + - `409 files:"unavailable"` on send keeps Ask ready, drops `can_attach`, and marks every chip with the web's words. The words can then be sent alone. |
| - `422 files:"stale"` marks the chips "This file has expired. Attach it again." |
| - 6. **D8 on paste:** if the pasteboard holds any text beyond the files' own names, the text is pasted (through `PasteMarkdown`, as now). Otherwise its images and files are attached. |
| - 7. **The refusal words are Base's** (the web's, copy review 13), keyed by Equipo's codes: `attachment_too_large`, `_type`, `_heic`, `_pixels`, `_limit`, `busy`. |
| -- **P9. Opened files live in the app's cache** (7.9, 12). |
| - - The folder is `Caches/Attachments/<account>/`, with `isExcludedFromBackup` set, files `0600`. |
| - - Originals come from `GET /ask/attachments/{id}` through the kit's `download(_:to:)`. |
| - - Previews come from `/preview` (bounded at 2 MiB) into an in-memory cache of 64 items. |
| - - The folder is cleared on sign-out, and anything older than 14 days is cleared at launch. |
| - - The 14-day sweep reads file dates, so `PrivacyInfo.xcprivacy` gains `NSPrivacyAccessedAPICategoryFileTimestamp` with reason `C617.1`. |
| -- **P10. Camera** needs `NSCameraUsageDescription` in `ios/project.yml`. Photos goes through `PhotosPicker`, which needs no permission. Files goes through `fileImporter`. On the Mac, `fileImporter` (multiple selection) takes the nine types plus HEIC, HEIF and TIFF, which become JPEG. |
| + 8. **D8:** text on the pasteboard beyond the files' own names is pasted as text (through `PasteMarkdown`, as now). Otherwise its images and files are attached. |
| + 9. **The refusal words are the web's** (copy review 13), keyed by code: `attachment_too_large`, `_type`, `_heic`, `_pixels`, `_limit`, `busy`. |
| + - A plain-text `400`, which is Base's body deadline on a slow link, shows the web's "Couldn't upload. Try again." with Retry. |
| +- **P9. The cache** (spec 7.6 and 7.9, 12, as amended; S11): |
| + - **Path:** `FileManager.urls(.cachesDirectory)/Attachments/<accountKey>/<attachment id>/<name>`. |
| + - `accountKey` is P5's. |
| + - `<attachment id>` is checked against `[A-Za-z0-9_-]{1,64}`. |
| + - `<name>` is the server's name reduced to its last path component, with `/`, `\`, NUL, a leading `.` and `..` removed, and cut to 120 bytes. Its extension is replaced with the media type's (`UTType(mimeType:).preferredFilenameExtension`; `bin` when unknown). |
| + - **Protection:** each file `0600`, excluded from backup, and on iOS written with `NSFileProtectionComplete`. |
| + - **One download per id at a time:** an actor holds the in-flight tasks, and a second tap awaits the first. |
| + - **Dates:** at download, the file's modification date is set to the message's `created_at`. The sweep removes anything dated more than 14 days ago. |
| + - **The sweep** also removes the folders of accounts not signed in now. It runs at launch, on every scene going active, when the Mac window opens, and on a daily timer while the Mac app runs. |
| + - **Cleared** on `end()` and when Ask is disconnected (`AskModel` sees `disconnected`). |
| + - **Previews** go in a 64-item memory cache, bounded at 2 MiB each. |
| + - **Privacy manifest:** the sweep reads file dates, so `PrivacyInfo.xcprivacy` gains `NSPrivacyAccessedAPICategoryFileTimestamp` with reason `C617.1`. |
| +- **P10. Camera, Photos and Files.** |
| + - **Camera** needs `NSCameraUsageDescription` in `ios/project.yml`. |
| + - **Photos** goes through `PhotosPicker` (`matching: .images`, which gives a Live Photo's still). Each item is loaded as a file through a `FileRepresentation` transferable, never as `Data`, so its size is checked before reading. |
| + - **Files** goes through `fileImporter`. |
| + - **On the Mac,** `fileImporter` takes the nine types plus HEIC, HEIF and TIFF. |
| + - **Before reading:** |
| + - a non-image file over 10 MiB is refused from its size alone; |
| + - an image over 128 MiB is refused. |
| + - **Names:** Camera and Photos items are named `Photo 1.jpg`, `Photo 2.jpg`, … in the order chosen, so "Remove Photo 2.jpg" says which one. |
| - **P11. Strings.** |
| - - Words the web already has keep the web's approved text, under native keys (copy review 13, `chat.html` `data-w-*`, Store and People templates). |
| - - New words are drafted in the catalog with a `DRAFT` comment, and listed in `copy-review/slice2-part1.json` in the main checkout (git-ignored), for Luna from 2026-12-02. |
| - - `check-strings.py`'s `WAITING` holds nothing new. |
| - - The release (Task 19) waits for the review. Building doesn't. |
| + - Words the web already has keep the web's approved text, under native keys. |
| + - New words are drafted with a `DRAFT 2026-11-28` comment and listed in `copy-review/slice2-part1.json` (main checkout, git-ignored) for Luna from 2026-12-02. |
| + - The release waits for that review. Building and the internal TestFlight build don't. |
| +- **P12. Version numbers.** |
| + - The mid-branch internal TestFlight build for the device check is **0.1.3 (4)**, for Paul only. |
| + - The release is **0.1.3 (5)**, Mac and TestFlight. |
| ## File map |
| ``` |
| -internal/web/store.go storeContent (moved out of storePage) |
| -internal/web/people.go peopleContent, invitePerson (moved out of people, invite) |
| -internal/web/api_team.go NEW: apiStoreRead, apiStoreInstall, apiStoreUninstall, apiPeopleRead, apiPeopleInvite |
| -internal/web/app.go five routes beside /api/v1/home |
| -internal/webtest/api_team_test.go NEW |
| -docs/api/base-native-v1.md "Store" and "People" sections |
| - |
| -native/apple/Sources/BaseKit/ |
| - API/Client.swift API/Models.swift store, people, uploads, can_attach |
| - Team/StoreModel.swift Team/StoreView.swift Team/PeopleModel.swift Team/PeopleView.swift NEW |
| - Home/SidebarFolds.swift NEW |
| - Home/BaseActions.swift own apps routed natively |
| - Mac/MacMainView.swift MacPane (ask | store | people), Apps fold |
| - Phone/PhoneAskScreen.swift AppsSheet: Apps fold, "Your team", NavigationStack |
| - Attachments/ NEW: AttachmentFile, FileAttachment, AttachmentDraft, |
| - AttachmentViews, PhoneAttachmentPicker, MacAttach, |
| - AttachmentPromises, AttachmentCache, QuickLook |
| - Ask/Composer.swift Ask/Thread.swift Ask/AskModel.swift Ask/PasteMarkdown.swift |
| +Base, api/store-people |
| + internal/web/store.go people.go storeContent, peopleContent, invitePerson |
| + internal/web/api_team.go NEW: the five handlers |
| + internal/web/app.go the routes beside /api/v1/home |
| + internal/web/team_internal_test.go NEW |
| + internal/webtest/api_team_test.go NEW |
| + docs/api/base-native-v1.md "Store" and "People" |
| + |
| +rastrillo/native, upload |
| + Sources/RastrilloApple/NativeHTTP.swift NativeTransport.swift |
| + Sources/RastrilloTestSupport/ScriptedTransport.swift |
| + Tests/RastrilloAppleTests/NativeHTTPUploadTests.swift NEW |
| + APPLE.md |
| + |
| +Base, native/slice2-part1 (native/apple/Sources/BaseKit unless shown) |
| + Session/BaseSession.swift SwappableTransport.upload; end() discards and clears the cache |
| + API/Client.swift API/Models.swift store, people, files, can_attach |
| + Team/StoreModel StoreView PeopleModel PeopleView .swift NEW |
| + Home/SidebarFolds.swift NEW; Home/BaseActions.swift |
| + Mac/MacMainView.swift MacPane, the Apps fold, the drop target |
| + Phone/PhoneAskScreen.swift AppsSheet: the fold, "Your team", NavigationStack |
| + Attachments/ (P7's files, and NEW: AttachGate, AttachIntake, AttachmentCache, QuickLook) |
| + Ask/Composer.swift Thread.swift AskModel.swift PasteMarkdown.swift |
| + ../BaseMac/BaseMacApp.swift the Paste command (Task 17) |
| Resources/Localizable.xcstrings |
| -native/apple/Tests/BaseKitTests/ StoreModelTests PeopleModelTests SidebarFoldsTests |
| - Attachment*Tests AttachmentCacheTests ClientTests (more) |
| -native/apple/Tests/BaseSnapshots/ TeamSnapshots.swift; AskSnapshots (chips, bubbles) |
| -native/ios/project.yml NSCameraUsageDescription |
| -native/PrivacyInfo.xcprivacy FileTimestamp C617.1 |
| + native/ios/project.yml native/PrivacyInfo.xcprivacy native/scripts/check-native.sh (-j 4) |
| + Tests/BaseKitTests/… Tests/BaseSnapshots/TeamSnapshots.swift AttachmentFixtures.swift AskSnapshots.swift |
| ``` |
| --- |
| -## Task 1: Store and People builders, shared |
| +## Part A: the server (branch `api/store-people`) |
| + |
| +### Task 1: Store and People builders, shared |
| -**Files:** `internal/web/store.go`, `internal/web/people.go`. Existing tests: `internal/webtest/store_test.go` and `people_test.go`. |
| +**Files:** `internal/web/store.go`, `people.go`, `team_internal_test.go` (new). |
| -- [ ] Write `internal/web/team_internal_test.go`. |
| - - `storeContent` returns a row per catalogue entry, with the install state and error, `owner`, and `installing`. |
| - - `peopleContent` returns a row per member, with `initial`, `name`, `email`, `role` (`owner` | `member` | `invited`) and `joined`. |
| - - `invitePerson` returns `inviteOK`, `inviteBadEmail` or `inviteMailFailed`, sends the invitation only until one is delivered, and changes nothing for an address already here. |
| -- [ ] Move the reads out of `storePage` and `people`, and the write out of `invite`, into those three functions. The pages render from them, with unchanged output. |
| +- [ ] **Tests first:** |
| + - **`storeContent`:** a row per catalogue entry, with its state and error, plus `owner` and `installing`. A failed read is an error. |
| + - **`peopleContent`:** a row per member, with `initial`, `name`, `email` and `role`. |
| + - **`invitePerson`:** returns `inviteOK` with the member, or `inviteBadEmail` or `inviteMailFailed`. |
| + - It sends only until one invitation has been delivered. |
| + - An address already here sends nothing and answers that member. |
| +- [ ] Move the reads out of `storePage` and `people`, and the write out of `invite`. The pages render the same. |
| - [ ] **Gate:** `go test -p 4 -count=1 ./internal/web -run 'TestStoreContent|TestPeopleContent|TestInvitePerson'` and `./internal/webtest -run 'TestStore|TestPeople|TestInvite'`. The existing page tests pass unchanged. |
| -## Task 2: `GET /api/v1/store` and `GET /api/v1/people` |
| - |
| -**Files:** `internal/web/api_team.go` (new), `internal/web/app.go`, `internal/webtest/api_team_test.go` (new), `docs/api/base-native-v1.md`. |
| - |
| -- [ ] **Tests first, in `api_team_test.go`, with `newHomeApp`, `link` and `nativeSignIn` (`native_test.go`):** |
| - - **`TestAPIStore`:** the owner gets the following, `no-store`, `application/json`: |
| - ``` |
| - {"owner": true, "rows": [{id, name, summary, tint, icon_svg, state, error}]} |
| - ``` |
| - - in catalogue order; |
| - - an installing app reads `installing`; |
| - - a failed one reads `failed` with its error; |
| - - a member who isn't the owner gets `"owner": false`. |
| - - **`TestAPIPeople`:** |
| - ``` |
| - {"owner": bool, "people": [{id, initial, name, email, role, joined}]} |
| - ``` |
| - The owner, a joined member and an invited address, in the page's order. |
| +### Task 2: The reads |
| + |
| +**Files:** `internal/web/api_team.go` (new), `app.go`, `internal/webtest/api_team_test.go` (new), `docs/api/base-native-v1.md`. |
| + |
| +- [ ] **Tests first** (`newHomeApp`, `link`, `nativeSignIn`, `nativeGet` from `native_test.go`): |
| + - **`TestAPIStore`:** P2's shape, `no-store`, `application/json`, in catalogue order. |
| + - Installing, installed and failed rows, the failed one with its error. |
| + - A member who isn't the owner gets `"owner": false`. |
| + - A failing installs read gets `503 unavailable`. |
| + - **`TestAPIPeople`:** the owner, a member and an invited address, with their roles, in the page's order. A web-cookie session gets the same answer (nit 4). |
| - **`TestAPITeamRefusesWithoutSession`:** `401 {"code":"unauthenticated"}` with no session, and for a removed member. |
| -- [ ] Implement both reads in `api_team.go` from Task 1's builders, and route them beside `/api/v1/home`. |
| -- [ ] **Docs:** add "Store" and "People" to `docs/api/base-native-v1.md`, with the shapes above. |
| + - **`TestAPIPeopleHasNoRemove`:** `DELETE /api/v1/people/<id>` is not 2xx (404 or 405), and the member is still there. |
| +- [ ] Implement both reads, and route them beside `/api/v1/home`. |
| +- [ ] **Docs:** "Store" and "People" in `base-native-v1.md`, from P2. |
| - [ ] **Gate:** `go test -p 4 -count=1 ./internal/webtest -run 'TestAPIStore|TestAPIPeople|TestAPITeam'`. |
| -## Task 3: The Store and People writes |
| +### Task 3: The writes |
| -**Files:** `internal/web/api_team.go`, `internal/web/app.go`, `internal/webtest/api_team_test.go`, `docs/api/base-native-v1.md`. |
| +**Files:** `internal/web/api_team.go`, `app.go`, `internal/webtest/api_team_test.go`, `docs/api/base-native-v1.md`. |
| - [ ] **Tests first:** |
| - - **`TestAPIStoreInstall`:** for the owner, `202` with the app `installing`, and the installer's `Start` called once. A member gets `403 owner_only`. An unknown app gets `404 unknown_app`. A request without `Origin` gets `403` (CSRF). |
| - - **`TestAPIStoreUninstall`:** `200` with the app gone from `installed`. `409 busy` while it installs (an installer that answers `install.ErrBusy`). An app already uninstalled gets `200`. |
| + - **`TestAPIStoreInstall`:** |
| + - the owner gets `202` with the row installing, and `Start` is called once; |
| + - an app already installing gets `202`, and one already installed gets `200`, with `Start` not called; |
| + - a `Start` that fails having claimed the install (the row reads failed) gets `202`; |
| + - a `Start` that fails having claimed nothing gets `503`; |
| + - a member gets `403 owner_only`, and an unknown app `404 unknown_app`; |
| + - no `Origin` gets `403` (CSRF). |
| + - **`TestAPIStoreUninstall`:** `200`; `409 busy` (an installer answering `install.ErrBusy`); `200` when already uninstalled; `403`; `404`. |
| - **`TestAPIPeopleInvite`:** |
| - - the owner gets `200` and the invitation is sent once (`capturingMailer`); |
| - - inviting the same address again sends nothing; |
| - - `{"email":"not an address"}` gets `422 bad_email`; |
| - - a failing mailer gets `502 mail_failed`, and a second invite sends again; |
| - - a member gets `403 owner_only`; |
| - - a form body gets `415`. |
| -- [ ] Implement the three writes. The JSON body is bounded at 4 KiB. |
| -- [ ] **Docs:** write P2's table into `base-native-v1.md`. |
| -- [ ] **Gate:** `go test -p 4 -count=1 ./internal/webtest -run 'TestAPIStore|TestAPIPeople'`. Push, and read hub CI (the whole Go suite runs there). |
| - |
| -## Task 4 (rastrillo/native): `NativeHTTP.upload` |
| - |
| -**Files (rastrillo/native):** |
| -- `Sources/RastrilloApple/NativeHTTP.swift` and `NativeTransport.swift`; |
| -- `Sources/RastrilloTestSupport/ScriptedTransport.swift`; |
| -- `Tests/RastrilloAppleTests/NativeHTTPUploadTests.swift` (new); |
| -- `APPLE.md`. |
| + - the owner gets `200 {"person"}`, sent once (`capturingMailer`); |
| + - the same address again sends nothing, and gets `200` with that member; |
| + - an address that isn't one gets `422 bad_email`; |
| + - a failing mailer gets `502 mail_failed`, then a second invite sends; |
| + - a member gets `403`; |
| + - a form body gets `415`; |
| + - a body over 4 KiB gets `413`. |
| +- [ ] Implement them. |
| +- [ ] **Docs:** P2's table. |
| +- [ ] **Gate:** `go test -p 4 -count=1 ./internal/webtest -run 'TestAPIStore|TestAPIPeople'`. Push, and read hub CI, which runs the whole Go suite. |
| + |
| +### Task 4: Land and deploy the server |
| + |
| +- [ ] Ask for a short review of `api/store-people` (Fable, or Codex Astra when Fable is limited) and answer it on the branch. Then land it on main through the hub, and read hub CI on main. |
| +- [ ] **Note the rollback SHA:** the release now live on `base.oficina.works` (`curl -sS -D - -o /dev/null https://base.oficina.works/api/version | grep -i x-carlos-version`). Write it in the branch handoff. |
| +- [ ] **Deploy** as the Base runbook does: account `bds`, app `base`, release and promote. Restart if the promote needs it, since "live" can mean the old process. |
| +- [ ] **Confirm:** |
| + - `x-carlos-version` shows the new release; |
| + - `curl -s https://base.oficina.works/api/v1/store` answers `401 {"code":"unauthenticated"}`, not `404`, which proves the route is there. |
| +- [ ] **The lagged team:** check whether it runs a Base (`carlos instances list --app base` on its account). This deploy is Paul's Base only. A lagged rollout waits for Paul. |
| +- [ ] **Rollback,** if needed: promote the noted SHA, then check `/api/version` again. |
| + |
| +## Part B: the kit (rastrillo/native, branch `upload`) |
| + |
| +### Task 5: `NativeHTTP.upload` |
| + |
| +**Files:** `Sources/RastrilloApple/NativeHTTP.swift`, `NativeTransport.swift`, `Sources/RastrilloTestSupport/ScriptedTransport.swift`, `Tests/RastrilloAppleTests/NativeHTTPUploadTests.swift` (new), `APPLE.md`. |
| + |
| +- [ ] **Tests first,** with a `URLProtocol` stub that captures the request: |
| + - `POST`, the body, `Content-Type`, and `Content-Length` equal to the body's size; |
| + - `Content-Disposition` is `attachment; filename*=UTF-8''…`, with `é`, spaces, `"`, `/` and `;` percent-encoded; |
| + - the request's `timeoutInterval` is 90, and a `responseDetails` request's is still the session default; |
| + - progress only grows and ends at 1.0; |
| + - `413`, `503` (with `Retry-After`) and `401` come back as a `NativeResponse` with their headers, never thrown; |
| + - a response over `maxBytes` throws; |
| + - cancelling the task cancels the upload. |
| + - `ScriptedTransport.upload` records the filename and the body's size. |
| +- [ ] **Implement it** with a `URLSessionUploadTask` and a task delegate, reusing `makeRequest` and `BoundedBody`. |
| + - It is a requirement with **no default** (B1). |
| + - Every in-repo conformer forwards or implements it: `NativeHTTP`, `ScriptedTransport`, and any in the kit's tests. |
| + - `APPLE.md` says that an app's own wrapping transport must forward it, naming Base's `SwappableTransport` as the example. |
| +- [ ] **Gate:** in rastrillo/native, `swift test -j 4 --filter NativeHTTPUploadTests`, then that repo's native gate once. |
| +- [ ] **Review:** ask Fable to review the `upload` branch (Codex Astra if Fable is limited), with this task and P6 as the brief. Answer every finding, then land it on rastrillo/native main and note the SHA. |
| + |
| +## Part C: the app (branch `native/slice2-part1`) |
| + |
| +### Task 6: Repin, and forward `upload` through `SwappableTransport` |
| + |
| +**Files:** `native/apple/Package.swift`, `native/ios/project.yml` (`RastrilloNative.revision`), `Session/BaseSession.swift`, `Tests/BaseKitTests/SessionTests.swift`, `native/scripts/check-native.sh`. |
| - [ ] **Tests first:** |
| - - the upload sends `POST`, the body and `Content-Type`; |
| - - `Content-Disposition` is `attachment; filename*=UTF-8''…`, with `é`, spaces and `"` percent-encoded; |
| - - progress reaches `1.0` and only grows; |
| - - a `413` or `503` comes back as a `NativeResponse` with its headers (`Retry-After`), never thrown; |
| - - cancelling the task cancels the upload; |
| - - a `401` calls `sessionRejected()`, as `responseDetails` does. |
| - - `ScriptedTransport` records `filename` and the body's size. |
| -- [ ] Implement it with a `URLSessionUploadTask` and a delegate, reusing `makeRequest` and `BoundedBody`. Add it as a `NativeTransport` requirement, with a default that throws `NativeClientError.message("Uploads aren't supported.")`. |
| -- [ ] **Gate:** `swift test -j 4 --filter NativeHTTPUploadTests` in rastrillo/native, then that repo's own native gate once. |
| -- [ ] **Land it on rastrillo/native main**, and note the SHA. In Base, bump `native/apple/Package.swift` and `ios/project.yml` (`RastrilloNative.revision`) to it, and run Base's `check-native.sh` once. |
| + - `SwappableTransport.upload` reaches the current inner transport; |
| + - after `swap(_:)`, the next upload reaches the new one; |
| + - an upload started before a swap finishes on the transport it started on. |
| +- [ ] Bump the kit to Task 5's SHA, and add `SwappableTransport.upload`. Without it the package doesn't compile, which is the point. |
| +- [ ] `check-native.sh` passes `-j 4` to `swift test` and `swift build`. |
| +- [ ] **Gate:** `swift test --package-path native/apple -j 4 --filter BaseKitTests.SessionTests`, then `build-iphone.sh simulator`. |
| -## Task 5: The client for Store and People |
| +### Task 7: The client for Store and People |
| -**Files:** `native/apple/Sources/BaseKit/API/Models.swift`, `API/Client.swift`, `Tests/BaseKitTests/ClientTests.swift`, `Fixtures/store.json`, `Fixtures/people.json`. |
| +**Files:** `API/Models.swift`, `API/Client.swift`, `Tests/BaseKitTests/ClientTests.swift`, `Fixtures/store.json`, `Fixtures/people.json`. |
| - [ ] **Tests first (`ScriptedTransport`):** |
| - - `store()` decodes the fixture; |
| - - `install(app:)` posts to `/api/v1/store/contra/install` with `Origin`, and decodes the `202`; |
| - - `uninstall(app:)` maps `409 busy` to `BaseAPIError.refused("busy")`; |
| - - `people()` decodes; |
| - - `invite(email:)` posts JSON, and maps `422 bad_email` and `502 mail_failed`; |
| - - a `404` on either read maps to `.notOnThisBase`, which P3 turns into the web fallback. |
| -- [ ] Add `StoreData`, `StoreRow` (with its `State` enum), `PeopleData`, `Person`, and the five client calls. |
| -- [ ] **Gate:** `swift test --package-path native/apple -j 4 --filter BaseKitTests.ClientTests`. |
| + - `store()` and `people()` decode; |
| + - `install(app:)` and `uninstall(app:)` post with `Origin`, and decode the store; |
| + - `busy`, `owner_only`, `unknown_app` and `unavailable` map to `BaseAPIError` cases; |
| + - `invite(email:)` posts JSON and decodes `{"person"}`; `bad_email` and `mail_failed` map; |
| + - a `404` on a read maps to `.notOnThisBase` (P3); |
| + - a `401` calls `rejected`. |
| +- [ ] Add `StoreData`, `StoreRow` (with `State`), `PeopleData`, `Person` (with `Role`), and the five calls. |
| +- [ ] **Gate:** `swift test … --filter BaseKitTests.ClientTests`. |
| -## Task 6: Store and People models |
| +### Task 8: Store and People models |
| -**Files:** `BaseKit/Team/StoreModel.swift`, `Team/PeopleModel.swift`, `Tests/BaseKitTests/StoreModelTests.swift`, `PeopleModelTests.swift`. |
| +**Files:** `Team/StoreModel.swift`, `Team/PeopleModel.swift`, `Tests/BaseKitTests/StoreModelTests.swift`, `PeopleModelTests.swift`. |
| -- [ ] **Tests first, with a clock and client you control:** |
| +- [ ] **Tests first (a clock and client you control):** |
| - **`StoreModel`:** |
| - - it loads; |
| - - it polls every 2 s while any row is installing, and stops when none is or when `stop()` is called; |
| - - `install` shows the row installing at once and reloads; |
| - - `uninstall` asks for a confirmation first (`pendingUninstall`), then posts; |
| + - P4's polling, backoff and stop on `401`; |
| + - `install` shows installing at once; |
| + - `uninstall` confirms first (`pendingUninstall`); |
| - `busy` shows "This app is still installing. Try again in a moment."; |
| - a failed row shows its error, or "The install didn't finish."; |
| - - a member sees no buttons, only "Installed". |
| + - a member sees no buttons; |
| + - an `announcement` is produced only when a row changes to installed or failed, never on a poll that changes nothing. |
| - **`PeopleModel`:** |
| - it loads; |
| - - `invite` trims and lowercases, as the web does; |
| - - `bad_email` shows "That doesn't look like an email address."; |
| - - `mail_failed` shows "The invitation wasn't sent. Try inviting them again."; |
| + - `invite` trims and lowercases; |
| + - each error has the web's words and is exposed as an announcement; |
| - success clears the field and reloads; |
| - - Invite is busy while the request runs (the 650 ms spinner rule, as Settings' buttons follow). |
| + - Invite is busy while in flight (the 650 ms spinner rule). |
| - [ ] Implement both as `@MainActor @Observable` classes. |
| - [ ] **Gate:** `swift test … --filter 'BaseKitTests.StoreModelTests|BaseKitTests.PeopleModelTests'`. |
| -## Task 7: Store and People screens |
| +### Task 9: Store and People screens |
| -**Files:** `BaseKit/Team/StoreView.swift`, `Team/PeopleView.swift`, `Tests/BaseSnapshots/TeamSnapshots.swift` (new), `ios/project.yml` (the iPhone snapshot target's sources, if listed by file). |
| +**Files:** `Team/StoreView.swift`, `Team/PeopleView.swift`, `Tests/BaseSnapshots/TeamSnapshots.swift` (new). |
| -- [ ] **Snapshots first:** in `TeamSnapshots`, as the mockups `mac-store`, `mac-people`, `phone-store` and `phone-people` draw them: |
| - - Store as the owner (one installed, one installing, one failed) and as a member; |
| - - People as the owner (with the invite field and an invited row) and as a member; |
| +- [ ] **Snapshots first,** as the mockups `mac-store`, `mac-people`, `phone-store` and `phone-people`: |
| + - Store as the owner (installed, installing, failed) and as a member; |
| + - People as the owner (invite field, an invited row) and as a member; |
| - the uninstall confirmation; |
| - Mac and iPhone, light and dark, iPhone also at AX3. |
| -- [ ] **Build the screens from the look's parts** (glass group, rows, `BaseFont`, frost primary and ghost buttons): |
| - - **Store:** the heading, the lead ("Apps that run on {team}'s Base…") and the rows. Uninstall goes through a `confirmationDialog` with the web's words ("Uninstall {app}? It's removed from Home for everyone at {team}…", Uninstall and Keep it). The line at the foot reads "Coming in later slices: Keymail, Sporran and the Oficina apps." |
| - - **People:** the heading, the lead, the owner's invite field (email keyboard, `.textContentType(.emailAddress)`, Return sends), and the rows (face, name or address, the second line, and the tag). |
| - - **VoiceOver:** each row reads as one element with its action. An installing row says "Installing". |
| -- [ ] **Gate:** `snapshots.sh record mac` and `record iphone` for the new pictures only. Review the contact sheets beside the mockups, then `compare` both. Then `check-native.sh`. |
| +- [ ] **Build them** from the look's parts. |
| + - **Uninstall** confirms with the web's words. |
| + - **VoiceOver:** each row is one element. |
| + - An owner's installed row has a named action, "Uninstall", and a failed row has "Try again". |
| + - Polling never moves focus. |
| + - The model's announcements are posted (`AccessibilityNotification.Announcement`), as are the invite's errors (the web's `role="status"`). |
| +- [ ] **Gate:** `snapshots.sh record mac` and `record iphone` for the new pictures only. Review them beside the mockups, then `compare` both. |
| -## Task 8: Getting to Store and People |
| +### Task 10: Getting to Store and People |
| -**Files:** `BaseKit/Mac/MacMainView.swift`, `Phone/PhoneAskScreen.swift`, `Home/BaseActions.swift`, `Tests/BaseKitTests/AskViewTests.swift`, `OpenerTests.swift`. |
| +**Files:** `Mac/MacMainView.swift`, `Phone/PhoneAskScreen.swift`, `Home/BaseActions.swift`, `Tests/BaseKitTests/AskViewTests.swift`, `OpenerTests.swift`. |
| - [ ] **Tests first:** |
| - - choosing `store` or `people` in the sidebar sets `MacPane.store` or `.people` and never calls `openURL`; |
| - - when a read answers `.notOnThisBase`, the same choice opens the web page, as slice 1 does; |
| - - on the iPhone, `AppsSheet` lists "Your team" (Store, and People with the member count) and pushes the screen; |
| - - `settings` still opens the Settings window, or the iPhone's settings. |
| -- [ ] **Mac:** `MacMainView` gains `@State var pane: MacPane`. The sidebar's Ask Base, Store and People rows select it, with the selected row's tint as in the mockups, and the pane shows the chosen screen with its title in the bar. |
| -- [ ] **iPhone:** `AppsSheet` wraps its content in a `NavigationStack`. Below the apps comes a "Your team" group: Store, and People with the count from `/api/v1/people` or `me`. Each pushes its screen, with the system back button. |
| -- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AskViewTests|BaseKitTests.OpenerTests'`, then `snapshots.sh compare` (the Mac main window and the apps sheet change, so record those after review), then `check-native.sh`. |
| + - choosing `store` or `people` sets `MacPane.store` or `.people` and never calls `openURL`; |
| + - when a read answered `.notOnThisBase`, the same choice opens the web page; |
| + - `AppsSheet` lists "Your team": Store, and People with the count of people once `/api/v1/people` has loaded, and no count before; |
| + - `settings` is unchanged. |
| +- [ ] **Mac:** `MacMainView` gains `@State var pane: MacPane`. The Ask Base, Store and People rows select it. |
| +- [ ] **iPhone:** `AppsSheet` wraps its content in a `NavigationStack`, and the "Your team" rows push the screens. |
| +- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AskViewTests|BaseKitTests.OpenerTests'`, then `build-iphone.sh simulator`, then `snapshots.sh compare`. The main window and the apps sheet change, so record those after review. |
| -## Task 9: The Apps section folds |
| +### Task 11: The Apps section folds |
| -**Files:** `BaseKit/Home/SidebarFolds.swift` (new), `Mac/MacMainView.swift`, `Phone/PhoneAskScreen.swift`, `Tests/BaseKitTests/SidebarFoldsTests.swift`, `BaseSnapshots/MacSnapshots.swift`. |
| +**Files:** `Home/SidebarFolds.swift` (new), `Mac/MacMainView.swift`, `Phone/PhoneAskScreen.swift`, `Tests/BaseKitTests/SidebarFoldsTests.swift`, `BaseSnapshots/MacSnapshots.swift`, `AskSnapshots.swift`. |
| - [ ] **Tests first:** |
| - it starts open; |
| - - folding is remembered across a fresh `SidebarFolds` for the same origin and member; |
| - - another member, or another Base, on the same device has its own state; |
| - - the key never contains the address or the origin in clear (P5); |
| - - signing out leaves it (it's a preference, not data). |
| -- [ ] **Mac:** the "Apps" heading becomes a button with a chevron (rotated when folded) and, when folded, the count ("8"). It works from the keyboard (Space, and ←/→ on the heading). VoiceOver hears "Apps, expanded" or "Apps, collapsed". |
| -- [ ] **iPhone:** the same heading in `AppsSheet`. |
| -- [ ] **Snapshots:** the Mac sidebar folded and unfolded, and the apps sheet folded. |
| -- [ ] **Gate:** `swift test … --filter BaseKitTests.SidebarFoldsTests`, `snapshots.sh compare` (after a reviewed record of the new pictures), `check-native.sh`. |
| - |
| -## Task 10: Copy Equipo's files code into BaseKit (R5) |
| - |
| -**Files:** `BaseKit/Attachments/` (new: the P7 list) and `Tests/BaseKitTests/` (the copied tests and fixtures). |
| - |
| -- [ ] **Copy** the P7 files from Equipo origin/main `8bd40ed1`, each with its provenance line. |
| + - a new `SidebarFolds` for the same account remembers; |
| + - another account, or another Base, has its own state; |
| + - the key is P5's hash, with no address or origin in clear; |
| + - it works with no `me` loaded. |
| +- [ ] **Build the heading** on both platforms: a button with a chevron, and the count when folded. |
| + - **Mac keyboard:** Space toggles it; ← folds and → unfolds. |
| + - **VoiceOver:** "Apps, expanded" or "Apps, collapsed". |
| + - **Reduce Motion:** no chevron animation. |
| +- [ ] **Snapshots:** the Mac sidebar folded and open; the apps sheet folded, also at AX3. |
| +- [ ] **Gate:** `swift test … --filter BaseKitTests.SidebarFoldsTests`, `build-iphone.sh simulator`, then `snapshots.sh compare` after a reviewed record. |
| + |
| +### Task 12: Copy Equipo's files code into BaseKit (R5) |
| + |
| +**Files:** P7's table, and nothing else. |
| + |
| +- [ ] Copy each file in P7, with its provenance line. |
| - [ ] **Make them compile and nothing more:** |
| - - rename `Equipo*` types to `Base*` where they name the app; |
| - - point strings at `BaseText`; |
| - - put an `AttachmentClient` protocol where Equipo's `EquipoClient` was. It has `upload`, `delete`, `data(id:preview:)` and `download(id:to:)`. |
| - - Behaviour is unchanged. This keeps the next diff (Task 12) readable as "Base's rules". |
| -- [ ] **Run the copied tests as they are.** Where one asserts Equipo-only behaviour that P8 changes, mark it `// Base differs: Task 12` and leave it failing-skipped (`XCTSkip`) for Task 12 to turn around. |
| -- [ ] **Gate:** `swift test … --filter 'BaseKitTests.Attachment'`, then `check-native.sh`. |
| + - Base names; |
| + - `BaseText` for strings; |
| + - an `AttachmentClient` protocol in place of `EquipoClient`, with `upload`, `delete`, `data(id:preview:)` and `download(id:to:)`. |
| + - Behaviour is unchanged. |
| +- [ ] **Run the copied tests.** Mark any that assert behaviour P8 changes with `// Base differs: Task 14` or `Task 15`, and skip them (`XCTSkip`) until then. |
| +- [ ] **Gate:** `swift test … --filter 'BaseKitTests.Attachment'`, then **`check-native.sh`** (the first of its two runs). |
| -## Task 11: The files client |
| +### Task 13: The files client |
| **Files:** `API/Client.swift`, `API/Models.swift`, `Tests/BaseKitTests/ClientTests.swift`, `Fixtures/attachment.json`. |
| - [ ] **Tests first:** |
| - **`AskSnapshot.canAttach`** decodes `can_attach`, and is `false` when it's missing. |
| - **`upload`:** |
| - - it calls the kit's `upload` on `/ask/attachments` and decodes `201 Attachment`; |
| - - `413`, `415` and `409` map to their `code`; |
| - - `503 busy` carries `Retry-After`. |
| - - **`deleteAttachment`:** `204`, and `404` count as done; `409 attachment_sent` is reported. |
| - - **`discard(ids:)`** posts at most five `id` fields per call. |
| - - **`attachmentData(id, preview: true)`** is bounded at 2 MiB. |
| - - **`downloadAttachment(id, to:)`** uses the kit's `download`. |
| - - **`send(text, key, attachments:)`** repeats the `attachments` field in order. |
| - - **On send:** `409 {"files":"unavailable"}` maps to `.filesUnavailable`, and `422 {"files":"stale"}` to `.filesStale`. Neither maps to a phase change. |
| + - it goes through the transport's `upload` to `/ask/attachments`, and decodes `201`; |
| + - each refusal maps to its code; |
| + - `503 busy` carries `Retry-After`; |
| + - a plain-text `400` maps to `.uploadFailed`; |
| + - a `401 unauthenticated` calls `rejected` (S1). |
| + - **`deleteAttachment`:** `204` and `404` are done; `409 attachment_sent` is `.alreadySent`. |
| + - **`discard(ids:)`:** five per call. |
| + - **`attachmentData(id, preview: true)`:** bounded at 2 MiB. |
| + - **`downloadAttachment(id, to:)`:** uses the transport's `download`. |
| + - **`send(text, key, attachments:)`:** repeats the field in order. |
| + - **On send:** `409 files:"unavailable"` maps to `.filesUnavailable`, and `422 files:"stale"` to `.filesStale`. Neither changes the phase. |
| - [ ] Implement these. `BaseClient` conforms to `AttachmentClient`. |
| - [ ] **Gate:** `swift test … --filter BaseKitTests.ClientTests`. |
| -## Task 12: Base's rules for drafts and sending |
| - |
| -**Files:** `Attachments/AttachmentDraft.swift`, `Ask/AskModel.swift`, `Tests/BaseKitTests/AttachmentDraftTests.swift` (from the copied tests), `AskModelTests.swift`. |
| - |
| -- [ ] **Tests first, with a scripted client and a controllable clock:** |
| - - the six P8 rules, each a test; |
| - - **limits:** five files a message, refused at the sixth chip with "You can attach up to 5 files to a message."; |
| - - **the PDF line:** a PDF chip says "Ask can't read PDFs yet."; |
| - - **sending:** |
| - - Send waits for every upload; |
| - - text may be empty with files; |
| - - the sent message's files clear the chips; |
| - - a failed send keeps them; |
| - - a resend reuses the key; |
| - - **`can_attach` false:** no paperclip or `+`, and `add` refuses; |
| - - **D5:** after `.filesUnavailable`, Ask is still `ready` and the words can be sent alone with one tap (the chips removed); |
| - - **switching accounts** discards the old account's unsent uploads. |
| -- [ ] Implement these, turning each `// Base differs: Task 12` test around. |
| -- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AttachmentDraftTests|BaseKitTests.AskModelTests'`, then `check-native.sh`. |
| - |
| -## Task 13: Files prepared on the device |
| - |
| -**Files:** `Attachments/AttachmentFile.swift`, `Tests/BaseKitTests/AttachmentFileTests.swift`, `Fixtures/attachments/` (a HEIC, a 48 MP JPEG, a TIFF, a PNG with GPS). |
| +### Task 14: The draft's rules |
| + |
| +**Files:** `Attachments/AttachmentDraft.swift`, `Attachments/AttachGate.swift` (new), `Session/BaseSession.swift`, `Tests/BaseKitTests/AttachmentDraftTests.swift`, `SessionTests.swift`. |
| + |
| +- [ ] **Tests first (a scripted client and a clock):** |
| + - **P8.1, Remove:** |
| + - Remove deletes; |
| + - `.alreadySent` drops the chip silently; |
| + - Remove is disabled while sending. |
| + - **P8.2, the gate:** |
| + - with five files added at once, at most two are preparing or uploading at any moment, in order; |
| + - a sixth file is refused at the chip. |
| + - **P8.3, busy:** |
| + - three retries with backoff; |
| + - the ring restarts at 0; |
| + - then the busy chip, with Retry. |
| + - **P8.4, discard:** |
| + - `end()` starts a discard of the unsent ids with the old client, bounded at 2 s, and returns at once; |
| + - a discard that answers `401` is dropped silently; |
| + - nothing is discarded on background. |
| + - **P8.5, background:** an upload in flight is wrapped in a background task (behind a protocol the test fakes), and a lost answer shows Retry. |
| + - **The PDF line:** a PDF chip says "Ask can't read PDFs yet." |
| +- [ ] Turn each `// Base differs: Task 14` test around. |
| +- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AttachmentDraftTests|BaseKitTests.SessionTests'`. |
| + |
| +### Task 15: Sending with files, and D5 |
| + |
| +**Files:** `Ask/AskModel.swift`, `Attachments/AttachmentDraft.swift`, `Tests/BaseKitTests/AskModelTests.swift`. |
| - [ ] **Tests first:** |
| - - HEIC, HEIF and TIFF become JPEG; |
| - - anything over 2560 px on its long edge is scaled down, keeping its aspect; |
| - - EXIF location is gone from the output; |
| - - a 48 MP photo comes out under 10 MiB and under 40 MP; |
| - - the chip's line says "from HEIC" (DRAFT string) for a converted photo; |
| - - a file over 10 MiB after preparing is refused on the chip with "This file is over the 10 MB limit.", never uploaded; |
| - - an unknown type is refused with the web's types line. |
| -- [ ] Wire the copied conversion into `AttachmentDraft.add`, off the main actor. |
| + - Send waits for every upload; |
| + - the text may be empty with files; |
| + - the sent message's files clear the chips; |
| + - a failed send keeps them, and a resend reuses the key; |
| + - with `can_attach` false there is no paperclip or `+`, and `add` refuses; |
| + - **D5:** after `.filesUnavailable` Ask stays ready, and the words go alone with one tap; `.filesStale` marks the chips; |
| + - switching accounts ends the old draft (Task 14's discard). |
| +- [ ] Implement these, and turn each `// Base differs: Task 15` test around. |
| +- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AskModelTests|BaseKitTests.AttachmentDraftTests'`. |
| + |
| +### Task 16: Files prepared on the device |
| + |
| +**Files:** `Attachments/AttachmentFile.swift`, `Tests/BaseKitTests/AttachmentFileTests.swift`. |
| + |
| +- [ ] **Tests first.** Fixtures are generated in the test with `CGImageDestination` (a HEIC, a 7952×5304 JPEG, a TIFF, a 2000 px PNG with GPS); nothing large is committed. |
| + - HEIC, HEIF and TIFF become JPEG, and `convertedFrom` says what from; |
| + - over 2560 px is scaled down, keeping its aspect; |
| + - **converted output** has no EXIF location (S10); |
| + - a PNG or JPEG at or under 2560 px goes up byte for byte, since Equipo strips location on arrival; |
| + - the 48 MP photo comes out under 10 MiB and 40 MP; |
| + - a non-image over 10 MiB is refused from its size, without being read; |
| + - an image over 128 MiB is refused; |
| + - an unknown type gets the web's types line. |
| +- [ ] Wire it into the draft behind Task 14's gate, off the main actor. |
| - [ ] **Gate:** `swift test … --filter BaseKitTests.AttachmentFileTests`. |
| -## Task 14: Attaching on the Mac |
| - |
| -**Files:** `Ask/Composer.swift`, `Attachments/MacAttach.swift` (from `MacComposer.swift`), `Attachments/AttachmentPromises.swift`, `Ask/PasteMarkdown.swift`, `Mac/MacMainView.swift`, `Tests/BaseKitTests/MacAttachmentTests.swift`, `BaseSnapshots/AskSnapshots.swift`. |
| - |
| -- [ ] **Tests first:** |
| - - **the paperclip:** it sits left of Send, only while `can_attach`, and opens `fileImporter` with multiple selection and the allowed types; |
| - - **drop:** file URLs, images and promises dropped on the composer or anywhere on the Ask pane are attached; an outline shows while dragging, with "Drop files to attach them"; |
| - - **paste (D8):** |
| - - ⌘V with an image alone attaches it; |
| - - with files alone attaches them; |
| - - with text and an image (Pages, Word, Excel) pastes the text only; |
| - - with a file's name as its only text attaches the file; |
| - - **the menu panel's composer** doesn't attach in part 1 (it opens Base to attach). Drops on it are refused quietly. |
| -- [ ] **Build it:** chips above the field, wrapping, at most 196 pt tall and then scrolling. Remove has the label "Remove {name}". VoiceOver announces "{name} attached" and "{name} not attached: {reason}", the web's words. |
| -- [ ] **Snapshots,** as the mockups `mac-attach` and `mac-drop`: chips (an image done, one uploading, a PDF, a refused file) and the drop outline, light and dark. |
| -- [ ] **Gate:** `swift test … --filter BaseKitTests.MacAttachmentTests`, `snapshots.sh compare mac` (after a reviewed record), `check-native.sh`. |
| - |
| -## Task 15: Attaching on the iPhone |
| - |
| -**Files:** `Ask/Composer.swift`, `Attachments/PhoneAttachmentPicker.swift`, `Phone/PhoneAskScreen.swift`, `ios/project.yml` (`NSCameraUsageDescription`: "Base uses the camera to take a photo for Ask."), `Tests/BaseKitTests/PhoneAttachmentTests.swift`, `BaseSnapshots/AskSnapshots.swift`. |
| - |
| -- [ ] **Tests first:** |
| - - **the `+`:** left of the field, only while `can_attach`. Its menu has Photos, Camera (only when a camera is available) and Files; |
| - - **Photos:** `PhotosPicker` with up to five minus the chips already there, images only; |
| - - **Camera:** the photo is converted as in Task 13; |
| - - **Files:** `fileImporter` with multiple selection; |
| - - **paste** follows D8; |
| - - **the chips** are one line that scrolls sideways. |
| -- [ ] Build it. |
| -- [ ] **Snapshots,** as the mockup `phone-attach`: the menu open, chips with a "from HEIC" photo and one uploading, light and dark, and AX3. |
| -- [ ] **Gate:** `swift test … --filter BaseKitTests.PhoneAttachmentTests`, `snapshots.sh compare iphone` (after a reviewed record), `check-native.sh`. |
| -- [ ] **By hand, once, on a device:** Photos and Camera on an iPhone (TestFlight internal build), including a 48 MP photo. Note the result in the task's commit. |
| - |
| -## Task 16: Files in the thread, and Quick Look |
| - |
| -**Files:** `Ask/Thread.swift` (the names line goes), `Attachments/AttachmentViews.swift`, `Attachments/AttachmentCache.swift` (new), `Attachments/QuickLook.swift` (new), `native/PrivacyInfo.xcprivacy`, `Session/BaseSession.swift` (clear on sign-out), `Tests/BaseKitTests/AttachmentCacheTests.swift`, `AskViewTests.swift`, `BaseSnapshots/AskSnapshots.swift`. |
| +### Task 17: Attaching on the Mac |
| + |
| +**Files:** `Attachments/AttachIntake.swift` (new), `Attachments/MacPasteboard.swift`, `AttachmentPromises.swift`, `Ask/Composer.swift`, `Mac/MacMainView.swift`, `../BaseMac/BaseMacApp.swift`, `Tests/BaseKitTests/MacAttachmentTests.swift`, `AttachIntakeTests.swift`, `BaseSnapshots/AskSnapshots.swift`. |
| + |
| +**Why not Equipo's editor.** |
| +- Equipo's Mac composer is `ComposerEditor`, an `NSTextView` subclass that overrides `paste(_:)` and the dragging methods. |
| +- Base's composer is a SwiftUI field whose window field editor it only observes (`ComposerInput`, `Composer.swift:103-135`), so there's nothing to subclass. |
| +- Base takes Paste and drops where they arrive instead. |
| + |
| +- [ ] **Tests first (platform-neutral):** `AttachIntake.decide(_ contents: PasteboardContents) -> .attach([Item]) | .text` implements D8: |
| + - an image alone attaches; |
| + - files alone attach; |
| + - text with an image (Pages, Word, Excel) is text; |
| + - text that is only the files' own names attaches; |
| + - a file promise attaches. |
| +- [ ] **Paste: a menu command.** |
| + - `BaseMacApp` replaces the Edit menu's pasteboard group (`CommandGroup(replacing: .pasteboard)`), re-adding Cut, Copy, Paste, Paste and Match Style, Delete and Select All with the standard selectors. |
| + - ⌘V arrives at its Paste through the menu, as every key equivalent does. |
| + - Paste asks `AttachIntake` first when the Ask composer has focus (`ComposerInput.focused`). On `.attach` it attaches and the field gets nothing. |
| + - Otherwise it sends `NSText.paste(_:)` down the responder chain. It sets `ComposerInput`'s `pasting` flag first, so the rich-paste path (`PasteMarkdown`) works as today. |
| + - The menu titles are the system's (`NSMenuItem` standard titles, through `Bundle(for: NSApplication.self)`), so no new strings. |
| +- [ ] **Drop: on the pane.** |
| + - The Ask pane takes `.onDrop(of: [.fileURL, .image, file promise types], isTargeted:)` and shows the outline (mockup `mac-drop`). |
| + - So that a drag over the field reaches the pane and doesn't insert a path, `ComposerInput.start()` re-registers the field and its field editor for text types only (`registerForDraggedTypes([.string])` after `unregisterDraggedTypes()`). Plain text can still be dragged into the field. |
| +- [ ] **Step 1 proves both by hand, before anything else is built on them.** Paste of a screenshot, a Finder file, and text from Pages; drop of a file onto the field and onto the thread. |
| + - **If either fails:** replace the Mac field with Equipo's `ComposerEditor` (copied from `MacComposer.swift`, P7 amended), and move `ComposerInput`'s undo, IME and rich-paste handling into it. Record the outcome in the commit, and in this plan's Review. |
| +- [ ] **The paperclip:** left of Send, only while `can_attach`. It opens `fileImporter` (multiple selection, P10's types). |
| +- [ ] **The menu panel's composer** doesn't attach in part 1. Drops there are refused quietly. |
| +- [ ] **Chips and accessibility:** |
| + - chips above the field, wrapping, at most 196 pt tall, then scrolling; |
| + - **keyboard:** Tab reaches each chip; Delete removes it; Return retries a failed one; |
| + - **VoiceOver:** |
| + - Remove and Retry are named actions; |
| + - the ring has a value ("62 percent"), updated without announcing each step; |
| + - "{name} attached" and "{name} not attached: {reason}" are announced (the web's words); |
| + - **Reduce Motion:** the ring jumps rather than animates. |
| +- [ ] **Snapshots,** as `mac-attach` and `mac-drop`, light and dark. |
| +- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AttachIntakeTests|BaseKitTests.MacAttachmentTests'`, then `snapshots.sh compare mac` after a reviewed record. |
| + |
| +### Task 18: Attaching on the iPhone |
| + |
| +**Files:** `Attachments/PhoneAttachmentPicker.swift`, `Attachments/AttachSources.swift` (new, platform-neutral), `Ask/Composer.swift` (`ComposerPaste`, `ComposerInput` on iOS), `Phone/PhoneAskScreen.swift`, `native/ios/project.yml`, `Tests/BaseKitTests/AttachSourcesTests.swift`, `BaseSnapshots/AskSnapshots.swift`. |
| + |
| +- [ ] **Tests first, on the platform-neutral `AttachSources`** (it holds the logic; the iOS views only call it): |
| + - which sources the menu offers: Photos, Camera only when available (injected), Files, and Paste only when the pasteboard says it has images or files (`UIPasteboard.hasImages` / `hasURLs`, injected); |
| + - how many more Photos may be chosen: `5 - chips`; |
| + - the names (P10: `Photo 1.jpg`…); |
| + - that the paste of an image through the field (`ComposerPaste`) attaches it and inserts nothing. |
| +- [ ] **The `+` menu:** Photos, Camera, Files and Paste, Equipo's four, with Equipo's labels as drafts for Base's review. |
| + - Paste reads the pasteboard as Equipo's `paste()` does, so the system shows its paste prompt. |
| +- [ ] **The field takes a pasted image.** |
| + - `ComposerInput` sets the `UITextView`'s `pasteConfiguration` to accept `public.image` as well as text. |
| + - `ComposerPaste`'s transform hands image items to the draft (`setNoResult()`), and leaves text as now. |
| +- [ ] **The rest:** |
| + - the chips are one line that scrolls sideways; |
| + - `NSCameraUsageDescription` is added (DRAFT: "Base uses the camera to take a photo for Ask."); |
| + - **VoiceOver,** as in Task 17. |
| +- [ ] **Snapshots,** as `phone-attach`: the menu open, chips with a "from HEIC" photo and one uploading, light and dark, and AX3. |
| +- [ ] **Gate:** `swift test … --filter BaseKitTests.AttachSourcesTests`, `build-iphone.sh simulator`, then `snapshots.sh compare iphone` after a reviewed record. |
| +- [ ] **On a device,** with internal TestFlight build **0.1.3 (4)** (DRAFT strings; Paul only): |
| + - five 48 MP photos picked at once (S8); |
| + - a Live Photo (its still); |
| + - a ProRAW photo (the 2560 px path); |
| + - Camera; |
| + - Files; |
| + - a pasted screenshot; |
| + - background during an upload. |
| + |
| + Note the results in the commit. |
| + |
| +### Task 19: Files in the thread, Quick Look, and the cache |
| + |
| +**Files:** `Ask/Thread.swift`, `Attachments/AttachmentViews.swift`, `Attachments/AttachmentCache.swift` (new), `Attachments/QuickLook.swift` (new), `Session/BaseSession.swift`, `Ask/AskModel.swift`, `BaseMac/BaseMacApp.swift`, `native/PrivacyInfo.xcprivacy`, `Tests/BaseKitTests/AttachmentCacheTests.swift`, `AskViewTests.swift`, `BaseSnapshots/AskSnapshots.swift`. |
| - [ ] **Tests first:** |
| - - **the bubble:** a person's message draws thumbnails (from `/preview`), then a pill per other file (mark, name, size), then the words. A lone image draws larger. A failed thumbnail shows its name. |
| - - **the cache (P9):** |
| - - originals are downloaded once into `Caches/Attachments/<account>/`, excluded from backup, `0600`; |
| - - signing out clears it; |
| - - files older than 14 days go at launch; |
| - - the in-memory preview cache holds 64 at most. |
| + - **The bubble:** thumbnails (from `/preview`), then pills (mark, name, size), then the words. A lone image draws larger. A failed thumbnail shows its name. |
| + - A thumbnail's label is "Image, {name}"; a pill's is "{name}, {size}"; both have the button trait. |
| + - **The cache:** every P9 rule, each a test. |
| + - The path, and sanitised names such as `../x.command` stored as `x.txt` for a `text/plain` file. |
| + - `0600`, excluded from backup, and `.complete` (iOS, checked through an injected file-attributes protocol). |
| + - One download per id. |
| + - The message date as the file date, and the 14-day sweep. |
| + - Other accounts' folders removed. |
| + - Cleared on `end()` and on `disconnected`. |
| + - The sweep's triggers, each injected. |
| - **Quick Look:** |
| - - on the Mac, a click, or Space on a selected file, opens `QLPreviewPanel` with the downloaded original; |
| - - on the iPhone, a tap presents `QLPreviewController`, which has Share; |
| - - a `404` (the file is gone, or Ask is disconnected) shows "This file isn't available any more." (DRAFT). |
| -- [ ] Build it, and remove the slice 1 names line, `FilesLine` (`Thread.swift:135-159`). |
| -- [ ] **Snapshots,** as `mac-quicklook` (the bubble only; the panel is the system's) and `phone-sent`. |
| -- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AttachmentCacheTests|BaseKitTests.AskViewTests'`, `snapshots.sh compare` (after a reviewed record), `check-native.sh`. |
| + - the Mac opens `QLPreviewPanel` on click, or Space on a selected file; |
| + - the iPhone presents `QLPreviewController`, which has Share; |
| + - focus returns to the thumbnail when it closes; |
| + - a `404` shows "This file isn't available any more." (DRAFT). |
| +- [ ] Build it. |
| + - Remove the names line, `FilesLine` (`Thread.swift:135-159`). |
| + - Delete the copied full-size preview in `AttachmentViews.swift`. |
| + - Add the privacy manifest's `C617.1`. |
| +- [ ] **Snapshots:** the bubble as `mac-quicklook` (the bubble only) and `phone-sent`, light and dark, and the iPhone at AX3. |
| +- [ ] **Gate:** `swift test … --filter 'BaseKitTests.AttachmentCacheTests|BaseKitTests.AskViewTests'`, `build-iphone.sh simulator`, then `snapshots.sh compare` after a reviewed record. |
| -## Task 17: Strings |
| +### Task 20: Strings |
| -**Files:** `Resources/Localizable.xcstrings`; `native/scripts/check-strings.py` (no new `WAITING` entries); `copy-review/slice2-part1.json` (main checkout, git-ignored). |
| +**Files:** `Resources/Localizable.xcstrings`; `copy-review/slice2-part1.json` (main checkout, git-ignored). |
| -- [ ] Every string from Tasks 6 to 16 is in the catalog. The web's approved words are reused verbatim: |
| - - the Store and People pages; |
| - - `data-w-*` in `chat.html`, for attach, drop, uploading, remove, failed, too many, PDF, unavailable, stale, too large, type, HEIC, pixels, limit, busy, attached and not attached. |
| -- [ ] **New words are drafted** with a `DRAFT 2026-11-28` comment and listed for Luna with their context: |
| +- [ ] **Every string from Tasks 8 to 19 is in the catalog.** The web's approved words are reused verbatim: the Store and People pages, and `data-w-*` in `chat.html`. |
| +- [ ] **These are new, drafted** (`DRAFT 2026-11-28`) and listed for Luna with their context: |
| - "from HEIC"; |
| - - Photos, Camera, Files; |
| + - Photos, Camera, Files, Paste (Equipo's approved words, which Base reviews in its own voice); |
| - "Your team"; |
| - "Apps, expanded" and "Apps, collapsed"; |
| + - "Image, {name}"; |
| - "This file isn't available any more."; |
| + - "Photo {n}"; |
| - the camera's purpose string. |
| - [ ] **Gate:** `python3 native/scripts/check-strings.py`. |
| -## Task 18: The branch's last checks |
| +### Task 21: The branch's last checks |
| -- [ ] Run `native/scripts/check-native.sh` once, then `snapshots.sh compare` for both platforms once. |
| -- [ ] Push, and read hub CI: `amadan ci status oficina/base -branch native/slice2-part1 -json`. It must pass on the tip. |
| -- [ ] **Hand checks on a Mac with this build:** |
| +- [ ] **`check-native.sh` once** (the second of its two runs), then `snapshots.sh compare` for both platforms once. |
| +- [ ] **Push and read hub CI** on the tip. It proves Go and the catalog only (Gates). |
| +- [ ] **Hand checks on a Mac with this build,** against the deployed server (Task 4): |
| - Store install and uninstall on a test Base; |
| - - invite to a test address; |
| - - Apps folds and is remembered after a relaunch; |
| - - drop, paste, the paperclip and Quick Look; |
| - - sign out clears `Caches/Attachments`. |
| -- [ ] **Ask for an independent code review** (Fable, or Codex Astra when Fable is limited) of the whole branch, with this plan and spec 7.4 to 7.6 as its brief. Answer it on the branch. |
| - |
| -## Task 19 (Controller): Copy review, deploy, release |
| - |
| -- [ ] Luna reviews `copy-review/slice2-part1.json` from 2026-12-02. `sync-strings.py`, then `check-strings.py`. |
| -- [ ] Land the branch on main through the hub. |
| -- [ ] Deploy Base's server (the five routes), and check `GET /api/v1/store` live with the app. |
| -- [ ] Release Mac 0.1.3 through Sparkle, and TestFlight 0.1.3, with the usual release scripts (`release-mac.sh`, `testflight.sh`). |
| + - an invite to a test address; |
| + - Apps folds, and stays folded after a relaunch and offline; |
| + - paste, drop, the paperclip and Quick Look; |
| + - sign-out clears `Caches/Attachments/<accountKey>`. |
| +- [ ] **An independent code review** of the whole branch (Fable, or Codex Astra), with this plan and spec 7.4 to 7.6 as the brief. Answer it on the branch. |
| + |
| +### Task 22 (Controller): Copy review, land, release |
| + |
| +- [ ] Luna reviews `copy-review/slice2-part1.json` from 2026-12-02. Run `sync-strings.py`, then `check-strings.py`. |
| +- [ ] Land the branch on main through the hub, and read hub CI on main. |
| +- [ ] Release **0.1.3 (5):** Mac through Sparkle (`release-mac.sh`) and TestFlight (`testflight.sh`). |
| +- [ ] **Check the release:** |
| + - the appcast lists 0.1.3; |
| + - TestFlight shows build 5 processed; |
| + - one Mac takes the update and opens Store natively. |
| + |
| +## Review |
| + |
| +How each finding from Fable's plan review (2026-11-28) is answered: |
| + |
| +| Finding | Answer | |
| +|---|---| |
| +| **B1** | P6 and Task 5: `upload` is a requirement with no default. Task 6 forwards it in `SwappableTransport`, with tests through it, including a swap mid-session | |
| +| **S1** | The `401` test moved from the kit (Task 5) to the client (Task 13, Task 7), where `rejected` is called | |
| +| **S2** | P6: a per-request timeout of 90 s, tested by inspecting the request. P8.9: a plain-text `400` shows the failed chip with Retry | |
| +| **S3** | Task 5 is on its own rastrillo/native branch, with its own Fable review before it lands. Base repins after (Task 6) | |
| +| **S4** | Gates: `check-native.sh` twice only (after Task 12, and in Task 21), filtered `swift test` per task, `build-iphone.sh` where iOS code changes, `-j 4` in the script. Hub CI's native step stated as it is (`--core-only`: the catalog only). Task 18's logic lives in the platform-neutral `AttachSources` | |
| +| **S5** | Task 17: Paste through a replaced Edit menu command, and drop on the pane with the field's drag types narrowed. Proven by hand in step 1, with Equipo's `ComposerEditor` as the fallback. Task 18: the `+` menu keeps Paste, and the field accepts image pastes (`pasteConfiguration`, `ComposerPaste`). P7: the fixtures adapted | |
| +| **S6** | P8.4 and P8.5: no discard on background. Uploads run as background tasks. A lost answer gives Retry, and the orphan is accepted and written down | |
| +| **S7** | P8.4: discard from `end()` with the old client, bounded at 2 s, never blocking. It covers every cause of `end()`. The kit's sign-out from another app is stated. The cache hangs off `end()`, and the launch sweep removes other accounts' folders. No quit hook: quitting is left to the 24-hour drop | |
| +| **S8** | P8.2 and Task 14: one gate for preparing and uploading, two at a time. P10: sizes checked before reading, and Photos loaded as files. Task 18: five 48 MP photos on the device | |
| +| **S9** | P8.3: three tries with backoff, the ring restarting, then the busy chip with Retry | |
| +| **S10** | Task 16: location checked on converted output only. Small PNGs and JPEGs go up as they are (Equipo strips on arrival). `convertedFrom` makes `AttachmentFile` "copied, then changed" in P7 | |
| +| **S11** | P9: exact path and name sanitising, the hashed account, iOS `.complete`, the date from the message, sweeps at launch, active, window open and daily, clearing on disconnect, one download per id, and Share copies stated (spec 7.6 amended) | |
| +| **S12** | P2: `503` everywhere a read can fail; a failed `Start` decided; repeat installs decided; invite answers `{"person"}` (spec 7.4 amended); `joined` dropped; a no-Remove test (Task 2) | |
| +| **S13** | Part A lands and deploys first (Task 4), with a rollback SHA, a live `/api/version` check with a restart if needed, a `401`-not-`404` route check, and the lagged team named. P12: 0.1.3 (4) internal and 0.1.3 (5) release | |
| +| **Accessibility** | Tasks 9, 11, 17, 18, 19: the ring's value, keyboard and VoiceOver actions, numbered photo names, quiet polling, named row actions, bubble labels and focus return, announced invite errors, and the missing AX3 and dark snapshots | |
| +| **Nits taken** | 1 (P7's "not copied on purpose"); 2 (fixtures generated); 3 (`@escaping`, `maxBytes`, `Content-Length`); 4 ("a member's session"); 5 (the count from `/api/v1/people` only); 6 (spec 7.5: a button heading); 7 (P5 keyed on the account); 8 (P4 backoff, stop on `401`); 9 (Task 19 deletes the preview); 10 (Live Photo and ProRAW on the device); 11 (`attachment_sent`: the chip just goes); 12 (Remove disabled while sending) | |
| +| **Order** | Task 12 is split into 14 and 15. Task 12 names every file it copies | |
diff --git a/docs/superpowers/specs/2026-11-23-base-native-design.md b/docs/superpowers/specs/2026-11-23-base-native-design.md| index 634a79a..f3ea002 100644 |
| --- a/docs/superpowers/specs/2026-11-23-base-native-design.md |
| +++ b/docs/superpowers/specs/2026-11-23-base-native-design.md |
| @@ -676,14 +676,25 @@ same owner checks: |
| - **`GET /api/v1/store`:** `{owner, rows: [{id, name, summary, tint, |
| icon_svg, state, error}]}`. `state` is `""`, `installing`, `installed` or |
| `failed`. |
| -- **`POST /api/v1/store/{app}/install`:** `202`, then poll every 2 s while |
| - any row is installing, as the web does. |
| -- **`POST /api/v1/store/{app}/uninstall`:** `200`, `409 busy` while |
| - installing, `403` if not the owner. |
| +- **`POST /api/v1/store/{app}/install`:** `202 {store}`, then poll every |
| + 2 s while any row is installing, as the web does. |
| + - An app already installing answers `202`, and one already installed |
| + `200`, both with the store and without starting anything. |
| + - If starting the install fails, the store is read again. A row that now |
| + shows installing or failed answers `202` as it stands. Otherwise the |
| + answer is `503 unavailable`, and nothing was claimed. |
| +- **`POST /api/v1/store/{app}/uninstall`:** `200 {store}`, `409 busy` |
| + while installing, `403 owner_only` if not the owner. |
| - **`GET /api/v1/people`:** `{owner, people: [{id, initial, name, email, |
| - role, joined}]}`. |
| -- **`POST /api/v1/people`:** `{email}`. It answers `200` with the person, |
| - `422 bad_email`, `502 mail_failed` (invite again to retry), or `403`. |
| + role}]}`. `role` is `owner`, `member` or `invited` (not yet signed in), |
| + so no separate `joined` is sent. |
| +- **`POST /api/v1/people`:** `{email}`. It answers `200 {person}` with the |
| + person invited (or already here), `422 bad_email`, `502 mail_failed` |
| + (invite again to retry), or `403 owner_only`. |
| +- **Every route** answers `503 unavailable` when Base can't read its own |
| + store, as the pages do, and `401 unauthenticated` without a member's |
| + session. Nothing removes a member: `DELETE /api/v1/people/{id}` stays |
| + unrouted. |
| - **Where they show:** |
| - **Mac:** in the window's pane, from the sidebar. |
| - **iPhone:** pushed from the apps sheet's new "Your team" section. |
| @@ -695,12 +706,15 @@ same owner checks: |
| ### 7.5 The sidebar |
| - **Apps folds** (Paul). |
| - - On the Mac it is a `Section(isExpanded:)` in the sidebar. On the iPhone |
| - it is a header with a chevron in the apps sheet. |
| + - On both, the "Apps" heading is a button with a chevron: in the Mac's |
| + glass sidebar (which isn't a `List`, so not `Section(isExpanded:)`) and |
| + in the iPhone's apps sheet. |
| - Folded, it shows the count. |
| - The state is remembered for each person on each device, in |
| - `UserDefaults`, keyed by Base origin and member id. It isn't synced, |
| - and the web's rail setting (migration 0007) is its own. |
| + `UserDefaults`. It is keyed by a hash of the signed-in account the |
| + session already holds, so it is right before `/api/v1/me` loads and |
| + offline. It isn't synced, and the web's rail setting (migration 0007) |
| + is its own. |
| - It starts open. |
| - **Made with Base.** Decided yes (7.9, 7). It lists what you made through |
| Ask that has an address: |
| @@ -739,19 +753,37 @@ points it at Base's `/ask/attachments`. |
| - A paperclip left of Send opens the file panel. |
| - Files can be dropped on the composer or anywhere on the window; the |
| outline uses the web's words. |
| - - ⌘V pastes. A paste with words pastes the words (D8). |
| + - ⌘V pastes. A paste with words pastes the words (D8). Base's composer is |
| + a SwiftUI field, not Equipo's `NSTextView`, so Base takes Paste in its |
| + own Edit menu command and narrows the field's drag types. The plan |
| + says how, and when it falls back to Equipo's editor. |
| - File promises are honoured, from Photos and Mail. |
| - **iPhone:** a `+` left of the field, with Photos (`PhotosPicker`, no |
| - permission needed), Camera (`NSCameraUsageDescription`) and Files. |
| + permission needed), Camera (`NSCameraUsageDescription`), Files and Paste |
| + (as Equipo's menu has). The field also takes a pasted image. |
| - **On the device,** HEIC, HEIF and TIFF become JPEG, and anything over |
| 2560 px is scaled down, before uploading (`AttachmentFile.swift`). A chip |
| says "from HEIC". 48 MP photos stop being refused. |
| + - At most two files are prepared at once, behind the same gate as the |
| + uploads. A file whose size already rules it out is refused without |
| + being read. |
| + - Only converted output loses its metadata on the device. A PNG or JPEG |
| + at or under 2560 px goes up as it is, and Equipo strips an image's |
| + location on arrival (files spec 1.1). |
| - **Chips:** |
| - each has a thumbnail, name, size, an upload ring and Remove; |
| - Remove deletes the upload; |
| - - unsent uploads are discarded, as best the app can, when it quits or |
| - signs out; |
| - - two uploads at a time, with a busy answer retried by itself; |
| + - uploads and chips survive the app going to the background. An upload |
| + in flight runs as a background task so it can finish. A lost answer |
| + shows Retry, and a retry is a second upload, so an orphan may count |
| + against the 20 for a day; |
| + - unsent uploads are discarded, as best the app can, when the session |
| + ends (`end()`: sign-out, account switch, a rejected session), bounded |
| + at 2 s. When another Oficina app signs the ID out, the session has |
| + gone before Base hears, so nothing can be discarded. Equipo's 24-hour |
| + drop catches that, a killed app, and quitting; |
| + - two uploads at a time. A busy answer is retried by itself up to three |
| + times with backoff, then the chip says busy and offers Retry; |
| - the paperclip shows only while `can_attach`; |
| - every refusal has the web's words (copy review 13), and the PDF chip |
| says "Ask can't read PDFs yet."; |
| @@ -762,8 +794,22 @@ points it at Base's `/ask/attachments`. |
| Open with Preview and Share. |
| - On the iPhone, a tap opens `QLPreviewController`, with Share. |
| - The original is fetched from `/ask/attachments/{id}` into the app's |
| - cache. It is kept out of backups, and cleared on sign-out and after |
| - 14 days (7.9, 12). |
| + cache (7.9, 12): |
| + - **Path:** `Caches/Attachments/<account hash>/<attachment id>/<name>`. |
| + The name is its last path component, with the extension taken from |
| + the media type, so a file can't preview or open as another type. |
| + - **Protection:** kept out of backups. On iOS it uses |
| + `NSFileProtectionComplete`. |
| + - **When it's cleared:** |
| + - on `end()`, and when Ask is disconnected; |
| + - 14 days after the message was sent (the file's date is set to the |
| + message's at download); |
| + - folders of accounts no longer signed in are cleared too; |
| + - the sweep runs at launch, on each return to the foreground, and on |
| + the Mac each time a window opens and daily. |
| + - **One download per file:** a double tap shares it. |
| + - **Copies:** Share and Open with Preview hand a copy to another app, |
| + which is outside these rules once the person sends it there. |
| - **Not doing:** Equipo's "recent screenshot" suggestion |
| (`RecentScreenshot.swift`). It needs Photos permission. |