Disable composer during slow mode#6499
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
WalkthroughThis PR adds slow-mode/cooldown functionality to the message composer. When a channel has cooldown enabled, the input field and attachments button are disabled, the border color changes, and a countdown placeholder is shown. Tests verify the behavior at unit, snapshot, and E2E levels. Localization strings support 9 languages. ChangesMessage Composer Slow Mode Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
@CodeRabbit review |
✅ Action performedReview finished.
|
While slow mode is active (coolDownTime > 0) the whole composer is locked: the input field and attachment button are disabled, the composer and attachment-button borders switch to the disabled colour, and the input placeholder shows the remaining seconds. It re-enables automatically when the timer reaches zero. Add the stream_ui_message_composer_placeholder_slow_mode string with translations, plus slow-mode snapshots for the full composer and the input.
Add an instrumented slow-mode suite to the compose sample, mirroring the iOS SlowMode_Tests. BackendRobot.setCooldown drives the shared mock server (config/cooldown), and the new UserRobot assertions check the cooldown indicator, the hidden send button, and the disabled input and attachment button. CoolDownIndicator gets a testTag so the e2e layer can locate it.
61f4779 to
aad304d
Compare
The composer gated slow mode on the channel's slow-mode own-capability. The backend grants that capability only when cooldown > 0 and the user cannot skip slow mode, so checking those two conditions directly is equivalent today and keeps the client correct if the backend later changes how the capability is granted, without needing a client release. This also aligns the behaviour with the iOS and Flutter SDKs, which do not require the capability either.
aad304d to
9bfa16e
Compare
|



Resolves AND-1177.
Goal
When slow mode is active on a channel (
coolDownTime > 0), the whole composer should be disabled, not just the send action. This follows the design decision DS-035 ("Slow Mode Locks the Entire Composer"). Before this change, only the send button was replaced by the countdown. The input field and the attachment "+" button stayed interactive and the composer border kept its default colour, which contradicted the spec.Implementation
While
coolDownTime > 0:MessageComposerInputCenterContent), and its placeholder shows the remaining seconds ("Slow mode, wait 9s…") via the newstream_ui_message_composer_placeholder_slow_modestring, with translations for all supported locales.MessageComposerLeadingContent). Its click action is removed from the accessibility tree while disabled.borderUtilityDisabledand returns toborderCoreDefaultonce the timer reaches zero (MessageInput). The composer node usesborder/utility/disabledhere (confirmed with design), so no new colour token was added.The composer re-enables automatically when the timer reaches zero, because every slot reads from
MessageComposerState.coolDownTime. Factory overrides that only replace the trailing content keep working without changes.Slow mode activation is also relaxed (
MessageComposerController): it now triggers oncooldown > 0and the absence of theskip-slow-modecapability, instead of also requiring theslow-modeown-capability. The backend only grantsslow-modewhencooldown > 0and the user cannot skip it, so this is equivalent today, but it keeps the client correct if the backend later tightens how that capability is granted, without needing a new client release. It also aligns the activation rule with the iOS and Flutter SDKs.🎨 UI Changes
Verify the snapshots diff
Testing
Manual steps:
channelClient.enableSlowMode(seconds)).Automated:
MessageComposerScreenTest(input and "+" disabled during cooldown, slow-mode placeholder, both enabled without cooldown) and Paparazzi snapshots inMessageComposerInputTestandMessageComposerTest.MessageComposerControllerTestassert the cooldown activates without theslow-modecapability and stays off when the user can skip slow mode.SlowModeTestsin the compose sample (cooldown shown after sending, composer locked during cooldown), mirroring the iOSSlowMode_Tests. The e2e suite needs the emulator and the mock-server driver, so it runs in CI.Summary by CodeRabbit
New Features
Tests