Skip to content

Commit f038cbb

Browse files
tellahoRizzCarl
authored
fix(sidebar): simplify unread indicators and emphasize priority activity (#7134)
**Category:** fix **User Impact:** The sidebar now presents unread activity consistently: unread rooms are bold, offscreen activity is counted by destination, and DMs or directed activity receive stronger emphasis. **Problem:** Sidebar unread state was split across competing signals: agent work could trigger overflow, message totals inflated its count, non-DM rows showed redundant numerals, and routine room activity looked as urgent as DMs or directed messages. This made the sidebar noisy and made the overflow value harder to interpret. **Solution:** Use one stable offscreen unread control that counts rooms and DMs—not messages—and remove agent work from that signal. Keep ordinary room activity quiet; promote DMs, mentions, broadcasts, and relevant thread replies; preserve DM avatars and targeting; bold every unread room; and retain thread dots while removing non-DM numerals. <details> <summary>File changes</summary> **desktop/src-tauri/src/unread_catch_up.rs** Classifies relevant thread replies as priority activity during native unread catch-up so startup state matches live rendering. **desktop/src/app/AppShell.tsx** Passes the priority unread destination set into the sidebar. **desktop/src/features/channels/useUnreadChannels.ts** Projects unread destinations, priority state, and thread replies consistently while keeping Dock badge behavior separate from sidebar emphasis. **desktop/src/features/sidebar/lib/useOffscreenActivityChannelIds.test.mjs** Removes tests for the superseded agent/activity overflow projection. **desktop/src/features/sidebar/lib/useOffscreenActivityChannelIds.ts** Removes the old agent-plus-message overflow projection so agent work alone no longer creates the unread indicator. **desktop/src/features/sidebar/lib/useSidebarActivityOverflow.ts** Replaces activity-volume overflow state with unread-destination overflow state. **desktop/src/features/sidebar/lib/useSidebarUnreadOverflow.test.mjs** Covers priority detection and destination-count labels for the new overflow projection. **desktop/src/features/sidebar/lib/useSidebarUnreadOverflow.ts** Counts distinct offscreen unread destinations and determines quiet versus primary treatment per direction. **desktop/src/features/sidebar/ui/AppSidebar.tsx** Renders one stable overflow control, preserves protected-DM visibility filtering, and prioritizes visible unread DMs for previews and navigation. **desktop/src/features/sidebar/ui/AppSidebar.types.ts** Adds the priority unread destination set to the sidebar contract. **desktop/src/features/sidebar/ui/CustomChannelSection.tsx** Stops forwarding non-DM unread counts into custom channel rows. **desktop/src/features/sidebar/ui/MoreUnreadButton.test.mjs** Updates control coverage for explicit emphasis, destination labels, and DM targeting. **desktop/src/features/sidebar/ui/MoreUnreadButton.tsx** Applies quiet or primary treatment without changing geometry, accessibility text, DM avatars, or click behavior. **desktop/src/features/sidebar/ui/SidebarSection.tsx** Removes non-DM row numerals while retaining unread weight and thread preview affordances. **desktop/src/shared/ui/UnreadPill.tsx** Shares one composition between quiet and primary states so only color treatment changes. **desktop/tests/e2e/badge.spec.ts** Covers destination counting, promotion without count inflation, DM/thread priority, row bolding, and removed numerals; also captures the reviewed UI states. **desktop/tests/e2e/channel-activity-popover.spec.ts** Updates channel activity assertions for the numeral-free row treatment. **desktop/tests/e2e/channels.spec.ts** Updates channel unread expectations to use bold text rather than a row count. **desktop/tests/e2e/thread-unread.spec.ts** Keeps thread unread-dot and popover coverage while asserting the room itself is bold. </details> ## Reproduction steps 1. Open a workspace with enough sidebar destinations to scroll rooms above or below the viewport. 2. Receive ordinary unread activity in an offscreen room; verify one quiet `N unread` indicator appears and counts the room once regardless of message volume. 3. Receive a mention, broadcast, or relevant thread reply in an offscreen room; verify the same count becomes primary without changing its geometry or adding a badge. 4. Receive an unread DM, including thread-only activity; verify the indicator is primary, shows the DM avatar when available, and navigates to that DM. 5. Scroll the destination onscreen or mark it read; verify the count and treatment update from the remaining offscreen destinations. 6. Inspect unread non-DM rows; verify their names are bold, numeric badges are absent, and thread dots still open the unread-thread preview. ## Screenshots ### Ordinary unread room Routine offscreen room activity uses the quiet treatment. ![Quiet unread overflow indicator](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/7134/sidebar-unread-overflow-default.png) ### Directed unread activity The same destination count becomes primary when an offscreen room has directed activity; geometry and label remain unchanged. ![Primary unread overflow indicator](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/7134/sidebar-unread-overflow-primary.png) ### Thread-only unread DM A DM stays primary and retains its avatar even when only its thread has unread activity. ![Primary DM thread overflow indicator](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/7134/sidebar-dm-thread-overflow-primary.png) --------- Signed-off-by: Taylor Ho <[email protected]> Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz> Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@buzz.block.builderlab.xyz>
1 parent 4d447b9 commit f038cbb

19 files changed

Lines changed: 352 additions & 343 deletions

‎desktop/src-tauri/src/unread_catch_up.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ fn classify_batch(
300300
let broadcast = has_exact_tag(&event.tags, "broadcast", "1");
301301
let threaded = reference.parent_id.is_some() && !broadcast;
302302
let high_priority = item.channel.channel_type == "dm"
303+
|| threaded
303304
|| broadcast
304305
|| has_tag_value(&event.tags, "p", &self_pubkey);
305306
max_trigger = max_trigger.max(event.created_at);
@@ -518,9 +519,9 @@ mod tests {
518519
assert_eq!(
519520
observed_events
520521
.iter()
521-
.map(|event| event.id.as_str())
522+
.map(|event| (event.id.as_str(), event.high_priority))
522523
.collect::<Vec<_>>(),
523-
["external-reply"]
524+
[("external-reply", true)]
524525
);
525526
assert_eq!(discovered.participated, ["root"]);
526527
}

‎desktop/src/app/AppShell.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,7 @@ export function AppShell() {
918918
selectedChannelId={selectedChannelId}
919919
selectedView={selectedView}
920920
unreadChannelIds={unreadChannelIds}
921+
{...{ highPriorityUnreadChannelIds }}
921922
previewActivityChannelIds={unreadThreadChannelIds}
922923
unreadChannelCounts={unreadChannelCounts}
923924
mutedChannelIds={mutedChannelIds}

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

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
} from "@/features/channels/useLiveChannelUpdates";
66
import {
77
countUnreadAppBadgeObservedEvents,
8-
countUnreadBadgeObservedEvents,
98
countUnreadHighPriorityObservedEvents,
109
countUnreadObservedEvents,
1110
hasUnreadTopLevelObservedEvent,
@@ -426,13 +425,14 @@ export function useUnreadChannels(
426425
const handleChannelMessage = React.useCallback(
427426
(channelId: string, event: RelayEvent) => {
428427
const channel = channelsRef.current.find((ch) => ch.id === channelId);
428+
const isThreadedReply =
429+
getThreadReference(event.tags).parentId !== null &&
430+
!isBroadcastReply(event.tags);
429431
const isHighPriority =
430432
channel?.channelType === "dm" ||
433+
isThreadedReply ||
431434
(normalizedPubkey !== null &&
432435
isHighPriorityEventForUser(event, normalizedPubkey));
433-
const isThreadedReply =
434-
getThreadReference(event.tags).parentId !== null &&
435-
!isBroadcastReply(event.tags);
436436
const didRecordUnreadEvent = recordUnreadEvent(
437437
channelId,
438438
makeObservedUnreadEvent({
@@ -852,38 +852,24 @@ export function useUnreadChannels(
852852
) {
853853
topLevelUnread.add(channel.id);
854854
}
855-
const badgeCount =
856-
nativeProjection?.badgeCount ??
857-
countUnreadBadgeObservedEvents(
858-
observedEvents,
859-
readAtForObservedEvent,
860-
);
861855
const appBadgeCount =
862856
nativeProjection?.appBadgeCount ??
863857
countUnreadAppBadgeObservedEvents(
864858
observedEvents,
865859
readAtForObservedEvent,
866860
);
867-
// Sidebar numerals on non-DM rows count every unread mention and
868-
// broadcast, including threaded ones. The Dock projection
869-
// (appBadgeCount) keeps excluding threaded replies because Home's
870-
// badge subtotal already counts those; reusing it here would hide
871-
// thread mentions from the channel row.
872861
const highPriorityCount =
873862
nativeProjection?.highPriorityCount ??
874863
countUnreadHighPriorityObservedEvents(
875864
observedEvents,
876865
readAtForObservedEvent,
877866
);
878-
counts.set(
879-
channel.id,
880-
channel.channelType === "dm" ? badgeCount : highPriorityCount,
881-
);
867+
counts.set(channel.id, unreadCount);
882868
unreadChannelNotificationCount += appBadgeCount;
883869

884870
// DM channels: any unread DM is high-priority. Non-DM: high-priority
885-
// only if at least one mention/broadcast remains unread in its own
886-
// channel/thread context.
871+
// only if at least one mention, broadcast, or relevant thread reply
872+
// remains unread in its own channel/thread context.
887873
if (channel.channelType === "dm" || highPriorityCount > 0) {
888874
highPriority.add(channel.id);
889875
}

‎desktop/src/features/sidebar/lib/useOffscreenActivityChannelIds.test.mjs‎

Lines changed: 0 additions & 52 deletions
This file was deleted.

‎desktop/src/features/sidebar/lib/useOffscreenActivityChannelIds.ts‎

Lines changed: 0 additions & 53 deletions
This file was deleted.

‎desktop/src/features/sidebar/lib/useSidebarActivityOverflow.ts‎

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import assert from "node:assert/strict";
2+
import test from "node:test";
3+
4+
import {
5+
hasHighPriorityOverflow,
6+
sidebarOverflowUnreadLabel,
7+
} from "./useSidebarUnreadOverflow.ts";
8+
9+
test("labels the destination total as unread", () => {
10+
assert.equal(sidebarOverflowUnreadLabel(3), "3 unread");
11+
});
12+
13+
test("promotes actionable unread and every offscreen DM", () => {
14+
const actionable = new Set(["mention"]);
15+
const dms = new Set(["dm"]);
16+
17+
assert.equal(hasHighPriorityOverflow(["channel"], actionable, dms), false);
18+
assert.equal(hasHighPriorityOverflow(["mention"], actionable, dms), true);
19+
assert.equal(hasHighPriorityOverflow(["dm"], actionable, dms), true);
20+
assert.equal(
21+
hasHighPriorityOverflow(["channel", "dm"], actionable, dms),
22+
true,
23+
);
24+
});
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import * as React from "react";
2+
3+
import { useUnreadOverflow } from "@/features/sidebar/lib/useUnreadOverflow";
4+
5+
type ScrollRef = Parameters<typeof useUnreadOverflow>[0]["scrollRef"];
6+
7+
/**
8+
* Returns whether any offscreen destination is a DM or has directed unread
9+
* activity, which should keep the sidebar overflow control emphasized.
10+
*/
11+
export function hasHighPriorityOverflow(
12+
offscreenChannelIds: readonly string[],
13+
highPriorityUnreadChannelIds: ReadonlySet<string>,
14+
dmChannelIds: ReadonlySet<string>,
15+
) {
16+
return offscreenChannelIds.some(
17+
(channelId) =>
18+
dmChannelIds.has(channelId) ||
19+
highPriorityUnreadChannelIds.has(channelId),
20+
);
21+
}
22+
23+
/** Formats the accessible label for a distinct unread destination count. */
24+
export function sidebarOverflowUnreadLabel(count: number) {
25+
return `${count} unread`;
26+
}
27+
28+
/**
29+
* Projects unread message and thread activity into offscreen destination sets.
30+
* Message and preview destinations are unioned and deduplicated; DMs and
31+
* destinations with directed unread activity receive high-priority treatment.
32+
*/
33+
export function useSidebarUnreadOverflow({
34+
dmChannelIds,
35+
highPriorityUnreadChannelIds,
36+
previewActivityChannelIds,
37+
scrollRef,
38+
unreadChannelIds,
39+
}: {
40+
dmChannelIds: ReadonlySet<string>;
41+
highPriorityUnreadChannelIds: ReadonlySet<string>;
42+
previewActivityChannelIds: ReadonlySet<string>;
43+
scrollRef: ScrollRef;
44+
unreadChannelIds: ReadonlySet<string>;
45+
}) {
46+
const messageChannelIds = React.useMemo(
47+
() => new Set([...unreadChannelIds, ...previewActivityChannelIds]),
48+
[previewActivityChannelIds, unreadChannelIds],
49+
);
50+
const messageOverflow = useUnreadOverflow({
51+
scrollRef,
52+
unreadChannelIds: messageChannelIds,
53+
});
54+
55+
return {
56+
...messageOverflow,
57+
unreadMessageBelowChannelIds: messageOverflow.unreadBelowChannelIds,
58+
hasHighPriorityAbove: hasHighPriorityOverflow(
59+
messageOverflow.unreadAboveChannelIds,
60+
highPriorityUnreadChannelIds,
61+
dmChannelIds,
62+
),
63+
hasHighPriorityBelow: hasHighPriorityOverflow(
64+
messageOverflow.unreadBelowChannelIds,
65+
highPriorityUnreadChannelIds,
66+
dmChannelIds,
67+
),
68+
};
69+
}

0 commit comments

Comments
 (0)