oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

Native composer attachments

Branch: native/attachments, in its own physical-TMPDIR worktree, based on origin/main at 2950f604, then rebased before its first push onto landed main 4024216e (including the stopped-work release follow-up). String catalogs were regenerated from the union of both slices' reviewed keys; both debug fixture entry points and the landed stopped-work behavior were retained.

Behavior

The conversation composer accepts up to five attachments. On iPhone, the plus menu offers Photos (PhotosPicker), Camera, Files, and Paste. PhotosPicker does not request full-library access. HEIC/HEIF photos convert to JPEG with orientation applied and source metadata omitted. Mac clipboard TIFF images also convert to JPEG. Mac supports image/file paste and drag-and-drop through the AppKit composer. Area capture is omitted as agreed with the controller: a permission-free area capture path was not established; ScreenCaptureKit capture requires Screen Recording permission.

The source file is checked before upload: at most 10 MiB, 12,000 pixels per side, and 40 megapixels. These constants are POST /attachments' published v1 contract and internal/attach/attach.go; /capabilities does not publish configurable attachment limits. Converted JPEG bytes are checked again. Files are read with a maximum byte count; image dimensions are read before raster conversion.

Each item has upload progress, failure, retry, and remove. Failed and uploading items block sending. Removing an item prevents a late response from restoring it. Sending carries the uploaded ids in /messages, including attachment-only messages. The session keeps attachment metadata with a pending outgoing message; retry keeps its ids and idempotency key. Signing out clears the draft.

Sent bubbles fetch thumbnails through authenticated /attachments/{id}/preview reads. Tapping opens the original through /attachments/{id}, full screen on iPhone and in a sheet on Mac. Images, text files, and PDFs have native previews. The transport remains ephemeral, without cookie storage or redirects, including the upload delegate. No server route changed.

Share extension, recent-screenshot offers, area capture, and task-thread attachments are outside this slice.

Copy

The web's chat.attach. and api.attachment_ entries are copied into the catalog byte-identically, except the existing %s to %@ native format conversion. team.close is the existing reviewed web word. Parity covers these namespaces.

The five native-only entries were approved by Luna through the controller on 2026-11-25:

| Key | Value | Use | | --- | --- | --- | | native.attach.photos | Photos | Picker menu | | native.attach.camera | Camera | Picker menu | | native.attach.files | Files | Picker menu | | native.attach.paste | Paste | Picker menu | | native.attach.camera_usage | Use your camera to take a photo to attach to your message. | Camera purpose string |

Approval is recorded beside the menu labels and Info.plist source in project.yml. Fixture message text is illustrative user content, not runtime interface copy. No further copy questions.

Test-first evidence

swift test --package-path native/apple --filter AttachmentTests first failed because AttachmentLimits, AttachmentFile, AttachmentDraft and attachment API methods were absent. The initial tests covered byte/pixel/type limits, HEIC conversion, upload headers, message attachment ids, image delivery to a fake Coordinator, failed upload retry, removal, and the send gate.

The expanded swift test --package-path native/apple --filter Attachment passed 10 tests in three suites. It also covers reservation of all five slots while uploading, an invalid image never reaching the upload endpoint, late completion after removal, duplicate ids, clearing the draft after send and sign-out, and the Mac paste/drop entry point.

A real loopback HTTP server test exercises URLSession's raw upload and progress delegate. The server resolves the submitted message ids to uploaded image bytes before exposing the fake Coordinator's received image; the test compares those bytes with the source image. The server binds only 127.0.0.1 and is terminated after the test.

The actual Coordinator already converts attachments to Claude image content and Codex localImage input, covered by internal/headless/attachments_test.go:TestHeadlessAttachments. The local command GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/headless -run TestHeadlessAttachments -count=1 could not build on macOS because internal/toolproxy/stdio.go uses Linux unix.O_PATH. Linux hub CI remains the gate for those server tests.

Mutations

