Skip to content

📂 fix: Respect supportedMimeTypes Config in File Picker Accept Filter#12596

Merged
danny-avila merged 3 commits into
devfrom
fix/file-picker-accept-mime-config
Apr 9, 2026
Merged

📂 fix: Respect supportedMimeTypes Config in File Picker Accept Filter#12596
danny-avila merged 3 commits into
devfrom
fix/file-picker-accept-mime-config

Conversation

@danny-avila

Copy link
Copy Markdown
Owner

Summary

The browser file picker's accept attribute was hardcoded by provider identity in AttachFileMenu.tsx, ignoring the endpoint's supportedMimeTypes from fileConfig. PR #12508 fixed the backend routing so custom MIME types are processed correctly, but the frontend file picker dialog still showed a restrictive filter — confusing users who configured permissive types like supportedMimeTypes: ['.*'].

  • Add isPermissiveMimeConfig utility in packages/data-provider/src/file-config.ts that detects wildcard patterns by testing a synthetic MIME type (application/x-librechat-any) against the endpoint's supportedMimeTypes RegExp array
  • Insert a new first branch in handleUploadClick that sets the file input accept to '' (unrestricted) when the endpoint's MIME config is permissive, short-circuiting the hardcoded provider-based strings
  • Retain existing provider-specific accept filters for non-permissive configs, preserving the current UX for default setups
  • Add 12 unit tests covering wildcard patterns (/.*/, /.+/, /^.*$/, /^.+$/), mixed arrays, category patterns, specific MIME types, defaults, edge cases, and the end-to-end convertStringsToRegexisPermissiveMimeConfig path

Closes #12589

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

  1. Configure fileConfig.endpoints.custom.supportedMimeTypes: ['.*'] in librechat.yaml
  2. Start a chat with a custom endpoint
  3. Click paperclip → Upload to Provider
  4. Verify the file picker dialog shows all files (no restrictive filter)
  5. Without the config override, verify the file picker still shows the original provider-specific filter (images/PDFs)
  6. Run cd packages/data-provider && npx jest file-config --verbose — all 113 tests pass

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

Copilot AI review requested due to automatic review settings April 9, 2026 20:36
The browser file picker's accept attribute was hardcoded by provider
identity, ignoring the endpoint's supportedMimeTypes from fileConfig.
Users who configured permissive MIME types (e.g., '.*') still saw a
restrictive filter in the upload dialog.

Add isPermissiveMimeConfig utility that detects wildcard patterns in
the endpoint's supportedMimeTypes. When permissive, the file picker
accept attribute is set to empty (unrestricted). Non-permissive
configs retain the existing provider-based defaults.

Closes #12589
@danny-avila danny-avila force-pushed the fix/file-picker-accept-mime-config branch from 29b54a9 to 0dc2c16 Compare April 9, 2026 20:38

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.

Pull request overview

Fixes the frontend file picker’s accept filter so endpoints configured with permissive supportedMimeTypes (e.g., '.*') don’t show an artificially restrictive file-type dialog, aligning the UI with the effective backend MIME handling.

Changes:

  • Add isPermissiveMimeConfig() in packages/data-provider and unit tests to detect permissive MIME regex configurations.
  • Update AttachFileMenu to clear the file input accept filter when the endpoint MIME config is permissive.
  • Add GitNexus indexing + Fly.io deployment workflows/config (not described in the PR metadata and operationally significant).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/data-provider/src/file-config.ts Adds isPermissiveMimeConfig() helper for permissive MIME regex detection.
packages/data-provider/src/file-config.spec.ts Adds unit tests for isPermissiveMimeConfig() (including convertStringsToRegex path).
client/src/components/Chat/Input/Files/AttachFileMenu.tsx Clears the accept attribute for permissive endpoint MIME configs to avoid restrictive picker filters.
.github/workflows/gitnexus-index.yml Adds a new CI workflow to generate and upload a GitNexus index artifact.
.github/workflows/gitnexus-deploy.yml Adds workflow to deploy the GitNexus index to Fly.io (includes security-sensitive setup guidance).
.fly/gitnexus/fly.toml Adds Fly.io app configuration for the GitNexus service.
.fly/gitnexus/entrypoint.sh Adds container entrypoint to run gitnexus serve behind Caddy.
.fly/gitnexus/Dockerfile Adds container build for GitNexus + Caddy, consuming the CI-produced index artifact.
.fly/gitnexus/Caddyfile Adds bearer-token auth proxy configuration for the GitNexus service.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Use non-standard MIME namespace probe (x-librechat/x-probe) so
  category-wildcard patterns like ^application\/.*$ no longer
  false-positive as permissive
