Skip to content

fix: custom doUploadRequest permission adjustments#3243

Merged
arnautov-anton merged 2 commits into
masterfrom
custom-do-upload-request-enhancements
Jul 16, 2026
Merged

fix: custom doUploadRequest permission adjustments#3243
arnautov-anton merged 2 commits into
masterfrom
custom-do-upload-request-enhancements

Conversation

@arnautov-anton

@arnautov-anton arnautov-anton commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

🎯 Goal

Ref: https://getstream.slack.com/archives/C02R5UCGN6N/p1784023573649669
Relies on: GetStream/stream-chat-js#1800

Summary by CodeRabbit

  • Bug Fixes
    • Improved file-upload availability by basing upload enablement on the message composer’s configured file limits.
    • Made the multi-action attachment UI consistently display the file upload option, even when channel capability details are unavailable.
    • Updated upload control behavior to better reflect current attachment slot availability and upload-request handling.
  • Chores
    • Updated the underlying stream-chat dependency version (main and example apps).

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: db4ca004-f63e-4812-ac0a-a0f70456871c

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between edb6505 and bc84fd0.

β›” Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
πŸ“’ Files selected for processing (3)
  • examples/tutorial/package.json
  • examples/vite/package.json
  • package.json

πŸ“ Walkthrough

Walkthrough

Upload handling now exposes additional attachment-manager state, always renders the file input in the selector, derives file settings from composer configuration without upload or cooldown-based disabling, and updates stream-chat to 9.50.2.

Changes

Upload eligibility

Layer / File(s) Summary
Attachment upload action filtering
src/components/MessageComposer/hooks/useAttachmentManagerState.ts, src/components/MessageComposer/AttachmentSelector/AttachmentSelector.tsx
The attachment manager exposes upload-slot and custom-request flags, while the selector renders UploadFileInput without checking channel capabilities.
File input configuration and enabled state
src/components/ReactFileUtilities/UploadButton.tsx
UploadFileInput reads accepted files and per-message limits from composer configuration and no longer applies upload-enabled or cooldown-based disabling.
stream-chat version alignment
package.json, examples/tutorial/package.json, examples/vite/package.json
Package manifests update stream-chat from ^9.49.0 to ^9.50.2.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: oliverlaz

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only states the goal and references links; it omits implementation details and the required UI Changes section. Add an Implementation details section summarizing the code changes and include the UI Changes section, even if there are no screenshots.
βœ… Passed checks (4 passed)
Check name Status Explanation
Title check βœ… Passed The title matches the main change: permission adjustments for custom doUploadRequest handling.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch custom-do-upload-request-enhancements

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/MessageComposer/AttachmentSelector/AttachmentSelector.tsx (1)

106-134: 🎯 Functional Correctness | πŸ”΄ Critical | ⚑ Quick win

Update the upload eligibility check to match the new logic.

SimpleAttachmentSelector still relies on channelCapabilities['upload-file'] to determine visibility. If uploadFile is the only available action because custom upload requests are permitted (despite the channel capability missing), this component will incorrectly evaluate to null and completely hide the upload button.

Update the check to use the new eligibility logic based on useAttachmentManagerState.

πŸ› Proposed fix
-  const { channelCapabilities } = useChannelStateContext();
+  const { hasAvailableUploadSlots, hasCustomDoUploadRequest, isUploadEnabled } =
+    useAttachmentManagerState();
   const { t } = useTranslationContext();
   const inputRef = useRef<HTMLInputElement | null>(null);
   const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(null);
   const id = useStableId();
   const isCooldownActive = useIsCooldownActive();
   const messageComposer = useMessageComposerController();
+  const channelConfig = messageComposer.channel.getConfig();
   const { command } = useStateStore(
     messageComposer.textComposer.state,
     textComposerStateSelector,
   );
   // Visually hidden via a CSS transition while a command is active; keep it out
   // of the a11y tree and tab order without setting `display: none`.
   const inertProps = useInertWhenHidden(!!command, { setHiddenAttribute: false });
 
   useEffect(() => {
     if (!buttonElement) return;
     const handleKeyUp = (event: KeyboardEvent) => {
       if (![' ', 'Enter'].includes(event.key) || !inputRef.current) return;
       event.preventDefault();
       inputRef.current.click();
     };
     buttonElement.addEventListener('keyup', handleKeyUp);
     return () => {
       buttonElement.removeEventListener('keyup', handleKeyUp);
     };
   }, [buttonElement]);
 