python3 "$TMPDIR/attachments-mutations.py" ran the focused swift test --package-path native/apple --filter Attachment suite for each mutation, required a failed assertion or thrown test error, and restored each source file in a finally block. All 13 mutations were caught:

| Deliberately broken behavior | Result | | --- | --- | | Byte limit removed | Caught | | Side-length limit removed | Caught | | Pixel-count limit removed | Caught | | Dimension validation before upload removed | Caught | | HEIC result advertised as HEIC instead of JPEG | Caught | | Five-item draft limit removed | Caught | | Uploading/failed items allowed to send | Caught | | Remove keeps the item | Caught | | Retry never uploads | Caught | | Message attachment ids omitted | Caught | | Upload bearer omitted | Caught | | Uploaded bytes replaced with an empty body | Caught | | Mac image paste/drop entry point disabled | Caught |

The first remove mutator produced invalid Swift; it was not counted. It was corrected to a compiling no-op remove and the assertions then failed.

Initial full native gate passed: 217 tests in 28 suites, one existing known issue, 125 parity strings, Mac build and iPhone Simulator build. Final gate and Linux CI are recorded with the final branch SHA.

Native captures are under polish-audit/equipo-daily-driver/site/build/slice2/: iphone-composer.png, iphone-sent.png, and mac-drop.png. The debug fixtures use the production composer, message views and API client with a fake transport. The Mac capture enters the same pasteboard handler as performDragOperation. No real account or screenshot permission is used.

Final contract check

The rebased native gate passed 244 tests in 31 suites, the existing known issue, 221 parity strings and both builds. A final comparison with attach.Inspect then found that native's initial text-extension list was narrower than the server: the server also accepts extensionless UTF-8 files and source files. A new textDetectionMatchesServerInsteadOfRestrictingExtensions test failed first. Native now uses the server's UTF-8/control-character rule, excludes misleading image/PDF suffixes from text fallback, and advertises JSON only when valid.

swift test --package-path native/apple --filter Attachment then passed 11 tests across three suites. Four further mutations, run by python3 "$TMPDIR/attachments-text-mutations.py", each failed assertions and were restored: wrong fallback media type, removed control-character check, removed image-suffix check, and removed JSON validity check. Total: 17 caught mutations. This contract correction adds no copy.

Screenshot review polish

The failed-upload sentence stays byte-identical. Its duplicate text button is now an arrow.clockwise icon beside remove, with a 44 by 44 point tap target and the reviewed read.retry accessibility label. Sent bubbles align the thumbnail tiles, filenames and message text to the same leading edge inside normal padding. An adaptive grid wraps when space is limited. The debug fixture now includes a portrait screenshot and a synthetic landscape JPEG to check mixed aspect ratios. Both fit side by side in the captured iPhone and Mac bubbles.

All three requested screenshots were recaptured from this branch and inspected. The Mac capture uses day appearance. Final native/scripts/check-native.sh passed: 245 tests in 31 suites, one existing known issue, 221 parity strings, zero reference failures, and Mac plus iPhone Simulator builds. No server files changed. No new copy was added by these polish fixes.

Fable review follow-up

Review of 69e059bc requested three P2 corrections and associated P3 polish. Slice 3 was paused before editing code. This follow-up remains on the published native/attachments branch, with new commits and no rebase.

Image preparation now matches chat-attach.js: JPEG quality 0.85, long edge 2560, orientation applied and transparency flattened onto white. HEIC/HEIF and TIFF are converted; other oversized images, including WebP, are converted; GIFs retain the web's exception. ImageIO creates only a bounded thumbnail, on the background preparation task. The server's 10 MiB/12000 px/40 MP limits apply to the upload. Local file reads use a separate 128 MiB input bound so large compressed photographs can be resized before the upload check.

