fix(desktop,ui,mobile): three paste defects found auditing the paste surfaces
Stacked on #6935 (base: fix-multipaste). That PR is a no-op refactor; this
one is the behaviour fixes the same audit turned up. Three independent
commits, reviewable separately.
1. The terminal rich input silently ate pasted files
TerminalRichInput renders PromptInput + TiptapPromptEditor with no
attachment tray. The editor's paste handler claimed the event and pushed the
files into state that nothing rendered and handleSubmit never read, so:
- pasting a screenshot into the terminal composer did nothing at all
- a clipboard carrying an image and text lost the text as well
Now the tray renders, and submit writes the attachments into the worktree's
.superset/attachments (the shared convention, so they self-ignore) and appends
their worktree-relative paths to the prompt. A PTY only takes bytes, so a path
is how a pasted image reaches the agent, and it matches what a file drop onto
the terminal already does. Attachments with no typed text are a valid
submission. An upload failure rejects the submit, which PromptInput already
restores the composer from, so a failed attach never costs the draft.
Both editors also stop swallowing text on a mixed image+text paste: attach the
files, then leave the paste unhandled so the text still lands.
Verified over CDP in the running app, real pasteboard, real Cmd+V, real PTY:
| Step | Result |
|---|---|
| Paste screenshot into rich input | tray shows image.png (before: nothing) |
| Paste image + text | text lands in editor and image attaches |
| Submit | PTY receives describe this screenshot .superset/attachments/image.png .superset/attachments/image_1.png |
| Files on disk | image.png (260B), image_1.png (351B), collision-probed |
.gitignore | written with *; git status stays clean |
| Composer | text and tray both cleared |
2. accept / maxFiles / maxFileSize were dead props on every v2 composer
usePromptInputAttachments prefers the provider context, and PromptInput
provided no attachments context at all in provider mode — it returned
inner bare. So every consumer got the controller's raw add, which does no
filtering. The constraints and onError were silently inert whenever a
PromptInputProvider was present, which is every v2 composer.
Concretely: the new-workspace screen asks for maxFiles={5} and a 10MB cap and
enforced neither. A paste of fifty files, or a single 2GB one, went straight in.
Extracts the validation into applyAttachmentConstraints so both storage modes
share it, routes the provider path through it, and re-provides the validated
context to PromptInput's subtree. State still lives in the controller.
9 unit tests cover capacity, per-file size, accept matching, and which
condition reports which error code.
3. apps/mobile/modules/paste-input was dead
Superseded by the composer module's own paste(itemProviders:) when the
composer became a native view (#6761). Nothing has imported
@superset/paste-input since; the only reference left was a tsconfig path
alias, so the Swift view and its JS wrapper were both unreachable. Removed.
Testing
bun testacrosspackages/ui,packages/chat-ui, and the TerminalPane
tree: 82 pass- New: 9 tests for
applyAttachmentConstraints, 5 for attachment paths in
prepareTerminalSubmission bun run --cwd apps/desktop typecheck,packages/ui,packages/chat-uibunx biome checkoverpackages,apps/desktop/src,apps/mobilebunx sherif
Risks
- (1) changes what submitting the terminal composer does when attachments are
present. It previously did nothing with them, so there is no prior behaviour
to regress; the text-only path is untouched. - (2) starts enforcing limits that were declared but inert. Composers that were
relying on the absence of enforcement would now seeonError; the only
in-repo callers are the ones that set the limits deliberately. - Rollback: revert per commit, they are independent.
Summary by cubic
Fixes three paste defects: terminal-pasted files now attach and reach the agent, composer attachment limits actually enforce, and the dead mobile paste-input module is gone. Two behavior changes — terminal submits with attachments and enforced constraints — are independent and revert separately.
Bug Fixes
- Terminal rich input had no attachment tray, so pasting a screenshot did nothing and a clipboard carrying image + text lost the text. The tray now renders, files are written to the worktree's
.superset/attachments(self-ignored like file drops), and their paths append to the prompt; attachments alone are a valid submission and a failed upload restores the draft. accept,maxFiles,maxFileSize, andonErrorwere dead props on every v2 composer because provider-backed composers read the controller's rawaddunvalidated. Constraints now register into the controller and are enforced byapplyAttachmentConstraintsat the singleaddevery caller funnels through, so the new-workspace screens' 5-file/10MB caps and the terminal's 10-file/50MB cap finally apply; partial rejections report too instead of dropping files silently.- Removed
apps/mobile/modules/paste-input— never imported since the native composer's ownpaste(itemProviders:)superseded it, and a tsconfig alias was the only reference left.
Summary by CodeRabbit
-
New Features
- Terminal prompts now support attaching multiple files, including file-only submissions.
- Uploaded attachments are available to terminal commands with safe path handling.
- Attachment chips are displayed in the terminal composer.
-
Improvements
- Pasting images alongside text now preserves both the attachment and pasted text.
- Attachment validation consistently enforces file type, size, and count limits.
-
Bug Fixes
- Attachment upload errors now appear as clear notifications.
- Prevented pasted text from being unintentionally discarded when files are included.