Repository navigation
fix(discord): ping mention-bearing final replies under live preview (#88360) - #88527
Conversation
|
Codex review: needs maintainer review before merge. Reviewed May 31, 2026, 5:32 AM ET / 09:32 UTC. Summary PR surface: Source +28, Tests +120. Total +148 across 4 files. Reproducibility: yes. for a source-level and handler-test reproduction: current main finalizes live-preview finals via edit, while the fresh send path is the path that rewrites aliases. A live Discord guild reproduction was not run here. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the focused fallback after a maintainer accepts the Discord delivery risk or verifies a live alias/literal mention round trip with the broadcast controls. Do we have a high-confidence way to reproduce the issue? Yes for a source-level and handler-test reproduction: current main finalizes live-preview finals via edit, while the fresh send path is the path that rewrites aliases. A live Discord guild reproduction was not run here. Is this the best way to solve the issue? Yes, the proposed fix is a narrow owner-local change that reuses the existing mention rewriter and normal fresh-delivery path instead of adding a new config or plugin API. The safer pre-merge step is live transport proof or explicit maintainer acceptance of the delivery semantics. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 70c8abdca191. Label changesLabel justifications:
Evidence reviewedPR surface: Source +28, Tests +120. Total +148 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
b3ef15f to
a6b029d
Compare
a6b029d to
a7633da
Compare
a7633da to
97ee70c
Compare
97ee70c to
6d583ea
Compare
6d583ea to
a9fcb66
Compare
a9fcb66 to
fb246b3
Compare
|
Maintainer pre-merge proof for #88527. Scope reviewed: Discord live-preview final delivery for mention-bearing replies. The patch reroutes targeted user/role mention finals from edit-based preview finalization to fresh message delivery, reusing the existing sendMessageDiscord mention rewrite path. Checks accepted before merge:
Known proof gap accepted for landing: no live Discord guild round trip was run here. The mocked production-handler proof covers the create-vs-edit decision, and the fresh-create path is the existing Discord send path that rewrites aliases before create-based delivery. |
Summary
channels.discord.mentionAliases(@handle→<@userId>) only fires when a reply is sent through themessagetool. When an agent puts the mention in its natural-language final answer (e.g.Done. @Vladislava please review.), the literal@handlereaches Discord as plain text and the target is never pinged. This breaks the multi-agent scenario the feature was introduced for (Discord outbound messages should reliably convert known @AgentName references into real <@userId> mentions #67587), where most cross-agent mentions originate in natural assistant text rather than explicitmessagetool calls.buildFinalEdit→editMessageDiscordinextensions/discord/src/monitor/message-handler.process.ts, through the coredeliverWithFinalizableLivePreviewAdapterinsrc/channels/message/live.ts). Discord fires mention notifications only on message create, never on edit — so finalizing in place can never ping, no matter how the mention is expressed. This affects every targeted mention in a streamed final answer: a configured alias (@handle), a directory-resolved handle, and a literal<@userId>/<@&roleId>the model emits directly (the plugin'smessageToolHintsactually instruct the model to use that canonical form). The non-streaming path was never affected — it delivers throughdeliverDiscordReply→sendMessageDiscord, which rewrites and creates a fresh message that pings. The reporter's claim thatsendMessageDiscorddoes not rewrite is inaccurate on currentmain(it has rewritten since at least v2026.5.12); the real gap is the live-preview finalize path.buildFinalEditinextensions/discord/src/monitor/message-handler.process.ts. Run the resolved final text throughrewriteDiscordKnownMentions(using the account'smentionAliasesviaresolveDiscordAccount); if the result contains a targeted user/role mention (<@id>/<@!id>/<@&id>), returnundefined, which routes delivery to the existing normal path (deliverNormally→deliverDiscordReply→sendMessageDiscord). That path discards the streamed preview and creates a fresh message with the rewrite applied and Discord's default mention parsing, so the mention actually notifies. This covers both aliases/handles and literal<@id>/<@&id>. When the final text has no targeted mention, the efficient in-place preview edit is kept unchanged.extensions/discord/src/mentions.ts— two small predicates next to the existing rewriter:discordTextHasTargetedMention(<@id>/<@!id>/<@&id>) anddiscordTextHasBroadcastMention(@everyone/@here), so the mention-format knowledge stays in one place.extensions/discord/src/monitor/message-handler.process.ts—buildFinalEditreturnsundefined(routing to the normal create-based delivery) when the rewritten final text has a targeted mention and no broadcast. Reuses the existingrewriteDiscordKnownMentionsrewriter,resolveDiscordAccountresolver, and the new predicates — the same rewrite themessage-tool/create path already uses.extensions/discord/src/mentions.test.ts— unit coverage for the two predicates (user/role vs. channel/plain/broadcast).extensions/discord/src/monitor/message-handler.process.test.ts— five integration cases pinning the delivery path: an alias-resolved final and a literal<@id>final are each delivered via fresh create (not an edit); an unaliased plain handle, an@everyonebroadcast, and a mixed targeted-plus-@everyonefinal each still finalize in place via the preview edit.extensions/discord/src/draft-stream.ts— streamed intermediate preview frames still suppress mentions (allowed_mentions: { parse: [] }) exactly as before; untouched.@everyone/@here— left as-is and not rerouted. The reroute is also skipped when a targeted mention is mixed with@everyone/@here(e.g.@Sentinel @everyone), so a broadcast mention is never escalated into a fresh-create ping; that reply finalizes in place as before.docs/reference/configedits).extensions/api.ts/runtime-api.ts, registry, or loader edits).Reproduction
channels.discord.mentionAliasesmapping a handle to a user ID (e.g.{ "Sentinel": "1485891428809707651" }).messagetool) — either as the aliasOn it @Sentinelor as the canonicalOn it <@1485891428809707651>.message.mentionsentry — for both the alias form and the literal<@id>form.@Sentinelrewritten to<@1485891428809707651>, or the literal<@1485891428809707651>preserved), which pings.Real behavior proof
Behavior addressed (#88360): a targeted mention (alias, directory handle, or literal
<@id>/<@&id>) in a Discord final answer under live preview streaming is delivered as a fresh message create (which rewrites and pings) instead of an in-place edit (which Discord never notifies on); plain text and@everyone/@herestill finalize in place unchanged.Real environment tested (Linux, Node 22, production Discord handler
processDiscordMessageInnerdriven against a mocked Discord REST transport): the test exercises the real outbound-finalize decision — in-placeeditMessageDiscordvs. fresh-createdeliverDiscordReply— with a realchannels.discord.mentionAliasesconfig resolved through the productionresolveDiscordAccount.Exact steps or command run after this patch:
pnpm test extensions/discord/src/monitor/message-handler.process.test.tsorigin/main(no guard), run the alias and literal cases, then restore the patched file.pnpm exec oxfmt --check --threads=1 extensions/discord/src/monitor/message-handler.process.ts extensions/discord/src/monitor/message-handler.process.test.tsEvidence before fix (verbatim vitest output, production file reverted to
origin/main— reproduces the bug):Both forms reproduce: the alias
On it @Sentineland the literalOn it <@1485891428809707651>are each finalized via an edit (editMessageDiscordis called) instead of a fresh create.Evidence after fix (verbatim vitest output for the four delivery-path cases):
Observed result after fix:
On it @SentinelwithmentionAliases: { Sentinel: "1485891428809707651" }) and a literal final (On it <@1485891428809707651>) no longer calleditMessageDiscord; both route todeliverDiscordReply(a fresh create that pings).On it @Sentinel, no alias configured) and an@everyonebroadcast still finalize in place via the preview edit — no escalation.Tests 90 passed (90).What was not tested:
<@id>) is the recommended maintainer-side confirmation.Regression tests:
message-handler.process.test.ts→delivers a fresh message instead of a preview edit when the final reply resolves a mention aliasanddelivers a fresh message instead of a preview edit for a literal user mention in the final reply(both fail before the fix; see Evidence before fix), plus the controlsstill finalizes via preview edit when an unaliased handle stays plain text,still finalizes via preview edit for broadcast mentions like @everyone, andstill finalizes via preview edit when a targeted mention is mixed with @everyone(this last one fails if the broadcast exclusion is dropped, locking the no-escalation guarantee).Risk / Mitigation
<@id>/<@&id>) and contains no@everyone/@here; plain text, broadcast-only, and mixed targeted-plus-broadcast replies all stay on the unchanged in-place edit (dedicated tests lock the@everyoneand mixed cases, so the create path can never newly ping everyone).@name→<@id>), which could affect chunking. Mitigation: the create path is the same one themessagetool uses and applies the existing chunking, so over-length handling is unchanged.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Fixes #88360
Related #67587