Skip to content

Commit d312ca3

Browse files
committed
fix(composer): clear provenance on typed deletion
Signed-off-by: morgmart <[email protected]>
1 parent 593f8d1 commit d312ca3

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export function useAgentAddressLockPicker({
161161
lockedAgentPubkeys.has(pubkey)
162162
) {
163163
const excludePubkey = audience.excludePubkey ?? audience.removePubkey;
164+
onImplicitPrefixRemoved?.(pubkey);
164165
excludePubkey(pubkey);
165166
}
166167
}
@@ -172,6 +173,7 @@ export function useAgentAddressLockPicker({
172173
audienceScope,
173174
lockedAgentPubkeys,
174175
mentions.getDraftMentionRefs,
176+
onImplicitPrefixRemoved,
175177
],
176178
);
177179

‎desktop/tests/e2e/persistent-agent-audience.spec.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,47 @@ test("an authored duplicate leading mention survives draft restoration", async (
11381138
.toBe("@Morgarita authored duplicate");
11391139
});
11401140

1141+
test("typed deletion preserves an identical authored mention in drafts", async ({
1142+
page,
1143+
}) => {
1144+
await installAudienceFixtures(page);
1145+
await openGeneral(page);
1146+
const composer = channelComposer(page);
1147+
const input = composer.getByTestId("message-input");
1148+
await automaticallyMention(composer, "Morgarita");
1149+
1150+
const selectAllShortcut = await page.evaluate(() =>
1151+
/mac|iphone|ipad|ipod/i.test(navigator.platform) ? "Meta+A" : "Control+A",
1152+
);
1153+
await input.press(selectAllShortcut);
1154+
await input.press("Backspace");
1155+
await expect(input).toHaveText("");
1156+
await expect(
1157+
composer.getByTestId(`composer-address-lock-${AGENT_A}`),
1158+
).toHaveCount(0);
1159+
1160+
await input.pressSequentially("@Morgarita manual after typed deletion");
1161+
await page.goto(`/#/channels/${RANDOM_CHANNEL_ID}`, {
1162+
waitUntil: "domcontentloaded",
1163+
});
1164+
await expect
1165+
.poll(() =>
1166+
page.evaluate((channelId) => {
1167+
for (const storageKey of Object.keys(window.localStorage)) {
1168+
if (!storageKey.startsWith("buzz-drafts.v2:")) continue;
1169+
const draft = (
1170+
JSON.parse(
1171+
window.localStorage.getItem(storageKey) ?? "{}",
1172+
) as Record<string, { content?: string }>
1173+
)[channelId];
1174+
if (draft) return draft.content ?? "";
1175+
}
1176+
return "";
1177+
}, CHANNEL_ID),
1178+
)
1179+
.toBe("@Morgarita manual after typed deletion");
1180+
});
1181+
11411182
test("removing an automatic mention preserves an identical authored mention in drafts", async ({
11421183
page,
11431184
}) => {

0 commit comments

Comments
 (0)