Repository navigation
fix(threads): notify the parent author when someone starts a thread - #8151
jrainville wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved thread-notification defects can notify thread creators, trigger notifications when Threads is disabled, and lose or misidentify parent context during edits or backup restoration.
4 open issues
What changed in this PR
Moves thread-start notifications into status-go, so clients no longer need a quoted reply to notify the parent author.
Changes:
- Adds once-per-thread Reply notifications using shared notification eligibility rules.
- Persists notification claims and marks existing threads as already notified.
- Adds notification and persistence tests.
| File | Description |
|---|---|
internal/protocol/migrations/sqlite/1796213200_add_thread_parent_author_notified.up.sql |
Adds and backfills the notification flag. |
internal/protocol/messenger.go |
Creates thread-start notifications with parent context. |
internal/protocol/messenger_activity_center_threads_test.go |
Tests notifications, deduplication, and claim eligibility. |
internal/protocol/message_persistence.go |
Adds the atomic notification claim. |
internal/protocol/activity_center.go |
Extracts shared chat eligibility checks. |
Review effort: Balanced
2a9fdd6 to
f976bb0
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved thread-notification bugs can replace reply targets, overwrite mention and read state, generate incorrect legacy-thread notifications, and miss notifications when the parent arrives late.
4 open issues
4 resolved since last review
Review effort: Balanced
Part of status-im/status-app#23479 When someone else starts a thread on the user's message, the first message from another member now creates a Reply notification in the Activity Center that points to the parent message. The first thread message no longer has to set `responseTo` to the parent, so it is not shown as a quoted reply. - Add `threads.parent_author_notified` so the parent author is notified only once per thread. Existing threads are marked as already notified. - Only the earliest message from another member can set the flag. Out-of-order delivery and restored history do not notify again. - Skip the notification when the user created the thread, or when the first message already mentions or replies to them. - Keep the existing rules for muted and inactive chats and for community messages sent before the user joined.
- Only notify the parent author when the Threads feature is enabled. - Load the parent from the thread's stored parent message ID, since restored threads can use a different thread ID. - Keep the parent message when the first thread message is edited while its notification is unread.
… author A thread message received before the thread's creation metadata has no known creator yet. Notifying then could tell the parent author that someone else started a thread they created on another device. - Skip the thread start claim while the thread's creator is pending. - When the creation metadata sets the creator, notify the parent author for the earliest message from someone else, if the thread was not created by them and that message did not already mention or reply to them. - Share the notification building between the received message and the creation metadata paths.
f976bb0 to
ac0bf00
Compare
…lace their parent on edit - Only claim the thread start notification when the thread's creator is recorded and is someone else. Restored threads without a creator may have been created by the parent author. - Keep the thread's parent in a thread start notification when the first message is edited, also when that message quotes another message.
When the thread creation metadata arrives after the first message, check whether that message already has a notification instead of inferring it from its current content. Edits can add or remove a mention before the metadata arrives.
Match claim ordering to the earliest-message lookup when clocks tie, and persist the notification with its claim so failed saves remain retryable.
ac0bf00 to
d2a1f0a
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Two moderate active findings identify notification paths that can permanently miss thread-start alerts when messages or creation metadata arrive through different sync and archive orders.
2 open issues
2 resolved since last review
Review effort: Lite
| parent, err := m.persistence.MessageByID(thread.ParentMessageID) | ||
| if errors.Is(err, common.ErrRecordNotFound) { | ||
| return nil | ||
| } |
| // Messages from others may have arrived before the creator was known. | ||
| if creatorResolved && !state.CurrentMessageState.FromArchive { | ||
| if err := m.notifyThreadStartAfterCreation(state.Response, chat, metadata.ThreadId); err != nil { |

Summary
Needed for status-im/status-app#23479
When someone else starts a thread on the user's message, the user now gets an Activity Center notification. Before, the app made this happen by sending the first thread message with the parent's ID as
responseTo. That made the first message show as a quoted reply (status-im/status-app#23479). status-go now creates the notification itself from the message'sthreadId, so the app no longer needsresponseTo.Changes
Notification: in
addNewActivityCenterNotification, a new message in a thread on the user's message, sent by someone else, creates a Reply notification. ItsReplyMessageis the parent message, so existing clients show it without changes.Only once per thread: a new
ClaimThreadStartNotificationsets thethreads.parent_author_notifiedflag in a single SQL update. It only succeeds if all of these hold:So the first message from someone else triggers it, even when messages arrive out of order or come from restored history.
No duplicates: if the first message already mentions or replies to the user, only that notification is created. The flag is still set, so nothing extra fires later.
Same rules as other notifications: muted and inactive chats, and community messages from before the user joined, are handled as for Mention and Reply. The chat check is moved into
chatShowsMentionAndReplyActivityCenterNotificationsso both paths share it.Migration
1796213200_add_thread_parent_author_notified: adds the column and marks existing threads as already notified, so nobody gets a notification for an old thread.Nothing changes in the messages sent between clients: no protobuf or wire changes.
Tests
TestMessengerActivityCenterMessageSuite/TestThreadStartNotifiesParentAuthorOnce, with two messengers in a group chat:responseTo, and a second message creates none;TestClaimThreadStartNotification: checks the ordering, parent-ownership, creator and "only once" rules.TestThreadMentionAndReplyNotifications,TestMutedThreadPreservesMentionAndReplyActivityandTestThreadMuteSuppressesOnlyOrdinaryThreadActivitystill pass.make test-single PKG=./internal/protocol TEST='TestMessengerActivityCenterMessageSuite': passes. The new "first message" test fails without the change inmessenger.go.Risk