mirror of
https://github.com/block/buzz.git
synced 2026-11-08 10:21:46 +00:00
Preserve persistent agent audience order (#1989)
Signed-off-by: npub1d6t84ajeg9skp2609l2k6axgcme8x7g7u7luj352r03hcwreg7lqnxcsex <6e967af659416160ab4f2fd56d74c8c6f273791ee7bfc9468a1be37c387947be@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1d6t84ajeg9skp2609l2k6axgcme8x7g7u7luj352r03hcwreg7lqnxcsex <6e967af659416160ab4f2fd56d74c8c6f273791ee7bfc9468a1be37c387947be@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import * as React from "react";
|
||||
import { ArrowDown } from "lucide-react";
|
||||
|
||||
import { useKnownAgentPubkeys } from "@/features/agents/useKnownAgentPubkeys";
|
||||
import { orderMentionPubkeysByText } from "@/features/messages/lib/orderMentionPubkeys";
|
||||
import { normalizePubkey } from "@/shared/lib/pubkey";
|
||||
import { resolveMentionProps } from "@/shared/lib/resolveMentionNames";
|
||||
import {
|
||||
buildThreadSummaryFromVisibleEntries,
|
||||
hasNestedThreadBranches,
|
||||
@@ -596,6 +600,30 @@ export function MessageThreadPanel({
|
||||
targetMessageId: scrollTargetId,
|
||||
});
|
||||
|
||||
const knownAgentPubkeys = useKnownAgentPubkeys();
|
||||
const initialAgentPubkeys = React.useMemo(() => {
|
||||
if (
|
||||
!threadHead ||
|
||||
!currentPubkey ||
|
||||
normalizePubkey(threadHead.signerPubkey ?? threadHead.pubkey ?? "") !==
|
||||
normalizePubkey(currentPubkey)
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
const { mentionPubkeysByName } = resolveMentionProps(
|
||||
threadHead.tags,
|
||||
profiles,
|
||||
);
|
||||
if (!mentionPubkeysByName) return [];
|
||||
|
||||
return orderMentionPubkeysByText(
|
||||
threadHead.body,
|
||||
mentionPubkeysByName,
|
||||
(pubkey) =>
|
||||
knownAgentPubkeys.has(pubkey) || profiles?.[pubkey]?.isAgent === true,
|
||||
);
|
||||
}, [currentPubkey, knownAgentPubkeys, profiles, threadHead]);
|
||||
|
||||
if (!threadHead) {
|
||||
return null;
|
||||
}
|
||||
@@ -884,6 +912,7 @@ export function MessageThreadPanel({
|
||||
audienceContext={{
|
||||
type: "thread",
|
||||
threadRootId: threadHead.id,
|
||||
initialAgentPubkeys,
|
||||
}}
|
||||
channelId={channelId}
|
||||
channelName={channelName}
|
||||
|
||||
Reference in New Issue
Block a user