Repository navigation
#644 Streamed attachment uploads in Session Chat - #855
Merged
Merged
Conversation
Stage 1 on both apps. A v2 prompt's metadata.attachments entries render as a chip for non-image files and as an aspect-correct inline image (height capped, no square crop) for images, on user and assistant messages. Image bytes load through the v2 file read route, which only serves files inside its location[directory], so the file's own folder is the location; any failure degrades to the chip. Tapping an image opens a full-screen viewer that letterboxes on black and dismisses from the close control or a tap outside the image. The "Attached file:" prompt lines are dropped from the bubble text. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Stage 2 on both apps. On a v2 server whose /openapi.json still declares POST /api/experimental/fs/write (required path query, octet-stream body, 200 data.path) and whose /api/info declares paths.tmp, a picked file is detected as text, binary or a native type (shared vectors in shared/attachment-mime) and either rides inline as a data URL (images and PDFs the model reads, up to 20 MB) or is streamed to <tmp>/uploads/<uuid>/<name> with progress and cancel on the existing attachment chip. Send waits for pending uploads, and a file with the same name and size as one in the draft is refused. The prompt gets an "Attached file:" line plus metadata.attachments and the file stays out of files[]. A contract miss (404/405/400/415 or a 200 without data.path) clears the flag for the connection and sends the file the old way with no new error; transport and auth failures show "Upload failed"; cancel is silent. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Collaborator
Author
7 tasks done
ivanfenenko
marked this pull request as ready for review
October 26, 2026 23:20
…cation Spec fixes, both apps: only 404, 405, 400 and 415 (or a 200 without data.path) are a contract miss, so 409, 413, 422 and every other status show "Upload failed" and keep uploads on; with no known model images and PDFs go inline and everything else uploads; a type declared as application/octet-stream falls back to the extension (new shared vectors with an optional filename); Android's contract check follows allOf/anyOf/oneOf and requires a JSON 200; a generic file never goes inline when uploads are unavailable; "Attached file:" lines are hidden only when the same message's metadata names that path. Standards fixes: unrelated reformatting removed from MessageModels and SessionCacheCodec (Android); one inline-or-reject decision shared by the add path and the contract-miss fallback; Attachment.uploadedServerPath and an inline-attachments helper replace the repeated unwrapping and the forced cast; server paths and prompt text moved out of AttachmentUploadFailure, which now only classifies. The viewer letterbox uses the theme scrim on Android and the image corners use the small radius token on iOS; the viewer's black letterbox stays literal on iOS and the Android close icon stays white because no token fits. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
There was a problem hiding this comment.
Automated review: 2 finding(s) that 2+ of 3 passes agreed on.
8 finding(s) from a single pass, not posted
ios/OpenCode Mobile/OpenCode Mobile/Domain/Message/Attachment/AttachmentLoader.swift:142high: Upload decision and byteCount use fileSize ?? 0 (muse-spark-1.3-contributor)android/app/src/main/java/dev/opencode/mobile/domain/message/remote/MessageDomainAdapter.kt:480medium: Inbox merge keeps an empty Text part for attachment-only prompts (muse-spark-1.3-contributor)android/app/src/main/java/dev/opencode/mobile/domain/connection/V2ServerContract.kt:104medium: Upload contract checks first 200 content type instead of application/json (muse-spark-1.3-contributor)ios/OpenCode Mobile/OpenCode Mobile/UI/SessionChat/Region/SessionChatComposer.swift:833medium: Contract-miss fallback loses the attachment's known mime and can drop the file (deepseek-v4.1-flash)android/app/src/main/java/dev/opencode/mobile/domain/message/MessageModels.kt:139medium: Uploaded attachments no longer trigger the file-backed v1 body, so v1 sends an empty URL (deepseek-v4.1-flash)ios/OpenCode Mobile/OpenCode Mobile/Domain/Event/EventDomainAdapter.swift:385medium: Uploaded parts are never emitted for top-level metadata because of the early return (deepseek-v4.1-flash)android/app/src/main/java/dev/opencode/mobile/data/remote/AttachmentUploadApi.kt:63medium: A failed response-body read on a 200 is treated as a contract miss (deepseek-v4.1-flash)ios/OpenCode Mobile/OpenCode Mobile/Domain/Message/Attachment/AttachmentUploadPolicy.swift:21low: Unknown model never reads natively, unlike Android (muse-spark-1.3-contributor)
opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.533
…attachment-uploads
A probe that found the write route but could not read /api/info cached "no tmp directory" for the server version, so streamed uploads stayed off until the release changed. Such a result is now marked unread and not cached, so the next probe reads it again; a 200 without paths.tmp is still a final answer. Same change on Android and iOS. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ivanfenenko
added a commit
that referenced
this pull request
Oct 27, 2026
* Close finished issues with Fixes in pull requests The feature skill's PR body example showed a bare "- #<number>", which only links the issue, so #855 merged without closing #644. Make "Fixes #<number>" the default for a PR that finishes its issue, re-decide it when a staged draft becomes complete, and check closingIssuesReferences during merge readiness. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Show both Issue line forms in the feature PR body example Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.







Summary
metadata.attachmentsentries show as a chip for non-image files and as an aspect-correct inline image (220 pt/dp height cap, no square crop) for images, on user and assistant messages. Image bytes load through/api/fs/read/*and any failure degrades to the chip. Tapping opens a full-screen viewer that letterboxes on black and dismisses from the close control or a tap outside the image. TheAttached file:prompt lines are hidden from the bubble text./openapi.jsonstill declaresPOST /api/experimental/fs/write(requiredpathquery, octet-stream body, 200data.path) and whose/api/infodeclarespaths.tmp, files stream to<tmp>/uploads/<uuid>/<name>with progress and cancel on the existing attachment chip. Mime detection uses shared vectors (shared/attachment-mime/attachment-mime-cases.json); images and PDFs the model reads (≤ 20 MB) stay inline, everything else uploads. Duplicates (same name and size in the draft) are refused, and send waits for pending uploads. The prompt carries theAttached file:line plusmetadata.attachments, and the file stays out offiles[].data.path) clears the flag for the connection and sends that file the old way with no new error; every other status (401/403, 408, 409, 413, 422, 429, 5xx), a timeout or a lost connection shows "Upload failed" and keeps the flag; cancel is silent./api/fs/read/*is confined to itslocation[directory](write is not), so the session directory cannot read an upload underpaths.tmp. Android reads uploads withpaths.tmpas the location and the relative path; iOS uses the file's parent folder. Both were verified against a v2 server.Checks
./gradlew :app:testDebugUnitTestpasses (new tests: contract shape, mime vectors, decision/duplicate/classification/prompt text, upload API, preview location, adapter and event projection, composer upload flow).metadata.attachments, chip shown); a text file uploaded on iOS; inline images keep their aspect ratio; the Android viewer letterboxes and ignores a tap on the image.Evidence
Screenshots in the evidence comment.
Issue
Risks / Follow-ups
Attached file:line in its text but nometadata, because the v2 command body has no metadata field, so no chip appears for it.Attached file:line until they reload.🤖 Generated with Claude Code