Skip to content

fix: custom doUploadRequest permission adjustments#3243

Open
arnautov-anton wants to merge 1 commit into
masterfrom
custom-do-upload-request-enhancements
Open

fix: custom doUploadRequest permission adjustments#3243
arnautov-anton wants to merge 1 commit 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 handling based on current attachment limits and upload configuration.
    • File uploads are now presented consistently, including when channel capability information is unavailable.
    • Updated upload controls to reflect the message composer’s configured file limits more reliably.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

πŸ“ Walkthrough

Walkthrough

Upload eligibility now uses attachment-manager state and composer configuration instead of channel capabilities, while the file input is always rendered and no longer disabled by upload or cooldown state.

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, which the selector uses to determine upload-file action availability and render UploadFileInput.
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.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: oliverlaz, martincupela

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only includes the goal and references, but misses the required implementation details and UI changes sections. Add the Implementation details section and include UI Changes or explicitly note that there are none.
βœ… Passed checks (4 passed)
Check name Status Explanation
Title check βœ… Passed The title matches the main change by calling out custom doUploadRequest permission adjustments.
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 docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ 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

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.

1 participant