Fix task unread scoping

This commit is contained in:
klopez4212
2026-06-30 08:15:44 +01:00
parent e0d62a4e28
commit ebda2aea03
2 changed files with 23 additions and 2 deletions
@@ -4,7 +4,10 @@ import { cacheSearchHitEvent } from "@/app/navigation/searchHitEventCache";
import { useAppNavigation } from "@/app/navigation/useAppNavigation";
import { useActiveChannelHeader } from "@/features/channels/useActiveChannelHeader";
import { useChannelPaneHandlers } from "@/features/channels/useChannelPaneHandlers";
import { buildAgentConversationMarkers } from "@/features/agents/agentConversations";
import {
buildAgentConversationMarkers,
getHiddenAgentConversationMessageIds,
} from "@/features/agents/agentConversations";
import {
useChannelMembersQuery,
useJoinChannelMutation,
@@ -446,6 +449,19 @@ export function ChannelScreen({
() => buildAgentConversationMarkers(resolvedMessages),
[resolvedMessages],
);
const unreadTimelineMessages = React.useMemo(() => {
const hiddenMessageIds = getHiddenAgentConversationMessageIds(
timelineMessages,
agentConversationMarkers,
);
if (hiddenMessageIds.size === 0) {
return timelineMessages;
}
return timelineMessages.filter(
(message) => !hiddenMessageIds.has(message.id),
);
}, [agentConversationMarkers, timelineMessages]);
const channelFind = useChannelFind({
channelId: activeChannelId,
messages: timelineMessages,
@@ -468,7 +484,7 @@ export function ChannelScreen({
unreadCount,
} = useChannelUnreadState({
activeChannelId,
timelineMessages,
timelineMessages: unreadTimelineMessages,
currentPubkey,
openThreadHeadId,
threadReplyTargetId,
@@ -22,7 +22,10 @@ abstract final class EventKind {
static const dmVisibility = 30622;
static const streamMessageV2 = 40002;
static const streamMessageEdit = 40003;
static const streamMessagePinned = 40004;
static const streamMessageDiff = 40008;
static const agentConversation = 40010;
static const agentConversationCompat = streamMessagePinned;
static const systemMessage = 40099;
static const forumPost = 45001;
static const forumComment = 45003;
@@ -48,7 +51,9 @@ abstract final class EventKind {
...channelMessageEventKinds,
40001, // legacy pre-migration stream messages
streamMessageEdit, // 40003
agentConversationCompat, // 40004 — staging-compatible task marker
streamMessageDiff, // 40008
agentConversation, // 40010 — task marker
systemMessage, // 40099
huddleStarted, // 48100 — visible huddle session row
huddleParticipantJoined, // 48101 — huddle lifecycle metadata