The new generated 8064 by 6048 HEIC test failed first with AttachmentFailure pixels. The large WebP fixture is a generated solid-colour 4096 by 2048 image (encoded with cwebp); both now become bounded JPEGs. The HEIC metadata test sets GPS and a private EXIF comment, verifies their removal, and checks a 90-degree orientation transform. A small injected output limit tests the size check after conversion independently of compression ratios.

Mac drag tests now send synthetic NSDraggingInfo through draggingEntered, draggingUpdated, prepareForDragOperation and performDragOperation. They first failed for PNG/TIFF at the update and prepare stages. All four stages now accept supported image/file/promise types and refuse web URLs. Promised files are received through NSFilePromiseReceiver into a mode-0700 temporary directory, read inside its coordinated callback, and removed. The draft retains the bytes for retry; the directory is removed when its readers release it. A receiver fixture verifies delivery and cleanup. Folders are refused before a draft item is created, using api.attachment_type.

Removing an item and clearing a draft cancel the owned upload tasks. The cancellation test first failed with the original non-cancelling implementation. Thumbnail and original-preview image decoding also move to detached tasks, with 512/4096 pixel bounds and a cancellation check before updating UI state.

The iPhone keeps the reviewed Paste menu item and accepts the system paste prompt, as explicitly permitted by the review. This choice keeps the attachment sources together in the menu. No new runtime copy is introduced.

swift test --package-path native/apple --filter Attachment passed 25 tests across four suites after the review fixes. The updated loopback HTTP test also rejects a 307 upload redirect and a response exceeding the per-request cap.

python3 "$TMPDIR/attachments-review-mutations.py" independently broke each of these 22 behaviors; each run failed an assertion or threw a test error and the source was restored in a finally block:

| Mutation | Result | | --- | --- | | Source metadata retained in converted JPEG | Caught | | Orientation transform disabled | Caught | | Attachment read bearer omitted | Caught | | Upload delegate follows redirect | Caught | | Transport response cap removed | Caught | | Attachment client response cap removed | Caught | | Composer canSend guard removed | Caught | | Lost-project retry drops attachment ids | Caught | | Task-thread send accepts attachments | Caught | | Retry allowed while already uploading | Caught | | Late progress overwrites a ready item | Caught | | Retry generation check removed | Caught | | Server attachment codes use generic copy | Caught | | Bounded-file read size check removed | Caught | | Converted output size check removed | Caught | | Empty data accepted | Caught | | Mac pasteboard accepts web URLs | Caught | | Removal does not cancel the upload | Caught | | Full-size conversion instead of 2560 thumbnail | Caught | | Large WebP skips JPEG conversion | Caught | | draggingUpdated refuses image data | Caught | | prepareForDragOperation refuses image data | Caught |

These are in addition to the original 17 mutations. Test scaffolding compile errors were corrected before running the mutations; no compiler failure is counted as a caught mutation.

The capture exercise found a further iPhone presentation defect: PhotosPicker inside the transient Menu closed without opening its picker. The menu now sets a binding for a photosPicker modifier on the stable parent. The retained AttachmentSourceUITests test taps Attach, opens Photos, and requires the system Photos navigation bar. It uses the real app with its debug transport. The first capture harness showed the missing picker; the corrected capture shows Private Access to Photos, without requesting full-library access.

General desktop automation lacked Accessibility permission and the standalone Mac XCTest runner could not start an automation session. No permissions were changed. The Mac screenshot fixture now runs all four drag destination methods with synthetic NSDraggingInfo before capturing, matching the regression test; it is not claimed as a physical mouse-drag capture.

Final verification: native/scripts/check-native.sh passed 259 tests in 32 suites (one pre-existing known issue), 221 parity strings, zero dead-reference failures, and both platform builds. Adding an explicit capture scheme initially hid XcodeGen's automatic EquipoPhone scheme; the app's original build scheme is now explicit too, and the full gate was rerun successfully.

