Skip to content

Commit 70f4d4b

Browse files
author
Larry
committed
fix(desktop): keep known edit recipients notified once
An unresolved recipient on the original made every current mention count as new, so a typo fix re-woke an agent the original already mentioned. Resolved original recipients now always count as already notified; only unresolved ones are revalidated. Signed-off-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
1 parent b1b0da9 commit 70f4d4b

2 files changed

Lines changed: 44 additions & 4 deletions

File tree

‎desktop/src/features/messages/ui/submitMessageEdit.test.mjs‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,44 @@ test("edit save uses edit-target refs that resolve after edit-open", async () =>
8686
});
8787
});
8888

89+
test("an unresolved recipient does not re-notify an unchanged agent mention", async () => {
90+
const { buildEditMentionState } = await import("../lib/draftMentionRefs.ts");
91+
const agent = "c".repeat(64);
92+
const originalContent = "@Agent @Missing User please chek";
93+
const editTarget = buildEditMentionState(
94+
originalContent,
95+
[
96+
["p", agent],
97+
["p", UNRESOLVED_USER],
98+
],
99+
{ [agent]: { displayName: "Agent" } },
100+
(pubkey) => pubkey === agent,
101+
);
102+
assert.deepEqual(
103+
editTarget.mentionRefs.map((ref) => ref.pubkey),
104+
[agent],
105+
);
106+
assert.deepEqual(editTarget.unresolvedMentionPubkeys, [UNRESOLVED_USER]);
107+
const calls = [];
108+
await submitMessageEdit({
109+
...baseOptions(async (_content, tags, notifying) => {
110+
calls.push(["save", tags, notifying]);
111+
}),
112+
content: "@Agent @Missing User please check",
113+
originalContent,
114+
editTarget,
115+
extractMentionPubkeys: (text) => (text.includes("@Agent") ? [agent] : []),
116+
revalidateMentionPubkeys: async (pubkeys) => {
117+
calls.push(["revalidate", pubkeys]);
118+
return pubkeys;
119+
},
120+
});
121+
assert.deepEqual(calls[0], ["revalidate", []]);
122+
const [, tags, notifying] = calls[1];
123+
assert.deepEqual(notifying, []);
124+
assert.ok(tags.some(([name, key]) => name === "mention" && key === agent));
125+
});
126+
89127
test("edit save revalidates added mentions immediately before save", async () => {
90128
const agent = "c".repeat(64);
91129
const calls = [];

‎desktop/src/features/messages/ui/submitMessageEdit.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ export async function submitMessageEdit({
117117
};
118118
// Current picker bindings must not reinterpret the original body: selecting a
119119
// different Scout would otherwise make that new key look already notified.
120-
// With unresolved history, conservatively revalidate all current recipients.
121-
const originalMentionPubkeys = editTarget.unresolvedMentionPubkeys?.length
122-
? []
123-
: (editTarget.mentionRefs ?? []).map((ref) => ref.pubkey);
120+
// Resolved historical keys are already recipients, so an unresolved neighbor
121+
// must not make them notify again. Unresolved keys have no trusted binding to
122+
// the edited text; they stay out of this set and are revalidated if present.
123+
const originalMentionPubkeys = (editTarget.mentionRefs ?? []).map(
124+
(ref) => ref.pubkey,
125+
);
124126
let addedMentionPubkeys: string[];
125127
try {
126128
addedMentionPubkeys = diffAddedMentionPubkeys(

0 commit comments

Comments
 (0)