Skip to content

Conversation

@nuno-vieira
Copy link
Member

@nuno-vieira nuno-vieira commented Oct 23, 2025

🔗 Issue Links

https://linear.app/stream/issue/IOS-1201/swiftui-deleting-a-draft-clears-newly-entered-text

🎯 Goal

Fix composer deleting newly entered text after deleting draft text.

🛠 Implementation

For now, we are going to remove the synchronisation of deleting the draft from the event while the channel is open. (The draft will still be deleted in the local state, but it won't be reflected in the composer if the channel is open). This use case is very rare; if you have 2 devices opened in the same channel, and from one of the devices you delete the draft, you probably don't care if the composer on the other device also gets deleted. You can simply delete it yourself.

The only way to properly solve this issue is if the deleted event contained the draft text that was deleted, so that we are sure we only delete drafts in the composer if the text still matches. At the moment, we don't have this. The issue is recorded on the backend here. But for now, better to remove this handling since it is causing serious harm for something that is not really useful.

🧪 Manual Testing Notes

  1. Open a channel
  2. Enter text
  3. Leave channel
  4. Open the same channel, draft message is there
  5. Select all, delete
  6. Quickly type new text
  7. Should not delete new text

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Documentation has been updated in the docs-content repo

@nuno-vieira nuno-vieira requested a review from a team as a code owner October 23, 2025 11:21
@coderabbitai
Copy link

coderabbitai bot commented Oct 23, 2025

Walkthrough

The PR removes the automatic clearing of composer content when a DraftDeletedEvent is received. This fixes a bug where newly entered text was inadvertently deleted alongside draft content, eliminating the problematic event-handling logic and its corresponding tests.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added bug fix entry documenting the resolution of issue #3854 regarding composer text deletion.
Event Handling Removal
Sources/StreamChatUI/ChatChannel/ChatChannelVC.swift, Sources/StreamChatUI/ChatThread/ChatThreadVC.swift
Removed DraftDeletedEvent handling that was clearing message composer content when drafts were deleted.
Test Removal
Tests/StreamChatUITests/SnapshotTests/ChatChannel/ChatChannelVC_Tests.swift, Tests/StreamChatUITests/SnapshotTests/ChatThread/ChatThreadVC_Tests.swift
Removed test cases validating the now-removed DraftDeletedEvent clearing behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

The changes consist of homogeneous removals across two event handlers and two corresponding test cases. The logic being removed is straightforward, requiring minimal reasoning per file. The pattern is consistent throughout, and the scope is well-contained.

Suggested labels

🟢 QAed

Suggested reviewers

  • laevandus
  • martinmitrevski

Poem

🐰 A draft so deleted, a fix now complete,
No more text vanishing in retreat!
We removed the code that caused the dismay,
Let composers compose—text here to stay! ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Fix composer deleting newly entered text after deleting draft text" directly and clearly describes the primary change in the changeset. The title accurately reflects the main objective of removing the DraftDeletedEvent handling that was unconditionally clearing composer content, which caused users' newly typed text to be lost. The title is concise, specific, and would allow a teammate scanning the commit history to understand the fix at a glance.
Linked Issues Check ✅ Passed The code changes directly address the objectives from IOS-1201 by removing the problematic DraftDeletedEvent handling that was unconditionally clearing the composer content. The PR eliminates the code branches in ChatChannelVC.swift and ChatThreadVC.swift that were executing clearInputData() when a DraftDeletedEvent matched the current channel or thread, preventing newly entered text from being deleted. The associated test cases are appropriately removed to reflect this behavior change. CHA-1409 is a backend task to include draft content in delete events, which is outside the scope of this PR and acknowledged in the PR objectives as a future improvement.
Out of Scope Changes Check ✅ Passed All changes in the pull request are directly scoped to fixing the draft deletion issue. The removals in ChatChannelVC.swift and ChatThreadVC.swift eliminate the DraftDeletedEvent handling logic that caused the bug, the test removals in ChatChannelVC_Tests.swift and ChatThreadVC_Tests.swift remove tests validating the removed behavior, and the CHANGELOG.md update documents the fix as a client-facing change. No unrelated features, refactoring, or incidental modifications are present in this changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/composer-new-input-text-deleted-after-deleting-draft

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 and usage tips.

@Stream-SDK-Bot
Copy link
Collaborator

SDK Performance

target metric benchmark branch performance status
MessageList Hitches total duration 10 ms 5.01 ms 49.9% 🔼 🟢
Duration 2.6 s 2.54 s 2.31% 🔼 🟢
Hitch time ratio 4 ms per s 1.97 ms per s 50.75% 🔼 🟢
Frame rate 75 fps 78.1 fps 4.13% 🔼 🟢
Number of hitches 1 0.6 40.0% 🔼 🟢

@Stream-SDK-Bot
Copy link
Collaborator

SDK Size

title develop branch diff status
StreamChat 8.26 MB 8.26 MB 0 KB 🟢
StreamChatUI 4.89 MB 4.89 MB 0 KB 🟢

@Stream-SDK-Bot
Copy link
Collaborator

StreamChatUI XCSize

Object Diff (bytes)
ChatChannelVC.o -376
ChatThreadVC.o -376

@github-actions
Copy link

Public Interface

🚀 No changes affecting the public interface.

@sonarqubecloud
Copy link

@nuno-vieira nuno-vieira merged commit de2f795 into develop Oct 23, 2025
14 checks passed
@nuno-vieira nuno-vieira deleted the fix/composer-new-input-text-deleted-after-deleting-draft branch October 23, 2025 13:27
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.

4 participants