🗜️ feat: Let Users Toggle Client-Side Image Resizing - #14883
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d19ea675f5
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
Adds a user-facing toggle for client-side image resizing (stored per device via localStorage) while allowing admins to enforce a global on/off value via librechat.yaml. The change also fixes a size-gating bug that previously prevented resizing from triggering for typical images.
Changes:
- Introduces
clientImageResize.enforcedin merged file config to indicate when admin-suppliedenabledshould override user preference. - Adds a Settings > Chat > Sending toggle (“Resize images before upload”) with enforced/managed UI messaging.
- Fixes
shouldResizeImagegating by switching from a ~51MB effective threshold to a 512KB minimum floor and adds tests for the new behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/data-provider/src/types/files.ts | Adds enforced?: boolean to clientImageResize so clients can detect admin override. |
| packages/data-provider/src/file-config.ts | Sets default enforced: false and marks configs as enforced when admin provides enabled. |
| packages/data-provider/src/file-config.spec.ts | Adds unit tests covering admin/user precedence and parameter-only overrides. |
| librechat.example.yaml | Documents admin override semantics vs user-controlled behavior for clientImageResize.enabled. |
| client/src/utils/imageResize.ts | Replaces the ineffective size gate with MIN_RESIZE_BYTES = 512KB and updates shouldResizeImage semantics. |
| client/src/utils/tests/imageResize.test.ts | Adds test cases for the default 512KB threshold and updates existing expectations. |
| client/src/store/settings.ts | Adds a persisted localStorage-backed atom for clientImageResize user preference. |
| client/src/locales/en/translation.json | Adds label + info strings for the new setting and enforced-state messaging. |
| client/src/hooks/Files/useClientResize.ts | Implements enforced-vs-user precedence and removes any-based config access. |
| client/src/hooks/Files/index.ts | Re-exports useClientResize from the Files hooks barrel. |
| client/src/hooks/Files/tests/useClientResize.spec.tsx | Adds tests validating both override directions and parameter-only admin config behavior. |
| client/src/components/Nav/SettingsTabs/Chat/ImageResize.tsx | Adds the new UI toggle with an enforced-state info message and disabled behavior. |
| client/src/components/Nav/Settings/registry.tsx | Registers the new setting under Chat → Sending. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d19ea675f5
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fc9850f5a
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 788f1398af
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b8ef6b1b0
ℹ️ 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".
Client-side image resizing could only be configured in librechat.yaml and defaulted to off, so users had no way to enable it for themselves. Add a "Resize images before upload" toggle in Settings > Chat > Sending, stored per device in localStorage. When librechat.yaml sets clientImageResize.enabled, mergeFileConfig marks the value as enforced and the toggle renders the admin value read-only. Admin resize parameters still apply without locking the toggle when enabled is omitted. Also fix shouldResizeImage, which compared file size against 10% of a 512MB fallback limit and so only triggered above roughly 51MB. It now uses a 512KB floor, which lets the setting affect everyday photos.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 943d6f1ef2
ℹ️ 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".
943d6f1 to
2562d0f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9b13955c8
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32f9e0e806
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65dee9e7f6
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db8333f632
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b46f6d194
ℹ️ 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".
The switch stayed clickable during the initial file-config load even though the checked state cannot update until that query settles.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9bd9c4b3c
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Client-side image resizing has existed since it was added under
fileConfig.clientImageResize, but it could only be turned on inlibrechat.yamland it defaults to off. Users had no way to enable it for themselves, and admins had no way to express "on for everyone" versus "let people choose".This adds a Resize images before upload toggle in Settings > Chat > Sending, stored per device in localStorage, and gives the admin config the final say over it:
clientImageResize.enabledinlibrechat.yaml→ that value wins, and the toggle renders it read-only with an explanation in its info popover.enabled→ the user's toggle decides. Admin-providedmaxWidth,maxHeight, andqualitystill apply.The precedence is computed in
mergeFileConfig, which now marks the served configenforcedwhen the admin suppliedenabled.useClientResizereads that first and falls back to the user's setting.This also fixes a bug that made the feature inert.
shouldResizeImagecompared the file size against 10% of a 512MB fallback limit, so it only returned true for images larger than roughly 51MB. Almost nothing is, which meant that even withclientImageResize.enabled: truean ordinary phone photo was uploaded at full size. It now uses a 512KB floor, below which the decode and encode round trip costs more than it saves.resizeImagealready returns the original file untouched when the image is within the configured dimensions, so no image is re-encoded needlessly.A follow-up documentation PR for librechat.ai is still to be submitted, covering the new override semantics.
Change Type
Testing
Unit tests cover both halves of the precedence rule and the corrected size gate:
Manual verification in the browser, in light and dark mode:
clientImageResizeinlibrechat.yaml, the toggle is interactive. Turning it on writesclientImageResize: "true"to localStorage and the switch reportsdata-state="checked".clientImageResize.enabled: falsein the config while the user preference was stilltrue, the switch renders unchecked and disabled, and its info popover reads "This setting is managed by your administrator and cannot be changed here."Test Configuration:
Node v24.16.0, MongoDB, backend and Vite dev server running from the same worktree. The admin override was verified against a throwaway config copy so the shared
librechat.yamlwas left untouched.Checklist