Skip to content

Commit 0362156

Browse files
authored
Allow following channel messages before their first reply (#7692)
## Summary Channel messages only offered Follow thread after receiving a reply. Add Follow/Unfollow to delivered messages immediately, so users can opt into future replies. Keep the same follow state when broadcast replies gain replies of their own. Threads you authored, participated in, or explicitly followed offer Unfollow. A mention alone leaves Follow available. These controls apply to channel timelines; DM notification behavior remains unchanged. ### Related issue None found in existing issues or PRs. ### Testing - Browser regressions cover keyboard follow/unfollow, persistence after reload, first-reply unread and notification delivery, suppression after unfollow, pending-message exclusion, broadcast reply transitions after revealing buffered arrivals, and immediate unfollow for your own messages. - Additional regressions cover following after a mention and the absence of Follow/Unfollow controls in DM timelines. - Desktop unit tests, typecheck, lint, and production build pass. - Browser notification routing is covered; native OS banner appearance was not tested. ### Screenshots | Before | After | |--------|--------| | <img width="979" height="301" alt="before" src="https://github.com/user-attachments/assets/1a739187-5bc3-4e23-a334-723ca69672f5" /> | <img width="979" height="337" alt="after" src="https://github.com/user-attachments/assets/57df4ff9-bac4-4b9d-a39f-5664e0f9ece0" /> | --------- Signed-off-by: Matthew Boston <[email protected]>
1 parent 0ee2ad7 commit 0362156

8 files changed

Lines changed: 487 additions & 23 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Desktop and shared changes
6+
7+
- Follow or unfollow delivered channel messages before their first reply.
8+
39
## v0.5.26
410

511
### Desktop and shared changes

‎desktop/playwright.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default defineConfig({
2323
"**/mock-subscription-readiness.spec.ts",
2424
"**/owned-agent-discovery.spec.ts",
2525
"**/thread-head-stale-edit.spec.ts",
26+
"**/thread-follow.spec.ts",
2627
"**/sidebar-offcanvas-rail.spec.ts",
2728
"**/tooltip-semantics.spec.ts",
2829
"**/search-scope-screenshots.spec.ts",

‎desktop/src/app/AppShell.tsx‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ export function AppShell() {
392392
setContextParentResolver,
393393
participatedRootIds,
394394
authoredRootIds,
395-
mentionedRootIds,
396395
recordThreadInteraction,
397396
threadActivityItems,
398397
mutedRootIds,
@@ -485,15 +484,8 @@ export function AppShell() {
485484
!mutedRootIds.has(rootId) &&
486485
(followedRootIds.has(rootId) ||
487486
participatedRootIds.has(rootId) ||
488-
authoredRootIds.has(rootId) ||
489-
mentionedRootIds.has(rootId)),
490-
[
491-
followedRootIds,
492-
mutedRootIds,
493-
participatedRootIds,
494-
authoredRootIds,
495-
mentionedRootIds,
496-
],
487+
authoredRootIds.has(rootId)),
488+
[followedRootIds, mutedRootIds, participatedRootIds, authoredRootIds],
497489
);
498490

499491
const handleFollowThread = React.useCallback(

‎desktop/src/features/channels/ui/ChannelScreen.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export function ChannelScreen({
117117
openChannelManagement: openGlobalChannelManagement,
118118
followThread,
119119
unfollowThread,
120-
isFollowingThread,
121120
isNotifiedForThread,
122121
recordThreadInteraction,
123122
isThreadMuted,
@@ -877,7 +876,7 @@ export function ChannelScreen({
877876
}
878877
followThreadById={followThread}
879878
unfollowThreadById={unfollowThread}
880-
isFollowingThreadById={isFollowingThread}
879+
isFollowingThreadById={isNotifiedForThread}
881880
isMessageUnreadById={isMessageUnread}
882881
isFollowingThread={isNotifiedForEffectiveThread}
883882
isSending={sendMessageMutation.isPending}
@@ -993,4 +992,4 @@ export function ChannelScreen({
993992
</ProfilePanelProvider>
994993
</AgentSessionProvider>
995994
);
996-
}
995+
}

‎desktop/src/features/channels/useUnreadChannels.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,23 +571,30 @@ export function useUnreadChannels(
571571

572572
const muteThread = React.useCallback(
573573
(rootId: string) => {
574+
const didAdd = !mutedRootIdsRef.current.has(rootId);
574575
mutedRootIdsRef.current.add(rootId);
575576
observedPersistence.updateMembership("muted_root", rootId, true);
576577
if (normalizedPubkey !== null) {
577578
mutedStore.write(normalizedPubkey, mutedRootIdsRef.current);
578579
}
580+
if (didAdd) {
581+
bumpMembershipVersion();
582+
}
579583
bumpLatestVersion();
580584
},
581585
[normalizedPubkey, observedPersistence],
582586
);
583587

584588
const unmuteThread = React.useCallback(
585589
(rootId: string) => {
586-
mutedRootIdsRef.current.delete(rootId);
590+
const didDelete = mutedRootIdsRef.current.delete(rootId);
587591
observedPersistence.updateMembership("muted_root", rootId, false);
588592
if (normalizedPubkey !== null) {
589593
mutedStore.write(normalizedPubkey, mutedRootIdsRef.current);
590594
}
595+
if (didDelete) {
596+
bumpMembershipVersion();
597+
}
591598
bumpLatestVersion();
592599
},
593600
[normalizedPubkey, observedPersistence],
@@ -949,6 +956,11 @@ export function useUnreadChannels(
949956
() => new Set(mentionedRootIdsRef.current) as ReadonlySet<string>,
950957
[membershipVersion],
951958
);
959+
// biome-ignore lint/correctness/useExhaustiveDependencies: membershipVersion is the intentional re-derivation signal
960+
const mutedRootIds = React.useMemo(
961+
() => new Set(mutedRootIdsRef.current) as ReadonlySet<string>,
962+
[membershipVersion],
963+
);
952964

953965
return {
954966
unreadChannelIds,
@@ -977,7 +989,7 @@ export function useUnreadChannels(
977989
currentActivityScope,
978990
threadActivityRef.current,
979991
),
980-
mutedRootIds: mutedRootIdsRef.current as ReadonlySet<string>,
992+
mutedRootIds,
981993
muteThread,
982994
unmuteThread,
983995
};

‎desktop/src/features/messages/ui/TimelineMessageList.tsx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ export const TimelineMessageList = React.memo(function TimelineMessageList({
249249
channelId={channelId}
250250
currentPubkey={currentPubkey}
251251
entry={item.entry}
252-
followThreadById={followThreadById}
252+
followThreadById={
253+
channelType === "dm" ? undefined : followThreadById
254+
}
253255
footer={messageFooters?.[item.entry.message.id] ?? null}
254256
highlightedMessageId={highlightedMessageId}
255257
huddleMemberPubkeys={huddleMemberPubkeys}
@@ -263,7 +265,9 @@ export const TimelineMessageList = React.memo(function TimelineMessageList({
263265
? false
264266
: item.isFollowedByContinuation
265267
}
266-
isFollowingThreadById={isFollowingThreadById}
268+
isFollowingThreadById={
269+
channelType === "dm" ? undefined : isFollowingThreadById
270+
}
267271
isUnread={isMessageUnreadById?.(item.entry.message.id)}
268272
playEntrance={item.entry.message.id === entranceMessageId}
269273
onEntranceComplete={onEntranceMessageComplete}
@@ -279,7 +283,9 @@ export const TimelineMessageList = React.memo(function TimelineMessageList({
279283
searchMatchingMessageIds={searchMatchingMessageIds}
280284
searchQuery={searchQuery}
281285
threadUnreadCounts={threadUnreadCounts}
282-
unfollowThreadById={unfollowThreadById}
286+
unfollowThreadById={
287+
channelType === "dm" ? undefined : unfollowThreadById
288+
}
283289
videoReviewContext={videoReviewContextById.get(
284290
item.entry.message.id,
285291
)}
@@ -289,6 +295,7 @@ export const TimelineMessageList = React.memo(function TimelineMessageList({
289295
},
290296
[
291297
channelId,
298+
channelType,
292299
alwaysShowMessageIdentity,
293300
currentPubkey,
294301
followThreadById,

‎desktop/src/features/messages/ui/TimelineMessageRow.tsx‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export function MessageRowItem({
130130
);
131131
const canDelete = canManage && onDelete ? onDelete : undefined;
132132
const canEdit = canManage && onEdit ? onEdit : undefined;
133+
const effectiveThreadRootId = message.rootId ?? message.id;
133134

134135
if (summary && onOpenThread) {
135136
const isHighlighted = message.id === highlightedMessageId;
@@ -149,8 +150,8 @@ export function MessageRowItem({
149150
huddleMemberPubkeysPending={huddleMemberPubkeysPending}
150151
hideAgentAccessBadge={hideAgentAccessBadges}
151152
isFollowingThread={
152-
isFollowingThreadById
153-
? isFollowingThreadById(message.id)
153+
!message.pending && isFollowingThreadById
154+
? isFollowingThreadById(effectiveThreadRootId)
154155
: undefined
155156
}
156157
isUnread={isUnread}
@@ -161,15 +162,17 @@ export function MessageRowItem({
161162
onDelete={canDelete}
162163
onEdit={canEdit}
163164
onFollowThread={
164-
followThreadById ? () => followThreadById(message.id) : undefined
165+
!message.pending && followThreadById
166+
? () => followThreadById(effectiveThreadRootId)
167+
: undefined
165168
}
166169
onMarkRead={onMarkRead}
167170
onMarkUnread={onMarkUnread}
168171
onToggleReaction={onToggleReaction}
169172
onReply={onReply}
170173
onUnfollowThread={
171-
unfollowThreadById
172-
? () => unfollowThreadById(message.id)
174+
!message.pending && unfollowThreadById
175+
? () => unfollowThreadById(effectiveThreadRootId)
173176
: undefined
174177
}
175178
profiles={profiles}
@@ -207,16 +210,31 @@ export function MessageRowItem({
207210
huddleMemberPubkeysPending={huddleMemberPubkeysPending}
208211
hideAgentAccessBadge={hideAgentAccessBadges}
209212
isContinuation={isContinuation}
213+
isFollowingThread={
214+
!message.pending && isFollowingThreadById
215+
? isFollowingThreadById(effectiveThreadRootId)
216+
: undefined
217+
}
210218
isUnread={isUnread}
211219
playEntrance={playEntrance}
212220
onEntranceComplete={onEntranceComplete}
213221
message={message}
214222
onDelete={canDelete}
215223
onEdit={canEdit}
224+
onFollowThread={
225+
!message.pending && followThreadById
226+
? () => followThreadById(effectiveThreadRootId)
227+
: undefined
228+
}
216229
onMarkRead={onMarkRead}
217230
onMarkUnread={onMarkUnread}
218231
onToggleReaction={onToggleReaction}
219232
onReply={onReply}
233+
onUnfollowThread={
234+
!message.pending && unfollowThreadById
235+
? () => unfollowThreadById(effectiveThreadRootId)
236+
: undefined
237+
}
220238
profiles={profiles}
221239
searchQuery={isSearchMatch ? searchQuery : undefined}
222240
showDepthGuides={false}

0 commit comments

Comments
 (0)