Repository navigation
Improve iOS attachment previews and file delivery #9907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 70 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
4b5cbc1
test: cover staged mobile attachment delivery
azooz2003-bit 2408b3f
test: pin attachment retry upload identity
azooz2003-bit 469e8f9
test: preserve attachment operation across retry
azooz2003-bit 5a438d0
feat: stream staged mobile attachments
azooz2003-bit 12e9654
test: require atomic attachment cleanup and resolution
azooz2003-bit 4c0857d
fix: make mobile attachment cleanup atomic
azooz2003-bit b4c0e75
test: allow empty staged terminal files
azooz2003-bit 3ea1fdd
test: cover empty attachment finalization
azooz2003-bit 17b2c0d
test: exercise staged attachment routing
azooz2003-bit f5d9075
feat: unify mobile attachment composer UI
azooz2003-bit dcb70bb
Merge remote-tracking branch 'origin/main' into feat-ios-attachment-ux
azooz2003-bit 8a02ad9
fix: match mobile attachment card layout
azooz2003-bit 6357405
fix: import mobile attachment store in chat
azooz2003-bit 7d9943f
fix: scope attachment localization helper
azooz2003-bit 5d0a761
fix: share mobile viewport report helper
azooz2003-bit b6a735d
fix: match localized string signature
azooz2003-bit aa80bca
test: avoid mutating attachment preview draft
azooz2003-bit 9d8e991
test: cover attachment retry and admission failures
azooz2003-bit db2a608
fix: surface attachment admission failures
azooz2003-bit fb4f945
test: cover attachment ownership and protocol boundaries
azooz2003-bit e44c26d
test: reject attachment operation directory escapes
azooz2003-bit 54d8fe4
test: cover immutable upload metadata fields
azooz2003-bit b1d8a27
fix: harden attachment lifecycle and errors
azooz2003-bit 5e9d79a
fix: gate attachment picker postprocessing
azooz2003-bit 59ace84
test: cover completed multi-chunk attachment retry
azooz2003-bit 3df4956
fix: accept completed attachment retry receipts
azooz2003-bit 3c0854f
test: validate staged attachment backing files
azooz2003-bit d974515
fix: validate staged attachment lifecycle
azooz2003-bit 29fb279
test: separate paste and attachment failures
azooz2003-bit 81801fc
fix: preserve terminal paste failures
azooz2003-bit 376179f
test: preserve pending attachment read failures
azooz2003-bit 238be3e
fix: preserve pending attachment read failures
azooz2003-bit fb52544
fix: report excess task photos
azooz2003-bit eb127fe
test: preserve exact task prompt fixture value
azooz2003-bit 534be90
fix: enable attachment controls in UI fixture
azooz2003-bit d245491
test: dismiss task attachment menu by coordinate
azooz2003-bit 813d9ec
test: require shared attachment card geometry
azooz2003-bit 4f684ba
fix: unify attachment card geometry
azooz2003-bit 7e5ea14
test: cover attachment UX across mobile composers
azooz2003-bit 8041d6b
test: capture attachment surface evidence
azooz2003-bit 0c323de
test: cover oversized and cancelled attachment staging
azooz2003-bit c2719aa
test: repeat attachment composer lifecycle
azooz2003-bit 0c64edd
fix: exercise attachment UX in real composers
azooz2003-bit 959bc49
test: capture attachment preview lifecycle
azooz2003-bit 7738a9e
fix: make attachment image fixture distinctive
azooz2003-bit a3e0d86
fix: satisfy attachment layout conventions
azooz2003-bit db2defc
fix: instantiate attachment UI fixtures
azooz2003-bit 9feaa95
test: stabilize attachment menu interactions
azooz2003-bit f927b5f
test: target attachment preview close action
azooz2003-bit 72d51fb
fix: identify attachment preview close action
azooz2003-bit 9cf11d8
test: scope Japanese attachment coverage
azooz2003-bit 0705733
test: preserve attachment fixture drafts
azooz2003-bit fe83927
test: assert terminal attachment containment
azooz2003-bit 89c4d2c
test: seed attachment lifecycle drafts
azooz2003-bit 5936cdb
test: isolate attachment lifecycle focus
azooz2003-bit a11df01
test: bound attachment lifecycle interactions
azooz2003-bit 3593f6e
test: keep attachment fixtures unfocused
azooz2003-bit 417a41d
fix: disable task attachments at capacity
azooz2003-bit 8358496
test: support remote Foundation overloads
azooz2003-bit 8071def
perf: decode attachment images off main thread
azooz2003-bit 580b440
test: cover attachment UX completion regressions
azooz2003-bit b010728
fix: complete iOS attachment UX
azooz2003-bit 3272aa9
test: correct attachment budget fixtures
azooz2003-bit e1838cc
test: import attachment store owner
azooz2003-bit 6dec5ee
Fix attachment preparation UI test handshake
azooz2003-bit 22c143b
Fix native Quick Look UI assertion
azooz2003-bit 0b15b56
Fix oriented attachment fixture metadata
azooz2003-bit 2466567
Fix attachment test compiler diagnostics
azooz2003-bit 34b7839
Normalize oriented preview size label
azooz2003-bit ab3159d
test: catch task composer toggle overflow
azooz2003-bit 15a3b40
Fix accessibility layout toggle sizing
azooz2003-bit 9238309
Fix layout toggle interaction shape
azooz2003-bit 3619b43
test: catch landscape attachment card overflow
azooz2003-bit c8a4320
Fix attachment card interaction boundary
azooz2003-bit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
103 changes: 85 additions & 18 deletions
103
Packages/Shared/CmuxAgentChat/Sources/CmuxAgentChat/Model/ChatOutboundAttachment.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,98 @@ | ||
| import Foundation | ||
|
|
||
| /// An attachment the user is sending with a prompt. | ||
| /// | ||
| /// Carries the binary payload from the composer to the ``ChatEventSource``, | ||
| /// which delivers it to the host out-of-band (image paste RPC). | ||
| public struct ChatOutboundAttachment: Sendable, Equatable { | ||
| /// The encoded image format of ``data``. | ||
| public enum Kind: String, Sendable, Equatable { | ||
| case image | ||
| case file | ||
| } | ||
|
|
||
| public enum Format: String, Sendable, Equatable { | ||
| /// PNG-encoded image data. | ||
| case png | ||
| /// JPEG-encoded image data. | ||
| case jpeg | ||
| } | ||
|
|
||
| /// The encoded payload. | ||
| public let data: Data | ||
| /// The attachment's explicit storage representation. | ||
| public enum Payload: Sendable, Equatable { | ||
| case inMemoryImage(data: Data, format: Format) | ||
| case stagedFile(url: URL, byteCount: Int) | ||
| } | ||
|
|
||
| /// Stable idempotency identity retained by a pending row across retries. | ||
| public let uploadID: UUID | ||
| /// Stable operation shared by all attachments in one prompt. | ||
| public let operationID: UUID | ||
| public let payload: Payload | ||
| public let fileName: String | ||
| public let kind: Kind | ||
| /// Bounded preview bytes prepared before the attachment reaches a view. | ||
| public let thumbnailData: Data? | ||
|
|
||
| public var localFileURL: URL? { | ||
| guard case let .stagedFile(url, _) = payload else { return nil } | ||
| return url | ||
| } | ||
|
|
||
| /// The encoding of ``data``. | ||
| public let format: Format | ||
| public var byteCount: Int { | ||
| switch payload { | ||
| case let .inMemoryImage(data, _): data.count | ||
| case let .stagedFile(_, count): count | ||
| } | ||
| } | ||
|
|
||
| public init( | ||
| data: Data, | ||
| format: Format, | ||
| uploadID: UUID = UUID(), | ||
| operationID: UUID = UUID() | ||
| ) { | ||
| self.uploadID = uploadID | ||
| self.operationID = operationID | ||
| self.payload = .inMemoryImage(data: data, format: format) | ||
| self.fileName = format == .png ? "attachment.png" : "attachment.jpg" | ||
| self.kind = .image | ||
| // Legacy callers have no bounded preview. Retaining `data` here would | ||
| // duplicate the full image payload in view-facing state. | ||
| self.thumbnailData = nil | ||
| } | ||
|
|
||
| public init( | ||
| localFileURL: URL, | ||
| byteCount: Int, | ||
| fileName: String, | ||
| kind: Kind, | ||
| thumbnailData: Data? = nil, | ||
| uploadID: UUID = UUID(), | ||
| operationID: UUID = UUID() | ||
| ) { | ||
| self.uploadID = uploadID | ||
| self.operationID = operationID | ||
| self.payload = .stagedFile(url: localFileURL, byteCount: byteCount) | ||
| self.fileName = fileName | ||
| self.kind = kind | ||
| self.thumbnailData = thumbnailData | ||
| } | ||
|
|
||
| /// Creates an outbound attachment. | ||
| /// | ||
| /// - Parameters: | ||
| /// - data: The encoded payload. | ||
| /// - format: The encoding of `data`. | ||
| public init(data: Data, format: Format) { | ||
| self.data = data | ||
| self.format = format | ||
| /// Returns the same payload and upload identity under a prompt-wide operation. | ||
| public func withOperationID(_ operationID: UUID) -> Self { | ||
| switch payload { | ||
| case let .inMemoryImage(data, format): | ||
| Self( | ||
| data: data, | ||
| format: format, | ||
| uploadID: uploadID, | ||
| operationID: operationID | ||
| ) | ||
| case let .stagedFile(url, byteCount): | ||
| Self( | ||
| localFileURL: url, | ||
| byteCount: byteCount, | ||
| fileName: fileName, | ||
| kind: kind, | ||
| thumbnailData: thumbnailData, | ||
| uploadID: uploadID, | ||
| operationID: operationID | ||
| ) | ||
| } | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.