- Add single-line JSDoc to isPermissiveMimeConfig
- Use !== undefined instead of != null (fileType is never null)
- Add endpointFileConfig to dropdownItems useMemo deps to prevent
  stale closure when config changes without endpoint change
- Add tests for broad application and multi-category patterns
@danny-avila

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ 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".

handleUploadClick is captured inside the dropdownItems useMemo but was
not in its dependency array. Wrap it in useCallback with
endpointFileConfig.supportedMimeTypes as the sole dependency, then
reference the stable callback in the useMemo deps.
@danny-avila danny-avila changed the title 📂 fix: Respect supportedMimeTypes Config in File Picker Accept Filter 📂 fix: Respect supportedMimeTypes Config in File Picker Accept Filter Apr 9, 2026
@danny-avila danny-avila changed the base branch from main to dev April 9, 2026 21:43
@danny-avila danny-avila merged commit daa8f0e into dev Apr 9, 2026
15 checks passed
@danny-avila danny-avila deleted the fix/file-picker-accept-mime-config branch April 9, 2026 21:43
yidianyiko pushed a commit to yidianyiko/LibreChat that referenced this pull request Apr 13, 2026
…er (danny-avila#12596)

* fix: respect supportedMimeTypes config in file picker accept filter

The browser file picker's accept attribute was hardcoded by provider
identity, ignoring the endpoint's supportedMimeTypes from fileConfig.
Users who configured permissive MIME types (e.g., '.*') still saw a
restrictive filter in the upload dialog.

Add isPermissiveMimeConfig utility that detects wildcard patterns in
the endpoint's supportedMimeTypes. When permissive, the file picker
accept attribute is set to empty (unrestricted). Non-permissive
configs retain the existing provider-based defaults.

Closes danny-avila#12589

* fix: address review findings for isPermissiveMimeConfig

- Use non-standard MIME namespace probe (x-librechat/x-probe) so
  category-wildcard patterns like ^application\/.*$ no longer
  false-positive as permissive
- Add single-line JSDoc to isPermissiveMimeConfig
- Use !== undefined instead of != null (fileType is never null)
- Add endpointFileConfig to dropdownItems useMemo deps to prevent
  stale closure when config changes without endpoint change
- Add tests for broad application and multi-category patterns

* fix: wrap handleUploadClick in useCallback to satisfy exhaustive-deps

handleUploadClick is captured inside the dropdownItems useMemo but was
not in its dependency array. Wrap it in useCallback with
endpointFileConfig.supportedMimeTypes as the sole dependency, then
reference the stable callback in the useMemo deps.
jcbartle pushed a commit to jcbartle/LibreChat that referenced this pull request May 11, 2026
…er (danny-avila#12596)

* fix: respect supportedMimeTypes config in file picker accept filter

The browser file picker's accept attribute was hardcoded by provider
identity, ignoring the endpoint's supportedMimeTypes from fileConfig.
Users who configured permissive MIME types (e.g., '.*') still saw a
restrictive filter in the upload dialog.

Add isPermissiveMimeConfig utility that detects wildcard patterns in
the endpoint's supportedMimeTypes. When permissive, the file picker
accept attribute is set to empty (unrestricted). Non-permissive
configs retain the existing provider-based defaults.

Closes danny-avila#12589

* fix: address review findings for isPermissiveMimeConfig

- Use non-standard MIME namespace probe (x-librechat/x-probe) so
  category-wildcard patterns like ^application\/.*$ no longer
  false-positive as permissive
- Add single-line JSDoc to isPermissiveMimeConfig
- Use !== undefined instead of != null (fileType is never null)
- Add endpointFileConfig to dropdownItems useMemo deps to prevent
  stale closure when config changes without endpoint change
- Add tests for broad application and multi-category patterns

* fix: wrap handleUploadClick in useCallback to satisfy exhaustive-deps

handleUploadClick is captured inside the dropdownItems useMemo but was
not in its dependency array. Wrap it in useCallback with
endpointFileConfig.supportedMimeTypes as the sole dependency, then
reference the stable callback in the useMemo deps.
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.

[Bug]: Allowed file types in Upload file popup does not match provider's allowed types

2 participants