Skip to content

Commit a2d8be5

Browse files
tellahoRizzCarl
authored
feat(desktop-messages): keep agents addressed across messages (#6315)
**Category:** new-feature **User Impact:** Users can keep selected agents addressed across consecutive messages without retyping their handles. **Problem:** Repeated conversations with agents require manually typing the same mentions on every turn, which adds friction and makes recipients easy to omit. **Solution:** The composer can now keep agents automatically addressed per channel, either from the mention controls or after a successful inline mention. Addressed agents remain visible in the toolbar, apply to channel threads, survive send failures safely, and never cross community boundaries. ## Changes <details> <summary>File changes</summary> **desktop/src-tauri/src/events/message_tags.rs** Preserves the automatic-address marker on validated mention reference tags. **desktop/src/features/channels/ui/ChannelPane.tsx** Wires the appropriate channel, thread, inbox, or forum composer context without leaking audiences across surfaces. **desktop/src/features/communities/useCommunityInit.ts** Clears composer audience state when the active community changes. **desktop/src/features/forum/ui/ForumComposer.tsx** Wires the appropriate channel, thread, inbox, or forum composer context without leaking audiences across surfaces. **desktop/src/features/forum/ui/ForumComposerAutocompletes.tsx** Wires the appropriate channel, thread, inbox, or forum composer context without leaking audiences across surfaces. **desktop/src/features/home/ui/InboxDetailPane.tsx** Wires the appropriate channel, thread, inbox, or forum composer context without leaking audiences across surfaces. **desktop/src/features/messages/lib/agentAddressMention.d.mts** Defines helpers and types for marked automatic-address mention tags. **desktop/src/features/messages/lib/agentAddressMention.mjs** Defines helpers and types for marked automatic-address mention tags. **desktop/src/features/messages/lib/agentAddressMention.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/lib/applyEditTagOverlay.mjs** Preserves automatic-address metadata when edited message tags are overlaid. **desktop/src/features/messages/lib/applyEditTagOverlay.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/lib/autoPinMentionedAgentsPreference.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/lib/autoPinMentionedAgentsPreference.ts** Stores the preference that keeps explicitly mentioned agents addressed for later messages. **desktop/src/features/messages/lib/extractMentionPersonas.ts** Separates persona recipients from the composer mention orchestration. **desktop/src/features/messages/lib/persistentAgentAudience.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/lib/persistentAgentAudience.ts** Maintains bounded, in-memory, channel-scoped automatic agent audiences. **desktop/src/features/messages/lib/useMentionSelection.ts** Centralizes mention picker selection state and agent-first selection behavior. **desktop/src/features/messages/lib/useMentions.ts** Exposes explicit picker origins and selection controls while preserving inline mention behavior. **desktop/src/features/messages/ui/ComposerAddressControls.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/ui/ComposerAddressControls.tsx** Renders compact addressed-agent avatars and the automatic-mention management entry point. **desktop/src/features/messages/ui/MentionAutocomplete.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/ui/MentionAutocomplete.tsx** Adds automatic-mention controls and options to the existing mention picker. **desktop/src/features/messages/ui/MessageAgentAddressPrefix.tsx** Shows which agents were automatically addressed on a sent message. **desktop/src/features/messages/ui/MessageComposer.tsx** Integrates automatic audiences, picker controls, accessible feedback, shortcuts, and send behavior. **desktop/src/features/messages/ui/MessageComposer.types.ts** Defines the simplified channel audience context shared by composer hosts. **desktop/src/features/messages/ui/MessageComposerToolbar.tsx** Places automatic-address controls in the composer toolbar without crowding narrow layouts. **desktop/src/features/messages/ui/MessageRow.tsx** Displays automatic-address metadata alongside sent message content. **desktop/src/features/messages/ui/MessageThreadPanel.tsx** Wires the appropriate channel, thread, inbox, or forum composer context without leaking audiences across surfaces. **desktop/src/features/messages/ui/composerAgentKeyboard.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/ui/persistentAgentAudienceHosts.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/ui/useAddressMentionPulse.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/ui/useAddressMentionPulse.ts** Provides success and failure animation signals for addressed-agent controls. **desktop/src/features/messages/ui/useAgentAddressLockPicker.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/ui/useAgentAddressLockPicker.ts** Coordinates adding, removing, and announcing automatically addressed agents. **desktop/src/features/messages/ui/useAlwaysAddressShortcut.ts** Implements the platform-aware shortcut for toggling automatic addressing. **desktop/src/features/messages/ui/useAutoPinMentionedAgents.ts** Promotes successfully sent inline agent mentions and provides a single undoable notification. **desktop/src/features/messages/ui/useComposerMentionPicker.ts** Opens the mention picker without rewriting the current draft. **desktop/src/features/messages/ui/useMentionSendFlow.helpers.test.mjs** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. **desktop/src/features/messages/ui/useMentionSendFlow.helpers.ts** Merges automatic and inline recipients, marks outgoing tags, and restores failed sends safely. **desktop/src/features/messages/ui/useMentionSendFlow.ts** Merges automatic and inline recipients, marks outgoing tags, and restores failed sends safely. **desktop/src/features/messages/ui/usePersistentAgentMentionHydration.ts** Removes the prior draft-text hydration approach now that automatic audiences stay at composer ingress. **desktop/src/features/settings/ui/AgentsSettingsPanel.tsx** Replaces the old global behavior with explicit composer-level automatic-mention controls. **desktop/src/features/settings/ui/PreventSleepSettingsCard.tsx** Replaces the old global behavior with explicit composer-level automatic-mention controls. **desktop/src/shared/lib/keyboard-shortcuts.ts** Defines the user-facing automatic-address keyboard shortcut label. **desktop/src/shared/ui/VideoReviewCommentMarkdown.tsx** Allows automatic-address prefixes to compose with video review timecodes. **desktop/tests/e2e/persistent-agent-audience.spec.ts** Covers the automatic-address behavior and its failure, keyboard, layout, or persistence boundaries. </details> ## Reproduction Steps 1. Open a channel with one or more agents and open the mention picker from the composer. 2. Select an agent for automatic mentions, then send several messages without retyping the handle; confirm the agent remains in the composer control and receives each message. 3. Mention another agent inline, send successfully, and confirm the agent becomes automatically addressed; use the notification's Undo action to reverse it. 4. Open a thread in the same channel and confirm the same addressed agents are available there. 5. Remove an agent from the composer control and confirm later messages stop addressing it. 6. Switch communities and confirm addressed agents do not carry into the other community. ## Screenshots All states below use the dark Buzz theme with a selected lilac accent. ### Addressed composer Selected agents stay visible at the composer ingress without adding handles to the draft. ![Two automatically addressed agents in the dark composer with a lilac accent](https://raw.githubusercontent.com/block/buzz/74c2cbbd80ed630a0c6e00c420505a691bd4994a/pr-6315--01-addressed-composer.png) ### Open mention menu The @ ingress opens the existing mention menu and shows which agents are already addressed. ![Open mention menu with automatically addressed agents highlighted](https://raw.githubusercontent.com/block/buzz/74c2cbbd80ed630a0c6e00c420505a691bd4994a/pr-6315--02-open-mention-menu.png) ### Mention options The inline options pane controls whether a successful one-time agent mention carries into later messages. ![Automatic mention options expanded above the mention menu](https://raw.githubusercontent.com/block/buzz/74c2cbbd80ed630a0c6e00c420505a691bd4994a/pr-6315--03-mention-options.png) ### Agent settings The same preference is available in **Settings → Agents → Conversations**. ![Automatic agent mentions preference in the Agents settings pane](https://raw.githubusercontent.com/block/buzz/74c2cbbd80ed630a0c6e00c420505a691bd4994a/pr-6315--04-agent-settings.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 723affe commit a2d8be5

49 files changed

Lines changed: 3565 additions & 1492 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎desktop/src-tauri/src/events/message_tags.rs‎

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use super::check_pubkey;
44

55
const MAX_THREAD_ROOT_EXCERPT_CHARS: usize = 64;
66
const SENT_FROM_THREAD_TAG: &str = "buzz:sent-from-thread";
7+
const AGENT_ADDRESS_MENTION_MARKER: &str = "agent-address";
78

89
pub(super) fn mention_reference_tags(
910
mentions: &[Vec<String>],
@@ -19,10 +20,20 @@ pub(super) fn mention_reference_tags(
1920
let Some(pubkey) = mention.get(1) else {
2021
return Err("mention reference tag missing pubkey".into());
2122
};
23+
if mention.len() > 3
24+
|| (mention.len() == 3
25+
&& mention.get(2).map(String::as_str) != Some(AGENT_ADDRESS_MENTION_MARKER))
26+
{
27+
return Err("mention reference tag has invalid display metadata".into());
28+
}
2229
check_pubkey(pubkey)?;
30+
let normalized_pubkey = pubkey.to_ascii_lowercase();
31+
let mut parts = vec!["mention", normalized_pubkey.as_str()];
32+
if mention.len() == 3 {
33+
parts.push(AGENT_ADDRESS_MENTION_MARKER);
34+
}
2335
tags.push(
24-
Tag::parse(vec!["mention", &pubkey.to_ascii_lowercase()])
25-
.map_err(|error| format!("invalid mention reference tag: {error}"))?,
36+
Tag::parse(parts).map_err(|error| format!("invalid mention reference tag: {error}"))?,
2637
);
2738
}
2839
Ok(())
@@ -115,8 +126,39 @@ pub(super) fn append_client_tags(
115126
mod tests {
116127
use super::*;
117128

129+
const PUBKEY: &str = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798";
118130
const ROOT_HEX: &str = "d24da132115ca0a46233cf4c2ad8338fbf914250cbcaa9181a6dd59533cb5ac1";
119131

132+
#[test]
133+
fn mention_reference_preserves_agent_address_display_metadata() {
134+
let mut tags = Vec::new();
135+
mention_reference_tags(
136+
&[vec![
137+
"mention".into(),
138+
PUBKEY.to_ascii_uppercase(),
139+
AGENT_ADDRESS_MENTION_MARKER.into(),
140+
]],
141+
&mut tags,
142+
)
143+
.unwrap();
144+
145+
assert_eq!(
146+
tags[0].as_slice(),
147+
&["mention", PUBKEY, AGENT_ADDRESS_MENTION_MARKER]
148+
);
149+
}
150+
151+
#[test]
152+
fn mention_reference_rejects_unknown_display_metadata() {
153+
let mut tags = Vec::new();
154+
let result = mention_reference_tags(
155+
&[vec!["mention".into(), PUBKEY.into(), "unknown".into()]],
156+
&mut tags,
157+
);
158+
159+
assert!(result.is_err());
160+
}
161+
120162
#[test]
121163
fn message_accepts_only_valid_sent_from_thread_provenance() {
122164
let source_tag = vec![

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ export const ChannelPane = React.memo(function ChannelPane({
692692
) : null}
693693
<ComposerDockBackdrop gutterClassName="inset-x-5" />
694694
<MessageComposer
695+
audienceContext={{ type: "channel" }}
695696
channelId={activeChannel?.id ?? null}
696697
channelName={activeChannel?.name ?? "channel"}
697698
channelType={activeChannel?.channelType ?? null}

‎desktop/src/features/communities/useCommunityInit.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import { resetRenderScopedReactionHydration } from "@/features/messages/lib/renderScopedReactions";
2424
import { resetBackgroundMediaUploads } from "@/features/messages/lib/backgroundMediaUploadStore";
2525
import { resetLinkPreviewPreparations } from "@/features/messages/lib/linkPreviewPreparationStore";
26+
import { resetPersistentAgentAudienceStore } from "@/features/messages/lib/persistentAgentAudience";
2627
import {
2728
resetActiveAgentTurnsStore,
2829
saveActiveAgentTurnsForCommunity,
@@ -76,6 +77,7 @@ async function resetCommunityState({
7677
resetRenderScopedReactionHydration();
7778
resetBackgroundMediaUploads();
7879
resetLinkPreviewPreparations();
80+
resetPersistentAgentAudienceStore();
7981
clearSearchHitEventCache();
8082
clearMarkdownNodeCache();
8183
resetMessageLinkMetadataCache();

‎desktop/src/features/forum/ui/ForumComposer.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ export function ForumComposer({
527527
mentions.isMentionOpen ? mentions.suggestions : []
528528
}
529529
onChannelSelect={applyChannelInsert}
530+
onMentionDismiss={mentions.cancelMentionAutocomplete}
530531
onMentionFetchMore={mentions.fetchMoreSuggestions}
531532
onMentionSelect={applyMentionInsert}
532533
position={autocompletePosition}

‎desktop/src/features/forum/ui/ForumComposerAutocompletes.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type ForumComposerAutocompletesProps = {
1212
mentionSuggestions: MentionSuggestion[];
1313
onChannelSelect: (suggestion: ChannelSuggestion) => void;
1414
onMentionFetchMore?: () => void;
15+
onMentionDismiss: () => void;
1516
onMentionSelect: (suggestion: MentionSuggestion) => void;
1617
position: "above" | "below";
1718
};
@@ -23,6 +24,7 @@ export function ForumComposerAutocompletes({
2324
mentionSuggestions,
2425
onChannelSelect,
2526
onMentionFetchMore,
27+
onMentionDismiss,
2628
onMentionSelect,
2729
position,
2830
}: ForumComposerAutocompletesProps) {
@@ -35,6 +37,7 @@ export function ForumComposerAutocompletes({
3537
suggestions={channelSuggestions}
3638
/>
3739
<MentionAutocomplete
40+
onDismiss={onMentionDismiss}
3841
onFetchMore={onMentionFetchMore}
3942
onSelect={onMentionSelect}
4043
position={position}

‎desktop/src/features/home/ui/InboxDetailPane.tsx‎

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {
3434
isWithinGroupingWindow,
3535
startsNewMessageGroup,
3636
} from "@/features/messages/lib/messageGrouping";
37-
import { orderMentionPubkeysByText } from "@/features/messages/lib/orderMentionPubkeys";
3837
import { canManageMessageForCurrentUser } from "@/features/messages/lib/canManageMessage";
3938
import { buildEditMentionState } from "@/features/messages/lib/draftMentionRefs";
4039
import { imetaMediaFromTags } from "@/features/messages/lib/imetaMediaMarkdown";
@@ -43,13 +42,11 @@ import {
4342
hasRenderedVideoAttachment,
4443
} from "@/features/messages/lib/videoReviewContext";
4544
import { getThreadReference } from "@/features/messages/lib/threading";
46-
import { normalizePubkey } from "@/shared/lib/pubkey";
4745
import { MessageComposer } from "@/features/messages/ui/MessageComposer";
4846
import { useAnchoredScroll } from "@/features/messages/ui/useAnchoredScroll";
4947
import { useComposerHeightPadding } from "@/features/messages/ui/useComposerHeightPadding";
5048
import { UpdateIndicator } from "@/features/settings/UpdateIndicator";
5149
import type { Channel, UserProfileSummary } from "@/shared/api/types";
52-
import { resolveMentionProps } from "@/shared/lib/resolveMentionNames";
5350
import { TopChromeInsetHeader } from "@/shared/layout/TopChromeInsetHeader";
5451
import { cn } from "@/shared/lib/cn";
5552
import { Button } from "@/shared/ui/button";
@@ -214,40 +211,6 @@ function InboxMessageDetailPane({
214211
// Build the plain, non-virtualized timeline the shared hook anchors against.
215212
// Live arrivals rerun its layout compensation without changing the target.
216213

217-
// A latest reply can represent an Inbox conversation. Resolve the actual
218-
// root from loaded context or the complete feed group; never treat an
219-
// unresolved root/profile lookup as an authoritative empty audience.
220-
const contextRoot = messages.find((message) => message.id === conversationId);
221-
const feedRoot = item
222-
? [item.item, ...item.groupItems].find(
223-
(groupItem) => groupItem.id === conversationId,
224-
)
225-
: undefined;
226-
const rootMessage = contextRoot
227-
? {
228-
authorPubkey: contextRoot.authorPubkey,
229-
content: contextRoot.content,
230-
mentionPubkeysByName: contextRoot.mentionPubkeysByName,
231-
}
232-
: feedRoot && profiles
233-
? {
234-
authorPubkey: feedRoot.pubkey,
235-
content: feedRoot.content,
236-
mentionPubkeysByName: resolveMentionProps(feedRoot.tags, profiles)
237-
.mentionPubkeysByName,
238-
}
239-
: null;
240-
const initialAgentPubkeys = rootMessage
241-
? currentPubkey &&
242-
normalizePubkey(rootMessage.authorPubkey) ===
243-
normalizePubkey(currentPubkey)
244-
? orderMentionPubkeysByText(
245-
rootMessage.content,
246-
rootMessage.mentionPubkeysByName,
247-
(pubkey) => agentPubkeys?.has(pubkey) === true,
248-
)
249-
: []
250-
: undefined;
251214
const displayMessages = React.useMemo<InboxDisplayMessage[]>(() => {
252215
const selectedMessage = messages.find((message) => message.isSelected);
253216
const pendingReplyMessages: InboxDisplayMessage[] = replies.map(
@@ -793,15 +756,7 @@ function InboxMessageDetailPane({
793756
/>
794757
<div className="pointer-events-auto">
795758
<MessageComposer
796-
audienceContext={
797-
isDirectMessage
798-
? null
799-
: {
800-
type: "thread",
801-
threadRootId: item.conversationId,
802-
initialAgentPubkeys,
803-
}
804-
}
759+
audienceContext={isDirectMessage ? null : { type: "thread" }}
805760
channelId={item.item.channelId}
806761
channelName={item.channelLabel ?? "channel"}
807762
channelType={composerChannelType}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const AGENT_ADDRESS_MENTION_MARKER: "agent-address";
2+
3+
export function buildAgentAddressMentionTags(
4+
addressedPubkeys: Iterable<string>,
5+
deliveredPubkeys: Iterable<string>,
6+
): string[][];
7+
8+
export function getAgentAddressMentionPubkeys(
9+
tags: readonly (readonly string[])[] | null | undefined,
10+
): string[];
11+
12+
export function isAgentAddressMentionTag(tag: readonly string[]): boolean;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { normalizePubkey } from "../../../shared/lib/pubkey.ts";
2+
3+
export const AGENT_ADDRESS_MENTION_MARKER = "agent-address";
4+
5+
/**
6+
* Persist the subset of delivered mentions that came from the composer's
7+
* address tray. The ordinary `p` tag remains the notification mechanism;
8+
* this annotated reference is display metadata for reconstructing the tray
9+
* state when the message is rendered later.
10+
*/
11+
export function buildAgentAddressMentionTags(
12+
addressedPubkeys,
13+
deliveredPubkeys,
14+
) {
15+
const delivered = new Set([...deliveredPubkeys].map(normalizePubkey));
16+
return [...new Set([...addressedPubkeys].map(normalizePubkey))]
17+
.filter((pubkey) => pubkey && delivered.has(pubkey))
18+
.map((pubkey) => ["mention", pubkey, AGENT_ADDRESS_MENTION_MARKER]);
19+
}
20+
21+
/** Return the ordered, deduplicated agent-address recipients on an event. */
22+
export function getAgentAddressMentionPubkeys(tags) {
23+
return [
24+
...new Set(
25+
(tags ?? [])
26+
.filter(
27+
(tag) =>
28+
tag[0] === "mention" &&
29+
tag[2] === AGENT_ADDRESS_MENTION_MARKER &&
30+
Boolean(tag[1]),
31+
)
32+
.map((tag) => normalizePubkey(tag[1])),
33+
),
34+
];
35+
}
36+
37+
export function isAgentAddressMentionTag(tag) {
38+
return tag[0] === "mention" && tag[2] === AGENT_ADDRESS_MENTION_MARKER;
39+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import assert from "node:assert/strict";
2+
import test from "node:test";
3+
4+
import {
5+
AGENT_ADDRESS_MENTION_MARKER,
6+
buildAgentAddressMentionTags,
7+
getAgentAddressMentionPubkeys,
8+
} from "./agentAddressMention.mjs";
9+
10+
const ALICE = "a".repeat(64);
11+
const BOB = "b".repeat(64);
12+
13+
test("builds address metadata only for recipients that survived admission", () => {
14+
assert.deepEqual(
15+
buildAgentAddressMentionTags([ALICE.toUpperCase(), BOB], [ALICE]),
16+
[["mention", ALICE, AGENT_ADDRESS_MENTION_MARKER]],
17+
);
18+
});
19+
20+
test("reads ordered address metadata without treating ordinary mentions as tray state", () => {
21+
assert.deepEqual(
22+
getAgentAddressMentionPubkeys([
23+
["p", BOB],
24+
["mention", BOB],
25+
["mention", ALICE.toUpperCase(), AGENT_ADDRESS_MENTION_MARKER],
26+
["mention", ALICE, AGENT_ADDRESS_MENTION_MARKER],
27+
]),
28+
[ALICE],
29+
);
30+
});

‎desktop/src/features/messages/lib/applyEditTagOverlay.mjs‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* TypeScript-facing callers get typed access via the sibling `.d.mts`.
1010
*/
1111

12+
import { isAgentAddressMentionTag } from "./agentAddressMention.mjs";
13+
1214
/**
1315
* Merge the original event's tags with an edit's tags so that:
1416
* - `imeta` tags come exclusively from the edit (full new attachment set);
@@ -17,7 +19,8 @@
1719
* snapshot from the edited composer (marked by `buzz:mention-snapshot`)
1820
* and therefore replace the original set; this preserves the edited body's
1921
* stable recipient identities even before profiles load or after an alias
20-
* changes;
22+
* changes. Agent-address mention metadata describes immutable send-time
23+
* state, so it survives that authored-mention snapshot;
2124
* - `emoji` (NIP-30 custom-emoji) tags come from the edit *when the edit
2225
* supplies any* — the edited body may add or remove custom emoji, so a
2326
* supplied set rebuilds the shortcode→url map. But when the edit supplies
@@ -39,7 +42,9 @@ export function applyEditTagOverlay(originalTags, editTags) {
3942
const hasMentionSnapshot = editTags.some(
4043
(t) => t[0] === "buzz:mention-snapshot",
4144
);
42-
const editMentions = editTags.filter((t) => t[0] === "mention");
45+
const editMentions = editTags.filter(
46+
(t) => t[0] === "mention" && !isAgentAddressMentionTag(t),
47+
);
4348
// imeta is always fully replaced by the edit. emoji is replaced only when
4449
// the edit actually supplies emoji tags; otherwise the original's are kept.
4550
// An edit carrying the private snapshot marker is authoritative, including
@@ -48,7 +53,12 @@ export function applyEditTagOverlay(originalTags, editTags) {
4853
const droppedFromOriginal = (tag) => {
4954
if (tag[0] === "imeta") return false;
5055
if (editEmoji.length > 0 && tag[0] === "emoji") return false;
51-
if (hasMentionSnapshot && tag[0] === "mention") return false;
56+
if (
57+
hasMentionSnapshot &&
58+
tag[0] === "mention" &&
59+
!isAgentAddressMentionTag(tag)
60+
)
61+
return false;
5262
return true;
5363
};
5464
const baseFromOriginal = originalTags.filter(droppedFromOriginal);

0 commit comments

Comments
 (0)