fix: custom doUploadRequest permission adjustments#3243
Conversation
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: β Files ignored due to path filters (1)
π Files selected for processing (3)
π WalkthroughWalkthroughUpload 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 ChangesUpload eligibility
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: π₯ Pre-merge checks | β 4 | β 1β Failed checks (1 warning)
β Passed checks (4 passed)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winUpdate the upload eligibility check to match the new logic.
SimpleAttachmentSelectorstill relies onchannelCapabilities['upload-file']to determine visibility. IfuploadFileis the only available action because custom upload requests are permitted (despite the channel capability missing), this component will incorrectly evaluate tonulland 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
π Files selected for processing (3)
src/components/MessageComposer/AttachmentSelector/AttachmentSelector.tsxsrc/components/MessageComposer/hooks/useAttachmentManagerState.tssrc/components/ReactFileUtilities/UploadButton.tsx
π€ Files with no reviewable changes (1)
- src/components/ReactFileUtilities/UploadButton.tsx
2205de8 to
edb6505
Compare
Codecov Reportβ
All modified and coverable lines are covered by tests. 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. π New features to boost your workflow:
|
|
Size Change: -35 B (0%) Total Size: 880 kB π¦ View Changed
βΉοΈ View Unchanged
|
## [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)
|
π This PR is included in version 14.9.0 π The release is available on: Your semantic-release bot π¦π |
π― Goal
Ref: https://getstream.slack.com/archives/C02R5UCGN6N/p1784023573649669
Relies on: GetStream/stream-chat-js#1800
Summary by CodeRabbit
stream-chatdependency version (main and example apps).