-  if (!channelCapabilities['upload-file']) return null;
+  const canUpload =
+    (!hasCustomDoUploadRequest && channelConfig?.uploads && isUploadEnabled) ||
+    (hasCustomDoUploadRequest && hasAvailableUploadSlots);
+
+  if (!canUpload) return null;
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/MessageComposer/AttachmentSelector/AttachmentSelector.tsx`
around lines 106 - 134, Update the visibility guard in SimpleAttachmentSelector
to use the eligibility state from useAttachmentManagerState instead of
channelCapabilities['upload-file']. Preserve the existing null return when
uploads are not eligible, while allowing the selector to remain visible when
custom upload requests make uploadFile available despite the channel capability.
πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/components/MessageComposer/AttachmentSelector/AttachmentSelector.tsx`:
- Around line 106-134: Update the visibility guard in SimpleAttachmentSelector
to use the eligibility state from useAttachmentManagerState instead of
channelCapabilities['upload-file']. Preserve the existing null return when
uploads are not eligible, while allowing the selector to remain visible when
custom upload requests make uploadFile available despite the channel capability.

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c28c9e5b-c217-4005-af19-d8849a0da453

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 6b6a828 and 2205de8.

πŸ“’ Files selected for processing (3)
  • src/components/MessageComposer/AttachmentSelector/AttachmentSelector.tsx
  • src/components/MessageComposer/hooks/useAttachmentManagerState.ts
  • src/components/ReactFileUtilities/UploadButton.tsx
πŸ’€ Files with no reviewable changes (1)
  • src/components/ReactFileUtilities/UploadButton.tsx

Comment thread src/components/ReactFileUtilities/UploadButton.tsx
@arnautov-anton
arnautov-anton force-pushed the custom-do-upload-request-enhancements branch from 2205de8 to edb6505 Compare July 16, 2026 09:27
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 85.21%. Comparing base (6b6a828) to head (bc84fd0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3243      +/-   ##
==========================================
- Coverage   85.21%   85.21%   -0.01%     
==========================================
  Files         505      505              
  Lines       15784    15779       -5     
  Branches     5010     5008       -2     
==========================================
- Hits        13451    13446       -5     
  Misses       2333     2333              

β˜” View full report in Codecov by Harness.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

Size Change: -35 B (0%)

Total Size: 880 kB

πŸ“¦ View Changed
Filename Size Change
dist/cjs/index.js 292 kB -15 B (-0.01%)
dist/es/index.mjs 290 kB -20 B (-0.01%)
ℹ️ View Unchanged
Filename Size
dist/cjs/audioProcessing.js 1.74 kB
dist/cjs/channel-detail.js 22.9 kB
dist/cjs/emojis.js 2.56 kB
dist/cjs/mp3-encoder.js 814 B
dist/cjs/ReactPlayerWrapper.js 547 B
dist/cjs/useChannelHeaderOnlineStatus.js 41 kB
dist/cjs/useMessageComposerController.js 1.01 kB
dist/cjs/useNotificationApi.js 57.5 kB
dist/css/channel-detail.css 2.84 kB
dist/css/emoji-picker.css 178 B
dist/css/emoji-replacement.css 456 B
dist/css/index.css 41.4 kB
dist/es/audioProcessing.mjs 1.65 kB
dist/es/channel-detail.mjs 22.6 kB
dist/es/emojis.mjs 2.48 kB
dist/es/mp3-encoder.mjs 768 B
dist/es/ReactPlayerWrapper.mjs 485 B
dist/es/useChannelHeaderOnlineStatus.mjs 40.5 kB
dist/es/useMessageComposerController.mjs 935 B
dist/es/useNotificationApi.mjs 56.1 kB

compressed-size-action

@arnautov-anton
arnautov-anton merged commit fa67adf into master Jul 16, 2026
14 checks passed
@arnautov-anton
arnautov-anton deleted the custom-do-upload-request-enhancements branch July 16, 2026 11:03
github-actions Bot pushed a commit that referenced this pull request Jul 16, 2026
## [14.9.0](v14.8.0...v14.9.0) (2026-07-16)

### Bug Fixes

* custom doUploadRequest permission adjustments ([#3243](#3243)) ([fa67adf](fa67adf)), closes [GetStream/stream-chat-js#1800](GetStream/stream-chat-js#1800)
* **MessageComposer:** make textarea full-width in custom composer layouts ([#3241](#3241)) ([05236db](05236db))

### Features

* expose internal contexts and composer components in the public API ([#3242](#3242)) ([6b6a828](6b6a828)), closes [GetStream/docs-content#1431](https://github.com/GetStream/docs-content/issues/1431)
@stream-ci-bot

Copy link
Copy Markdown

πŸŽ‰ This PR is included in version 14.9.0 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants