Skip to content

🤖 fix: support JSON attachments#3601

Open
LeonidasZhak wants to merge 3 commits into
coder:mainfrom
LeonidasZhak:codex/json-attachment
Open

🤖 fix: support JSON attachments#3601
LeonidasZhak wants to merge 3 commits into
coder:mainfrom
LeonidasZhak:codex/json-attachment

Conversation

@LeonidasZhak

@LeonidasZhak LeonidasZhak commented Jun 20, 2026

Copy link
Copy Markdown

Summary

Allow JSON files to be attached in the chat composer while keeping the shared provider attachment allowlist restricted to model-supported media types.

Background

Fixes #3546. JSON files were rejected by the chat composer even though they can be carried through the existing generic file-part send path. The agent-facing attach_file tool must still reject JSON so agents use file_read for text files.

Implementation

  • Adds a chat-scoped attachment helper that accepts application/json and .json without expanding the shared provider attachment allowlist.
  • Includes JSON in the chat file picker accept list and tooltip copy.
  • Adds focused coverage for JSON MIME handling, extension-based detection when macOS drag/drop provides an empty MIME type, and the attach_file boundary.

Validation

  • Focused attachment tests: 40 passed
  • Focused ESLint and Prettier checks passed
  • tsgo --noEmit --project tsconfig.json passed
  • git diff --check passed
  • make static-check passed

Risks

Low. JSON support is scoped to user-selected chat attachments. The provider media allowlist and agent attach_file behavior remain unchanged.


Generated with mux • Model: GPT-5 • Thinking: unknown • Cost: $unknown

@LeonidasZhak

Copy link
Copy Markdown
Author

@codex review

Please review this small JSON attachment support fix for #3546. The diff only expands the attachment media-type allowlist and file picker copy, with focused coverage for application/json and empty-MIME .json drag/drop handling.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 834e8e47c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LeonidasZhak
LeonidasZhak force-pushed the codex/json-attachment branch from 834e8e4 to 4cf1aa1 Compare June 30, 2026 04:19
@LeonidasZhak

Copy link
Copy Markdown
Author

@codex review

Rebased this PR onto the latest main and resolved the attachment conflicts by preserving upstream staged ZIP attachment support while keeping JSON as a provider-supported attachment type.

Validation:

  • bun test --timeout=10000 src/browser/utils/attachmentsHandling.test.ts src/common/utils/attachments/supportedAttachmentMediaTypes.test.ts - 19 tests passed
  • focused ESLint for AttachFileButton, attachment handling tests, and supported media-type files
  • ./node_modules/.bin/tsgo --noEmit --project tsconfig.json
  • git diff --check origin/main...HEAD
  • make static-check

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4cf1aa10ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/utils/attachments/supportedAttachmentMediaTypes.ts
@LeonidasZhak

Copy link
Copy Markdown
Author

@codex review

Addressed the JSON allowlist feedback. JSON remains supported for user-selected chat attachments through a chat-scoped helper, but the shared provider attachment allowlist no longer treats application/json or .json as model media attachments. This keeps attach_file({ path: "package.json" }) rejected so the agent can use file_read.

Validation:

  • bun test --timeout=10000 src/common/utils/attachments/supportedAttachmentMediaTypes.test.ts src/browser/utils/attachmentsHandling.test.ts src/node/services/tools/attach_file.test.ts - 39 tests passed
  • focused ESLint for attachment helpers, browser attachment handling, AttachFileButton, and attach_file tests
  • ./scripts/generate-version.sh && ./node_modules/.bin/tsgo --noEmit --project tsconfig.json
  • git diff --check origin/main...HEAD
  • make static-check

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 35ff6ea336

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Allow application/json files through the attachment media-type allowlist and file picker, with focused coverage for MIME and extension-based JSON attachment handling.

Generated with mux • Model: GPT-5 • Thinking: unknown • Cost:

mux-attribution: model=GPT-5 thinking=unknown costs=unknown
Keep JSON support available for user-selected chat attachments while leaving the shared provider attachment allowlist unchanged, so attach_file continues to reject JSON paths for file_read.

---

_Generated with `mux` • Model: `GPT-5` • Thinking: `unknown` • Cost: ``_

<!-- mux-attribution: model=GPT-5 thinking=unknown costs=unknown -->
@LeonidasZhak
LeonidasZhak force-pushed the codex/json-attachment branch from 35ff6ea to 9181e19 Compare July 16, 2026 16:23
@LeonidasZhak

Copy link
Copy Markdown
Author

@codex review

Rebased onto the latest main and resolved the attachment conflict by preserving upstream display-only handling for unsupported source files. JSON remains supported only for user-selected chat attachments; attach_file still treats it as display-only rather than a model attachment.

Validation: 40 focused tests passed; focused ESLint, Prettier, and TypeScript checks passed; git diff --check passed; full make static-check passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9181e190d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/utils/attachments/supportedAttachmentMediaTypes.ts Outdated
@LeonidasZhak

Copy link
Copy Markdown
Author

@codex review

Addressed the generic-MIME JSON feedback in 3c26cff31. Chat attachments now fall back to the filename when a non-empty MIME is unsupported, and the data URL is canonicalized to the resolved media type. Provider/agent attachment boundaries remain unchanged.

Validation: 41 focused tests passed; focused ESLint, Prettier, and TypeScript checks passed; git diff --check passed; full make static-check passed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 3c26cff31d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

Unsupported attachment type: application/json

1 participant