Skip to content

feat(app): attach any file and deliver unsupported ones by path - #49467

Merged
Hona merged 1 commit into
v2from
attachment-fallback
Sep 17, 2026
Merged

Hona merged 1 commit into
v2from
attachment-fallback

Conversation

@Hona

@Hona Hona commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Stacked on #49466.

Drop, paste, or pick any file into the composer. If the selected model reads it natively, nothing changes. Otherwise, instead of the "Unsupported attachment" toast, the model gets a path it can open with its tools.

Composer with a .pptx attached Sent message, remote server, GPT-5.6 Sol reading the zip via unzip -l
Composer showing Quarterly-Review.pptx as a PPTX attachment card above an empty editor Sent message showing the typed text with a ZIP attachment card, followed by the model's answer
flowchart TD
  A[Attachment on submit] --> B{Model reads<br/>this MIME natively?}
  B -- "text/plain · png/jpeg/gif/webp (image input) · pdf (pdf input)" --> C["inline: data: URI in files (unchanged)"]
  B -- no --> D{Server local and<br/>source path known?}
  D -- yes --> E["path = source path"]
  D -- no --> F["fs.write → &lt;info.paths.tmp&gt;/uploads/&lt;uuid&gt;/&lt;name&gt;"] --> G["path = resolved server path"]
  E & G --> H["text += Attached file: `&lt;path&gt;`<br/>metadata.attachments += { name, mime, path }"]
Loading
  • Decided at submit in packages/app/src/composer/attachments/deliver.ts, so it uses the model selected at send time and covers prompts, custom commands, and queued-prompt edits.
  • Same AttachmentCard everywhere: in the composer before sending, and on the sent message. The sent message renders it from metadata.attachments (same mechanism as review comments), so it survives reloads and other clients; displayText stays the typed text while the model sees:
How many .svg files are in the attached zip? Answer with a number only.
Attached file: `/tmp/opencode/uploads/0960c4cc-…/opencode-brand-assets.zip`
  • Verified end to end from this PC against a server on a VPS: 20 531-byte zip uploaded raw, sha256 matched on the server, model listed the archive and reported the VPS hostname.
  • Removed: static accepted-type lists (composer, hidden <input accept>, desktop picker filter, file-picker.ts) and prompt.toast.pasteUnsupported.* in all locales.

@Hona
Hona added this pull request to stack #49468 September 17, 2026 03:48
@Hona
Hona marked this pull request as ready for review September 17, 2026 03:49
@Hona
Hona requested a review from Brendonovich as a code owner September 17, 2026 03:49
Copilot AI lite review requested due to automatic review settings September 17, 2026 03:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Hona
Hona force-pushed the attachment-fallback branch from 7b382f2 to d5cad78 Compare September 17, 2026 04:26
@Hona
Hona force-pushed the attachment-fallback branch from d5cad78 to 4f474c9 Compare September 17, 2026 04:48
@Hona
Hona force-pushed the attachment-fallback branch 3 times, most recently from 73a7aba to 5acf084 Compare September 17, 2026 10:13
Base automatically changed from fs-write to v2 September 17, 2026 10:17
Drag, paste, and pick no longer reject files the model cannot read.
On submit each attachment is delivered inline when the selected model
reads it natively; otherwise the prompt references it by path: the
source path on a local server, or a copy staged under the server tmp
directory (from /api/info) via fs.write on a remote one. Removes the
accepted-type filters and the unsupported-attachment toast.
@Hona
Hona force-pushed the attachment-fallback branch from 5acf084 to 721033b Compare September 17, 2026 10:17
@Hona
Hona merged commit f04c3fd into v2 Sep 17, 2026
8 checks passed
@Hona
Hona deleted the attachment-fallback branch September 17, 2026 10:35
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants