Skip to content

Commit e8cd751

Browse files
tellahoRizz
andauthored
fix(desktop): respect automatic mention preference after send (#6837)
**Category:** fix **User Impact:** Disabling automatic agent mentions now keeps one-time agent mentions out of the next message draft. **Problem:** A successfully sent inline agent mention was treated as eligible for post-send restoration even when **Automatically mention agents** was disabled, so the agent immediately reappeared in the composer. **Solution:** Gate the send-success restoration path on the live preference while leaving explicitly pinned agents and enabled automatic mentions unchanged. <details> <summary>File changes</summary> **desktop/src/features/messages/ui/MessageComposer.tsx** Skips the automatic post-send mention restoration path when the preference is disabled. **desktop/tests/e2e/persistent-agent-audience.spec.ts** Reproduces disabling the toggle before sending an inline agent mention and verifies the next composer is empty while the outgoing mention still reaches the agent. </details> ## Reproduction steps 1. Enable **Automatically mention agents** in the composer mention options. 2. Disable it again. 3. Compose and send `@Agent test` using the inline mention picker. 4. Confirm the message still mentions the agent, but the cleared composer does not repopulate `@Agent`. 5. Re-enable the preference and repeat; confirm the mention is restored for the next message. ## Testing At `a179a2d00a6ac5cf0bc4a1c7c1ef3d5dfa9d0875`: - Full desktop unit suite: 5,501 passed. - Desktop check and typecheck passed in the pre-push hooks. - Desktop file-size ratchet passed in the pre-push hooks. - Full `persistent-agent-audience.spec.ts` Playwright file: 17 passed, including preference off (empty composer), preference on (restored mention), and the existing address-undo journey. ## Visual validation | Automatic mentions off | Automatic mentions on | | --- | --- | | After sending a one-time mention, the outgoing message is preserved and the next composer stays empty. | After sending, the agent remains addressed and is restored in the next composer. | | ![Automatic mentions disabled: empty composer after send](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/6837/disabled-after-send.png) | ![Automatic mentions enabled: agent restored after send](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/6837/enabled-after-send.png) | <details> <summary>Original regression</summary> With automatic mentions disabled, sending `@Alia test` still repopulated `@Alia` in the cleared composer. ![Original regression: the sent agent reappears in the composer](https://d24qwcpro867f5.cloudfront.net/repos/buzz/prs/6837/auto-mention-regression-before.png) </details> Signed-off-by: Taylor Ho <[email protected]> Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz>
1 parent 820a858 commit e8cd751

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎desktop/src/features/messages/ui/MessageComposer.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ function MessageComposerImpl({
347347
restoreAddressedAgentMentionsRef.current(pubkeys),
348348
onAddressedAgentsSendFailed: addressPulse.shakeMany,
349349
onAddressedAgentsSendSucceeded: (pubkeys, newlyPinnedPubkeys) => {
350-
if (newlyPinnedPubkeys.length === 0) return;
350+
if (!keepMentionedAgentsPinned || newlyPinnedPubkeys.length === 0) return;
351351
const sentChannelId = channelId;
352352
if (restoreAddressedAgentMentionsFrameRef.current !== null) {
353353
cancelAnimationFrame(restoreAddressedAgentMentionsFrameRef.current);

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,40 @@ test("Tab inserts a one-time agent mention by default", async ({ page }) => {
312312
).toHaveCount(0);
313313
});
314314

315+
test("disabling automatic mentions leaves the composer empty after send", async ({
316+
page,
317+
}) => {
318+
await keepMentionedAgentsPinned(page);
319+
await installAudienceFixtures(page);
320+
await openGeneral(page);
321+
322+
const composer = channelComposer(page);
323+
const input = composer.getByTestId("message-input");
324+
await composer.getByTestId("message-insert-mention").click();
325+
await composer.getByTestId("mention-options-trigger").click();
326+
const preference = composer.getByTestId("mention-keep-agents-pinned-toggle");
327+
await expect(preference).toHaveAttribute("data-state", "checked");
328+
await preference.click();
329+
await expect(preference).toHaveAttribute("data-state", "unchecked");
330+
await input.press("Escape");
331+
332+
await input.fill("@Mor");
333+
await expect(composer.getByTestId("mention-autocomplete")).toBeVisible();
334+
await input.press("Tab");
335+
await input.type("test");
336+
await expect(input).toHaveText("@Morgarita test");
337+
await input.press("Enter");
338+
339+
await expect(input).toHaveText("");
340+
await expect(input.locator(".agent-mention-highlight")).toHaveCount(0);
341+
await expect(
342+
composer.getByTestId(`composer-address-lock-${AGENT_A}`),
343+
).toHaveCount(0);
344+
await expect
345+
.poll(() => readOutgoingMentionPubkeys(page, "@Morgarita test"))
346+
.toContain(AGENT_A);
347+
});
348+
315349
test("primary+Shift+M addresses the default agent, then selects the highlighted agent", async ({
316350
page,
317351
}) => {
@@ -457,7 +491,7 @@ test("the mention button opens settings and can undo an address", async ({
457491

458492
await input.type("later");
459493
await input.press("Enter");
460-
await expect(input).toHaveText("@Morgarita ");
494+
await expect(input).toHaveText("");
461495
await expect
462496
.poll(() => readOutgoingMentionPubkeys(page, "@Morgarita later"))
463497
.toContain(AGENT_A);

0 commit comments

Comments
 (0)