xcodebuild -project EquipoPhone.xcodeproj -scheme AttachmentSources -destination 'platform=iOS Simulator,id=C86CAA29-B99C-40AB-84C4-DF7C74926904' -derivedDataPath ../build/Phone CODE_SIGNING_ALLOWED=NO test passed its retained UI test. Its XCTest screenshots were exported with xcresulttool export attachments, inspected, and saved as iphone-add-menu.png and iphone-photos-picker.png beside the refreshed mac-drop.png in slice2. The Photos picker explicitly shows Oficina Equipo can access only selected items. Its Location Included system label describes the selected source; converted images drop metadata and the server strips location on every upload.

Security-scoped Files follow-up, 2026-11-26

Fable's delta review found that the immediate folder check ran before iPhone fileImporter URLs entered security-scoped access. The draft now checks file metadata inside a balanced access window, before creating an item. Local URLs whose startAccessingSecurityScopedResource returns false remain supported. The later bounded read retains its own balanced access window. Folders still produce api.attachment_type immediately and never become retryable items.

A fake resolver rejects metadata reads unless access is active. With the old ordering, swift test --package-path native/apple --filter AttachmentFollowupTests failed with three assertions: the file was refused and the access sequence was wrong for both files and folders. With the fix, both paths observe start, metadata, stop, and the file reaches the fake server.

The Mac composer delegates ordinary text drags to NSTextView in all four callbacks. A real NSTextView baseline and synthetic NSDraggingInfo exercise entry, update, preparation and insertion; the original code failed six assertions, including actual text insertion. The controller clarified that web URLs must also insert as plain text, not be blocked. The URL drop test first failed five assertions against the explicit URL refusal. Both URL drops and actual NSTextView paste now insert the URL as text, with no draft item or upload request. PNG/TIFF, file URLs and file promises retain the attachment path. The paste test preserves and restores the system clipboard in memory within one synchronous scope; no clipboard contents are logged.

Additional tests distinguish cancellation after preparation from the item's identity check, cancel every upload on clear, enforce 10 MiB for an image that is not resized, inspect the flattened JPEG's pixel color, reject a promised file outside its private directory, and require per-file deletion while a promise reader still holds the directory alive. This last test cannot pass merely because directory deinit eventually removes everything.

swift test --package-path native/apple --filter 'AttachmentFollowupTests|MacAttachmentTests' passed 13 tests in two suites. No new runtime copy or server changes are included.

python3 "$TMPDIR/attachments-followup-mutations.py" mutates one guard at a time, runs the two suites above, requires a built test binary and an assertion failure, then restores the source in a finally block. Its cases are:

| Mutation | Expected regression | | --- | --- | | Metadata before scoped access | Selected file refused; wrong access order | | clear does not cancel uploads | Both server operations remain active | | Cancellation check after preparation removed | Cancelled preparation uploads | | Unresized-image byte limit removed | Oversized PNG accepted | | White canvas fill removed | Transparent pixels become black | | Promise directory containment removed | Outside file enters draft | | Per-file promise removal removed | Delivered file remains during other reads | | Text draggingEntered refuses fallback | Entry differs from NSTextView | | Text draggingUpdated refuses fallback | Update differs from NSTextView | | Text prepareForDragOperation refuses fallback | Preparation refused | | Text performDragOperation refuses fallback | Text never inserted | | File-URL-only pasteboard filter removed | Web URL becomes an attachment instead of text |

All 12 mutations were caught. After the URL behavior clarification, case 12 was replaced with removal of the file-URL-only filter and rerun using python3 "$TMPDIR/attachments-followup-mutations.py" 12; it failed the URL text/attachment assertions. The other 11 mutations and their tests were unchanged. No compiler failure was counted as a caught mutation.

Final native/scripts/check-native.sh passed after the URL clarification: 268 tests in 33 suites, one pre-existing known issue, 221 byte-identical parity strings, zero dead-reference failures, and successful Mac and iPhone Simulator builds. The exact mutation script, failure logs and final gate log are retained with the slice2 evidence as scoped-verification-evidence.tar.gz and scoped-native-gate.log.